tybotflow-widget 0.5.4 → 0.5.6
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 +230 -23
- package/README.npm.md +42 -0
- package/dist/index.d.ts +4 -21
- package/dist/index.es.js +75310 -2
- package/package.json +2 -1
- package/dist/html2canvas.esm-B5Zl-F6w.mjs +0 -4871
- package/dist/index-C6SfnKe2.mjs +0 -63238
- package/dist/index.es-v5ymGHeX.mjs +0 -6652
- package/dist/purify.es-8O7LIJdo.mjs +0 -553
package/README.md
CHANGED
|
@@ -1,42 +1,249 @@
|
|
|
1
|
-
# TybotFlow Widget
|
|
1
|
+
# TybotFlow Widget - Development Documentation
|
|
2
2
|
|
|
3
3
|
A modern, customizable React widget for Tybot chat integration.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📋 Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Prerequisites](#prerequisites)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Project Structure](#project-structure)
|
|
10
|
+
- [Development](#development)
|
|
11
|
+
- [Building](#building)
|
|
12
|
+
- [Publishing to NPM](#publishing-to-npm)
|
|
13
|
+
- [Configuration](#configuration)
|
|
14
|
+
- [Technologies Used](#technologies-used)
|
|
15
|
+
- [Common Issues](#common-issues)
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
Before you begin, ensure you have the following installed:
|
|
20
|
+
|
|
21
|
+
- **Node.js** (v16 or higher)
|
|
22
|
+
- **npm** or **yarn**
|
|
23
|
+
- **Git**
|
|
24
|
+
|
|
25
|
+
## Getting Started
|
|
26
|
+
|
|
27
|
+
### 1. Clone the Repository
|
|
6
28
|
|
|
7
29
|
```bash
|
|
8
|
-
|
|
30
|
+
git clone https://github.com/Tython-dev/tybotflow-widget.git
|
|
31
|
+
cd tybotflow-widget
|
|
9
32
|
```
|
|
10
33
|
|
|
11
|
-
|
|
34
|
+
### 2. Install Dependencies
|
|
12
35
|
|
|
13
|
-
|
|
36
|
+
```bash
|
|
37
|
+
npm install
|
|
38
|
+
```
|
|
14
39
|
|
|
15
|
-
|
|
16
|
-
import { createTybotWidget } from "tybotflow-widget";
|
|
40
|
+
### 3. Start Development Server
|
|
17
41
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
42
|
+
```bash
|
|
43
|
+
npm run dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The development server will start at `http://localhost:5500`.
|
|
47
|
+
|
|
48
|
+
## Project Structure
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
tybot-widget-dev/
|
|
52
|
+
├── src/
|
|
53
|
+
│ ├── assets/ # Images, fonts, and static assets
|
|
54
|
+
│ ├── components/ # React components
|
|
55
|
+
│ │ ├── TybotWidget.tsx # Main widget component
|
|
56
|
+
│ │ ├── AudioPlayer.tsx
|
|
57
|
+
│ │ ├── CarouselSlider.tsx
|
|
58
|
+
│ │ ├── Products.tsx
|
|
59
|
+
│ │ └── ...
|
|
60
|
+
│ ├── index.tsx # Library entry point
|
|
61
|
+
│ ├── main.tsx # Development entry point
|
|
62
|
+
│ ├── types.ts # TypeScript type definitions
|
|
63
|
+
│ └── index.css # Global styles
|
|
64
|
+
├── dist/ # Built files (generated)
|
|
65
|
+
├── index.html # Development HTML file
|
|
66
|
+
├── package.json # Package configuration
|
|
67
|
+
├── vite.config.ts # Vite build configuration
|
|
68
|
+
├── tailwind.config.js # Tailwind CSS configuration
|
|
69
|
+
├── tsconfig.json # TypeScript configuration
|
|
70
|
+
├── README.md # Developer documentation (this file)
|
|
71
|
+
└── README.npm.md # NPM package documentation
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
### Running the Development Server
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run dev
|
|
25
80
|
```
|
|
26
81
|
|
|
27
|
-
with
|
|
82
|
+
This starts a local development server with hot module replacement (HMR). Open your browser and navigate to `http://localhost:5500`.
|
|
83
|
+
|
|
84
|
+
### Testing the Widget
|
|
85
|
+
|
|
86
|
+
The `index.html` file includes a test implementation of the widget. You can modify this file to test different configurations:
|
|
28
87
|
|
|
29
88
|
```html
|
|
30
|
-
<script src="https://unpkg.com/tybotflow-widget/dist/index.umd.js"></script>
|
|
31
89
|
<script>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// ...other config options
|
|
36
|
-
});
|
|
90
|
+
TybotWidget.createTybotWidget({
|
|
91
|
+
bot: { botId: 'your-bot-id' },
|
|
92
|
+
});
|
|
37
93
|
</script>
|
|
38
94
|
```
|
|
39
95
|
|
|
40
|
-
|
|
96
|
+
### Making Changes
|
|
97
|
+
|
|
98
|
+
1. **Components**: Edit files in `src/components/`
|
|
99
|
+
2. **Styles**: Modify `src/index.css` or component-specific styles
|
|
100
|
+
3. **Types**: Update `src/types.ts` for TypeScript definitions
|
|
101
|
+
4. **Entry Point**: Main export is in `src/index.tsx`
|
|
102
|
+
|
|
103
|
+
### Code Style
|
|
104
|
+
|
|
105
|
+
- Follow TypeScript best practices
|
|
106
|
+
- Use functional components with React hooks
|
|
107
|
+
- Keep components modular and reusable
|
|
108
|
+
- Use Tailwind CSS for styling
|
|
109
|
+
|
|
110
|
+
## Building
|
|
111
|
+
|
|
112
|
+
### Build for Production
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm run build
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This command:
|
|
119
|
+
|
|
120
|
+
- Compiles TypeScript to JavaScript
|
|
121
|
+
- Bundles the code using Vite
|
|
122
|
+
- Generates both ES and UMD formats
|
|
123
|
+
- Creates TypeScript declaration files (`.d.ts`)
|
|
124
|
+
- Outputs everything to the `dist/` directory
|
|
125
|
+
|
|
126
|
+
### Build Output
|
|
127
|
+
|
|
128
|
+
After building, the `dist/` directory will contain:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
dist/
|
|
132
|
+
├── index.es.js # ES module format
|
|
133
|
+
├── index.umd.js # UMD format (for script tags)
|
|
134
|
+
└── index.d.ts # TypeScript declarations
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Preview Production Build
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm run preview
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Publishing to NPM
|
|
144
|
+
|
|
145
|
+
### Prerequisites for Publishing
|
|
146
|
+
|
|
147
|
+
1. **NPM Account**: You need access to the Tython npm account
|
|
148
|
+
2. **Login to NPM**: Run `npm login` and enter the Tython npm account credentials
|
|
149
|
+
3. **Access Rights**: Ensure the Tython account has publish rights to the `tybotflow-widget` package
|
|
150
|
+
|
|
151
|
+
### Publishing Steps
|
|
152
|
+
|
|
153
|
+
#### 1. Update Version
|
|
154
|
+
|
|
155
|
+
Update the version in `package.json` following [Semantic Versioning](https://semver.org/):
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Patch release (bug fixes): 0.5.4 -> 0.5.5
|
|
159
|
+
npm version patch
|
|
160
|
+
|
|
161
|
+
# Minor release (new features): 0.5.4 -> 0.6.0
|
|
162
|
+
npm version minor
|
|
163
|
+
|
|
164
|
+
# Major release (breaking changes): 0.5.4 -> 1.0.0
|
|
165
|
+
npm version major
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Or manually edit the version in `package.json`:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"version": "0.5.5"
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### 2. Build the Package
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm run build
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Verify the build was successful and check the `dist/` directory.
|
|
183
|
+
|
|
184
|
+
#### 3. Test the Package Locally (Optional)
|
|
185
|
+
|
|
186
|
+
Test the built package using the `index.html` file:
|
|
187
|
+
|
|
188
|
+
1. Build the package: `npm run build`
|
|
189
|
+
2. Open `index.html` in your browser
|
|
190
|
+
3. Uncomment the local script tag:
|
|
191
|
+
```html
|
|
192
|
+
<script src="./dist/index.umd.js"></script>
|
|
193
|
+
<script>
|
|
194
|
+
TybotWidget.createTybotWidget({
|
|
195
|
+
bot: { botId: "bot-id" },
|
|
196
|
+
});
|
|
197
|
+
</script>
|
|
198
|
+
```
|
|
199
|
+
4. Comment out the react main script if it's active
|
|
200
|
+
```html
|
|
201
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
202
|
+
```
|
|
203
|
+
5. Test the widget functionality
|
|
204
|
+
|
|
205
|
+
#### 4. Publish to NPM
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npm publish
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### 5. Verify Publication
|
|
212
|
+
|
|
213
|
+
Visit `https://www.npmjs.com/package/tybotflow-widget` to confirm the new version is live.
|
|
214
|
+
|
|
215
|
+
### Publishing Checklist
|
|
216
|
+
|
|
217
|
+
- [ ] Update version in `package.json`
|
|
218
|
+
- [ ] Update `README.npm.md` if needed
|
|
219
|
+
- [ ] Run `npm run build` successfully
|
|
220
|
+
- [ ] Test the build locally
|
|
221
|
+
- [ ] Commit all changes
|
|
222
|
+
- [ ] Run `npm publish`
|
|
223
|
+
- [ ] Push changes to GitHub
|
|
224
|
+
|
|
225
|
+
## Technologies Used
|
|
226
|
+
|
|
227
|
+
- **React 19** - UI library
|
|
228
|
+
- **TypeScript** - Type safety
|
|
229
|
+
- **Vite** - Build tool and dev server
|
|
230
|
+
- **Tailwind CSS** - Utility-first CSS framework
|
|
231
|
+
- **Axios** - HTTP client
|
|
232
|
+
- **React Markdown** - Markdown rendering
|
|
233
|
+
- **Lucide React** - Icon library
|
|
234
|
+
- **WaveSurfer** - Audio visualization
|
|
235
|
+
- **jsPDF** - PDF generation
|
|
236
|
+
|
|
237
|
+
## Common Issues
|
|
238
|
+
|
|
239
|
+
### Build Fails
|
|
240
|
+
|
|
241
|
+
- Ensure all dependencies are installed: `npm install`
|
|
242
|
+
- Clear the cache: `rm -rf node_modules dist && npm install`
|
|
243
|
+
- Check TypeScript errors: `npx tsc --noEmit`
|
|
244
|
+
|
|
245
|
+
### NPM Publish Fails
|
|
41
246
|
|
|
42
|
-
|
|
247
|
+
- Verify you're logged in: `npm whoami`
|
|
248
|
+
- Check if the version already exists on NPM
|
|
249
|
+
- Ensure you have publish rights to the package
|
package/README.npm.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# TybotFlow Widget SDK
|
|
2
|
+
|
|
3
|
+
A modern, customizable React widget for Tybot chat integration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install tybotflow-widget
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
in react
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { createTybotWidget } from "tybotflow-widget";
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
createTybotWidget({
|
|
20
|
+
bot: { botId: "your-bot-id", name: "My Bot" },
|
|
21
|
+
mainColor: "#FF0000",
|
|
22
|
+
// ...other config options
|
|
23
|
+
});
|
|
24
|
+
}, []);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
with script tag
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<script src="https://unpkg.com/tybotflow-widget/dist/index.umd.js"></script>
|
|
31
|
+
<script>
|
|
32
|
+
TybotWidget.createTybotWidget({
|
|
33
|
+
bot: { botId: "your-bot-id", name: "My Bot" },
|
|
34
|
+
mainColor: "#FF0000",
|
|
35
|
+
// ...other config options
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Props
|
|
41
|
+
|
|
42
|
+
See `dist/index.d.ts` for all available configuration options.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* Mounts the Tybot Widget to the DOM.
|
|
4
|
-
* @param config - Configuration options for the widget.
|
|
5
|
-
* @example
|
|
6
|
-
* ```html
|
|
7
|
-
* <script>
|
|
8
|
-
* TybotWidget.createTybotWidget(
|
|
9
|
-
* {
|
|
10
|
-
* bot: { botId: '123', name: 'Support Bot' }
|
|
11
|
-
* }
|
|
12
|
-
* );
|
|
13
|
-
* </script>
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function createTybotWidget(
|
|
17
|
-
config: TybotWidgetConfig
|
|
18
|
-
): void;
|
|
1
|
+
export declare function createTybotWidget(config: TybotWidgetConfig): void;
|
|
19
2
|
|
|
20
3
|
/**
|
|
21
4
|
* Information about a bot instance.
|
|
22
5
|
* @category Types
|
|
23
6
|
*/
|
|
24
|
-
declare interface IBot {
|
|
7
|
+
export declare interface IBot {
|
|
25
8
|
/** Bot's numeric ID (optional). */
|
|
26
9
|
id?: number;
|
|
27
10
|
/** Unique bot identifier string. */
|
|
@@ -48,7 +31,7 @@ declare interface IBot {
|
|
|
48
31
|
* Configuration for the Tybot Widget instance.
|
|
49
32
|
* @category Props
|
|
50
33
|
*/
|
|
51
|
-
declare interface TybotWidgetConfig {
|
|
34
|
+
export declare interface TybotWidgetConfig {
|
|
52
35
|
/** Current user object or ID. */
|
|
53
36
|
user?: any;
|
|
54
37
|
/** Authentication token for API calls. */
|
|
@@ -113,4 +96,4 @@ declare interface TybotWidgetConfig {
|
|
|
113
96
|
bot: IBot;
|
|
114
97
|
}
|
|
115
98
|
|
|
116
|
-
export { }
|
|
99
|
+
export { }
|