zcw-shared 2.11.0 → 2.13.0

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.
Files changed (43) hide show
  1. package/dist/constants/apiErrorCodes.d.ts +2 -2
  2. package/dist/constants/apiErrorCodes.js +11 -12
  3. package/dist/constants/apiErrorCodes.js.map +1 -1
  4. package/dist/functions/chat/chatShellTabConfig.d.ts +6 -2
  5. package/dist/functions/chat/chatShellTabConfig.js +25 -27
  6. package/dist/functions/chat/chatShellTabConfig.js.map +1 -1
  7. package/dist/functions/chat/chatShellTabEditor.js +1 -1
  8. package/dist/functions/chat/chatShellTabEditor.js.map +1 -1
  9. package/dist/functions/dom/copyHtmlAndPlainToClipboard.d.ts +1 -0
  10. package/dist/functions/dom/copyHtmlAndPlainToClipboard.js +68 -0
  11. package/dist/functions/dom/copyHtmlAndPlainToClipboard.js.map +1 -0
  12. package/dist/functions/im/forwardBundlePayload.d.ts +23 -0
  13. package/dist/functions/im/forwardBundlePayload.js +59 -0
  14. package/dist/functions/im/forwardBundlePayload.js.map +1 -0
  15. package/dist/functions/im/getActiveMentionQuery.d.ts +4 -0
  16. package/dist/functions/im/getActiveMentionQuery.js +23 -0
  17. package/dist/functions/im/getActiveMentionQuery.js.map +1 -0
  18. package/dist/functions/im/imInlineContentTokens.d.ts +49 -0
  19. package/dist/functions/im/imInlineContentTokens.js +185 -0
  20. package/dist/functions/im/imInlineContentTokens.js.map +1 -0
  21. package/dist/functions/im/imRichClipboardPlain.d.ts +8 -0
  22. package/dist/functions/im/imRichClipboardPlain.js +162 -0
  23. package/dist/functions/im/imRichClipboardPlain.js.map +1 -0
  24. package/dist/functions/im/imRichContentHtml.d.ts +53 -0
  25. package/dist/functions/im/imRichContentHtml.js +476 -0
  26. package/dist/functions/im/imRichContentHtml.js.map +1 -0
  27. package/dist/functions/im/index.d.ts +4 -0
  28. package/dist/functions/im/index.js +5 -0
  29. package/dist/functions/im/index.js.map +1 -0
  30. package/dist/functions/im/parseImMentionSegments.d.ts +8 -4
  31. package/dist/functions/im/parseImMentionSegments.js +32 -2
  32. package/dist/functions/im/parseImMentionSegments.js.map +1 -1
  33. package/dist/functions/tencent-cloud/deploy.tcb.d.ts +0 -1
  34. package/dist/functions/tencent-cloud/deploy.tcb.js +0 -1
  35. package/dist/functions/tencent-cloud/deploy.tcb.js.map +1 -1
  36. package/dist/schemas/video.schema.d.ts +6 -6
  37. package/package.json +22 -15
  38. package/types/chat-shell-tab-config.d.ts +3 -7
  39. package/types/im-api.d.ts +12 -1
  40. package/types/im-chat.d.ts +52 -4
  41. package/types/im-forward.d.ts +37 -0
  42. package/types/im-reply.d.ts +6 -0
  43. package/types/sticker-pack.d.ts +38 -0
