ai-chat-ui-kit 0.1.0 → 0.1.1

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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -7
  3. package/package.json +8 -4
  4. package/.eslintrc.cjs +0 -74
  5. package/.github/actions/screenshot/action.yml +0 -35
  6. package/.github/workflows/pages.yml +0 -46
  7. package/docs/README.md +0 -176
  8. package/docs/api/components.md +0 -344
  9. package/docs/api/core.md +0 -349
  10. package/docs/chat-style-1-minimal.html +0 -78
  11. package/docs/chat-style-2-neon.html +0 -74
  12. package/docs/chat-style-3-glass.html +0 -73
  13. package/docs/chat-style-4-terminal.html +0 -84
  14. package/docs/chat-style-5-gradient.html +0 -69
  15. package/docs/chat-style-6-corporate.html +0 -116
  16. package/docs/examples/basic-chat.md +0 -291
  17. package/docs/examples/custom-plugins.md +0 -431
  18. package/docs/examples/multi-model.md +0 -466
  19. package/docs/guide/api-adapters.md +0 -431
  20. package/docs/guide/getting-started.md +0 -244
  21. package/docs/guide/headless-mode.md +0 -508
  22. package/docs/guide/plugins.md +0 -416
  23. package/docs/guide/themes.md +0 -327
  24. package/docs/index.html +0 -256
  25. package/docs/theme-preview-1-minimal.html +0 -74
  26. package/docs/theme-preview-2-neon.html +0 -73
  27. package/docs/theme-preview-3-glass.html +0 -77
  28. package/docs/theme-preview-4-terminal.html +0 -86
  29. package/docs/theme-preview-5-gradient.html +0 -79
  30. package/docs/theme-preview-6-corporate.html +0 -71
  31. package/examples/index.html +0 -414
  32. package/examples/react-app/App.tsx +0 -131
  33. package/examples/react-app/index.html +0 -12
  34. package/examples/react-app/main.tsx +0 -15
  35. package/examples/react-app/package.json +0 -24
  36. package/examples/vue-app/index.html +0 -12
  37. package/examples/vue-app/package.json +0 -22
  38. package/examples/vue-app/src/App.vue +0 -145
  39. package/examples/vue-app/src/main.ts +0 -9
  40. package/packages/components/package.json +0 -25
  41. package/packages/components/src/chat/chat.css +0 -80
  42. package/packages/components/src/chat/chat.ts +0 -236
  43. package/packages/components/src/index.ts +0 -36
  44. package/packages/components/src/input/input.css +0 -52
  45. package/packages/components/src/input/input.ts +0 -116
  46. package/packages/components/src/markdown/markdown.css +0 -118
  47. package/packages/components/src/markdown/markdown.ts +0 -229
  48. package/packages/components/src/message/message.css +0 -56
  49. package/packages/components/src/message/message.ts +0 -72
  50. package/packages/components/src/styles/global.css +0 -43
  51. package/packages/components/src/tool-call/tool-call.css +0 -98
  52. package/packages/components/src/tool-call/tool-call.ts +0 -171
  53. package/packages/components/src/types.ts +0 -55
  54. package/packages/components/src/utils/helpers.ts +0 -128
  55. package/packages/components/tsconfig.json +0 -25
  56. package/packages/components/tsup.config.ts +0 -18
  57. package/packages/core/package.json +0 -47
  58. package/packages/core/pnpm-lock.yaml +0 -2032
  59. package/packages/core/pnpm-workspace.yaml +0 -2
  60. package/packages/core/src/api/adapters.ts +0 -717
  61. package/packages/core/src/api/base.ts +0 -210
  62. package/packages/core/src/api/index.ts +0 -54
  63. package/packages/core/src/index.ts +0 -93
  64. package/packages/core/src/parser/latex.ts +0 -274
  65. package/packages/core/src/parser/markdown.test.ts +0 -58
  66. package/packages/core/src/parser/markdown.ts +0 -206
  67. package/packages/core/src/parser/mermaid.ts +0 -276
  68. package/packages/core/src/plugins/PluginManager.ts +0 -232
  69. package/packages/core/src/plugins/builtin.ts +0 -406
  70. package/packages/core/src/store/ChatStore.ts +0 -163
  71. package/packages/core/src/store/ModelConfigStore.ts +0 -136
  72. package/packages/core/src/store/ToolCallStore.ts +0 -164
  73. package/packages/core/src/store/base.ts +0 -75
  74. package/packages/core/src/types/index.ts +0 -133
  75. package/packages/core/tsup.config.ts +0 -18
  76. package/packages/themes/package.json +0 -33
  77. package/packages/themes/src/corporate/index.ts +0 -52
  78. package/packages/themes/src/corporate/theme.css +0 -228
  79. package/packages/themes/src/glass/index.ts +0 -52
  80. package/packages/themes/src/glass/theme.css +0 -237
  81. package/packages/themes/src/gradient/index.ts +0 -53
  82. package/packages/themes/src/gradient/theme.css +0 -218
  83. package/packages/themes/src/index.ts +0 -13
  84. package/packages/themes/src/minimal/index.ts +0 -52
  85. package/packages/themes/src/minimal/theme.css +0 -198
  86. package/packages/themes/src/neon/index.ts +0 -52
  87. package/packages/themes/src/neon/theme.css +0 -233
  88. package/packages/themes/src/terminal/index.ts +0 -52
  89. package/packages/themes/src/terminal/theme.css +0 -235
  90. package/packages/themes/src/types.ts +0 -10
  91. package/packages/themes/src/vite-env.d.ts +0 -9
  92. package/packages/themes/tsup.config.ts +0 -21
  93. package/pnpm-workspace.yaml +0 -4
  94. package/tsconfig.json +0 -27
  95. package/vite.config.ts +0 -25
  96. package/vitest.config.ts +0 -28
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 edenxpzhang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,4 @@
1
- /**
2
- * @generated-by AI: edenxpzhang
3
- * @generated-date 2026-05-13
4
- */
1
+
5
2
  # AI Chat UI Kit
