@axsdk/browser 0.1.2 → 0.1.3
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 +11 -11
- package/dist/axsdk-browser.js +1 -1
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Vanilla JS embed SDK for the [AXSDK](https://axsdk.ai) AI chat widget. No framew
|
|
|
14
14
|
```
|
|
15
15
|
Host Page iframe (srcdoc)
|
|
16
16
|
──────────────────────────────── ──────────────────────────────────────────
|
|
17
|
-
<script src="axsdk-browser.
|
|
17
|
+
<script src="axsdk-browser.js">
|
|
18
18
|
AXSDKBrowser.init(config) ─────────► AXSDK_INIT (postMessage)
|
|
19
19
|
AXSDK.init({ ...config, axHandler: rpc })
|
|
20
20
|
<AXUI /> mounted in document.body
|
|
@@ -24,7 +24,7 @@ user axHandler callback
|
|
|
24
24
|
AXSDK_HANDLER_RESPONSE ────────────► Promise resolves / rejects
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
The parent-page loader (`axsdk-browser.
|
|
27
|
+
The parent-page loader (`axsdk-browser.js`) has no React dependency and is very small. The full React + UI bundle (`axsdk-browser-frame.js`) is loaded inside the iframe.
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
@@ -63,7 +63,7 @@ Both files **must be served from the same path prefix** — the loader automatic
|
|
|
63
63
|
|
|
64
64
|
```html
|
|
65
65
|
<!-- Both files must live at the same URL prefix -->
|
|
66
|
-
<script src="https://
|
|
66
|
+
<script src="https://unpkg.com/@axsdk/browser/axsdk-browser.js"></script>
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
---
|
|
@@ -80,7 +80,7 @@ Both files **must be served from the same path prefix** — the loader automatic
|
|
|
80
80
|
<body>
|
|
81
81
|
<!-- Your page content -->
|
|
82
82
|
|
|
83
|
-
<script src="https://
|
|
83
|
+
<script src="https://unpkg.com/@axsdk/browser/axsdk-browser.js"></script>
|
|
84
84
|
<script>
|
|
85
85
|
AXSDKBrowser.init({
|
|
86
86
|
apiKey: 'YOUR_API_KEY',
|
|
@@ -119,7 +119,7 @@ AXSDKBrowser.init(config: AXSDKBrowserConfig): void
|
|
|
119
119
|
#### Example with `axHandler`
|
|
120
120
|
|
|
121
121
|
```html
|
|
122
|
-
<script src="https://
|
|
122
|
+
<script src="https://unpkg.com/@axsdk/browser/axsdk-browser.js"></script>
|
|
123
123
|
<script>
|
|
124
124
|
AXSDKBrowser.init({
|
|
125
125
|
apiKey: 'YOUR_API_KEY',
|
|
@@ -218,8 +218,8 @@ Sent by `AXSDKBrowser` after calling the user-provided `axHandler`.
|
|
|
218
218
|
|
|
219
219
|
| File | Description |
|
|
220
220
|
|---|---|
|
|
221
|
-
| `dist/axsdk-browser.
|
|
222
|
-
| `dist/axsdk-browser-frame.
|
|
221
|
+
| `dist/axsdk-browser.js` | Lightweight parent-page loader. No React. Exposes `AXSDKBrowser` global. |
|
|
222
|
+
| `dist/axsdk-browser-frame.js` | Self-contained iframe bundle — bundles React, `@axsdk/core`, `@axsdk/react`, and inlines all CSS. |
|
|
223
223
|
|
|
224
224
|
---
|
|
225
225
|
|
|
@@ -265,11 +265,11 @@ bun run publish
|
|
|
265
265
|
```
|
|
266
266
|
packages/axsdk-browser/
|
|
267
267
|
├── src/
|
|
268
|
-
│ ├── embed.ts # Parent-page loader → dist/axsdk-browser.
|
|
269
|
-
│ └── frame.tsx # iframe React app → dist/axsdk-browser-frame.
|
|
268
|
+
│ ├── embed.ts # Parent-page loader → dist/axsdk-browser.js
|
|
269
|
+
│ └── frame.tsx # iframe React app → dist/axsdk-browser-frame.js
|
|
270
270
|
├── dist/
|
|
271
|
-
│ ├── axsdk-browser.
|
|
272
|
-
│ └── axsdk-browser-frame.
|
|
271
|
+
│ ├── axsdk-browser.js
|
|
272
|
+
│ └── axsdk-browser-frame.js
|
|
273
273
|
├── vite.config.browser.ts # Vite config for the loader bundle
|
|
274
274
|
├── vite.config.frame.ts # Vite config for the iframe bundle (inlines CSS)
|
|
275
275
|
├── tsconfig.json
|
package/dist/axsdk-browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var AXSDK=(function(){"use strict";let e=null,s;const c=window.matchMedia("(max-width: 767px)");function l(r){e&&(r?e.style.cssText=["position:fixed","top:0","left:0","right:0","bottom:0","width:100%","height:100dvh","border:none","z-index:99999","background:transparent"].join(";"):e.style.cssText=["position:fixed","right:0","bottom:0","width:420px","height:680px","border:none","z-index:99999","background:transparent"].join(";"))}c.addEventListener("change",r=>{l(r.matches)});const d=document.currentScript,m=((d==null?void 0:d.src)??"").replace(/axsdk-browser\.
|
|
1
|
+
var AXSDK=(function(){"use strict";let e=null,s;const c=window.matchMedia("(max-width: 767px)");function l(r){e&&(r?e.style.cssText=["position:fixed","top:0","left:0","right:0","bottom:0","width:100%","height:100dvh","border:none","z-index:99999","background:transparent"].join(";"):e.style.cssText=["position:fixed","right:0","bottom:0","width:420px","height:680px","border:none","z-index:99999","background:transparent"].join(";"))}c.addEventListener("change",r=>{l(r.matches)});const d=document.currentScript,m=((d==null?void 0:d.src)??"").replace(/axsdk-browser\.js$/,""),p=m?m+"axsdk-browser-frame.js":"./axsdk-browser-frame.js";return window.addEventListener("message",async r=>{var a,t;if(!e||r.source!==e.contentWindow)return;const n=r.data;if((n==null?void 0:n.type)==="AXSDK_HANDLER_REQUEST"&&s){const{requestId:o,command:h,args:f}=n;try{const i=await s(h,f);(a=e.contentWindow)==null||a.postMessage({type:"AXSDK_HANDLER_RESPONSE",requestId:o,result:i},"*")}catch(i){const u=i instanceof Error?i.message:String(i);(t=e.contentWindow)==null||t.postMessage({type:"AXSDK_HANDLER_RESPONSE",requestId:o,error:u},"*")}}}),{init(r){if(e){console.warn("[AXSDKBrowser] Already initialized. Ignoring duplicate init() call.");return}s=r.axHandler;const{axHandler:n,...a}=r,t=document.createElement("iframe");e=t,l(c.matches),t.setAttribute("allowtransparency","true"),t.setAttribute("frameborder","0"),t.srcdoc=["<!DOCTYPE html>","<html>","<head>",'<meta charset="utf-8">','<meta name="viewport" content="width=device-width,initial-scale=1">',"<style>*{margin:0;padding:0;box-sizing:border-box}html,body{height:100%;width:100%;overflow:hidden}</style>","</head>","<body>",`<script src="${p}"><\/script>`,"</body>","</html>"].join(""),t.addEventListener("load",()=>{var o;(o=t.contentWindow)==null||o.postMessage({type:"AXSDK_INIT",config:a},"*")}),document.body.appendChild(t)},destroy(){e&&e.parentNode&&e.parentNode.removeChild(e),e=null,s=void 0}}})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axsdk/browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "axsdk browser - embed AXSDK widget in web",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "lordkeios@layorixinc.com",
|
|
17
17
|
"type": "module",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/axsdk-browser.js",
|
|
20
|
+
"./frame": {
|
|
21
|
+
"default": "./dist/axsdk-browser-frame.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
18
24
|
"files": [
|
|
19
25
|
"dist"
|
|
20
26
|
],
|