@courseecho/ai-widget-jquery 1.0.2 → 1.0.4
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 +14 -15
- package/dist/ai-widget-jquery.umd.min.js +36 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -68,21 +68,19 @@ $('#widget').aiChatWidget({ /* options */ });
|
|
|
68
68
|
|
|
69
69
|
## 📦 CDN URLs
|
|
70
70
|
|
|
71
|
-
**
|
|
71
|
+
**CourseEcho CDN (Recommended):**
|
|
72
72
|
```html
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<!-- Specific version -->
|
|
77
|
-
<script src="https://unpkg.com/@courseecho/ai-widget-jquery@1.0.1/dist/ai-widget-jquery.js"></script>
|
|
73
|
+
<script src="https://cdn.courseecho.com/ai-widget-jquery.js"></script>
|
|
74
|
+
```
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
**unpkg (Alternative):**
|
|
77
|
+
```html
|
|
78
|
+
<script src="https://unpkg.com/@courseecho/ai-widget-jquery/dist/ai-widget-jquery.js"></script>
|
|
81
79
|
```
|
|
82
80
|
|
|
83
|
-
**jsDelivr:**
|
|
81
|
+
**jsDelivr (Alternative):**
|
|
84
82
|
```html
|
|
85
|
-
<script src="https://cdn.jsdelivr.net/npm/@courseecho/ai-widget-jquery
|
|
83
|
+
<script src="https://cdn.jsdelivr.net/npm/@courseecho/ai-widget-jquery/dist/ai-widget-jquery.js"></script>
|
|
86
84
|
```
|
|
87
85
|
|
|
88
86
|
## 🎯 API Methods
|
|
@@ -386,12 +384,13 @@ MIT © 2026 CourseEcho
|
|
|
386
384
|
- 📖 Docs: https://courseecho.com/docs
|
|
387
385
|
- 🐛 Issues: [GitHub Issues](https://github.com/courseecho/ai-widget-sdk/issues)
|
|
388
386
|
- 💬 Chat: [Discord](https://discord.gg/courseecho)
|
|
387
|
+
- 📚 Full Guide: [Script Tag Integration](https://github.com/courseecho/ai-widget-sdk/blob/main/SCRIPT_TAG_USAGE.html)
|
|
389
388
|
|
|
390
389
|
---
|
|
391
390
|
|
|
392
391
|
**Other frameworks:**
|
|
393
|
-
- [React](
|
|
394
|
-
- [Vue 3](
|
|
395
|
-
- [Angular 19+](
|
|
396
|
-
- [Node.js](
|
|
397
|
-
- [Core SDK](
|
|
392
|
+
- [React](https://www.npmjs.com/package/@courseecho/ai-widget-react)
|
|
393
|
+
- [Vue 3](https://www.npmjs.com/package/@courseecho/ai-widget-vue)
|
|
394
|
+
- [Angular 19+](https://www.npmjs.com/package/@courseecho/ai-widget-angular)
|
|
395
|
+
- [Node.js](https://www.npmjs.com/package/@courseecho/ai-client-node)
|
|
396
|
+
- [Core SDK](https://www.npmjs.com/package/@courseecho/ai-core-sdk)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";var AiWidgetjQuery=(()=>{var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var r=(e,i)=>{for(var s in i)a(e,s,{get:i[s],enumerable:!0})},p=(e,i,s,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of g(i))!c.call(e,n)&&n!==s&&a(e,n,{get:()=>i[n],enumerable:!(t=h(i,n))||t.enumerable});return e};var l=e=>p(a({},"__esModule",{value:!0}),e);var u={};r(u,{createJQueryPlugin:()=>w});function w(e){let i={init(s,t){let n=e(s),o=new d(s,t);return n.data("aiWidget",o),n},send(s,t){let n=e(s).data("aiWidget");if(n)return n.sendMessage(t)},getMessages(s){let t=e(s).data("aiWidget");return t?t.getMessages():[]},clear(s){let t=e(s).data("aiWidget");return t&&t.clearMessages(),e(s)},setContext(s,t){let n=e(s).data("aiWidget");return n&&n.updateContext(t),e(s)},isLoading(s){let t=e(s).data("aiWidget");return t?t.isLoadingState():!1},destroy(s){let t=e(s).data("aiWidget");return t&&t.destroy(),e(s).removeData("aiWidget").empty(),e(s)}};e.fn.aiChatWidget=function(...s){let t=s[0],n=s.slice(1);return t===void 0||typeof t=="object"?this.each(function(){e(this).data("aiWidget")||i.init(this,t||{})}):i[t]?this.each(function(){i[t](this,...n)}):this}}var d=class{constructor(i,s){this.messages=[],this.isOpen=!1,this.isLoading=!1,this.element=i,this.options={theme:"light",position:"bottom-right",...s},this.initialize()}initialize(){let i=window.$;i(this.element).addClass(`ai-widget-container ai-widget-${this.options.theme} ai-widget-${this.options.position}`),this.$button=i(`
|
|
2
|
+
<button class="ai-widget-toggle-button" aria-label="Open AI Chat">
|
|
3
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
4
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
|
|
5
|
+
</svg>
|
|
6
|
+
</button>
|
|
7
|
+
`),this.$widget=i(`
|
|
8
|
+
<div class="ai-widget-window" style="display: none;">
|
|
9
|
+
<div class="ai-widget-header">
|
|
10
|
+
<h3>AI Assistant</h3>
|
|
11
|
+
<button class="ai-widget-close-button">\xD7</button>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="ai-widget-messages">
|
|
14
|
+
<div class="ai-widget-welcome">
|
|
15
|
+
<p>\u{1F44B} Hello! I'm your AI assistant.</p>
|
|
16
|
+
<p>How can I help you today?</p>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<form class="ai-widget-form">
|
|
20
|
+
<input type="text" class="ai-widget-input" placeholder="Type your message..." />
|
|
21
|
+
<button type="submit" class="ai-widget-send-button">\u2192</button>
|
|
22
|
+
</form>
|
|
23
|
+
</div>
|
|
24
|
+
`),this.$messages=this.$widget.find(".ai-widget-messages"),this.$input=this.$widget.find(".ai-widget-input"),this.$button.on("click",()=>this.open()),this.$widget.find(".ai-widget-close-button").on("click",()=>this.close()),this.$widget.find(".ai-widget-form").on("submit",t=>{t.preventDefault(),this.sendMessage(this.$input.val()),this.$input.val("")}),i(this.element).append(this.$button).append(this.$widget)}open(){this.isOpen=!0,window.$(this.element).find(".ai-widget-button").hide(),window.$(this.element).find(".ai-widget-window").show()}close(){this.isOpen=!1,window.$(this.element).find(".ai-widget-button").show(),window.$(this.element).find(".ai-widget-window").hide()}async sendMessage(i){if(!i.trim()||this.isLoading)return;let s={id:`${Date.now()}-${Math.random()}`,role:"user",content:i,timestamp:new Date};this.messages.push(s),this.appendMessageToUI(s),this.isLoadingState(!0),this.options.onLoading&&this.options.onLoading(!0);try{let t=await window.fetch(`${this.options.apiEndpoint}/api/aiorchestrator/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.options.jwtToken||""}`},body:JSON.stringify({userQuery:i,pageType:this.options.context.pageType,entityId:this.options.context.entityId,contextData:this.options.context.customData})});if(!t.ok)throw new Error(`HTTP ${t.status}`);let n=await t.json(),o={id:n.sessionId,role:"assistant",content:n.response,timestamp:new Date(n.timestamp)};this.messages.push(o),this.appendMessageToUI(o),this.options.onMessage&&this.options.onMessage(o)}catch(t){let n=String(t);this.options.onError&&this.options.onError(n)}finally{this.isLoadingState(!1),this.options.onLoading&&this.options.onLoading(!1)}}appendMessageToUI(i){let s=window.$,t=s(`
|
|
25
|
+
<div class="ai-widget-message ai-widget-message-${i.role}">
|
|
26
|
+
<div class="ai-widget-message-content">${i.content}</div>
|
|
27
|
+
<div class="ai-widget-message-time">
|
|
28
|
+
${new Date(i.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
`);this.$messages.find(".ai-widget-welcome").length&&this.$messages.find(".ai-widget-welcome").remove(),this.$messages.append(t),this.$messages.scrollTop(this.$messages.prop("scrollHeight"))}getMessages(){return[...this.messages]}clearMessages(){this.messages=[];let i=window.$;this.$messages.html(`
|
|
32
|
+
<div class="ai-widget-welcome">
|
|
33
|
+
<p>\u{1F44B} Hello! I'm your AI assistant.</p>
|
|
34
|
+
<p>How can I help you today?</p>
|
|
35
|
+
</div>
|
|
36
|
+
`)}updateContext(i){this.options.context={...this.options.context,...i}}isLoadingState(i){return i!==void 0&&(this.isLoading=i),this.isLoading}destroy(){this.$button.off("click"),this.$widget.find(".ai-widget-close-button").off("click"),this.$widget.find(".ai-widget-form").off("submit")}};return l(u);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@courseecho/ai-widget-jquery",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "jQuery plugin for AI Chat Widget - enables vanilla JavaScript/HTML integration via npm or script tag",
|
|
5
5
|
"main": "dist/ai-widget-jquery.cjs",
|
|
6
6
|
"module": "dist/ai-widget-jquery.mjs",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc",
|
|
24
24
|
"build:umd": "tsc \u0026\u0026 npm run esbuild",
|
|
25
|
-
"esbuild": "esbuild dist/
|
|
25
|
+
"esbuild": "esbuild dist/ai-widget-jquery.js --bundle --minify --format=iife --global-name=AiWidgetjQuery --outfile=dist/ai-widget-jquery.umd.min.js",
|
|
26
26
|
"dev": "tsc --watch"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"jquery": "\u003e=1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"esbuild": "^0.19.12",
|
|
33
|
+
"typescript": "^5.3.0"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"ai",
|