obi-sdk 0.1.3 → 0.1.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 +41 -0
- package/dist/index-e52b38be.js +5223 -0
- package/dist/modular/chunks/assistant-5a47c1b4.js +234 -0
- package/dist/modular/chunks/assistant-5a47c1b4.js.map +1 -0
- package/dist/modular/chunks/mitt-3c1f932d.js +20 -0
- package/dist/modular/chunks/mitt-3c1f932d.js.map +1 -0
- package/dist/modular/chunks/{obi-widget-9c0306f4.js → obi-widget-0d63936f.js} +4561 -4561
- package/dist/modular/chunks/obi-widget-0d63936f.js.map +1 -0
- package/dist/modular/chunks/{session-37970ed1.js → session-88fd0dca.js} +18 -39
- package/dist/modular/chunks/session-88fd0dca.js.map +1 -0
- package/dist/modular/core.js +11 -238
- package/dist/modular/core.js.map +1 -1
- package/dist/modular/index.js +78 -403
- package/dist/modular/index.js.map +1 -1
- package/dist/modular/ui.js +16 -16
- package/dist/obi-sdk.es.js +8 -22754
- package/dist/obi-sdk.standalone.iife.js +40 -172
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/obi-sdk.umd.js +89 -259
- package/dist/session-33b71dff.js +15762 -0
- package/package.json +2 -2
- package/dist/modular/chunks/obi-widget-9c0306f4.js.map +0 -1
- package/dist/modular/chunks/session-37970ed1.js.map +0 -1
package/README.md
CHANGED
|
@@ -222,6 +222,47 @@ const sdk = new ObiSDK({
|
|
|
222
222
|
})
|
|
223
223
|
```
|
|
224
224
|
|
|
225
|
+
## Always Load the Latest SDK Version
|
|
226
|
+
|
|
227
|
+
The SDK includes a simple function to always load the latest version from the CDN, which can be useful for applications that need to ensure users always have the newest features. The dynamic loader follows the same version detection mechanism as the inline script, querying the npm registry to get the latest version.
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import { initObi } from "obi-sdk"
|
|
231
|
+
|
|
232
|
+
// In a React component:
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
const setupObi = async () => {
|
|
235
|
+
try {
|
|
236
|
+
// This will:
|
|
237
|
+
// 1. Check npm registry for the latest version
|
|
238
|
+
// 2. Load that specific version from unpkg.com
|
|
239
|
+
// 3. Initialize the widget with your config
|
|
240
|
+
await initObi({
|
|
241
|
+
apiKey: "YOUR_API_KEY",
|
|
242
|
+
position: "bottom-right",
|
|
243
|
+
user: {
|
|
244
|
+
id: "user-123",
|
|
245
|
+
email: "user@example.com",
|
|
246
|
+
},
|
|
247
|
+
})
|
|
248
|
+
console.log("Obi Assistant initialized with latest SDK")
|
|
249
|
+
} catch (error) {
|
|
250
|
+
console.error("Failed to initialize Obi Assistant:", error)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Initialize Obi
|
|
255
|
+
setupObi()
|
|
256
|
+
}, [])
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
This approach ensures your application always uses the newest SDK version without requiring updates to your codebase. The loader will:
|
|
260
|
+
|
|
261
|
+
1. Query the npm registry to find the latest published version
|
|
262
|
+
2. Load that specific version from unpkg.com
|
|
263
|
+
3. Fall back to the "latest" tag if the specific version fails to load
|
|
264
|
+
4. Initialize the Obi widget with your configuration
|
|
265
|
+
|
|
225
266
|
## Building the SDK
|
|
226
267
|
|
|
227
268
|
To build the SDK locally:
|