tia-chatbot 1.0.0 โ†’ 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 CHANGED
@@ -1,193 +1,146 @@
1
- # TIA Chatbot Widget
1
+ # TIA Widget
2
2
 
3
- A modern, reusable AI chatbot widget powered by Chainlit. Easily integrate an AI assistant into any web application with just a few lines of code.
3
+ A reusable CDN widget for integrating the TIA chatbot into any website.
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/tia-chatbot.svg)](https://www.npmjs.com/package/tia-chatbot)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
-
8
- ## โœจ Features
9
-
10
- - ๐Ÿš€ **Easy Integration** - Add to any website with NPM or CDN
11
- - ๐Ÿ’ฌ **Real-time Chat** - Interactive messaging with AI assistant
12
- - ๐ŸŽจ **Modern UI** - Clean, responsive interface with smooth animations
13
- - ๐ŸŽค **Voice Support** - Voice-to-text and text-to-speech capabilities
14
- - ๐Ÿ“ฑ **Mobile Friendly** - Works seamlessly on all devices
15
- - โšก **Lightweight** - Optimized bundle size with tree-shaking support
16
- - ๐Ÿ”ง **Customizable** - Easy to style and configure
17
- - ๐Ÿ“ฆ **TypeScript** - Full TypeScript support with type definitions
18
-
19
- ## ๐Ÿ“ฆ Installation
5
+ ## Installation
20
6
 
21
7
  ### Via NPM
22
8
 
23
9
  ```bash
24
- npm install tia-chatbot
10
+ npm install tia-widget
25
11
  ```
26
12
 
27
13
  ### Via CDN
28
14
 
29
15
  ```html
30
- <!-- React Dependencies -->
31
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
32
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
33
-
34
- <!-- TIA Chatbot Widget -->
35
- <script src="https://unpkg.com/tia-chatbot@latest/dist/tia-chatbot.umd.js"></script>
36
- <link rel="stylesheet" href="https://unpkg.com/tia-chatbot@latest/dist/style.css">
16
+ <script src="https://unpkg.com/tia-widget@latest/dist/tia-widget.iife.js"></script>
37
17
  ```
38
18
 
39
- ## ๐Ÿš€ Quick Start
40
-
41
- ### NPM Usage (React/TypeScript)
42
-
43
- ```typescript
44
- import { initTiaChatbot } from 'tia-chatbot';
45
- import 'tia-chatbot/style.css';
19
+ ## Usage
46
20
 
47
- const widget = initTiaChatbot({
48
- serverUrl: 'https://your-chainlit-server.com',
49
- container: '#chatbot-container'
50
- });
51
-
52
- // Later, to remove the widget
53
- widget.destroy();
54
- ```
21
+ ### Automatic Initialization (CDN)
55
22
 
56
- ### CDN Usage (Vanilla JavaScript)
23
+ Add the script tag with data attributes for auto-initialization:
57
24
 
58
25
  ```html
59
26
  <!DOCTYPE html>
60
27
  <html>
61
28
  <head>
62
- <link rel="stylesheet" href="https://unpkg.com/tia-chatbot@latest/dist/style.css">
29
+ <title>My Website</title>
30
+ <!-- Include React and ReactDOM for the widget -->
31
+ <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
32
+ <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
63
33
  </head>
64
34
  <body>
65
- <div id="chatbot-container"></div>
35
+ <!-- Your website content -->
36
+
37
+ <!-- TIA Widget Script -->
38
+ <script
39
+ src="https://unpkg.com/tia-widget@latest/dist/tia-widget.iife.js"
40
+ data-auto-init
41
+ data-api-url="https://your-api-endpoint.com"
42
+ data-container-id="custom-widget-container">
43
+ </script>
44
+ </body>
45
+ </html>
46
+ ```
66
47
 
48
+ ### Manual Initialization
49
+
50
+ ```html
51
+ <!DOCTYPE html>
52
+ <html>
53
+ <head>
54
+ <title>My Website</title>
55
+ <!-- Include React and ReactDOM -->
67
56
  <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
68
57
  <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
69
- <script src="https://unpkg.com/tia-chatbot@latest/dist/tia-chatbot.umd.js"></script>
58
+ </head>
59
+ <body>
60
+ <!-- Your website content -->
61
+ <div id="my-widget"></div>
70
62
 
63
+ <!-- TIA Widget Script -->
64
+ <script src="https://unpkg.com/tia-widget@latest/dist/tia-widget.iife.js"></script>
71
65
  <script>
72
- TiaChatbot.initTiaChatbot({
73
- serverUrl: 'https://your-chainlit-server.com',
74
- container: '#chatbot-container'
66
+ // Initialize the widget manually
67
+ const widget = window.TIAWidget.init({
68
+ apiUrl: 'https://your-api-endpoint.com',
69
+ containerId: 'my-widget',
70
+ onError: (error) => {
71
+ console.error('TIA Widget Error:', error);
72
+ }
75
73
  });
74
+
75
+ // Optional: Unmount the widget later
76
+ // widget.unmount();
76
77
  </script>
77
78
  </body>
78
79
  </html>
79
80
  ```
80
81
 
81
- ## ๐Ÿ“– Documentation
82
+ ### Programmatic Usage (NPM)
82
83
 
83
- For detailed documentation, including:
84
- - Configuration options
85
- - Framework integration (React, Vue, Angular, Next.js)
86
- - Styling and customization
87
- - API reference
88
- - Troubleshooting
84
+ ```javascript
85
+ import { initTIAWidget } from 'tia-widget';
89
86
 
90
- See [WIDGET_USAGE.md](./WIDGET_USAGE.md)
91
-
92
- ## โš™๏ธ Configuration
87
+ // Initialize the widget
88
+ const widget = initTIAWidget({
89
+ apiUrl: 'https://your-api-endpoint.com',
90
+ containerId: 'my-widget',
91
+ onError: (error) => {
92
+ console.error('Widget error:', error);
93
+ }
94
+ });
93
95
 
94
- ```typescript
95
- interface TiaChatbotConfig {
96
- serverUrl: string; // Your Chainlit server URL (required)
97
- container?: string | HTMLElement; // Container element (default: '#tia-chatbot-root')
98
- }
96
+ // Later, unmount if needed
97
+ widget.unmount();
99
98
  ```
100
99
 
101
- ## ๐ŸŽจ Customization
100
+ ## Configuration Options
102
101
 
103
- Override default styles with CSS:
102
+ | Option | Type | Default | Description |
103
+ |--------|------|---------|-------------|
104
+ | `apiUrl` | `string` | `window.origin + routerBasename` | The API endpoint URL for the TIA chatbot |
105
+ | `containerId` | `string` | `'tia-widget-root'` | The ID of the DOM element where the widget will be mounted |
106
+ | `onError` | `function` | `console.error` | Error handler function |
104
107
 
105
- ```css
106
- :root {
107
- --tia-primary-color: #f56057;
108
- --tia-secondary-color: #283068;
109
- }
108
+ ## Data Attributes (for CDN auto-init)
110
109
 
111
- #tia-chatbot-root {
112
- position: fixed;
113
- bottom: 20px;
114
- right: 20px;
115
- }
116
- ```
110
+ - `data-auto-init`: Enables automatic initialization
111
+ - `data-api-url`: Sets the API URL
112
+ - `data-container-id`: Sets the container element ID
117
113
 
118
- ## ๐Ÿ› ๏ธ Development
114
+ ## Publishing to NPM
119
115
 
120
- ### Prerequisites
121
- - Node.js 16+
122
- - npm or pnpm
116
+ ```bash
117
+ npm run build:cdn
118
+ npm publish
119
+ ```
123
120
 
124
- ### Setup
121
+ ## Development
125
122
 
126
123
  ```bash