@@ -310,8 +310,8 @@ export declare const VideoCommentSchema: z.ZodObject<{
310
310
  created_at: z.ZodOptional<z.ZodString>;
311
311
  updated_at: z.ZodOptional<z.ZodString>;
312
312
  }, "strip", z.ZodTypeAny, {
313
- id: number;
314
313
  content: string;
314
+ id: number;
315
315
  video_id: string;
316
316
  user_id: string;
317
317
  created_at?: string | undefined;
@@ -319,8 +319,8 @@ export declare const VideoCommentSchema: z.ZodObject<{
319
319
  updated_at?: string | undefined;
320
320
  parent_id?: number | null | undefined;
321
321
  }, {
322
- id: number;
323
322
  content: string;
323
+ id: number;
324
324
  video_id: string;
325
325
  user_id: string;
326
326
  created_at?: string | undefined;
@@ -339,8 +339,8 @@ export declare const VideoCommentsResponseSchema: z.ZodObject<{
339
339
  created_at: z.ZodOptional<z.ZodString>;
340
340
  updated_at: z.ZodOptional<z.ZodString>;
341
341
  }, "strip", z.ZodTypeAny, {
342
- id: number;
343
342
  content: string;
343
+ id: number;
344
344
  video_id: string;
345
345
  user_id: string;
346
346
  created_at?: string | undefined;
@@ -348,8 +348,8 @@ export declare const VideoCommentsResponseSchema: z.ZodObject<{
348
348
  updated_at?: string | undefined;
349
349
  parent_id?: number | null | undefined;
350
350
  }, {
351
- id: number;
352
351
  content: string;
352
+ id: number;
353
353
  video_id: string;
354
354
  user_id: string;
355
355
  created_at?: string | undefined;
@@ -362,8 +362,8 @@ export declare const VideoCommentsResponseSchema: z.ZodObject<{
362
362
  offset: z.ZodNumber;
363
363
  }, "strip", z.ZodTypeAny, {
364
364
  data: {
365
- id: number;
366
365
  content: string;
366
+ id: number;
367
367
  video_id: string;
368
368
  user_id: string;
369
369
  created_at?: string | undefined;
@@ -376,8 +376,8 @@ export declare const VideoCommentsResponseSchema: z.ZodObject<{
376
376
  offset: number;
377
377
  }, {
378
378
  data: {
379
- id: number;
380
379
  content: string;
380
+ id: number;
381
381
  video_id: string;
382
382
  user_id: string;
383
383
  created_at?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcw-shared",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "files": [
5
5
  "references",
6
6
  "dist",
@@ -12,19 +12,6 @@
12
12
  "license": "ISC",
13
13
  "type": "module",
14
14
  "description": "",
15
- "scripts": {
16
- "build": "tsc -p tsconfig.build.json && tsx scripts/generate-exports.ts",
17
- "publish:patch": "npx tsx scripts/publish.ts patch",
18
- "publish:minor": "npx tsx scripts/publish.ts minor",
19
- "publish:major": "npx tsx scripts/publish.ts major",
20
- "publish:prerelease": "npx tsx scripts/publish.ts prerelease",
21
- "docs:dev": "vitepress dev docs",
22
- "docs:build": "NODE_OPTIONS=--max-old-space-size=4096 vitepress build docs",
23
- "docs:preview": "vitepress preview docs",
24
- "deploy:cos:build": "NODE_OPTIONS=--max-old-space-size=4096 vitepress build docs",
25
- "deploy:tcb": "npx tsx scripts/deploy-tcb.ts",
26
- "deploy:cos": "npx tsx scripts/deploy-cos.ts"
27
- },
28
15
  "dependencies": {
29
16
  "zod": "^3.23.8"
30
17
  },
@@ -159,6 +146,7 @@
159
146
  "./functions/design-tokens/mixColors": "./dist/functions/design-tokens/mixColors.js",
160
147
  "./functions/design-tokens/parseDesignTokens": "./dist/functions/design-tokens/parseDesignTokens.js",
161
148
  "./functions/dom/computePosition": "./dist/functions/dom/computePosition.js",
149
+ "./functions/dom/copyHtmlAndPlainToClipboard": "./dist/functions/dom/copyHtmlAndPlainToClipboard.js",
162
150
  "./functions/dom/copyTextToClipboard": "./dist/functions/dom/copyTextToClipboard.js",
163
151
  "./functions/dom/createSharedKeyboardCenter": "./dist/functions/dom/createSharedKeyboardCenter.js",
164
152
  "./functions/dom/createThrottledEventListener": "./dist/functions/dom/createThrottledEventListener.js",
@@ -200,7 +188,10 @@
200
188
  "./functions/hybrid/postBridgeMessage": "./dist/functions/hybrid/postBridgeMessage.js",
201
189
  "./functions/hybrid/validateBridgeMessage": "./dist/functions/hybrid/validateBridgeMessage.js",
202
190
  "./functions/im/formatImChatConversationListTime": "./dist/functions/im/formatImChatConversationListTime.js",
203
- "./functions/im/parseImMentionSegments": "./dist/functions/im/parseImMentionSegments.js",
191
+ "./functions/im/forwardBundlePayload": "./dist/functions/im/forwardBundlePayload.js",
192
+ "./functions/im/getActiveMentionQuery": "./dist/functions/im/getActiveMentionQuery.js",
193
+ "./functions/im/imRichClipboardPlain": "./dist/functions/im/imRichClipboardPlain.js",
194
+ "./functions/im/imRichContentHtml": "./dist/functions/im/imRichContentHtml.js",
204
195
  "./functions/image/compressImageToWidth": "./dist/functions/image/compressImageToWidth.js",
205
196
  "./functions/image/compressToTargetSize": "./dist/functions/image/compressToTargetSize.js",
206
197
  "./functions/image/generateFavIcon": "./dist/functions/image/generateFavIcon.js",
@@ -445,7 +436,9 @@
445
436
  "./types/hybrid": "./types/hybrid.d.ts",
446
437
  "./types/im-api": "./types/im-api.d.ts",
447
438
  "./types/im-chat": "./types/im-chat.d.ts",
439
+ "./types/im-forward": "./types/im-forward.d.ts",
448
440
  "./types/im-message-display": "./types/im-message-display.d.ts",
441
+ "./types/im-reply": "./types/im-reply.d.ts",
449
442
  "./types/ios-build": "./types/ios-build.d.ts",
450
443
  "./types/music": "./types/music.d.ts",
451
444
  "./types/notification": "./types/notification.d.ts",
@@ -465,6 +458,7 @@
465
458
  "./types/review": "./types/review.d.ts",
466
459
  "./types/semver": "./types/semver.d.ts",
467
460
  "./types/software": "./types/software.d.ts",
461
+ "./types/sticker-pack": "./types/sticker-pack.d.ts",
468
462
  "./types/storage": "./types/storage.d.ts",
469
463
  "./types/tencent-cloud": "./types/tencent-cloud.d.ts",
470
464
  "./types/uniapp-android-build": "./types/uniapp-android-build.d.ts",
@@ -474,5 +468,18 @@
474
468
  "./types/video": "./types/video.d.ts",
475
469
  "./types/vue": "./types/vue.d.ts",
476
470
  "./types/worker": "./types/worker.d.ts"
471
+ },
472
+ "scripts": {
473
+ "build": "tsc -p tsconfig.build.json && tsx scripts/generate-exports.ts",
474
+ "publish:patch": "npx tsx scripts/publish.ts patch",
475
+ "publish:minor": "npx tsx scripts/publish.ts minor",
476
+ "publish:major": "npx tsx scripts/publish.ts major",
477
+ "publish:prerelease": "npx tsx scripts/publish.ts prerelease",
478
+ "docs:dev": "vitepress dev docs",
479
+ "docs:build": "NODE_OPTIONS=--max-old-space-size=4096 vitepress build docs",
480
+ "docs:preview": "vitepress preview docs",
481
+ "deploy:cos:build": "NODE_OPTIONS=--max-old-space-size=4096 vitepress build docs",
482
+ "deploy:tcb": "npx tsx scripts/deploy-tcb.ts",
483
+ "deploy:cos": "npx tsx scripts/deploy-cos.ts"
477
484
  }
478
485
  }
@@ -32,10 +32,10 @@ export interface ChatShellTabConfig {
32
32
  /** 使用「我的」头像而非 icon */
33
33
  useMineAvatar?: boolean
34
34
  /**
35
- * 该 Tab 激活时切换整应用为深色主题(`html[data-theme="dark"]`),Dialog 等与主界面一致。
36
- * 默认仅 AI Tab 开启;其它 Tab 可在 page-config「更多」里勾选。
35
+ * 该 Tab 激活时隐藏壳层 Tabbar(移动端底栏 + 宽屏左侧导航,含底部头像入口)。
36
+ * 切换到其它 Tab Tabbar 恢复;适合全屏沉浸页。
37
37
  */
38
- shellDark?: boolean
38
+ hideTabbar?: boolean
39
39
  }
40
40
 
41
41
  export interface ChatShellDisplaysConfig {
@@ -45,10 +45,6 @@ export interface ChatShellDisplaysConfig {
45
45
  /** page-config `displays` 中与 Chat 壳层相关的字段 */
46
46
  export interface ChatAppDisplaysConfig {
47
47
  chatShell?: ChatShellDisplaysConfig
48
- /** @deprecated 使用 chatShell.tabs */
49
- mobileTabbar?: {
50
- enabledTabs?: string[]
51
- }
52
48
  }
53
49
 
54
50
  export interface ChatShellTabbarItem {
package/types/im-api.d.ts CHANGED
@@ -31,7 +31,16 @@ export interface ImApiMessage {
31
31
  sender_id: string
32
32
  conversation_id: string
33
33
  content: string
34
- type: 'text' | 'markdown' | 'image' | 'file' | 'system' | 'audio' | 'video'
34
+ type:
35
+ | 'text'
36
+ | 'markdown'
37
+ | 'image'
38
+ | 'file'
39
+ | 'system'
40
+ | 'audio'
41
+ | 'video'
42
+ | 'forward_bundle'
43
+ | 'sticker'
35
44
  status: 'sent' | 'delivered' | 'read'
36
45
  /** 发送方在该会话中的第几条(由服务端写入;旧数据可由接口补算) */
37
46
  sender_seq?: number
@@ -47,6 +56,8 @@ export interface ImApiMessage {
47
56
  outbound_status?: ImOutboundStatus
48
57
  /**
49
58
  * 可含 attachments、im_display(多段展示,见 types/im-message-display)等。
59
+ * 用户消息引用:`extra_data.reply_to`(见 `types/im-reply.d.ts` 的 `ImReplyToRef`)。
60
+ * 合并转发:主载荷在 `content`(JSON,见 `types/im-forward.d.ts`);旧数据可能仍在 `extra_data.forward_bundle`。
50
61
  * 智能体中断回复:`extra_data.ai_reply` 见 {@link ImApiAiReplyExtra}。
51
62
  */
52
63
  extra_data?: Record<string, any>
@@ -5,17 +5,53 @@
5
5
  * 在仓库层做 `ImApiMessage` → `ChatMessage` 的映射即可两端共类型、各层语义清晰。
6
6
  */
7
7
  import type { ImMessageDisplaySpec } from './im-message-display'
8
+ import type { ImForwardBundleStoredItem } from './im-forward'
9
+ import type { ImReplyToRef } from './im-reply'
10
+
11
+ /** 引用预览(仅 UI 解析 id 后填充,不落库) */
12
+ export interface ChatMessageQuotePreview {
13
+ senderName: string
14
+ snippet: string
15
+ /** 原消息不在当前线程缓存中(已删或未加载) */
16
+ missing?: boolean
17
+ }
8
18
 
9
19
  /** 与 `ImMessage.extra_data.attachments[]` 对齐的列表项(会话消息内联附件) */
10
20
  export interface ChatInlineAttachmentListItem {
11
21
  url: string
12
22
  name?: string
13
23
  mimeType?: string
24
+ /** 字节数,来自 extra_data.attachments[].size */
25
+ size?: number
26
+ }
27
+
28
+ /** 合并转发气泡内单条预览(由 `forward_bundle` 解析) */
29
+ export interface ChatForwardBundleItem {
30
+ senderName: string
31
+ snippet: string
32
+ /** 原会话消息 id(合并转发快照内) */
33
+ messageId?: string
34
+ /** 原会话发送方序号 #N */
35
+ senderSeq?: number
36
+ /** 原消息 IM type(text / markdown / image …) */
37
+ type?: string
38
+ /** 转发快照正文(URL 或文本) */
39
+ content?: string
40
+ /** 原消息展示用 extra(缩略图、im_display 等) */
41
+ extraData?: Record<string, unknown>
14
42
  }
15
43
 
16
44
  export interface ChatMessage {
17
45
  id: string
18
- type: 'text' | 'markdown' | 'image' | 'video' | 'voice' | 'file'
46
+ type:
47
+ | 'text'
48
+ | 'markdown'
49
+ | 'image'
50
+ | 'video'
51
+ | 'voice'
52
+ | 'file'
53
+ | 'forward_bundle'
54
+ | 'sticker'
19
55
  content: string
20
56
  timestamp: Date
21
57
  sender: {
@@ -38,7 +74,8 @@ export interface ChatMessage {
38
74
  * 媒体出站细分阶段:登记接口尚未返回时没有 OSS 字节进度,勿与实际上传百分比混淆。
39
75
  * server_storage:客户端向 COS 直传时的占位阶段(如 PUT 已发出、等待完成回调)。
40
76
  */
41
- mediaUploadPhase?: 'registering' | 'oss' | 'server_storage'
77
+ /** queued:已落本地草稿、排队等待串行上传;仅当前活跃条在 UI 上映射为 registering */
78
+ mediaUploadPhase?: 'queued' | 'registering' | 'oss' | 'server_storage'
42
79
  /** 终端幂等 id,与 ImApiMessage.client_message_id 一致 */
43
80
  clientMessageId?: string
44
81
  /** 媒体登记时原名(content 尚为空时用于文件气泡标题) */
@@ -58,8 +95,9 @@ export interface ChatMessage {
58
95
  /** 与 `extra_data.attachments` 同步的只读列表(用于附件列表弹窗等) */
59
96
  inlineAttachments?: ChatInlineAttachmentListItem[]
60
97
  /**
61
- * 正文同条「内联附件」正在本地上传(`extra_data.inline_uploading`)。
62
- * 进度用 {@link inlineUploadUploadedCount} / {@link inlineUploadTotalCount},勿往 `content` 拼接文案。
98
+ * 正文富文本仍在本地补齐资源(`extra_data.inline_uploading`):
99
+ * 工具栏待传附件条,或正文 `img:[local:…]` / blob 预览 OSS。
100
+ * 进度用 {@link inlineUploadUploadedCount} / {@link inlineUploadTotalCount}(仅附件条);勿往 `content` 拼接文案。
63
101
  */
64
102
  inlineUploading?: boolean
65
103
  /** 已完成上传的附件个数(`extra_data.inline_upload_uploaded_count`) */
@@ -74,6 +112,16 @@ export interface ChatMessage {
74
112
  agentProxyRetryable?: boolean
75
113
  /** 代理失败时的错误文案(如库不可用、ENOTFOUND) */
76
114
  agentProxyError?: string
115
+ /** `extra_data.reply_to.message_id`:引用的目标消息 */
116
+ replyToMessageId?: string
117
+ /** 由列表层按 {@link replyToMessageId} 从同会话消息解析,仅展示用 */
118
+ quotePreview?: ChatMessageQuotePreview
119
+ /** `type === 'forward_bundle'` 时由 content JSON(兼容 extra_data.forward_bundle)解析 */
120
+ forwardBundle?: ChatForwardBundleItem[]
121
+ /** `type === 'sticker'`:来自 extra_data.sticker */
122
+ stickerPackId?: number
123
+ stickerId?: number
124
+ stickerName?: string
77
125
  }
78
126
 
79
127
 
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 合并转发:`ImMessage.type === 'forward_bundle'`,载荷在 **content**(JSON,见 {@link ImForwardBundleContentPayload})。
3
+ * 引用回复才用 `extra_data.reply_to`;合并转发不是引用,不应占用 extra 主载荷。
4
+ * 旧数据可能仍在 `extra_data.forward_bundle`,读路径在 `parseForwardBundleFromImMessage` 中兼容。
5
+ */
6
+ export const IM_FORWARD_BUNDLE_EXTRA_KEY: 'forward_bundle'
7
+
8
+ /** content 内 JSON 版本号 */
9
+ export const IM_FORWARD_BUNDLE_CONTENT_VERSION: 1
10
+
11
+ /** 合并转发条目中单条原消息的快照(落库) */
12
+ export interface ImForwardBundleStoredItem {
13
+ sender_id?: string
14
+ sender_name: string
15
+ /** 原消息 IM type(text / markdown / image …) */
16
+ type: string
17
+ /** 转发发送用的正文(URL 或文本) */
18
+ content: string
19
+ /** 列表/气泡内预览文案 */
20
+ snippet: string
21
+ /** 原会话中的消息主键(便于详情展示 #序号 或跳转) */
22
+ message_id?: string
23
+ /** 原会话中的发送方序号(与气泡元数据 #N 一致) */
24
+ sender_seq?: number
25
+ /** 原消息展示用 extra(如 im_display、缩略图字段等) */
26
+ extra_data?: Record<string, unknown>
27
+ }
28
+
29
+ export interface ImForwardBundleExtra {
30
+ items: ImForwardBundleStoredItem[]
31
+ }
32
+
33
+ /** 写入 `ImMessage.content` 的 JSON 结构 */
34
+ export interface ImForwardBundleContentPayload {
35
+ v: typeof IM_FORWARD_BUNDLE_CONTENT_VERSION
36
+ items: ImForwardBundleStoredItem[]
37
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 用户消息「引用」:`ImApiMessage.extra_data.reply_to`(与 `ai_reply.reply_to_message_id` 无关)。
3
+ */
4
+ export interface ImReplyToRef {
5
+ message_id: string | number
6
+ }
@@ -0,0 +1,38 @@
1
+ /** 表情包(运营配置,客户端拉取展示) */
2
+
3
+ export type StickerPackStatus = 'active' | 'inactive' | 'draft'
4
+
5
+ export interface StickerItem {
6
+ id: number
7
+ pack_id: number
8
+ name?: string
9
+ /** 表情图 URL(建议 OSS 公网或签名 URL) */
10
+ url: string
11
+ sort_order?: number
12
+ status?: StickerPackStatus
13
+ width?: number
14
+ height?: number
15
+ created_at?: string
16
+ updated_at?: string
17
+ }
18
+
19
+ export interface StickerPack {
20
+ id: number
21
+ name: string
22
+ cover_url?: string
23
+ sort_order?: number
24
+ status: StickerPackStatus
25
+ stickers?: StickerItem[]
26
+ created_at?: string
27
+ updated_at?: string
28
+ }
29
+
30
+ /** IM 消息 extra_data.sticker */
31
+ export interface ImMessageStickerExtra {
32
+ pack_id: number
33
+ sticker_id: number
34
+ url: string
35
+ name?: string
36
+ width?: number
37
+ height?: number
38
+ }