@courseecho/ai-widget-vue 1.0.0 → 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/LICENSE +25 -0
- package/README.md +336 -0
- package/package.json +32 -30
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CourseEcho
|
|
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.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
For more information about CourseEcho, visit https://courseecho.com
|
package/README.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# 💚 @courseecho/ai-widget-vue
|
|
2
|
+
|
|
3
|
+
**Vue 3 component for AI chat widget** - Intelligent chat for Vue applications.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@courseecho/ai-widget-vue)
|
|
6
|
+
[](https://vuejs.org)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
## 📖 Overview
|
|
10
|
+
|
|
11
|
+
A **Vue 3 component** for seamless integration of CourseEcho AI chat into your Vue applications.
|
|
12
|
+
|
|
13
|
+
- ✅ Vue 3.0+
|
|
14
|
+
- ✅ Composition API & `<script setup>` support
|
|
15
|
+
- ✅ TypeScript fully typed
|
|
16
|
+
- ✅ 12KB minified
|
|
17
|
+
- ✅ Nuxt 3 compatible
|
|
18
|
+
|
|
19
|
+
## 🚀 Quick Start
|
|
20
|
+
|
|
21
|
+
### Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @courseecho/ai-widget-vue @courseecho/ai-core-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Basic Usage
|
|
28
|
+
|
|
29
|
+
```vue
|
|
30
|
+
<template>
|
|
31
|
+
<AiChatWidget
|
|
32
|
+
:api-endpoint="apiEndpoint"
|
|
33
|
+
:context="context"
|
|
34
|
+
:jwt-token="jwtToken"
|
|
35
|
+
/>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup>
|
|
39
|
+
import { AiChatWidget } from '@courseecho/ai-widget-vue';
|
|
40
|
+
|
|
41
|
+
const apiEndpoint = 'https://api.courseecho.com/api';
|
|
42
|
+
const context = {
|
|
43
|
+
pageType: 'course',
|
|
44
|
+
entityId: 'course-123',
|
|
45
|
+
userId: 'user-456'
|
|
46
|
+
};
|
|
47
|
+
const jwtToken = 'your-jwt-token';
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 🎯 Props
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
interface AiChatWidgetProps {
|
|
55
|
+
apiEndpoint: string; // Your API endpoint
|
|
56
|
+
context: ContextData; // Page context
|
|
57
|
+
jwtToken?: string; // JWT authentication
|
|
58
|
+
apiKey?: string; // Alternative: API key
|
|
59
|
+
theme?: 'light' | 'dark'; // Theme (default: 'light')
|
|
60
|
+
position?: PositionType; // Widget position
|
|
61
|
+
class?: string; // Custom CSS class
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type PositionType = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 🪣 Composables
|
|
68
|
+
|
|
69
|
+
Use composables for fine-grained control:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import {
|
|
73
|
+
useAiChat,
|
|
74
|
+
useAiMessages,
|
|
75
|
+
useAiLoading,
|
|
76
|
+
useAiError,
|
|
77
|
+
useAiContext
|
|
78
|
+
} from '@courseecho/ai-widget-vue';
|
|
79
|
+
|
|
80
|
+
export default {
|
|
81
|
+
setup() {
|
|
82
|
+
const { sendMessage, state } = useAiChat({
|
|
83
|
+
apiEndpoint: 'https://api.courseecho.com/api',
|
|
84
|
+
context: { pageType: 'course' }
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const messages = useAiMessages();
|
|
88
|
+
const loading = useAiLoading();
|
|
89
|
+
const error = useAiError();
|
|
90
|
+
const { context, setContext } = useAiContext();
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
messages,
|
|
94
|
+
loading,
|
|
95
|
+
error,
|
|
96
|
+
sendMessage,
|
|
97
|
+
setContext
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Available Composables
|
|
104
|
+
|
|
105
|
+
| Composable | Returns | Purpose |
|
|
106
|
+
|-----------|---------|---------|
|
|
107
|
+
| `useAiChat()` | `{ sendMessage, state }` | Main chat composable |
|
|
108
|
+
| `useAiMessages()` | `Ref<ChatMessage[]>` | Get messages ref |
|
|
109
|
+
| `useAiLoading()` | `Ref<boolean>` | Get loading state ref |
|
|
110
|
+
| `useAiError()` | `Ref<string \| null>` | Get error ref |
|
|
111
|
+
| `useAiContext()` | `{ context, setContext }` | Manage context |
|
|
112
|
+
|
|
113
|
+
## 💡 Examples
|
|
114
|
+
|
|
115
|
+
### Example 1: Course Page with `<script setup>`
|
|
116
|
+
|
|
117
|
+
```vue
|
|
118
|
+
<template>
|
|
119
|
+
<div class="course-page">
|
|
120
|
+
<h1>JavaScript Fundamentals</h1>
|
|
121
|
+
<main>
|
|
122
|
+
<!-- Course content -->
|
|
123
|
+
</main>
|
|
124
|
+
|
|
125
|
+
<AiChatWidget
|
|
126
|
+
api-endpoint="https://api.courseecho.com/api"
|
|
127
|
+
:context="courseContext"
|
|
128
|
+
:jwt-token="userToken"
|
|
129
|
+
position="bottom-right"
|
|
130
|
+
theme="light"
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
</template>
|
|
134
|
+
|
|
135
|
+
<script setup>
|
|
136
|
+
import { AiChatWidget } from '@courseecho/ai-widget-vue';
|
|
137
|
+
import { ref, computed } from 'vue';
|
|
138
|
+
import { useRoute } from 'vue-router';
|
|
139
|
+
|
|
140
|
+
const route = useRoute();
|
|
141
|
+
const userToken = ref('user-token');
|
|
142
|
+
|
|
143
|
+
const courseContext = computed(() => ({
|
|
144
|
+
pageType: 'course',
|
|
145
|
+
entityId: route.params.courseId,
|
|
146
|
+
userId: 'current-user-id'
|
|
147
|
+
}));
|
|
148
|
+
</script>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Example 2: Theme Reactivity
|
|
152
|
+
|
|
153
|
+
```vue
|
|
154
|
+
<template>
|
|
155
|
+
<div>
|
|
156
|
+
<button @click="isDark = !isDark">
|
|
157
|
+
{{ isDark ? '☀️' : '🌙' }}
|
|
158
|
+
</button>
|
|
159
|
+
|
|
160
|
+
<AiChatWidget
|
|
161
|
+
api-endpoint="..."
|
|
162
|
+
:context="context"
|
|
163
|
+
:theme="isDark ? 'dark' : 'light'"
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
</template>
|
|
167
|
+
|
|
168
|
+
<script setup>
|
|
169
|
+
import { ref } from 'vue';
|
|
170
|
+
import { AiChatWidget } from '@courseecho/ai-widget-vue';
|
|
171
|
+
|
|
172
|
+
const isDark = ref(false);
|
|
173
|
+
const context = { pageType: 'app' };
|
|
174
|
+
</script>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Example 3: Custom Chat UI with Composable
|
|
178
|
+
|
|
179
|
+
```vue
|
|
180
|
+
<template>
|
|
181
|
+
<div class="custom-chat">
|
|
182
|
+
<div class="messages">
|
|
183
|
+
<div
|
|
184
|
+
v-for="msg in messages"
|
|
185
|
+
:key="msg.id"
|
|
186
|
+
:class="['message', msg.role]"
|
|
187
|
+
>
|
|
188
|
+
{{ msg.content }}
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div v-if="loading" class="loading">Thinking...</div>
|
|
193
|
+
<div v-if="error" class="error">{{ error }}</div>
|
|
194
|
+
|
|
195
|
+
<input
|
|
196
|
+
@keyup.enter="handleSendMessage"
|
|
197
|
+
placeholder="Ask a question..."
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
</template>
|
|
201
|
+
|
|
202
|
+
<script setup>
|
|
203
|
+
import {
|
|
204
|
+
useAiChat,
|
|
205
|
+
useAiMessages,
|
|
206
|
+
useAiLoading,
|
|
207
|
+
useAiError
|
|
208
|
+
} from '@courseecho/ai-widget-vue';
|
|
209
|
+
|
|
210
|
+
const { sendMessage } = useAiChat({
|
|
211
|
+
apiEndpoint: 'https://api.courseecho.com/api',
|
|
212
|
+
context: { pageType: 'course' }
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const messages = useAiMessages();
|
|
216
|
+
const loading = useAiLoading();
|
|
217
|
+
const error = useAiError();
|
|
218
|
+
|
|
219
|
+
const handleSendMessage = async (e) => {
|
|
220
|
+
const text = e.target.value;
|
|
221
|
+
if (text) {
|
|
222
|
+
await sendMessage(text);
|
|
223
|
+
e.target.value = '';
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
</script>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Example 4: Nuxt 3 Integration
|
|
230
|
+
|
|
231
|
+
```vue
|
|
232
|
+
<!-- pages/course/[id].vue -->
|
|
233
|
+
<template>
|
|
234
|
+
<div>
|
|
235
|
+
<h1>{{ course.title }}</h1>
|
|
236
|
+
<AiChatWidget
|
|
237
|
+
api-endpoint="https://api.courseecho.com/api"
|
|
238
|
+
:context="courseContext"
|
|
239
|
+
/>
|
|
240
|
+
</div>
|
|
241
|
+
</template>
|
|
242
|
+
|
|
243
|
+
<script setup>
|
|
244
|
+
import { AiChatWidget } from '@courseecho/ai-widget-vue';
|
|
245
|
+
|
|
246
|
+
definePageMeta({
|
|
247
|
+
layout: 'course'
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const route = useRoute();
|
|
251
|
+
const { data: course } = await useFetch(`/api/courses/${route.params.id}`);
|
|
252
|
+
|
|
253
|
+
const courseContext = computed(() => ({
|
|
254
|
+
pageType: 'course',
|
|
255
|
+
entityId: route.params.id,
|
|
256
|
+
userId: useAuthStore().user.id
|
|
257
|
+
}));
|
|
258
|
+
</script>
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 🎨 Styling
|
|
262
|
+
|
|
263
|
+
Override default styles with scoped CSS:
|
|
264
|
+
|
|
265
|
+
```vue
|
|
266
|
+
<style scoped>
|
|
267
|
+
:deep(.ai-chat-widget) {
|
|
268
|
+
border-radius: 12px;
|
|
269
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
:deep(.ai-chat-message) {
|
|
273
|
+
font-size: 14px;
|
|
274
|
+
line-height: 1.5;
|
|
275
|
+
}
|
|
276
|
+
</style>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## 🔐 Authentication
|
|
280
|
+
|
|
281
|
+
### Using JWT
|
|
282
|
+
|
|
283
|
+
```vue
|
|
284
|
+
<AiChatWidget
|
|
285
|
+
api-endpoint="..."
|
|
286
|
+
:context="context"
|
|
287
|
+
:jwt-token="userStore.token"
|
|
288
|
+
/>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Using API Key
|
|
292
|
+
|
|
293
|
+
```vue
|
|
294
|
+
<AiChatWidget
|
|
295
|
+
api-endpoint="..."
|
|
296
|
+
:context="context"
|
|
297
|
+
api-key="sk-123456789..."
|
|
298
|
+
/>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## 📦 Package Contents
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
dist/
|
|
305
|
+
├── index.mjs # ES Module
|
|
306
|
+
├── index.cjs # CommonJS
|
|
307
|
+
├── index.d.ts # TypeScript definitions
|
|
308
|
+
└── ...
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## 🌍 About CourseEcho
|
|
312
|
+
|
|
313
|
+
[CourseEcho](https://courseecho.com) powers intelligent education with AI.
|
|
314
|
+
|
|
315
|
+
- 🌐 Website: https://courseecho.com
|
|
316
|
+
- 📧 Support: support@courseecho.com
|
|
317
|
+
- 📱 Product: https://courseecho.com/products/ai-widget
|
|
318
|
+
|
|
319
|
+
## 📄 License
|
|
320
|
+
|
|
321
|
+
MIT © 2026 CourseEcho
|
|
322
|
+
|
|
323
|
+
## 📞 Support
|
|
324
|
+
|
|
325
|
+
- 📖 Docs: https://courseecho.com/docs
|
|
326
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/courseecho/ai-widget-sdk/issues)
|
|
327
|
+
- 💬 Chat: [Discord](https://discord.gg/courseecho)
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
**Other frameworks:**
|
|
332
|
+
- [React](../ai-widget-react)
|
|
333
|
+
- [Angular 19+](../ai-widget-angular)
|
|
334
|
+
- [jQuery](../ai-widget-jquery)
|
|
335
|
+
- [Node.js](../ai-client-node)
|
|
336
|
+
- [Core SDK](../ai-core-sdk)
|
package/package.json
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
"name": "@courseecho/ai-widget-vue",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Vue 3 component for AI chat widget",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "CourseEcho",
|
|
7
|
+
"main": "dist/index.cjs",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"dev": "tsc --watch"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"vue": "^3.0.0",
|
|
26
|
+
"@courseecho/ai-core-sdk": "^1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"vue": "^3.3.0",
|
|
30
|
+
"@courseecho/ai-core-sdk": "^1.0.0",
|
|
31
|
+
"typescript": "^5.3.0",
|
|
32
|
+
"@types/node": "^20.0.0"
|
|
33
|
+
}
|
|
32
34
|
}
|