bstp-agent-widget 0.1.0 → 0.2.0
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 +18 -11
- package/dist/agent-widget.cjs +1 -1
- package/dist/agent-widget.cjs.map +1 -1
- package/dist/agent-widget.js +19 -1
- package/dist/agent-widget.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/index.d.ts +9 -0
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ Create a wrapper component:
|
|
|
78
78
|
|
|
79
79
|
```ts
|
|
80
80
|
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';
|
|
81
|
-
import {
|
|
81
|
+
import { mountAgentChatWidgetFromEnvironment } from 'bstp-agent-widget';
|
|
82
82
|
|
|
83
83
|
@Component({
|
|
84
84
|
selector: 'app-agent-chat-widget',
|
|
@@ -88,21 +88,15 @@ export class AgentChatWidgetComponent implements AfterViewInit, OnDestroy {
|
|
|
88
88
|
@ViewChild('widgetHost', { static: true }) widgetHost!: ElementRef<HTMLDivElement>;
|
|
89
89
|
private cleanup: (() => void) | null = null;
|
|
90
90
|
|
|
91
|
-
ngAfterViewInit(): void {
|
|
92
|
-
this.cleanup =
|
|
93
|
-
config: {
|
|
94
|
-
baseUrl: 'https://your-genai-api-url',
|
|
95
|
-
assistantId: 123,
|
|
96
|
-
genaiInit: {
|
|
97
|
-
email: 'agent@example.com',
|
|
98
|
-
clientSecret: 'secret',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
91
|
+
async ngAfterViewInit(): Promise<void> {
|
|
92
|
+
this.cleanup = await mountAgentChatWidgetFromEnvironment(this.widgetHost.nativeElement, {
|
|
101
93
|
runtime: {
|
|
102
94
|
customerId: '590100010884',
|
|
103
95
|
customerToken: 'jwt-token',
|
|
104
96
|
language: 'en-US',
|
|
105
97
|
},
|
|
98
|
+
// Optional: defaults to /environment.json
|
|
99
|
+
// environmentUrl: '/environment.json',
|
|
106
100
|
});
|
|
107
101
|
}
|
|
108
102
|
|
|
@@ -112,6 +106,19 @@ export class AgentChatWidgetComponent implements AfterViewInit, OnDestroy {
|
|
|
112
106
|
}
|
|
113
107
|
```
|
|
114
108
|
|
|
109
|
+
The function reads `genai.config` from `environment.json`:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"genai": {
|
|
114
|
+
"config": {
|
|
115
|
+
"assistantId": 220,
|
|
116
|
+
"url": "https://.../genai/api/v1"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
115
122
|
# React Starter Kit
|
|
116
123
|
|
|
117
124
|
A modern, enterprise-grade React Starter Kit built with TypeScript, providing a comprehensive foundation for building scalable web applications. This starter kit includes all the essential tools and configurations needed for modern React development.
|
package/dist/agent-widget.cjs
CHANGED
|
@@ -451,5 +451,5 @@ Learn more: https://react.dev/warnings/version-mismatch`))})(),typeof Map==`func
|
|
|
451
451
|
You might need to use a local HTTP server (instead of file://): https://react.dev/link/react-devtools-faq`:``),`font-weight:bold`)}e.createRoot=function(e,t){if(!_(e))throw Error(`Target container is not a DOM element.`);hf(e);var n=!1,r=``,i=Vo,a=Ho,o=Uo;return t!=null&&(t.hydrate?console.warn(`hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead.`):typeof t==`object`&&t&&t.$$typeof===xf&&console.error(`You passed a JSX element to createRoot. You probably meant to call root.render instead. Example usage:
|
|
452
452
|
|
|
453
453
|
let root = createRoot(domContainer);
|
|
454
|
-
root.render(<App />);`),!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=Vd(e,1,!1,null,null,n,r,null,i,a,o,ff),e[Rp]=t.current,Ql(e),new pf(t)},e.hydrateRoot=function(e,t,n){if(!_(e))throw Error(`Target container is not a DOM element.`);hf(e),t===void 0&&console.error(`Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)`);var r=!1,i=``,a=Vo,o=Ho,s=Uo,c=null;return n!=null&&(!0===n.unstable_strictMode&&(r=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(a=n.onUncaughtError),n.onCaughtError!==void 0&&(o=n.onCaughtError),n.onRecoverableError!==void 0&&(s=n.onRecoverableError),n.formState!==void 0&&(c=n.formState)),t=Vd(e,1,!0,t,n??null,r,i,c,a,o,s,ff),t.context=Hd(null),n=t.current,r=Bc(n),r=ke(r),i=Li(r),i.callback=null,Ri(n,i,r),Gr(r,`hydrateRoot()`,null),n=r,t.current.lanes=n,we(t,n),Fl(t),e[Rp]=t.current,Ql(e),new mf(t)},e.version=`19.2.4`,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),zA=e.r(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`)){if(process.env.NODE_ENV!==`production`)throw Error(`^_^`);try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}}process.env.NODE_ENV===`production`?(n(),t.exports=LA()):t.exports=RA()}))();function BA({config:e,runtime:t}){return(0,H.jsx)(NA,{config:e,children:(0,H.jsx)(MA,{runtime:t,children:(0,H.jsx)(jA,{})})})}var VA=new WeakMap;function HA(e,t){let n=VA.get(e);n&&n.unmount();let r=(0,zA.createRoot)(e);return r.render((0,H.jsx)(BA,{...t})),VA.set(e,r),()=>{let t=VA.get(e);t&&(t.unmount(),VA.delete(e))}}exports.AgentChatWidget=BA,exports.mountAgentChatWidget=HA;
|
|
454
|
+
root.render(<App />);`),!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=Vd(e,1,!1,null,null,n,r,null,i,a,o,ff),e[Rp]=t.current,Ql(e),new pf(t)},e.hydrateRoot=function(e,t,n){if(!_(e))throw Error(`Target container is not a DOM element.`);hf(e),t===void 0&&console.error(`Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)`);var r=!1,i=``,a=Vo,o=Ho,s=Uo,c=null;return n!=null&&(!0===n.unstable_strictMode&&(r=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(a=n.onUncaughtError),n.onCaughtError!==void 0&&(o=n.onCaughtError),n.onRecoverableError!==void 0&&(s=n.onRecoverableError),n.formState!==void 0&&(c=n.formState)),t=Vd(e,1,!0,t,n??null,r,i,c,a,o,s,ff),t.context=Hd(null),n=t.current,r=Bc(n),r=ke(r),i=Li(r),i.callback=null,Ri(n,i,r),Gr(r,`hydrateRoot()`,null),n=r,t.current.lanes=n,we(t,n),Fl(t),e[Rp]=t.current,Ql(e),new mf(t)},e.version=`19.2.4`,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==`function`&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()})),zA=e.r(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`)){if(process.env.NODE_ENV!==`production`)throw Error(`^_^`);try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}}process.env.NODE_ENV===`production`?(n(),t.exports=LA()):t.exports=RA()}))();function BA({config:e,runtime:t}){return(0,H.jsx)(NA,{config:e,children:(0,H.jsx)(MA,{runtime:t,children:(0,H.jsx)(jA,{})})})}var VA=new WeakMap;function HA(e,t){let n=VA.get(e);n&&n.unmount();let r=(0,zA.createRoot)(e);return r.render((0,H.jsx)(BA,{...t})),VA.set(e,r),()=>{let t=VA.get(e);t&&(t.unmount(),VA.delete(e))}}function UA(e){let t=e.genai?.config;if(!t?.url||!t?.assistantId)throw Error(`GenAI config is missing in environment.json.`);return{baseUrl:t.url,assistantId:t.assistantId,assistants:t.agents,genaiInit:e.genai?.init}}async function WA(e,t){let n=t.environmentUrl??`/environment.json`,r=await fetch(n);if(!r.ok)throw Error(`Failed to load environment from ${n}.`);return HA(e,{config:UA(await r.json()),runtime:t.runtime})}exports.AgentChatWidget=BA,exports.mountAgentChatWidget=HA,exports.mountAgentChatWidgetFromEnvironment=WA;
|
|
455
455
|
//# sourceMappingURL=agent-widget.cjs.map
|