6
3
 
7
4
  ![Version](https://img.shields.io/badge/version-0.1.0-blue.svg)
@@ -43,17 +40,17 @@
43
40
 
44
41
  ### 使用 PNPM(推荐)
45
42
  ```bash
46
- pnpm add @ai-chat/core @ai-chat/components @ai-chat/themes
43
+ pnpm add @ai-chat-ui-kit/core @ai-chat-ui-kit/components @ai-chat-ui-kit/themes
47
44
  ```
48
45
 
49
46
  ### 使用 NPM
50
47
  ```bash
51
- npm install @ai-chat/core @ai-chat/components @ai-chat/themes
48
+ npm install @ai-chat-ui-kit/core @ai-chat-ui-kit/components @ai-chat-ui-kit/themes
52
49
  ```
53
50
 
54
51
  ### 使用 Yarn
55
52
  ```bash
56
- yarn add @ai-chat/core @ai-chat/components @ai-chat/themes
53
+ yarn add @ai-chat-ui-kit/core @ai-chat-ui-kit/components @ai-chat-ui-kit/themes
57
54
  ```
58
55
 
59
56
  ## 🚀 快速开始
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "ai-chat-ui-kit",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "AI Chat UI Kit - Web Components based chat UI with headless mode",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
8
- "build:core": "pnpm --filter @ai-chat/core run build",
9
- "build:components": "pnpm --filter @ai-chat/components run build",
10
- "build:themes": "pnpm --filter @ai-chat/themes run build",
8
+ "build:core": "pnpm --filter @ai-chat-ui-kit/core run build",
9
+ "build:components": "pnpm --filter @ai-chat-ui-kit/components run build",
10
+ "build:themes": "pnpm --filter @ai-chat-ui-kit/themes run build",
11
11
  "build": "pnpm run build:core && pnpm run build:components && pnpm run build:themes",
12
12
  "test": "vitest run",
13
13
  "test:watch": "vitest",
@@ -26,6 +26,10 @@
26
26
  ],
