obi-sdk 0.1.9 → 0.1.10
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 +6 -7
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -14,12 +14,11 @@ A JavaScript SDK with dynamic content capabilities for integrating Obi into your
|
|
|
14
14
|
|
|
15
15
|
The loader accepts the following configuration options:
|
|
16
16
|
|
|
17
|
-
| Option | Type
|
|
18
|
-
| ---------- |
|
|
19
|
-
| `position` | string
|
|
20
|
-
| `apiKey` | string
|
|
21
|
-
| `
|
|
22
|
-
| `user` | object | - | User information with `id` (required), `email` (optional) and `metadata` (optional) |
|
|
17
|
+
| Option | Type | Default | Description |
|
|
18
|
+
| ---------- | ------ | ---------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| `position` | string | `'bottom-right'` | Position of the widget on the page. Options: `'bottom-right'`, `'bottom-left'`, `'top-right'`, `'top-left'` |
|
|
20
|
+
| `apiKey` | string | - | Your Obi API key (required for production) |
|
|
21
|
+
| `user` | object | - | User information with `id` (required), `email` (optional) and `metadata` (optional) |
|
|
23
22
|
|
|
24
23
|
## Installation Options
|
|
25
24
|
|
|
@@ -52,7 +51,7 @@ The simplest way to add Obi to your website is by using the inline loader script
|
|
|
52
51
|
<body>
|
|
53
52
|
<!-- Your website content -->
|
|
54
53
|
<script>
|
|
55
|
-
(()=>{var s=window,
|
|
54
|
+
(()=>{var s=window,r=document,d={position:"bottom-right"};function t(){var t,e,o,a=s.obiWidgetConfig||{};for(t in d)t in a||(a[t]=d[t]);if("function"==typeof s.ObiSDK||"object"==typeof s.ObiSDK)l(a);else if(s.__obiSDKLoading)e=function(){l(a)},o=s.setInterval(function(){"function"!=typeof s.ObiSDK&&"object"!=typeof s.ObiSDK||(s.clearInterval(o),e())},100);else{var i=function(t){var e,o,i,n;t=t,e=function(){s.__obiSDKLoading=!1,l(a)},s.__obiSDKLoading=!0,(o=r.createElement("script")).type="text/javascript",o.async=!0,o.src=(i="https://unpkg.com/obi-sdk")+"@"+(n=t||"latest")+"/dist/obi-sdk.standalone.iife.js",o.onload=e,o.onerror=function(){"latest"!==n?(console.warn("Failed to load specific version, falling back to latest"),o.src=i+"@latest/dist/obi-sdk.standalone.iife.js",o.onload=e):(s.__obiSDKLoading=!1,console.error("Failed to load Obi SDK"))},r.head.appendChild(o)};try{var n=new XMLHttpRequest;n.open("GET","https://registry.npmjs.org/obi-sdk/latest"),n.onload=function(){if(200===n.status)try{var t=JSON.parse(n.responseText);i(t.version)}catch(t){i(null)}else i(null)},n.onerror=function(){i(null)},n.send()}catch(t){i(null)}}}function l(t){var e;r.querySelector("obi-widget")?console.log("Obi Widget already exists on the page"):customElements.get("obi-widget")?(e=r.createElement("obi-widget"),t.apiKey&&e.setAttribute("api-key",t.apiKey),t.position&&e.setAttribute("position",t.position),t.user&&e.setAttribute("user",JSON.stringify(t.user)),r.body.appendChild(e),console.log("Obi Widget added to page")):console.warn("Obi Widget component not registered - SDK may not have loaded properly")}s.__obiSDKLoading=s.__obiSDKLoading||!1,"complete"===r.readyState?t():s.attachEvent?s.attachEvent("onload",t):s.addEventListener("load",t,!1)})();
|
|
56
55
|
</script>
|
|
57
56
|
</body>
|
|
58
57
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "obi-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "JavaScript SDK for Obi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/obi-sdk.umd.js",
|
|
@@ -60,9 +60,8 @@
|
|
|
60
60
|
"prettier": "^3.0.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
63
|
-
"rollup-plugin-visualizer": "^5.14.0",
|
|
64
63
|
"terser": "^5.39.0",
|
|
65
64
|
"typescript": "^5.0.2",
|
|
66
65
|
"vite": "^4.5.0"
|
|
67
66
|
}
|
|
68
|
-
}
|
|
67
|
+
}
|