@tdesign-react/chat 1.0.2-alpha.8 → 1.0.2
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/CHANGELOG.md +18 -1
- package/es/_util/reactify.js +1 -1
- package/es/_util/useDynamicStyle.js +1 -1
- package/es/attachments/index.js +1 -1
- package/es/chat-actionbar/_example-js/base.d.ts +2 -0
- package/es/chat-actionbar/_example-js/custom.d.ts +2 -0
- package/es/chat-actionbar/_example-js/style.d.ts +2 -0
- package/es/chat-actionbar/index.js +1 -1
- package/es/chat-attachments/_example-js/base.d.ts +2 -0
- package/es/chat-attachments/_example-js/scroll-x.d.ts +2 -0
- package/es/chat-attachments/_example-js/scroll-y.d.ts +2 -0
- package/es/chat-attachments/index.js +3 -1
- package/es/chat-attachments/index.js.map +1 -1
- package/es/chat-engine/_example-js/agui-basic.d.ts +10 -0
- package/es/chat-engine/_example-js/agui-comprehensive.d.ts +2 -0
- package/es/chat-engine/_example-js/agui-test.d.ts +11 -0
- package/es/chat-engine/_example-js/agui-toolcall.d.ts +5 -0
- package/es/chat-engine/_example-js/agui-videoclip.d.ts +8 -0
- package/es/chat-engine/_example-js/agui.d.ts +1 -0
- package/es/chat-engine/_example-js/basic.d.ts +9 -0
- package/es/chat-engine/_example-js/components/HotelCard.d.ts +3 -0
- package/es/chat-engine/_example-js/components/HumanInputForm.d.ts +6 -0
- package/es/chat-engine/_example-js/components/HumanInputResult.d.ts +3 -0
- package/es/chat-engine/_example-js/components/ItineraryCard.d.ts +3 -0
- package/es/chat-engine/_example-js/components/PlanningStatePanel.d.ts +4 -0
- package/es/chat-engine/_example-js/components/Toolcall.d.ts +4 -0
- package/es/chat-engine/_example-js/components/WeatherCard.d.ts +3 -0
- package/es/chat-engine/_example-js/components/login.d.ts +1 -0
- package/es/chat-engine/_example-js/comprehensive.d.ts +12 -0
- package/es/chat-engine/_example-js/custom-content.d.ts +1 -0
- package/es/chat-engine/_example-js/hookComponent.d.ts +1 -0
- package/es/chat-engine/_example-js/initial-messages.d.ts +9 -0
- package/es/chat-engine/_example-js/instance-methods.d.ts +13 -0
- package/es/chat-engine/_example-js/travel-actions.d.ts +91 -0
- package/es/chat-engine/_example-js/travelToolcall.d.ts +1 -0
- package/es/chat-engine/components/activity/index.js +19 -0
- package/es/chat-engine/components/activity/registry.d.ts +44 -0
- package/es/{chatbot/components/toolcall → chat-engine/components/activity}/registry.js +32 -22
- package/es/chat-engine/components/activity/registry.js.map +1 -0
- package/es/chat-engine/components/activity/render.d.ts +15 -0
- package/es/chat-engine/components/activity/render.js +117 -0
- package/es/chat-engine/components/activity/render.js.map +1 -0
- package/es/chat-engine/components/activity/types.d.ts +29 -0
- package/es/chat-engine/components/activity/types.js +7 -0
- package/es/chat-engine/components/activity/types.js.map +1 -0
- package/es/chat-engine/components/index.d.ts +3 -0
- package/es/chat-engine/components/index.js +29 -0
- package/es/chat-engine/components/index.js.map +1 -0
- package/es/chat-engine/components/provider/agent-state.js +1 -1
- package/es/chat-engine/components/toolcall/index.js +5 -2
- package/es/chat-engine/components/toolcall/index.js.map +1 -1
- package/es/chat-engine/components/toolcall/registry.js +1 -1
- package/es/chat-engine/components/toolcall/render.d.ts +1 -1
- package/es/chat-engine/components/toolcall/render.js +72 -26
- package/es/chat-engine/components/toolcall/render.js.map +1 -1
- package/es/chat-engine/components/toolcall/types.js +1 -1
- package/es/chat-engine/hooks/index.d.ts +4 -0
- package/es/chat-engine/hooks/index.js +20 -0
- package/es/chat-engine/hooks/index.js.map +1 -0
- package/es/chat-engine/hooks/useAgentActivity.d.ts +15 -0
- package/es/chat-engine/hooks/useAgentActivity.js +73 -0
- package/es/chat-engine/hooks/useAgentActivity.js.map +1 -0
- package/es/chat-engine/hooks/useAgentState.js +1 -1
- package/es/chat-engine/hooks/useAgentState.js.map +1 -1
- package/es/chat-engine/hooks/useAgentToolcall.js +1 -1
- package/es/chat-engine/hooks/useChat.d.ts +1 -1
- package/es/chat-engine/hooks/useChat.js +1 -1
- package/es/chat-engine/hooks/useChat.js.map +1 -1
- package/es/chat-engine/index.d.ts +2 -2
- package/es/chat-engine/index.js +13 -3
- package/es/chat-engine/index.js.map +1 -1
- package/es/chat-filecard/_example-js/base.d.ts +1 -0
- package/es/chat-filecard/index.js +1 -1
- package/es/chat-loading/_example-js/base.d.ts +2 -0
- package/es/chat-loading/_example-js/text.d.ts +2 -0
- package/es/chat-loading/index.js +1 -1
- package/es/chat-markdown/_example-js/base.d.ts +1 -0
- package/es/chat-markdown/_example-js/custom.d.ts +2 -0
- package/es/chat-markdown/_example-js/event.d.ts +1 -0
- package/es/chat-markdown/_example-js/footnote.d.ts +2 -0
- package/es/chat-markdown/_example-js/plugin.d.ts +2 -0
- package/es/chat-markdown/_example-js/theme.d.ts +2 -0
- package/es/chat-markdown/index.js +1 -1
- package/es/chat-message/_example-js/action.d.ts +1 -0
- package/es/chat-message/_example-js/base.d.ts +1 -0
- package/es/chat-message/_example-js/configure.d.ts +1 -0
- package/es/chat-message/_example-js/content.d.ts +1 -0
- package/es/chat-message/_example-js/custom.d.ts +1 -0
- package/es/chat-message/_example-js/handle-actions.d.ts +7 -0
- package/es/chat-message/_example-js/status.d.ts +1 -0
- package/es/chat-message/_example-js/think.d.ts +1 -0
- package/es/chat-message/index.js +1 -1
- package/es/chat-sender/_example-js/attachment.d.ts +2 -0
- package/es/chat-sender/_example-js/base.d.ts +2 -0
- package/es/chat-sender/_example-js/custom.d.ts +2 -0
- package/es/chat-sender/index.js +1 -1
- package/es/chat-thinking/_example-js/base.d.ts +1 -0
- package/es/chat-thinking/_example-js/style.d.ts +1 -0
- package/es/chat-thinking/index.js +1 -1
- package/es/chatbot/_example-js/agent.d.ts +1 -0
- package/es/chatbot/_example-js/agui-toolcall.d.ts +11 -0
- package/es/chatbot/_example-js/agui.d.ts +13 -0
- package/es/chatbot/_example-js/backup/travel.d.ts +1 -0
- package/es/chatbot/_example-js/basic.d.ts +1 -0
- package/es/chatbot/_example-js/code.d.ts +1 -0
- package/es/chatbot/_example-js/components/ItineraryCard.d.ts +3 -0
- package/es/chatbot/_example-js/components/login.d.ts +1 -0
- package/es/chatbot/_example-js/comprehensive.d.ts +1 -0
- package/es/chatbot/_example-js/custom-content.d.ts +1 -0
- package/es/chatbot/_example-js/custom-merge.d.ts +1 -0
- package/es/chatbot/_example-js/custom.d.ts +1 -0
- package/es/chatbot/_example-js/docs.d.ts +1 -0
- package/es/chatbot/_example-js/image.d.ts +1 -0
- package/es/chatbot/_example-js/initial-messages.d.ts +9 -0
- package/es/chatbot/_example-js/instance-methods.d.ts +14 -0
- package/es/chatbot/_example-js/nostream.d.ts +1 -0
- package/es/chatbot/_example-js/quick-start.d.ts +9 -0
- package/es/chatbot/_example-js/research.d.ts +1 -0
- package/es/chatbot/_example-js/role-message-config.d.ts +22 -0
- package/es/chatbot/_example-js/sender-config.d.ts +20 -0
- package/es/chatbot/_example-js/service-config.d.ts +17 -0
- package/es/chatbot/_example-js/simple.d.ts +1 -0
- package/es/chatbot/_example-js/utils/messageRenderer.d.ts +5 -0
- package/es/chatbot/index.js +1 -1
- package/es/index.js +8 -1
- package/es/index.js.map +1 -1
- package/es/style/index.js +1 -1
- package/package.json +15 -15
- package/es/chatbot/components/provider/agent-state.d.ts +0 -5
- package/es/chatbot/components/provider/agent-state.js +0 -28
- package/es/chatbot/components/provider/agent-state.js.map +0 -1
- package/es/chatbot/components/toolcall/index.js +0 -19
- package/es/chatbot/components/toolcall/registry.d.ts +0 -35
- package/es/chatbot/components/toolcall/registry.js.map +0 -1
- package/es/chatbot/components/toolcall/render.d.ts +0 -13
- package/es/chatbot/components/toolcall/render.js +0 -207
- package/es/chatbot/components/toolcall/render.js.map +0 -1
- package/es/chatbot/components/toolcall/types.d.ts +0 -57
- package/es/chatbot/components/toolcall/types.js +0 -15
- package/es/chatbot/components/toolcall/types.js.map +0 -1
- package/es/chatbot/hooks/useAgentState.d.ts +0 -40
- package/es/chatbot/hooks/useAgentState.js +0 -76
- package/es/chatbot/hooks/useAgentState.js.map +0 -1
- package/es/chatbot/hooks/useAgentToolcall.d.ts +0 -28
- package/es/chatbot/hooks/useAgentToolcall.js +0 -78
- package/es/chatbot/hooks/useAgentToolcall.js.map +0 -1
- package/es/chatbot/hooks/useChat.d.ts +0 -11
- package/es/chatbot/hooks/useChat.js +0 -66
- package/es/chatbot/hooks/useChat.js.map +0 -1
- /package/es/{chatbot/components/toolcall → chat-engine/components/activity}/index.d.ts +0 -0
- /package/es/{chatbot/components/toolcall → chat-engine/components/activity}/index.js.map +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ toc: false
|
|
|
5
5
|
spline: explain
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
## 🌈
|
|
8
|
+
## 🌈 1.0.2 `2026-02-05`
|
|
9
|
+
|
|
10
|
+
### 🚀 Features
|
|
11
|
+
|
|
12
|
+
- `ChatEngine`:
|
|
13
|
+
- 支持AG-UI Activity-Snapshot/Delta事件的适配,新增useAgentActivity注册hook,并增加示例 @carolin913 ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
14
|
+
- 增加在无 UI 场景下使用 ChatEngine 事件总线机制,并增加示例 @carolin913 ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
15
|
+
- ToolCallRender 增加错误边界处理 @carolin913 ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
16
|
+
- AG-UI协议下几个Delta事件,支持自动初始化接收无Snapshot情况下SSE Chunk流 @carolin913 ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
17
|
+
- Immutable JSON Patch 性能优化,并支持append操作用来追加字符串 @carolin913 ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
18
|
+
- `ChatMarkdown`: 大幅优化依赖CherryMarkdown造成的打包体积膨胀问题,**不再内置highlight代码块样式高亮**,需要业务自行引入配置 @LzhengH @carolin913 ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
19
|
+
- `ChatSender`: 支持readyToSend可以接管发送前校验 @LzhengH ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
20
|
+
|
|
21
|
+
### 📝 Documentation
|
|
22
|
+
|
|
23
|
+
- `ChatEngine`: 增加AI友好型文档:AGENTS.md和llm.txt @carolin913 ([#4119](https://github.com/Tencent/tdesign-react/pull/4119))
|
|
24
|
+
|
|
25
|
+
## 🌈 1.0.0 `2026-11-20`
|
|
9
26
|
|
|
10
27
|
- Release 1st version
|
package/es/_util/reactify.js
CHANGED
package/es/attachments/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.
|
|
2
|
+
* tdesign v1.0.1
|
|
3
3
|
* (c) 2025 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -17,6 +17,8 @@ import '@babel/runtime/helpers/defineProperty';
|
|
|
17
17
|
import '@babel/runtime/helpers/slicedToArray';
|
|
18
18
|
import '@babel/runtime/helpers/typeof';
|
|
19
19
|
import 'react';
|
|
20
|
+
import 'react-dom';
|
|
21
|
+
import 'react-dom/client';
|
|
20
22
|
|
|
21
23
|
var Attachments = reactify("t-attachments");
|
|
22
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-attachments/index.ts"],"sourcesContent":["import { TdAttachmentsProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/attachments';\nimport reactify from '../_util/reactify';\n\nexport const Attachments: React.ForwardRefExoticComponent<\n Omit<TdAttachmentsProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdAttachmentsProps>('t-attachments');\n\nexport default Attachments;\n\nexport type { TdAttachmentsProps, TdAttachmentItem } from 'tdesign-web-components';\n"],"names":["Attachments","reactify"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../pro-components/chat/chat-attachments/index.ts"],"sourcesContent":["import { TdAttachmentsProps } from 'tdesign-web-components';\nimport 'tdesign-web-components/lib/attachments';\nimport reactify from '../_util/reactify';\n\nexport const Attachments: React.ForwardRefExoticComponent<\n Omit<TdAttachmentsProps, 'ref'> & React.RefAttributes<HTMLElement | undefined>\n> = reactify<TdAttachmentsProps>('t-attachments');\n\nexport default Attachments;\n\nexport type { TdAttachmentsProps, TdAttachmentItem } from 'tdesign-web-components';\n"],"names":["Attachments","reactify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAIaA,WAAA,GAETC,SAA6B,eAAe;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-UI 协议基础示例
|
|
3
|
+
*
|
|
4
|
+
* 学习目标:
|
|
5
|
+
* - 开启 AG-UI 协议支持(protocol: 'agui')
|
|
6
|
+
* - 理解 AG-UI 协议的自动解析机制
|
|
7
|
+
* - 处理文本消息事件(TEXT_MESSAGE_*)
|
|
8
|
+
* - 初始化加载历史消息方法 AGUIAdapter.convertHistoryMessages
|
|
9
|
+
*/
|
|
10
|
+
export default function AguiBasicExample(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AG-UI 协议基础示例
|
|
3
|
+
*
|
|
4
|
+
* 学习目标:
|
|
5
|
+
* - 开启 AG-UI 协议支持(protocol: 'agui')
|
|
6
|
+
* - 理解 AG-UI 协议的自动解析机制
|
|
7
|
+
* - 处理文本消息事件(TEXT_MESSAGE_*)
|
|
8
|
+
* - 初始化加载历史消息方法 AGUIAdapter.convertHistoryMessages
|
|
9
|
+
* - 调试 ToolCall 组件状态问题
|
|
10
|
+
*/
|
|
11
|
+
export default function AguiBasicExample(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 使用状态订阅机制的视频剪辑Agent聊天组件
|
|
3
|
+
* 演示如何结合状态订阅和工具调用功能
|
|
4
|
+
*/
|
|
5
|
+
export default function VideoClipAgentChatWithSubscription(): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export function VideoClipSteps({ boundStateKey }: {
|
|
7
|
+
boundStateKey: any;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ComponentsBuild(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function BaseForm(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CustomContent(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ComponentsBuild(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 实例方法示例
|
|
3
|
+
*
|
|
4
|
+
* 学习目标:
|
|
5
|
+
* - 通过 chatEngine 调用实例方法
|
|
6
|
+
* - 了解各种实例方法的使用场景
|
|
7
|
+
*
|
|
8
|
+
* 方法分类:
|
|
9
|
+
* 1. 消息设置:sendUserMessage、sendSystemMessage、setMessages
|
|
10
|
+
* 2. 发送控制: regenerateAIMessage、abortChat
|
|
11
|
+
* 3. 获取状态
|
|
12
|
+
*/
|
|
13
|
+
export default function InstanceMethods(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export namespace weatherForecastAction {
|
|
2
|
+
export let name: string;
|
|
3
|
+
export let description: string;
|
|
4
|
+
export let parameters: {
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
}[];
|
|
9
|
+
export { WeatherDisplay as component };
|
|
10
|
+
}
|
|
11
|
+
export namespace itineraryPlanAction {
|
|
12
|
+
let name_1: string;
|
|
13
|
+
export { name_1 as name };
|
|
14
|
+
let description_1: string;
|
|
15
|
+
export { description_1 as description };
|
|
16
|
+
let parameters_1: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
required: boolean;
|
|
20
|
+
}[];
|
|
21
|
+
export { parameters_1 as parameters };
|
|
22
|
+
export { PlanItinerary as component };
|
|
23
|
+
export function handler(args: any, backendResult: any): Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export namespace hotelRecommendAction {
|
|
26
|
+
let name_2: string;
|
|
27
|
+
export { name_2 as name };
|
|
28
|
+
let description_2: string;
|
|
29
|
+
export { description_2 as description };
|
|
30
|
+
let parameters_2: {
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
required: boolean;
|
|
34
|
+
}[];
|
|
35
|
+
export { parameters_2 as parameters };
|
|
36
|
+
export { HotelRecommend as component };
|
|
37
|
+
}
|
|
38
|
+
export namespace travelPreferencesAction {
|
|
39
|
+
let name_3: string;
|
|
40
|
+
export { name_3 as name };
|
|
41
|
+
let description_3: string;
|
|
42
|
+
export { description_3 as description };
|
|
43
|
+
let parameters_3: {
|
|
44
|
+
name: string;
|
|
45
|
+
type: string;
|
|
46
|
+
required: boolean;
|
|
47
|
+
}[];
|
|
48
|
+
export { parameters_3 as parameters };
|
|
49
|
+
export { TravelPreferences as component };
|
|
50
|
+
}
|
|
51
|
+
export const travelActions: {
|
|
52
|
+
name: string;
|
|
53
|
+
description: string;
|
|
54
|
+
parameters: {
|
|
55
|
+
name: string;
|
|
56
|
+
type: string;
|
|
57
|
+
required: boolean;
|
|
58
|
+
}[];
|
|
59
|
+
component: ({ status, args, result, error }: {
|
|
60
|
+
status: any;
|
|
61
|
+
args: any;
|
|
62
|
+
result: any;
|
|
63
|
+
error: any;
|
|
64
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
}[];
|
|
66
|
+
declare function WeatherDisplay({ status, args, result, error }: {
|
|
67
|
+
status: any;
|
|
68
|
+
args: any;
|
|
69
|
+
result: any;
|
|
70
|
+
error: any;
|
|
71
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
declare function PlanItinerary({ status, args, result, error }: {
|
|
73
|
+
status: any;
|
|
74
|
+
args: any;
|
|
75
|
+
result: any;
|
|
76
|
+
error: any;
|
|
77
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
declare function HotelRecommend({ status, args, result, error }: {
|
|
79
|
+
status: any;
|
|
80
|
+
args: any;
|
|
81
|
+
result: any;
|
|
82
|
+
error: any;
|
|
83
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
declare function TravelPreferences({ status, args, result, error, respond }: {
|
|
85
|
+
status: any;
|
|
86
|
+
args: any;
|
|
87
|
+
result: any;
|
|
88
|
+
error: any;
|
|
89
|
+
respond: any;
|
|
90
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function TravelPlannerChat(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tdesign v1.0.2
|
|
3
|
+
* (c) 2026 tdesign
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import './types.js';
|
|
8
|
+
export { activityRegistry } from './registry.js';
|
|
9
|
+
export { ActivityRenderer } from './render.js';
|
|
10
|
+
import '@babel/runtime/helpers/classCallCheck';
|
|
11
|
+
import '@babel/runtime/helpers/createClass';
|
|
12
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
13
|
+
import 'react';
|
|
14
|
+
import '@babel/runtime/helpers/slicedToArray';
|
|
15
|
+
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
16
|
+
import '@babel/runtime/helpers/getPrototypeOf';
|
|
17
|
+
import '@babel/runtime/helpers/inherits';
|
|
18
|
+
import 'react-fast-compare';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ActivityConfig, ActivityRegistry, ActivityComponentProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Activity 注册表管理器
|
|
5
|
+
* 业务方注册具体的 activityType(如 json-render-main-card),精确匹配
|
|
6
|
+
*/
|
|
7
|
+
declare class ActivityRegistryManager {
|
|
8
|
+
private registry;
|
|
9
|
+
private renderFunctionCache;
|
|
10
|
+
/**
|
|
11
|
+
* 注册一个 Activity 配置
|
|
12
|
+
*/
|
|
13
|
+
register<TContent = any>(config: ActivityConfig<TContent>): void;
|
|
14
|
+
/**
|
|
15
|
+
* 获取指定类型的 Activity 配置
|
|
16
|
+
*/
|
|
17
|
+
get(activityType: string): ActivityConfig | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* 获取或创建缓存的组件渲染函数
|
|
20
|
+
*/
|
|
21
|
+
getRenderFunction(activityType: string): React.MemoExoticComponent<React.ComponentType<ActivityComponentProps>> | null;
|
|
22
|
+
/**
|
|
23
|
+
* 获取所有已注册的 Activity 配置
|
|
24
|
+
*/
|
|
25
|
+
getAll(): ActivityRegistry;
|
|
26
|
+
/**
|
|
27
|
+
* 取消注册指定的 Activity
|
|
28
|
+
*/
|
|
29
|
+
unregister(activityType: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* 清空所有注册的 Activity
|
|
32
|
+
*/
|
|
33
|
+
clear(): void;
|
|
34
|
+
/**
|
|
35
|
+
* 检查指定类型是否已注册
|
|
36
|
+
*/
|
|
37
|
+
has(activityType: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 获取所有已注册的 Activity 类型
|
|
40
|
+
*/
|
|
41
|
+
getRegisteredTypes(): string[];
|
|
42
|
+
}
|
|
43
|
+
export declare const activityRegistry: ActivityRegistryManager;
|
|
44
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.0.
|
|
3
|
-
* (c)
|
|
2
|
+
* tdesign v1.0.2
|
|
3
|
+
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -11,42 +11,42 @@ import React from 'react';
|
|
|
11
11
|
|
|
12
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
_classCallCheck(this,
|
|
14
|
+
var ActivityRegistryManager = /*#__PURE__*/function () {
|
|
15
|
+
function ActivityRegistryManager() {
|
|
16
|
+
_classCallCheck(this, ActivityRegistryManager);
|
|
17
17
|
_defineProperty(this, "registry", {});
|
|
18
18
|
_defineProperty(this, "renderFunctionCache", /* @__PURE__ */new Map());
|
|
19
19
|
}
|
|
20
|
-
return _createClass(
|
|
20
|
+
return _createClass(ActivityRegistryManager, [{
|
|
21
21
|
key: "register",
|
|
22
22
|
value: function register(config) {
|
|
23
|
-
var existingConfig = this.registry[config.
|
|
23
|
+
var existingConfig = this.registry[config.activityType];
|
|
24
24
|
if (existingConfig && existingConfig.component !== config.component) {
|
|
25
|
-
this.renderFunctionCache["delete"](config.
|
|
25
|
+
this.renderFunctionCache["delete"](config.activityType);
|
|
26
26
|
}
|
|
27
|
-
this.registry[config.
|
|
28
|
-
window.dispatchEvent(new CustomEvent("
|
|
27
|
+
this.registry[config.activityType] = config;
|
|
28
|
+
window.dispatchEvent(new CustomEvent("activity-registered", {
|
|
29
29
|
detail: {
|
|
30
|
-
|
|
30
|
+
activityType: config.activityType
|
|
31
31
|
}
|
|
32
32
|
}));
|
|
33
33
|
}
|
|
34
34
|
}, {
|
|
35
35
|
key: "get",
|
|
36
|
-
value: function get(
|
|
37
|
-
return this.registry[
|
|
36
|
+
value: function get(activityType) {
|
|
37
|
+
return this.registry[activityType];
|
|
38
38
|
}
|
|
39
39
|
}, {
|
|
40
40
|
key: "getRenderFunction",
|
|
41
|
-
value: function getRenderFunction(
|
|
42
|
-
var config = this.registry[
|
|
41
|
+
value: function getRenderFunction(activityType) {
|
|
42
|
+
var config = this.registry[activityType];
|
|
43
43
|
if (!config) return null;
|
|
44
|
-
var memoizedComponent = this.renderFunctionCache.get(
|
|
44
|
+
var memoizedComponent = this.renderFunctionCache.get(activityType);
|
|
45
45
|
if (!memoizedComponent) {
|
|
46
46
|
memoizedComponent = /*#__PURE__*/React.memo(function (props) {
|
|
47
47
|
return /*#__PURE__*/React.createElement(config.component, props);
|
|
48
48
|
});
|
|
49
|
-
this.renderFunctionCache.set(
|
|
49
|
+
this.renderFunctionCache.set(activityType, memoizedComponent);
|
|
50
50
|
}
|
|
51
51
|
return memoizedComponent;
|
|
52
52
|
}
|
|
@@ -57,9 +57,9 @@ var AgentToolcallRegistryManager = /*#__PURE__*/function () {
|
|
|
57
57
|
}
|
|
58
58
|
}, {
|
|
59
59
|
key: "unregister",
|
|
60
|
-
value: function unregister(
|
|
61
|
-
delete this.registry[
|
|
62
|
-
this.renderFunctionCache["delete"](
|
|
60
|
+
value: function unregister(activityType) {
|
|
61
|
+
delete this.registry[activityType];
|
|
62
|
+
this.renderFunctionCache["delete"](activityType);
|
|
63
63
|
}
|
|
64
64
|
}, {
|
|
65
65
|
key: "clear",
|
|
@@ -67,9 +67,19 @@ var AgentToolcallRegistryManager = /*#__PURE__*/function () {
|
|
|
67
67
|
this.registry = {};
|
|
68
68
|
this.renderFunctionCache.clear();
|
|
69
69
|
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "has",
|
|
72
|
+
value: function has(activityType) {
|
|
73
|
+
return activityType in this.registry;
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "getRegisteredTypes",
|
|
77
|
+
value: function getRegisteredTypes() {
|
|
78
|
+
return Object.keys(this.registry);
|
|
79
|
+
}
|
|
70
80
|
}]);
|
|
71
81
|
}();
|
|
72
|
-
var
|
|
82
|
+
var activityRegistry = new ActivityRegistryManager();
|
|
73
83
|
|
|
74
|
-
export {
|
|
84
|
+
export { activityRegistry };
|
|
75
85
|
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sources":["../../../../../pro-components/chat/chat-engine/components/activity/registry.ts"],"sourcesContent":["import React from 'react';\nimport type { ActivityConfig, ActivityRegistry, ActivityComponentProps } from './types';\n\n/**\n * Activity 注册表管理器\n * 业务方注册具体的 activityType(如 json-render-main-card),精确匹配\n */\nclass ActivityRegistryManager {\n private registry: ActivityRegistry = {};\n\n // 组件渲染函数缓存,避免重复创建 React 组件\n private renderFunctionCache = new Map<\n string,\n React.MemoExoticComponent<React.ComponentType<ActivityComponentProps>>\n >();\n\n /**\n * 注册一个 Activity 配置\n */\n register<TContent = any>(config: ActivityConfig<TContent>): void {\n const existingConfig = this.registry[config.activityType];\n\n // 如果组件发生变化,清除旧的缓存\n if (existingConfig && existingConfig.component !== config.component) {\n this.renderFunctionCache.delete(config.activityType);\n }\n\n this.registry[config.activityType] = config;\n\n // 触发注册事件,支持动态注册\n window.dispatchEvent(\n new CustomEvent('activity-registered', {\n detail: { activityType: config.activityType },\n }),\n );\n }\n\n /**\n * 获取指定类型的 Activity 配置\n */\n get(activityType: string): ActivityConfig | undefined {\n return this.registry[activityType];\n }\n\n /**\n * 获取或创建缓存的组件渲染函数\n */\n getRenderFunction(activityType: string): React.MemoExoticComponent<React.ComponentType<ActivityComponentProps>> | null {\n const config = this.registry[activityType];\n if (!config) return null;\n\n // 检查缓存\n let memoizedComponent = this.renderFunctionCache.get(activityType);\n\n if (!memoizedComponent) {\n // 创建 memo 化的组件\n memoizedComponent = React.memo((props: ActivityComponentProps) => \n React.createElement(config.component, props)\n );\n\n // 缓存组件\n this.renderFunctionCache.set(activityType, memoizedComponent);\n }\n\n return memoizedComponent;\n }\n\n /**\n * 获取所有已注册的 Activity 配置\n */\n getAll(): ActivityRegistry {\n return { ...this.registry };\n }\n\n /**\n * 取消注册指定的 Activity\n */\n unregister(activityType: string): void {\n delete this.registry[activityType];\n this.renderFunctionCache.delete(activityType);\n }\n\n /**\n * 清空所有注册的 Activity\n */\n clear(): void {\n this.registry = {};\n this.renderFunctionCache.clear();\n }\n\n /**\n * 检查指定类型是否已注册\n */\n has(activityType: string): boolean {\n return activityType in this.registry;\n }\n\n /**\n * 获取所有已注册的 Activity 类型\n */\n getRegisteredTypes(): string[] {\n return Object.keys(this.registry);\n }\n}\n\n// 导出单例实例\nexport const activityRegistry = new ActivityRegistryManager();\n"],"names":["ActivityRegistryManager","_classCallCheck","_defineProperty","Map","_createClass","key","value","register","config","existingConfig","registry","activityType","component","renderFunctionCache","window","dispatchEvent","CustomEvent","detail","get","getRenderFunction","memoizedComponent","React","memo","props","createElement","set","getAll","_objectSpread","unregister","clear","has","getRegisteredTypes","Object","keys","activityRegistry"],"mappings":";;;;;;;;;;;;;AAAkB,IAOZA,uBAAwB,gBAAA,YAAA;AAAA,EAAA,SAAAA,uBAAA,GAAA;AAAAC,IAAAA,eAAA,OAAAD,uBAAA,CAAA,CAAA;IAAAE,eAAA,CAAA,IAAA,EAAA,UAAA,EACS,EAAC,CAAA,CAAA;AAAAA,IAAAA,eAAA,CAGR,IAAA,EAAA,qBAAA,qBAAIC,GAGhC,EAAA,CAAA,CAAA;AAAA,GAAA;EAAA,OAAAC,YAAA,CAAAJ,uBAAA,EAAA,CAAA;IAAAK,GAAA,EAAA,UAAA;AAAAC,IAAAA,KAAA,EAKF,SAAAC,SAAyBC,MAAwC,EAAA;MACzD,IAAAC,cAAA,GAAiB,IAAK,CAAAC,QAAA,CAASF,MAAO,CAAAG,YAAA,CAAA,CAAA;MAG5C,IAAIF,cAA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Data;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Activity 渲染器组件
|
|
8
|
+
* 根据 activityType 精确匹配查找注册的组件进行渲染
|
|
9
|
+
*
|
|
10
|
+
* 性能优化:
|
|
11
|
+
* - 使用 react-fast-compare 替代 JSON.stringify 进行深比较
|
|
12
|
+
* - 短路比较,发现差异立即停止,对大型 JSON 树性能提升显著
|
|
13
|
+
*/
|
|
14
|
+
export declare const ActivityRenderer: React.NamedExoticComponent<ActivityRendererProps>;
|
|
15
|
+
export {};
|