27
27
  "author": "eden_zxpzhang",
28
28
  "license": "MIT",
29
+ "files": [
30
+ "README.md",
31
+ "LICENSE"
32
+ ],
29
33
  "devDependencies": {
30
34
  "@typescript-eslint/eslint-plugin": "^6.0.0",
31
35
  "@typescript-eslint/parser": "^6.0.0",
package/.eslintrc.cjs DELETED
@@ -1,74 +0,0 @@
1
- /**
2
- * @generated-by AI: edenxpzhang
3
- * @generated-date 2026-05-13
4
- */
5
-
6
- module.exports = {
7
- root: true,
8
- env: {
9
- browser: true,
10
- es2020: true,
11
- node: true,
12
- },
13
- parser: '@typescript-eslint/parser',
14
- parserOptions: {
15
- ecmaVersion: 2020,
16
- sourceType: 'module',
17
- ecmaFeatures: {
18
- jsx: true,
19
- tsx: true,
20
- },
21
- },
22
- plugins: ['@typescript-eslint'],
23
- extends: [
24
- 'eslint:recommended',
25
- 'plugin:@typescript-eslint/recommended',
26
- ],
27
- rules: {
28
- // TypeScript specific rules
29
- '@typescript-eslint/no-explicit-any': 'warn',
30
- '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
31
- '@typescript-eslint/explicit-function-return-type': 'off',
32
- '@typescript-eslint/explicit-module-boundary-types': 'off',
33
- '@typescript-eslint/no-non-null-assertion': 'warn',
34
- '@typescript-eslint/consistent-type-imports': 'error',
35
-
36
- // General rules
37
- 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
38
- 'no-debugger': 'error',
39
- 'no-alert': 'warn',
40
- 'no-restricted-syntax': 'off',
41
-
42
- // Import rules
43
- 'no-unused-vars': 'off', // Handled by @typescript-eslint
44
- },
45
- overrides: [
46
- // Lit component rules
47
- {
48
- files: ['*.ts'],
49
- excludedFiles: ['*.test.ts', '*.spec.ts'],
50
- rules: {
51
- 'class-methods-use-this': 'off',
52
- },
53
- },
54
- // Test files
55
- {
56
- files: ['*.test.ts', '*.spec.ts', '**/tests/**/*.ts'],
57
- env: {
58
- jest: true,
59
- },
60
- rules: {
61
- '@typescript-eslint/no-explicit-any': 'off',
62
- },
63
- },
64
- ],
65
- ignorePatterns: [
66
- 'dist/',
67
- 'node_modules/',
68
- '*.config.js',
69
- '*.config.cjs',
70
- 'build/',
71
- 'coverage/',
72
- '.turbo/',
73
- ],
74
- };
@@ -1,35 +0,0 @@
1
- /**
2
- * @generated-by AI: edenxpzhang
3
- * @generated-date 2026-05-13
4
- */
5
- name: Generate Theme Screenshots
6
- description: Take screenshots of all 6 chat UI themes
7
-
8
- inputs:
9
- output-dir:
10
- description: Directory to save screenshots
11
- required: false
12
- default: docs/screenshots
13
-
14
- runs:
15
- using: composite
16
- steps:
17
- - name: Install Playwright
18
- shell: bash
19
- run: |
20
- npm install -g playwright
21
- playwright install chromium
22
-
23
- - name: Take screenshots
24
- shell: bash
25
- run: |
26
- mkdir -p ${{ inputs.output-dir }}
27
- for theme in minimal neon glass terminal gradient corporate; do
28
- echo "Screenshotting ${theme}..."
29
- playwright screenshot \
30
- --url "file://$(pwd)/docs/chat-style-${theme}.html" \
31
- --output "${{ inputs.output-dir }}/${theme}.png" \
32
- --viewport "400,700" \
33
- --timeout 10000 || true
34
- done
35
- echo "Screenshots saved to ${{ inputs.output-dir }}/"
@@ -1,46 +0,0 @@
1
- /**
2
- * @generated-by AI: edenxpzhang
3
- * @generated-date 2026-05-13
4
- */
5
- name: Deploy to GitHub Pages
6
-
7
- on:
8
- push:
9
- branches: [master]
10
- workflow_dispatch:
11
-
12
- permissions:
13
- contents: read
14
- pages: write
15
- id-token: write
16
-
17
- concurrency:
18
- group: pages
19
- cancel-in-progress: true
20
-
21
- jobs:
22
- deploy:
23
- environment:
24
- name: github-pages
25
- url: ${{ steps.deployment.outputs.page_url }}
26
- runs-on: ubuntu-latest
27
- steps:
28
- - name: Checkout
29
- uses: actions/checkout@v4
30
-
31
- - name: Setup Node.js
32
- uses: actions/setup-node@v4
33
- with:
34
- node-version: 20
35
-
36
- - name: Generate screenshots
37
- uses: .github/actions/screenshot
38
-
39
- - name: Upload artifact
40
- uses: actions/upload-pages-artifact@v3
41
- with:
42
- path: ./docs
43
-
44
- - name: Deploy to GitHub Pages
45
- id: deployment
46
- uses: actions/deploy-pages@v4
package/docs/README.md DELETED
@@ -1,176 +0,0 @@
1
- # AI Chat UI Kit 文档
2
-
3
- ![Version](https://img.shields.io/badge/version-0.1.0-blue.svg)
4
- ![License](https://img.shields.io/badge/license-MIT-green.svg)
5
-
6
- 欢迎使用 AI Chat UI Kit 官方文档!
7
-
8
- ## 📖 文档导航
9
-
10
- ### 🚀 快速开始
11
- - [快速开始指南](./guide/getting-started.md) - 5分钟上手教程
12
- - [安装指南](./guide/getting-started.md#安装) - 详细安装步骤
13
-
14
- ### 📚 使用指南
15
- - [Headless 模式](./guide/headless-mode.md) - 只使用逻辑层,自定义 UI
16
- - [主题定制](./guide/themes.md) - 自定义主题和样式
17
- - [插件开发](./guide/plugins.md) - 扩展功能
18
- - [API 适配器](./guide/api-adapters.md) - 兼容多种后端 API
19
-
20
- ### 🔧 API 参考
21
- - [Core 包 API](./api/core.md) - 核心逻辑层 API
22
- - [Components 包 API](./api/components.md) - Web Components API
23
-
24
- ### 💡 示例
25
- - [基本聊天](./examples/basic-chat.md) - 最简单的聊天功能
26
- - [自定义插件](./examples/custom-plugins.md) - 创建自定义插件
27
- - [多模型支持](./examples/multi-model.md) - 切换不同 AI 模型
28
-
29
- ## 🎯 项目简介
30
-
31
- AI Chat UI Kit 是一套基于 Web Components 的 AI 聊天 UI 组件库,具有以下特点:
32
-
33
- - ✨ **跨框架兼容** - 原生 Web Components,支持 React、Vue、Angular 等
34
- - 🎨 **Headless 模式** - 可只使用逻辑层,完全自定义 UI
35
- - 🎭 **多主题支持** - 内置默认、气泡、扁平三种主题
36
- - 🔌 **插件系统** - 易于扩展功能
37
- - 📡 **API 适配器** - 兼容多种后端 API 格式
38
- - 📦 **轻量级** - 无 heavy dependencies
39
-
40
- ## 📦 安装
41
-
42
- ```bash
43
- # PNPM(推荐)
44
- pnpm add @ai-chat/core @ai-chat/components @ai-chat/themes
45
-
46
- # NPM
47
- npm install @ai-chat/core @ai-chat/components @ai-chat/themes
48
-
49
- # Yarn
50
- yarn add @ai-chat/core @ai-chat/components @ai-chat/themes
51
- ```
52
-
53
- ## 🚀 快速开始
54
-
55
- ### 原生 HTML
56
-
57
- ```html
58
- <!DOCTYPE html>
59
- <html lang="zh-CN">
60
- <head>
61
- <meta charset="UTF-8">
62
- <title>AI Chat Demo</title>
63
- <script type="module">
64
- import '@ai-chat/components';
65
- import '@ai-chat/themes/default';
66
- </script>
67
- </head>
68
- <body>
69
- <div style="height: 100vh">
70
- <ai-chat></ai-chat>
71
- </div>
72
-
73
- <script>
74
- const chat = document.querySelector('ai-chat');
75
- chat.setMessageHandler(async (message) => {
76
- await new Promise(resolve => setTimeout(resolve, 1000));
77
- return `您说的是:${message}`;
78
- });
79
- </script>
80
- </body>
81
- </html>
82
- ```
83
-
84
- ### React
85
-
86
- ```tsx
87
- import React, { useEffect, useRef } from 'react';
88
- import '@ai-chat/components';
89
- import '@ai-chat/themes/default';
90
-
91
- const ChatApp: React.FC = () => {
92
- const chatRef = useRef<HTMLElement>(null);
93
-
94
- useEffect(() => {
95
- if (chatRef.current) {
96
- (chatRef.current as any).setMessageHandler(async (message: string) => {
97
- await new Promise(resolve => setTimeout(resolve, 1000));
98
- return `AI 回复:${message}`;
99
- });
100
- }
101
- }, []);
102
-
103
- return (
104
- <div style={{ height: '100vh' }}>
105
- <ai-chat ref={chatRef}></ai-chat>
106
- </div>
107
- );
108
- };
109
-
110
- export default ChatApp;
111
- ```
112
-
113
- ### Vue 3
114
-
115
- ```vue
116
- <template>
117
- <div style="height: 100vh">
118
- <ai-chat ref="chatRef"></ai-chat>
119
- </div>
120
- </template>
121
-
122
- <script setup lang="ts">
123
- import { ref, onMounted } from 'vue';
124
- import '@ai-chat/components';
125
- import '@ai-chat/themes/default';
126
-
127
- const chatRef = ref<HTMLElement>();
128
-
129
- onMounted(() => {
130
- if (chatRef.value) {
131
- (chatRef.value as any).setMessageHandler(async (message: string) => {
132
- await new Promise(resolve => setTimeout(resolve, 1000));
133
- return `AI 回复:${message}`;
134
- });
135
- }
136
- });
137
- </script>
138
- ```
139
-
140
- ## 🎨 主题切换
141
-
142
- ```typescript
143
- // 使用默认主题
144
- import '@ai-chat/themes/default';
145
-
146
- // 使用气泡主题(仿微信/QQ 风格)
147
- import '@ai-chat/themes/bubble';
148
-
149
- // 使用扁平主题
150
- import '@ai-chat/themes/flat';
151
- ```
152
-
153
- ## 🏗️ 项目结构
154
-
155
- ```
156
- ai-chat-ui-kit/
157
- ├── packages/
158
- │ ├── core/ # 核心逻辑层(状态管理、API 适配)
159
- │ ├── components/ # Web Components 封装(Lit)
160
- │ └── themes/ # 主题包(CSS + 配置)
161
- ├── docs/ # 文档
162
- ├── examples/ # 使用示例
163
- └── README.md # 项目说明
164
- ```
165
-
166
- ## 🤝 贡献
167
-
168
- 欢迎提交 Issue 和 Pull Request!
169
-
170
- ## 📄 许可证
171
-
172
- [MIT License](./LICENSE)
173
-
174
- ---
175
-
176
- Built with ❤️ using [Lit](https://lit.dev/)