@sksharma72000/ai-chat-websdk 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/README.md CHANGED
@@ -18,14 +18,16 @@ Drop it into any page with a single `initialize()` call — no framework require
18
18
  npm install @sksharma72000/ai-chat-websdk
19
19
  ```
20
20
 
21
- > **Peer dependencies** — React 18 and ReactDOM 18 must be present in your host application.
21
+ > **Peer dependencies** — React 18 and ReactDOM 18 must be present in your host application (Option A only).
22
+
23
+ ## Quick Start
24
+
25
+ ### Option A — npm (React / Vue / Angular / any bundler)
22
26
 
23
27
  ```bash
24
- npm install react react-dom
28
+ npm install @sksharma72000/ai-chat-websdk react react-dom
25
29
  ```
26
30
 
27
- ## Quick Start
28
-
29
31
  ```ts
30
32
  import AIChatSDK from '@sksharma72000/ai-chat-websdk';
31
33
  import '@sksharma72000/ai-chat-websdk/style.css';
@@ -76,9 +78,55 @@ AIChatSDK.setToken('Bearer eyJnew...');
76
78
  AIChatSDK.destroy();
77
79
  ```
78
80
 
79
- ## Configuration Reference
81
+ ### Option B — Script Tag / CDN (No React, No npm, No bundler)
82
+
83
+ The **standalone bundle** has React baked in — drop two tags into any HTML page and you're done.
84
+
85
+ ```html
86
+ <!-- Styles (shared with all bundle variants) -->
87
+ <link rel="stylesheet" href="https://unpkg.com/@sksharma72000/ai-chat-websdk/style.css" />
88
+ <!-- Standalone bundle (React included) -->
89
+ <script src="https://unpkg.com/@sksharma72000/ai-chat-websdk/ai-chat-websdk.standalone.js"></script>
90
+
91
+ <script>
92
+ AIChatSDK.initialize({
93
+ apiUrl: 'https://api.example.com',
94
+ jwtToken: 'Bearer eyJ...',
80
95
 
81
- | Option | Type | Default | Description |
96
+ onTokenExpired: async () => {
97
+ const res = await fetch('/auth/refresh', { method: 'POST' });
98
+ const { token } = await res.json();
99
+ return token;
100
+ },
101
+
102
+ title: 'Support Chat',
103
+ theme: {
104
+ primaryColor: '#6366f1',
105
+ secondaryColor: '#8b5cf6',
106
+ },
107
+ });
108
+
109
+ // Update token later
110
+ AIChatSDK.setToken('Bearer new-token');
111
+
112
+ // Remove widget
113
+ AIChatSDK.destroy();
114
+ </script>
115
+ ```
116
+
117
+ > The standalone bundle is larger (~2 MB unminified) because React is included.
118
+ > For production React projects use **Option A** to avoid shipping React twice.
119
+
120
+ ### Build outputs
121
+
122
+ | File | Use case |
123
+ |---|---|
124
+ | `ai-chat-websdk.es.js` | ES module — React apps, bundlers (Vite, webpack, etc.) |
125
+ | `ai-chat-websdk.umd.js` | CommonJS / UMD — Node SSR, older bundlers |
126
+ | `ai-chat-websdk.standalone.js` | IIFE — plain HTML, CMS, no-framework pages |
127
+ | `style.css` | Stylesheet for all bundle variants |
128
+
129
+ ## Configuration Reference
82
130
  |---|---|---|---|
83
131
  | `apiUrl` | `string` | **required** | Base URL of the AI server |
84
132
  | `jwtToken` | `string` | — | JWT token (with or without `Bearer ` prefix) |