127
124
  # Install dependencies
128
- npm install
125
+ pnpm install
129
126
 
130
127
  # Start development server
131
- npm run dev
128
+ pnpm run dev
132
129
 
133
130
  # Build for production
134
- npm run build
135
-
136
- # Preview production build
137
- npm run preview
138
- ```
139
-
140
- ### Project Structure
141
-
142
- ```
143
- src/
144
- โ”œโ”€โ”€ components/ # React components
145
- โ”‚ โ”œโ”€โ”€ ChatPopup.tsx # Main chat interface
146
- โ”‚ โ””โ”€โ”€ ...
147
- โ”œโ”€โ”€ state/ # Recoil state management
148
- โ”œโ”€โ”€ lib/ # Utility functions
149
- โ”œโ”€โ”€ index.tsx # Widget entry point
150
- โ”œโ”€โ”€ App.tsx # Main app component
151
- โ””โ”€โ”€ index.css # Global styles
152
- ```
131
+ pnpm run build
153
132
 
154
- ## ๐Ÿ“‹ Requirements
155
-
156
- ### Peer Dependencies
157
- - `react` >= 18.3.1
158
- - `react-dom` >= 18.3.1
159
-
160
- ### Browser Support
161
- - Chrome (latest)
162
- - Firefox (latest)
163
- - Safari (latest)
164
- - Edge (latest)
165
-
166
- ## ๐Ÿงช Testing
167
-
168
- Open `example.html` in a browser after building to test the UMD build:
169
-
170
- ```bash
171
- npm run build
172
- # Open example.html in your browser
133
+ # Build for CDN
134
+ pnpm run build:cdn
173
135
  ```
174
136
 
175
- ## ๐Ÿ“„ License
176
-
177
- MIT License - see [LICENSE](./LICENSE) for details
178
-
179
- ## ๐Ÿค Contributing
180
-
181
- Contributions are welcome! Please feel free to submit a Pull Request.
182
-
183
- ## ๐Ÿ› Issues
184
-
185
- Found a bug or have a feature request? Please open an issue on GitHub.
137
+ ## Requirements
186
138
 
187
- ## ๐Ÿ“ž Support
139
+ - React 18+
140
+ - React DOM 18+
188
141
 
189
- For questions and support, please refer to the [documentation](./WIDGET_USAGE.md) or open an issue.
142
+ The widget bundles React and other dependencies, but for CDN usage, you need to include React and ReactDOM scripts separately.
190
143
 
191
- ---
144
+ ## License
192
145
 
193
- Built with โค๏ธ using React, TypeScript, and Chainlit
146
+ MIT
@@ -0,0 +1 @@
1
+ export {}