obi-sdk 0.1.1 → 0.1.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
@@ -30,7 +30,7 @@ The loader accepts the following configuration options:
30
30
 
31
31
  The simplest way to add Obi to your website is by using the inline loader script:
32
32
 
33
- 1. Copy the full inline loader script from above
33
+ 1. Copy the full inline loader script from below
34
34
  2. Add it to your HTML page
35
35
  3. Configure the widget using `window.obiWidgetConfig`
36
36
 
@@ -126,10 +126,10 @@ The simplest way to add Obi to your website is by using the inline loader script
126
126
  var s = d.createElement("script")
127
127
  s.type = "text/javascript"
128
128
  s.async = !0
129
- var b = "https://cdn.iamobi.ai/obi-sdk"
129
+ var b = "https://unpkg.com/obi-sdk"
130
130
  s.src = f.noCacheSDK
131
- ? b + "-" + f.sdkVersion + ".js?t=" + Date.now()
132
- : b + "-" + f.sdkVersion + ".js"
131
+ ? b + "@" + f.sdkVersion + "/dist/obi-sdk.standalone.iife.js?t=" + Date.now()
132
+ : b + "@" + f.sdkVersion + "/dist/obi-sdk.standalone.iife.js"
133
133
  s.onload = cb
134
134
  s.onerror = function () {
135
135
  w.__obiSDKLoading = !1
@@ -197,6 +197,54 @@ The simplest way to add Obi to your website is by using the inline loader script
197
197
 
198
198
  The widget will automatically appear in the specified position on your page.
199
199
 
200
+ ## How It Works
201
+
202
+ The loader script:
203
+
204
+ 1. Dynamically checks for the latest version using the npm registry API
205
+ 2. Loads the Obi SDK from unpkg.com with the appropriate version
206
+ 3. Creates and positions the `<obi-widget>` custom element on your page
207
+ 4. Initializes the widget with your API key and configuration
208
+
209
+ ## Installation for npm Projects
210
+
211
+ You can also install the SDK via npm:
212
+
213
+ ```bash
214
+ npm install obi-sdk
215
+ ```
216
+
217
+ And import it in your application:
218
+
219
+ ```javascript
220
+ import ObiSDK from "obi-sdk"
221
+
222
+ // Initialize the SDK
223
+ const sdk = new ObiSDK({
224
+ apiKey: "YOUR_API_KEY",
225
+ apiBaseUrl: "https://www.iamobi.ai/api/",
226
+ })
227
+ ```
228
+
229
+ ## Building the SDK
230
+
231
+ To build the SDK locally:
232
+
233
+ ```bash
234
+ # Install dependencies
235
+ npm install
236
+
237
+ # Build all formats (UMD, ES, standalone IIFE, and loader)
238
+ npm run build:all
239
+ ```
240
+
241
+ This generates the following in the `dist` directory:
242
+
243
+ - `obi-sdk.umd.js` - UMD format for CommonJS/AMD environments
244
+ - `obi-sdk.es.js` - ES Module format for modern bundlers
245
+ - `obi-sdk.standalone.iife.js` - IIFE format with all dependencies bundled
246
+ - `obi-loader.iife.js` - Standalone loader script
247
+
200
248
  ## Coming Soon
201
249
 
202
250
  The following features are under development and will be available in future releases:
@@ -218,14 +266,14 @@ The inline loader script provides a self-contained way to add the Obi Widget to
218
266
  5. It creates the `<obi-widget>` element and positions it on the page
219
267
  6. It configures the widget with the provided options
220
268
 
221
- Before using in production, you should update the CDN URL to point to where you host the SDK files:
269
+ Before using in production, you can use unpkg.com as a CDN which automatically serves files from npm packages:
222
270
 
223
271
  ```js
224
- // In the loader script, change this line:
225
- var b = "https://cdn.iamobi.ai/obi-sdk"
272
+ // The loader automatically uses unpkg.com to load the package:
273
+ var b = "https://unpkg.com/obi-sdk"
226
274
 
227
- // To point to your CDN:
228
- var b = "https://your-cdn.iamobi.ai/path/to/obi-sdk"
275
+ // Which resolves to URLs like:
276
+ // https://unpkg.com/obi-sdk@0.1.1/dist/obi-sdk.standalone.iife.js
229
277
  ```
230
278
 
231
279
  ### Widget Positioning