@zov-chatui/base 1.0.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.
- package/README.md +347 -0
- package/dist/components/Chat/AnimatedRobot.d.ts +5 -0
- package/dist/components/Chat/AnimatedRobot.d.ts.map +1 -0
- package/dist/components/Chat/ChatInput.d.ts +4 -0
- package/dist/components/Chat/ChatInput.d.ts.map +1 -0
- package/dist/components/Chat/ChatList.d.ts +4 -0
- package/dist/components/Chat/ChatList.d.ts.map +1 -0
- package/dist/components/Chat/ChatMessage.d.ts +4 -0
- package/dist/components/Chat/ChatMessage.d.ts.map +1 -0
- package/dist/components/Chat/MessageContent.d.ts +8 -0
- package/dist/components/Chat/MessageContent.d.ts.map +1 -0
- package/dist/components/Chat/MobileChatInput.d.ts +4 -0
- package/dist/components/Chat/MobileChatInput.d.ts.map +1 -0
- package/dist/components/Chat/TypewriterPlaceholder.d.ts +12 -0
- package/dist/components/Chat/TypewriterPlaceholder.d.ts.map +1 -0
- package/dist/components/Chat/index.d.ts +8 -0
- package/dist/components/Chat/index.d.ts.map +1 -0
- package/dist/components/Layout/Header.d.ts +4 -0
- package/dist/components/Layout/Header.d.ts.map +1 -0
- package/dist/components/Layout/MobileSettingsPanel.d.ts +4 -0
- package/dist/components/Layout/MobileSettingsPanel.d.ts.map +1 -0
- package/dist/components/Layout/SettingsPanel.d.ts +4 -0
- package/dist/components/Layout/SettingsPanel.d.ts.map +1 -0
- package/dist/components/Layout/index.d.ts +4 -0
- package/dist/components/Layout/index.d.ts.map +1 -0
- package/dist/components/LoadingSpinner/LoadingSpinner.d.ts +4 -0
- package/dist/components/LoadingSpinner/LoadingSpinner.d.ts.map +1 -0
- package/dist/components/LoadingSpinner/index.d.ts +2 -0
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -0
- package/dist/components/MessageContent/index.d.ts +3 -0
- package/dist/components/MessageContent/index.d.ts.map +1 -0
- package/dist/components/Toast/Toast.d.ts +4 -0
- package/dist/components/Toast/Toast.d.ts.map +1 -0
- package/dist/components/Toast/ToastContainer.d.ts +4 -0
- package/dist/components/Toast/ToastContainer.d.ts.map +1 -0
- package/dist/components/Toast/index.d.ts +3 -0
- package/dist/components/Toast/index.d.ts.map +1 -0
- package/dist/components/Voice/VoiceInput.d.ts +4 -0
- package/dist/components/Voice/VoiceInput.d.ts.map +1 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/contexts/BaseChatContext.d.ts +13 -0
- package/dist/contexts/BaseChatContext.d.ts.map +1 -0
- package/dist/contexts/chatReducer.d.ts +55 -0
- package/dist/contexts/chatReducer.d.ts.map +1 -0
- package/dist/contexts/index.d.ts +3 -0
- package/dist/contexts/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useChatActions.d.ts +18 -0
- package/dist/hooks/useChatActions.d.ts.map +1 -0
- package/dist/hooks/useI18n.d.ts +8 -0
- package/dist/hooks/useI18n.d.ts.map +1 -0
- package/dist/hooks/useResponsive.d.ts +3 -0
- package/dist/hooks/useResponsive.d.ts.map +1 -0
- package/dist/hooks/useToast.d.ts +19 -0
- package/dist/hooks/useToast.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2469 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2469 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/ThemeProvider.d.ts +14 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/themes.d.ts +6 -0
- package/dist/theme/themes.d.ts.map +1 -0
- package/dist/theme/types.d.ts +64 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +187 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/androidBridge.d.ts +133 -0
- package/dist/utils/androidBridge.d.ts.map +1 -0
- package/dist/utils/chat.d.ts +16 -0
- package/dist/utils/chat.d.ts.map +1 -0
- package/dist/utils/file.d.ts +18 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/streamProcessor.d.ts +61 -0
- package/dist/utils/streamProcessor.d.ts.map +1 -0
- package/dist/utils/textToSpeech.d.ts +72 -0
- package/dist/utils/textToSpeech.d.ts.map +1 -0
- package/dist/utils/url.d.ts +6 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/uuid.d.ts +4 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/voicePlayback.d.ts +16 -0
- package/dist/utils/voicePlayback.d.ts.map +1 -0
- package/dist/utils/voiceRecorder.d.ts +14 -0
- package/dist/utils/voiceRecorder.d.ts.map +1 -0
- package/dist/utils/voiceSettings.d.ts +19 -0
- package/dist/utils/voiceSettings.d.ts.map +1 -0
- package/package.json +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
# @chat-ui/base
|
|
2
|
+
|
|
3
|
+
基于 React 和 TypeScript 的聊天界面基座组件库,提供可复用的 UI 组件、主题系统、国际化支持等核心能力。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🎨 **主题系统** - 支持明暗主题切换,可自定义主题配置
|
|
8
|
+
- 🌍 **国际化** - 内置中英文支持,易于扩展其他语言
|
|
9
|
+
- 📱 **响应式设计** - 支持移动端和桌面端适配
|
|
10
|
+
- 🧩 **模块化组件** - 高度可复用的聊天相关组件
|
|
11
|
+
- 📝 **TypeScript** - 完整的类型定义支持
|
|
12
|
+
- 🎯 **无业务耦合** - 纯 UI 组件,不包含业务逻辑
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @chat-ui/base
|
|
18
|
+
# 或
|
|
19
|
+
yarn add @chat-ui/base
|
|
20
|
+
# 或
|
|
21
|
+
pnpm add @chat-ui/base
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 依赖
|
|
25
|
+
|
|
26
|
+
本组件库依赖以下 peer dependencies:
|
|
27
|
+
|
|
28
|
+
- `react` >= 16.8.0
|
|
29
|
+
- `react-dom` >= 16.8.0
|
|
30
|
+
- `styled-components` >= 5.0.0
|
|
31
|
+
|
|
32
|
+
## 快速开始
|
|
33
|
+
|
|
34
|
+
### 1. 基础使用
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import React from 'react';
|
|
38
|
+
import {
|
|
39
|
+
ThemeProvider,
|
|
40
|
+
BaseChatProvider,
|
|
41
|
+
ChatList,
|
|
42
|
+
ChatInput,
|
|
43
|
+
Header
|
|
44
|
+
} from '@chat-ui/base';
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<ThemeProvider>
|
|
49
|
+
<BaseChatProvider>
|
|
50
|
+
<div style={{ height: '100vh', display: 'flex', flexDirection: 'column' }}>
|
|
51
|
+
<Header
|
|
52
|
+
title="我的聊天应用"
|
|
53
|
+
onNewChat={() => console.log('新建对话')}
|
|
54
|
+
/>
|
|
55
|
+
<ChatList
|
|
56
|
+
messages={[]}
|
|
57
|
+
onRetry={(id) => console.log('重试消息', id)}
|
|
58
|
+
/>
|
|
59
|
+
<ChatInput
|
|
60
|
+
onSend={(content, type, metadata) => console.log('发送消息', { content, type, metadata })}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</BaseChatProvider>
|
|
64
|
+
</ThemeProvider>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. 自定义主题
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { ThemeProvider } from '@chat-ui/base';
|
|
73
|
+
|
|
74
|
+
function App() {
|
|
75
|
+
return (
|
|
76
|
+
<ThemeProvider defaultMode="dark">
|
|
77
|
+
{/* 你的应用 */}
|
|
78
|
+
</ThemeProvider>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. 国际化配置
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { ThemeProvider } from '@chat-ui/base';
|
|
87
|
+
import i18n from '@chat-ui/base/i18n';
|
|
88
|
+
|
|
89
|
+
// 组件库会自动初始化 i18n
|
|
90
|
+
function App() {
|
|
91
|
+
return (
|
|
92
|
+
<ThemeProvider>
|
|
93
|
+
{/* 你的应用 */}
|
|
94
|
+
</ThemeProvider>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 组件
|
|
100
|
+
|
|
101
|
+
### 主题系统
|
|
102
|
+
|
|
103
|
+
#### ThemeProvider
|
|
104
|
+
|
|
105
|
+
主题提供者组件,管理应用的主题状态。
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
interface ThemeProviderProps {
|
|
109
|
+
children: ReactNode;
|
|
110
|
+
defaultMode?: 'light' | 'dark' | 'auto';
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### useTheme
|
|
115
|
+
|
|
116
|
+
获取当前主题的 Hook。
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
const { theme, toggleTheme, setThemeMode } = useTheme();
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 聊天组件
|
|
123
|
+
|
|
124
|
+
#### ChatMessage
|
|
125
|
+
|
|
126
|
+
聊天消息组件,支持多种消息类型。
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
interface ChatMessageProps {
|
|
130
|
+
message: BaseMessage;
|
|
131
|
+
onRetry?: (messageId: string) => void;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### ChatInput
|
|
136
|
+
|
|
137
|
+
聊天输入组件,支持文件上传、多种输入模式。
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
interface ChatInputProps {
|
|
141
|
+
onSend?: (content: string, type: string, metadata?: any) => void;
|
|
142
|
+
disabled?: boolean;
|
|
143
|
+
placeholder?: string;
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### ChatList
|
|
148
|
+
|
|
149
|
+
聊天列表组件,展示消息列表。
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
interface ChatListProps {
|
|
153
|
+
messages: BaseMessage[];
|
|
154
|
+
onRetry?: (messageId: string) => void;
|
|
155
|
+
isLoading?: boolean;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 布局组件
|
|
160
|
+
|
|
161
|
+
#### Header
|
|
162
|
+
|
|
163
|
+
头部组件,支持移动端菜单。
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
interface HeaderProps {
|
|
167
|
+
title?: string;
|
|
168
|
+
onNewChat?: () => void;
|
|
169
|
+
onClearChat?: () => void;
|
|
170
|
+
onSettings?: () => void;
|
|
171
|
+
showMobileMenu?: boolean;
|
|
172
|
+
onToggleMobileMenu?: () => void;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### SettingsPanel
|
|
177
|
+
|
|
178
|
+
设置面板组件。
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
interface SettingsPanelProps {
|
|
182
|
+
isOpen: boolean;
|
|
183
|
+
onClose: () => void;
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 消息内容渲染器
|
|
188
|
+
|
|
189
|
+
#### MessageContent(已整合)
|
|
190
|
+
|
|
191
|
+
消息内容渲染器,根据消息类型自动选择合适的渲染器。自 vNext 起,`MessageContent` 已整合至 `components/Chat/MessageContent.tsx`,请从包根或 `components/Chat` 路径导入。
|
|
192
|
+
|
|
193
|
+
#### ImageRenderer
|
|
194
|
+
|
|
195
|
+
图片渲染器,支持预览和下载。
|
|
196
|
+
|
|
197
|
+
#### FileRenderer
|
|
198
|
+
|
|
199
|
+
文件渲染器,支持多种文件类型。
|
|
200
|
+
|
|
201
|
+
#### ChartRenderer
|
|
202
|
+
|
|
203
|
+
图表渲染器(示例实现基于 Recharts)。
|
|
204
|
+
|
|
205
|
+
#### MermaidRenderer
|
|
206
|
+
|
|
207
|
+
Mermaid 图表渲染器。
|
|
208
|
+
|
|
209
|
+
### 反馈组件
|
|
210
|
+
|
|
211
|
+
#### Toast
|
|
212
|
+
|
|
213
|
+
消息提示组件。
|
|
214
|
+
|
|
215
|
+
#### ToastContainer
|
|
216
|
+
|
|
217
|
+
消息提示容器。
|
|
218
|
+
|
|
219
|
+
#### LoadingSpinner
|
|
220
|
+
|
|
221
|
+
加载指示器。
|
|
222
|
+
|
|
223
|
+
## 类型定义
|
|
224
|
+
|
|
225
|
+
### BaseMessage
|
|
226
|
+
|
|
227
|
+
基础消息类型。
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
interface BaseMessage {
|
|
231
|
+
id: string;
|
|
232
|
+
content: string;
|
|
233
|
+
type: 'text' | 'image' | 'chart' | 'markdown' | 'file' | 'code';
|
|
234
|
+
role: 'user' | 'assistant' | 'system';
|
|
235
|
+
timestamp: number;
|
|
236
|
+
metadata?: {
|
|
237
|
+
fileName?: string;
|
|
238
|
+
fileSize?: number;
|
|
239
|
+
fileType?: string;
|
|
240
|
+
chartData?: any;
|
|
241
|
+
codeLanguage?: string;
|
|
242
|
+
imageUrl?: string;
|
|
243
|
+
[key: string]: any;
|
|
244
|
+
};
|
|
245
|
+
status?: 'sending' | 'sent' | 'error' | 'thinking' | 'typing';
|
|
246
|
+
error?: string;
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### BaseChatSession
|
|
251
|
+
|
|
252
|
+
聊天会话类型。
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
interface BaseChatSession {
|
|
256
|
+
id: string;
|
|
257
|
+
title: string;
|
|
258
|
+
messages: BaseMessage[];
|
|
259
|
+
createdAt: number;
|
|
260
|
+
updatedAt: number;
|
|
261
|
+
settings?: {
|
|
262
|
+
model?: string;
|
|
263
|
+
temperature?: number;
|
|
264
|
+
maxTokens?: number;
|
|
265
|
+
[key: string]: any;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## 工具函数
|
|
271
|
+
|
|
272
|
+
### 消息工具
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import {
|
|
276
|
+
createMessage,
|
|
277
|
+
createUserMessage,
|
|
278
|
+
createAssistantMessage,
|
|
279
|
+
formatTimestamp,
|
|
280
|
+
isMessageFromUser
|
|
281
|
+
} from '@chat-ui/base/utils';
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### 文件工具
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import {
|
|
288
|
+
formatFileSize,
|
|
289
|
+
isImageFile,
|
|
290
|
+
readFileAsText
|
|
291
|
+
} from '@chat-ui/base/utils';
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### UUID 工具
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
import {
|
|
298
|
+
generateUUID,
|
|
299
|
+
generateUUID32
|
|
300
|
+
} from '@chat-ui/base/utils';
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## 自定义主题
|
|
304
|
+
|
|
305
|
+
你可以通过 CSS 变量或直接修改主题对象来自定义主题:
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
import { ThemeProvider } from '@chat-ui/base';
|
|
309
|
+
|
|
310
|
+
const customTheme = {
|
|
311
|
+
colors: {
|
|
312
|
+
primary: '#your-color',
|
|
313
|
+
// ... 其他颜色
|
|
314
|
+
},
|
|
315
|
+
// ... 其他主题配置
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
function App() {
|
|
319
|
+
return (
|
|
320
|
+
<ThemeProvider>
|
|
321
|
+
{/* 你的应用 */}
|
|
322
|
+
</ThemeProvider>
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## 国际化
|
|
328
|
+
|
|
329
|
+
组件库内置了中英文支持,你可以通过以下方式切换语言:
|
|
330
|
+
|
|
331
|
+
```tsx
|
|
332
|
+
import { useI18n } from '@chat-ui/base';
|
|
333
|
+
|
|
334
|
+
function MyComponent() {
|
|
335
|
+
const { changeLanguage, t } = useI18n();
|
|
336
|
+
|
|
337
|
+
return (
|
|
338
|
+
<button onClick={() => changeLanguage('en-US')}>
|
|
339
|
+
{t('common.user')}
|
|
340
|
+
</button>
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## 许可证
|
|
346
|
+
|
|
347
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatedRobot.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/AnimatedRobot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA6G1B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,CAwClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatInput.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAyJ7C,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAuP9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatList.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA+C5C,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA+G5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatMessage.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAoO/C,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAkNjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageContent.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/MessageContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AASzC,UAAU,mBAAmB;IAC3B,OAAO,EAAE,WAAW,CAAA;CACrB;AA6GD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA+KxD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileChatInput.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/MobileChatInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA2gB7C,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAg+BpD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TypewriterPlaceholderProps {
|
|
3
|
+
theme: any;
|
|
4
|
+
texts: string[];
|
|
5
|
+
shouldShow: boolean;
|
|
6
|
+
hasConversationStarted?: boolean;
|
|
7
|
+
typingSpeed?: number;
|
|
8
|
+
deletingSpeed?: number;
|
|
9
|
+
pauseTime?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const TypewriterPlaceholder: React.FC<TypewriterPlaceholderProps>;
|
|
12
|
+
//# sourceMappingURL=TypewriterPlaceholder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypewriterPlaceholder.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/TypewriterPlaceholder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAkC3D,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAoHtE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './ChatMessage';
|
|
2
|
+
export * from './ChatInput';
|
|
3
|
+
export * from './MobileChatInput';
|
|
4
|
+
export * from './ChatList';
|
|
5
|
+
export * from './MessageContent';
|
|
6
|
+
export * from './TypewriterPlaceholder';
|
|
7
|
+
export * from './AnimatedRobot';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AAIjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA+I1C,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAwIxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileSettingsPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/MobileSettingsPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA6OjD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmO5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/SettingsPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAgQjD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmNtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingSpinner.d.ts","sourceRoot":"","sources":["../../../src/components/LoadingSpinner/LoadingSpinner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAmClD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAexD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LoadingSpinner/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MessageContent/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsHzC,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CA+BtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastContainer.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/ToastContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA+ClD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAkBxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceInput.d.ts","sourceRoot":"","sources":["../../../src/components/Voice/VoiceInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAMtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAiN9C,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA2KhD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AAEzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { BaseChatContextType, BaseMessage, TTSSettings } from '../types';
|
|
3
|
+
import { ChatAction } from './chatReducer';
|
|
4
|
+
export type { ChatAction };
|
|
5
|
+
interface BaseChatProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
onSendMessage?: (content: string, type: BaseMessage['type'], metadata?: BaseMessage['metadata']) => Promise<void>;
|
|
8
|
+
/** TTS 配置选项 */
|
|
9
|
+
tts?: TTSSettings;
|
|
10
|
+
}
|
|
11
|
+
export declare const BaseChatProvider: React.FC<BaseChatProviderProps>;
|
|
12
|
+
export declare const useBaseChat: () => BaseChatContextType;
|
|
13
|
+
//# sourceMappingURL=BaseChatContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseChatContext.d.ts","sourceRoot":"","sources":["../../src/contexts/BaseChatContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,SAAS,EAAkC,MAAM,OAAO,CAAC;AAChH,OAAO,EACL,mBAAmB,EACnB,WAAW,EAEX,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,OAAO,EAAiC,UAAU,EAAE,MAAM,eAAe,CAAC;AAI1E,YAAY,EAAE,UAAU,EAAE,CAAC;AAI3B,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClH,eAAe;IACf,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA2O5D,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,mBAM9B,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BaseChatState, BaseMessage, BaseChatSession } from '../types';
|
|
2
|
+
export type ChatAction = {
|
|
3
|
+
type: 'SET_LOADING';
|
|
4
|
+
payload: boolean;
|
|
5
|
+
} | {
|
|
6
|
+
type: 'SET_TYPING';
|
|
7
|
+
payload: boolean;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'SET_USER_TYPING';
|
|
10
|
+
payload: {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
isTyping: boolean;
|
|
13
|
+
tempMessageId?: string;
|
|
14
|
+
preview?: string;
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
17
|
+
type: 'SET_ERROR';
|
|
18
|
+
payload: string | null;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'CREATE_SESSION';
|
|
21
|
+
payload: BaseChatSession;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'DELETE_SESSION';
|
|
24
|
+
payload: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'SWITCH_SESSION';
|
|
27
|
+
payload: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'ADD_MESSAGE';
|
|
30
|
+
payload: BaseMessage;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'UPDATE_MESSAGE';
|
|
33
|
+
payload: {
|
|
34
|
+
id: string;
|
|
35
|
+
updates: Partial<BaseMessage>;
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
type: 'UPDATE_STREAMING_MESSAGE';
|
|
39
|
+
payload: {
|
|
40
|
+
id: string;
|
|
41
|
+
content: string;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
type: 'CLEAR_SESSION';
|
|
45
|
+
} | {
|
|
46
|
+
type: 'LOAD_SESSIONS';
|
|
47
|
+
payload: BaseChatSession[];
|
|
48
|
+
};
|
|
49
|
+
export declare const initialChatState: BaseChatState;
|
|
50
|
+
/**
|
|
51
|
+
* 共享的聊天状态管理reducer
|
|
52
|
+
* 处理所有与会话和消息相关的状态更新
|
|
53
|
+
*/
|
|
54
|
+
export declare const chatReducer: (state: BaseChatState, action: ChatAction) => BaseChatState;
|
|
55
|
+
//# sourceMappingURL=chatReducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatReducer.d.ts","sourceRoot":"","sources":["../../src/contexts/chatReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEvE,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACxH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;KAAE,CAAA;CAAE,GAClF;IAAE,IAAI,EAAE,0BAA0B,CAAC;IAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,aAM9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,aAAa,EAAE,QAAQ,UAAU,KAAG,aAkKtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|