droplinked-chatbot-next 1.0.8 → 1.0.9
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 +75 -13
- package/dist/Chatbot.d.ts +12 -0
- package/dist/index-C40_v4mv.js +48660 -0
- package/dist/index-C40_v4mv.js.map +1 -0
- package/dist/index-z0lPynKU.js +48700 -0
- package/dist/index-z0lPynKU.js.map +1 -0
- package/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.client-n6MaYrH1.js +48658 -0
- package/dist/index.client-n6MaYrH1.js.map +1 -0
- package/dist/index.client.d.ts +12 -0
- package/dist/index.client.js +5 -0
- package/dist/index.client.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd-C5JNg43q.js +17719 -0
- package/dist/index.umd-C5JNg43q.js.map +1 -0
- package/dist/index.umd-CUkx0ACx.js +17717 -0
- package/dist/index.umd-CUkx0ACx.js.map +1 -0
- package/dist/index.umd-DUVv0nFT.js +17717 -0
- package/dist/index.umd-DUVv0nFT.js.map +1 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,25 +1,80 @@
|
|
|
1
1
|
# Droplinked Chatbot
|
|
2
2
|
|
|
3
|
-
A React-based chatbot component with AI capabilities.
|
|
3
|
+
A React-based chatbot component with AI capabilities, now supporting both SSR and browser environments with dual builds.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install droplinked-chatbot
|
|
8
|
+
npm install droplinked-chatbot-next
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
### For SSR Frameworks (Next.js, etc.)
|
|
14
|
+
|
|
15
|
+
For SSR frameworks like Next.js, use the client export with dynamic imports:
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
'use client'
|
|
19
|
+
|
|
20
|
+
import dynamic from 'next/dynamic'
|
|
21
|
+
|
|
22
|
+
const Chatbot = dynamic(
|
|
23
|
+
() => import('droplinked-chatbot-next/client'),
|
|
24
|
+
{ ssr: false }
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
return (
|
|
29
|
+
<Chatbot
|
|
30
|
+
apiBaseUrl="https://your-api-base-url.com"
|
|
31
|
+
drawerTrigger={(onClick) => (
|
|
32
|
+
<button onClick={onClick}>Open Chat</button>
|
|
33
|
+
)}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### For Browser-Only Applications (Vite, Create React App, etc.)
|
|
40
|
+
|
|
41
|
+
For browser-only applications, you can import directly:
|
|
42
|
+
|
|
13
43
|
```jsx
|
|
14
|
-
import { Chatbot } from 'droplinked-chatbot'
|
|
44
|
+
import { Chatbot } from 'droplinked-chatbot-next'
|
|
15
45
|
|
|
16
46
|
function App() {
|
|
17
47
|
return (
|
|
18
48
|
<Chatbot
|
|
19
|
-
apiBaseUrl="https://your-api-base-url.com"
|
|
20
|
-
|
|
49
|
+
apiBaseUrl="https://your-api-base-url.com"
|
|
50
|
+
drawerTrigger={(onClick) => (
|
|
51
|
+
<button onClick={onClick}>Open Chat</button>
|
|
52
|
+
)}
|
|
21
53
|
/>
|
|
22
|
-
)
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Dual Builds
|
|
59
|
+
|
|
60
|
+
This package now provides dual builds for maximum compatibility:
|
|
61
|
+
|
|
62
|
+
- **CommonJS**: `dist/index.cjs` - For Node.js/SSR environments
|
|
63
|
+
- **ES Module**: `dist/index.mjs` - For modern browser bundlers
|
|
64
|
+
- **Client Export**: `dist/index.client.js` - For client-side only imports
|
|
65
|
+
|
|
66
|
+
The package.json uses modern `"exports"` field for proper resolution:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"exports": {
|
|
71
|
+
".": {
|
|
72
|
+
"import": "./dist/index.mjs",
|
|
73
|
+
"require": "./dist/index.cjs",
|
|
74
|
+
"types": "./dist/index.d.ts"
|
|
75
|
+
},
|
|
76
|
+
"./client": "./dist/index.client.js"
|
|
77
|
+
}
|
|
23
78
|
}
|
|
24
79
|
```
|
|
25
80
|
|
|
@@ -90,10 +145,10 @@ This indicates a mismatch between ES modules and CommonJS modules. To fix this:
|
|
|
90
145
|
2. Use import syntax instead of require:
|
|
91
146
|
```js
|
|
92
147
|
// Good
|
|
93
|
-
import { Chatbot } from 'droplinked-chatbot';
|
|
148
|
+
import { Chatbot } from 'droplinked-chatbot-next';
|
|
94
149
|
|
|
95
150
|
// Avoid
|
|
96
|
-
const { Chatbot } = require('droplinked-chatbot');
|
|
151
|
+
const { Chatbot } = require('droplinked-chatbot-next');
|
|
97
152
|
```
|
|
98
153
|
|
|
99
154
|
3. If you must use CommonJS, rename your files to use the `.cjs` extension.
|
|
@@ -130,9 +185,8 @@ The chatbot requires an `apiBaseUrl` prop to connect to your backend services:
|
|
|
130
185
|
|------|------|----------|-------------|
|
|
131
186
|
| apiBaseUrl | string | Yes | Base URL for API endpoints |
|
|
132
187
|
| apiKey | string | No | API key for authentication |
|
|
133
|
-
| buttonType | "floating" \| "solid" | No | Chat button style (default: "floating") |
|
|
134
|
-
| buttonText | string | No | Custom text for solid button |
|
|
135
188
|
| user | object | No | Initial user information |
|
|
189
|
+
| drawerTrigger | function | Yes | Function that returns a React element to trigger the chat drawer |
|
|
136
190
|
|
|
137
191
|
## Development
|
|
138
192
|
|
|
@@ -147,6 +201,13 @@ npm run dev
|
|
|
147
201
|
npm run build
|
|
148
202
|
```
|
|
149
203
|
|
|
204
|
+
## Examples
|
|
205
|
+
|
|
206
|
+
See the [examples](./examples) directory for detailed usage in different frameworks:
|
|
207
|
+
|
|
208
|
+
- [Next.js Example](./examples/nextjs/README.md)
|
|
209
|
+
- [React + Vite Example](./examples/react-vite/README.md)
|
|
210
|
+
|
|
150
211
|
## Troubleshooting
|
|
151
212
|
|
|
152
213
|
### Node.js Version Warning
|
|
@@ -187,7 +248,7 @@ To test the chatbot in another project:
|
|
|
187
248
|
|
|
188
249
|
2. In your test project:
|
|
189
250
|
```bash
|
|
190
|
-
npm link droplinked-chatbot
|
|
251
|
+
npm link droplinked-chatbot-next
|
|
191
252
|
```
|
|
192
253
|
|
|
193
254
|
3. Make sure your test project has all peer dependencies installed:
|
|
@@ -199,7 +260,8 @@ To test the chatbot in another project:
|
|
|
199
260
|
|
|
200
261
|
When publishing to npm, the package is built with both CommonJS and ES module formats for maximum compatibility:
|
|
201
262
|
|
|
202
|
-
- `dist/index.
|
|
203
|
-
- `dist/index.
|
|
263
|
+
- `dist/index.cjs` - CommonJS format
|
|
264
|
+
- `dist/index.mjs` - ES module format
|
|
265
|
+
- `dist/index.client.js` - Client-only format
|
|
204
266
|
|
|
205
267
|
The package.json includes proper export maps to ensure the correct format is used based on the importing environment.
|