obi-sdk 0.3.7 → 0.3.9
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/dist/modular/chunks/{obi-widget-7060085d.js → obi-widget-d6306b0d.js} +1 -3
- package/dist/modular/chunks/{obi-widget-7060085d.js.map → obi-widget-d6306b0d.js.map} +1 -1
- package/dist/modular/index.js +1 -1
- package/dist/modular/ui.js +10 -10
- package/dist/obi-sdk.es.js +2 -2
- package/dist/obi-sdk.standalone.iife.js +1 -1
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/obi-sdk.umd.js +1 -1
- package/package.json +1 -1
package/dist/modular/index.js
CHANGED
package/dist/modular/ui.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as SDKState } from "./chunks/types-82772f00.js";
|
|
2
|
-
import { i, n, a as i$1, x } from "./chunks/obi-widget-
|
|
3
|
-
import { A, C, c, d, D, N, b, O, S } from "./chunks/obi-widget-
|
|
2
|
+
import { i, n, a as i$1, x } from "./chunks/obi-widget-d6306b0d.js";
|
|
3
|
+
import { A, C, c, d, D, N, b, O, S } from "./chunks/obi-widget-d6306b0d.js";
|
|
4
4
|
var __defProp$1 = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
@@ -227,14 +227,14 @@ const controlPanel = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.define
|
|
|
227
227
|
function defineCustomElements() {
|
|
228
228
|
Promise.resolve().then(() => statusWidget);
|
|
229
229
|
Promise.resolve().then(() => controlPanel);
|
|
230
|
-
import("./chunks/obi-widget-
|
|
231
|
-
import("./chunks/obi-widget-
|
|
232
|
-
import("./chunks/obi-widget-
|
|
233
|
-
import("./chunks/obi-widget-
|
|
234
|
-
import("./chunks/obi-widget-
|
|
235
|
-
import("./chunks/obi-widget-
|
|
236
|
-
import("./chunks/obi-widget-
|
|
237
|
-
import("./chunks/obi-widget-
|
|
230
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.o);
|
|
231
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.j);
|
|
232
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.k);
|
|
233
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.e);
|
|
234
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.f);
|
|
235
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.s);
|
|
236
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.g);
|
|
237
|
+
import("./chunks/obi-widget-d6306b0d.js").then((n2) => n2.h);
|
|
238
238
|
}
|
|
239
239
|
export {
|
|
240
240
|
A as AudioEqualizer,
|
package/dist/obi-sdk.es.js
CHANGED
|
@@ -23240,7 +23240,7 @@ class Ge extends HA {
|
|
|
23240
23240
|
speaker: "ASSISTANT",
|
|
23241
23241
|
volume: 0,
|
|
23242
23242
|
spectrum: []
|
|
23243
|
-
}, this.sessionToken = null, this.roomToken = null, this.roomUrl = null, this.boundSaveSessionData = null, this.closeNavTimeoutRef = null
|
|
23243
|
+
}, this.sessionToken = null, this.roomToken = null, this.roomUrl = null, this.boundSaveSessionData = null, this.closeNavTimeoutRef = null;
|
|
23244
23244
|
const e = () => {
|
|
23245
23245
|
this.activeSession && this.sessionToken && this.roomToken && this.roomUrl && this.saveSessionData();
|
|
23246
23246
|
};
|
|
@@ -23400,7 +23400,7 @@ class Ge extends HA {
|
|
|
23400
23400
|
});
|
|
23401
23401
|
}
|
|
23402
23402
|
render() {
|
|
23403
|
-
if (
|
|
23403
|
+
if (!this.isActive)
|
|
23404
23404
|
return Zr;
|
|
23405
23405
|
const e = ur(this.state).with(H.LOADING, () => se`<obi-dot-loader></obi-dot-loader>`).with(H.RESEARCHING, () => se`<obi-searching-loader></obi-searching-loader>`).with(
|
|
23406
23406
|
Ym.union(H.USER_SPEAKING, H.AGENT_SPEAKING),
|
|
@@ -405,7 +405,7 @@ var A=function(A){"use strict";const e="https://obi.getcor.io/api";function t(A)
|
|
|
405
405
|
font-weight: 500;
|
|
406
406
|
font-size: 14px;
|
|
407
407
|
}
|
|
408
|
-
`,customElements.get("obi-searching-loader")||customElements.define("obi-searching-loader",OB);var MB=Object.defineProperty,NB=Object.getOwnPropertyDescriptor,KB=(A,e,t,n)=>{for(var i,r=n>1?void 0:n?NB(e,t):e,s=A.length-1;s>=0;s--)(i=A[s])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&MB(e,t,r),r};const _B="49206C6F7665204F6269_session";class VB extends _f{constructor(){super(),this.apiKey="",this.isActive=!0,this.position="bottom-right",this.user=null,this.state=Pa.READY,this.storedActiveState=void 0,this.showCourseModal=!1,this.isHovering=!1,this.navVisible=!1,this.activeSession=null,this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.sessionToken=null,this.roomToken=null,this.roomUrl=null,this.boundSaveSessionData=null,this.closeNavTimeoutRef=null
|
|
408
|
+
`,customElements.get("obi-searching-loader")||customElements.define("obi-searching-loader",OB);var MB=Object.defineProperty,NB=Object.getOwnPropertyDescriptor,KB=(A,e,t,n)=>{for(var i,r=n>1?void 0:n?NB(e,t):e,s=A.length-1;s>=0;s--)(i=A[s])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&MB(e,t,r),r};const _B="49206C6F7665204F6269_session";class VB extends _f{constructor(){super(),this.apiKey="",this.isActive=!0,this.position="bottom-right",this.user=null,this.state=Pa.READY,this.storedActiveState=void 0,this.showCourseModal=!1,this.isHovering=!1,this.navVisible=!1,this.activeSession=null,this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.sessionToken=null,this.roomToken=null,this.roomUrl=null,this.boundSaveSessionData=null,this.closeNavTimeoutRef=null;const A=()=>{this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl&&this.saveSessionData()};window.addEventListener("beforeunload",A),window.addEventListener("pagehide",A)}updateFromConfig(){window.obiWidgetConfig&&(this.apiKey=window.obiWidgetConfig.apiKey||this.apiKey,this.position=window.obiWidgetConfig.position||this.position,this.user=window.obiWidgetConfig.user||this.user,void 0!==window.obiWidgetConfig.isActive&&(this.isActive=window.obiWidgetConfig.isActive),this.style.setProperty("--obi-primary",window.obiWidgetConfig?.primaryColor||"#9500ff"),this.style.setProperty("--obi-secondary",window.obiWidgetConfig?.secondaryColor||"#c4b5fd"))}removeSessionFromUrl(){const A=new URL(window.location.href);A.searchParams.delete(_B),window.history.replaceState({},"",A.toString())}async connectObi(A){if(this.activeSession)console.log("Connection already exists");else try{const t=new Ra({sessionId:A,apiBaseUrl:e});if(!t)return console.error("Failed to create session"),this.state=Pa.ERROR,this.activeSession=null,void this.removeSessionFromUrl();t.on("stateChanged",(A=>{this.state=A,A!==Pa.READY&&(this.storedActiveState=A)})),t.on("volume",(({speaker:A,spectrum:e,volume:t})=>{this.volume={speaker:A,spectrum:e,volume:t}})),t.on("screenCaptureRequested",(async()=>{try{const t=(await(A=document.documentElement,e={useCORS:!0,allowTaint:!0,foreignObjectRendering:!0},void 0===e&&(e={}),function(A,e){return Oa(void 0,void 0,void 0,(function(){var t,n,i,r,s,o,a,c,d,l,u,h,g,p,m,f,B,w,v,C,y,b,Q,U,k,E,F,S,T,I,P,H,R,D,x,L,O,M;return Ma(this,(function(N){switch(N.label){case 0:if(!A||"object"!=typeof A)return[2,Promise.reject("Invalid element provided as first argument")];if(!(t=A.ownerDocument))throw new Error("Element is not attached to a Document");if(!(n=t.defaultView))throw new Error("Document is not attached to a Window");return i={allowTaint:null!==(b=e.allowTaint)&&void 0!==b&&b,imageTimeout:null!==(Q=e.imageTimeout)&&void 0!==Q?Q:15e3,proxy:e.proxy,useCORS:null!==(U=e.useCORS)&&void 0!==U&&U,customIsSameOrigin:e.customIsSameOrigin},r=La({logging:null===(k=e.logging)||void 0===k||k,cache:e.cache},i),s={windowWidth:null!==(E=e.windowWidth)&&void 0!==E?E:n.innerWidth,windowHeight:null!==(F=e.windowHeight)&&void 0!==F?F:n.innerHeight,scrollX:null!==(S=e.scrollX)&&void 0!==S?S:n.pageXOffset,scrollY:null!==(T=e.scrollY)&&void 0!==T?T:n.pageYOffset},o=new Ka(s.scrollX,s.scrollY,s.windowWidth,s.windowHeight),a=new Hm(r,o),c=null!==(I=e.foreignObjectRendering)&&void 0!==I&&I,d={allowTaint:null!==(P=e.allowTaint)&&void 0!==P&&P,onclone:e.onclone,ignoreElements:e.ignoreElements,inlineImages:c,copyStyles:c},a.logger.debug("Starting document clone with size ".concat(o.width,"x").concat(o.height," scrolled to ").concat(-o.left,",").concat(-o.top)),l=new wp(a,A,d),(u=l.clonedReferenceElement)?[4,l.toIFrame(t,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return h=N.sent(),g=Wg(u)||"HTML"===u.tagName?function(A){var e=A.body,t=A.documentElement;if(!e||!t)throw new Error("Unable to get document size");var n=Math.max(Math.max(e.scrollWidth,t.scrollWidth),Math.max(e.offsetWidth,t.offsetWidth),Math.max(e.clientWidth,t.clientWidth)),i=Math.max(Math.max(e.scrollHeight,t.scrollHeight),Math.max(e.offsetHeight,t.offsetHeight),Math.max(e.clientHeight,t.clientHeight));return new Ka(0,0,n,i)}(u.ownerDocument):_a(a,u),p=g.width,m=g.height,f=g.left,B=g.top,w=Rm(a,u,e.backgroundColor),v={canvas:e.canvas,backgroundColor:w,scale:null!==(R=null!==(H=e.scale)&&void 0!==H?H:n.devicePixelRatio)&&void 0!==R?R:1,x:(null!==(D=e.x)&&void 0!==D?D:0)+f,y:(null!==(x=e.y)&&void 0!==x?x:0)+B,width:null!==(L=e.width)&&void 0!==L?L:Math.ceil(p),height:null!==(O=e.height)&&void 0!==O?O:Math.ceil(m)},c?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new Tm(a,v).render(u)]):[3,3];case 2:return C=N.sent(),[3,5];case 3:return a.logger.debug("Document cloned, element located at ".concat(f,",").concat(B," with size ").concat(p,"x").concat(m," using computed rendering")),a.logger.debug("Starting DOM parsing"),y=xg(a,u),w===y.styles.backgroundColor&&(y.styles.backgroundColor=xl.TRANSPARENT),a.logger.debug("Starting renderer for element at ".concat(v.x,",").concat(v.y," with size ").concat(v.width,"x").concat(v.height)),[4,new Qm(a,v).render(y)];case 4:C=N.sent(),N.label=5;case 5:return(null===(M=e.removeContainer)||void 0===M||M)&&(wp.destroy(h)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,C]}}))}))}(A,e))).toDataURL("image/png");this.activeSession.emit("screenCaptureComplete",t)}catch(t){console.error("[obi] error capturing screen:",t),this.activeSession.emit("screenCaptureComplete","error")}var A,e})),t.on("error",(A=>{console.error("Session error:",A),this.state=Pa.ERROR,this.activeSession=null,this.removeSessionFromUrl()}));const n=await t.connect();n&&(this.sessionToken=A,this.roomToken=n.token,this.roomUrl=n.url,this.removeSessionFromUrl()),this.activeSession=t}catch(t){console.error("Failed to start session:",t),this.state=Pa.ERROR,this.activeSession=null,this.removeSessionFromUrl()}}async handleSessionStart(A){this.activeSession?console.log("Connection already in progress or active session exists"):(this.showCourseModal=!1,this.state=Pa.LOADING,await this.connectObi(A))}async checkExistingSession(){try{const A=JSON.parse(Yf.getItem(Xf)||"{}"),{sessionToken:t,roomToken:n,roomUrl:i,sessionExpiry:r,obiState:s}=A;if(!t||!n||!i)return;if(r&&new Date(r)<new Date)return void this.clearSessionStorage();this.state=Pa.LOADING;const o=new Ra({sessionId:t,apiBaseUrl:e});if(!o)return console.error("Failed to create session"),this.state=Pa.ERROR,void this.clearSessionStorage();o.on("stateChanged",(A=>{this.state=A,A!==Pa.READY&&(this.storedActiveState=A)})),o.on("volume",(({speaker:A,spectrum:e,volume:t})=>{this.volume={speaker:A,spectrum:e,volume:t}})),o.on("error",(A=>{console.error("Session error:",A),this.state=Pa.ERROR,this.activeSession=null,this.clearSessionStorage()})),await o.reconnect(i,n,s)?(this.activeSession=o,this.sessionToken=t,this.roomToken=n,this.roomUrl=i,this.state=s,this.storedActiveState=s):this.clearSessionStorage()}catch(A){console.error("Error reconnecting to session:",A),this.state=Pa.ERROR,this.clearSessionStorage()}}clearSessionStorage(){Yf.removeItem(Xf)}saveSessionData(){if(this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl){const A=new Date;A.setMinutes(A.getMinutes()+5);const e={sessionToken:this.sessionToken,roomToken:this.roomToken,roomUrl:this.roomUrl,obiState:this.storedActiveState??this.state,sessionExpiry:A.toISOString()};Yf.setItem(Xf,JSON.stringify(e))}}async sessionConnectionCheck(){if(await this.checkExistingSession(),!this.activeSession){const A=new URLSearchParams(window.location.search).get(_B);A&&this.handleSessionStart(A)}}connectedCallback(){super.connectedCallback(),this.updateFromConfig(),this.setAttribute("position",this.position),this.boundSaveSessionData=this.saveSessionData.bind(this),window.addEventListener("beforeunload",this.boundSaveSessionData),window.addEventListener("pagehide",this.boundSaveSessionData),this.sessionConnectionCheck()}disconnectedCallback(){null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),this.boundSaveSessionData&&(window.removeEventListener("beforeunload",this.boundSaveSessionData),window.removeEventListener("pagehide",this.boundSaveSessionData)),this.removeSessionFromUrl(),super.disconnectedCallback()}handleMouseEnter(){this.isHovering=!0,this.navVisible=!0}handleMouseLeave(){this.isHovering=!1,null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),this.closeNavTimeoutRef=window.setTimeout((()=>{this.isHovering||(this.navVisible=!1),this.closeNavTimeoutRef=null}),300)}terminateSession(){this.clearSessionStorage(),this.sessionToken=null,this.roomToken=null,this.roomUrl=null,this.activeSession&&(this.activeSession.disconnect(),this.activeSession=null),this.state=Pa.READY}handleItemSelect(A,e){"experiences"!==A?Sa([A,e]).with(["pause",!0],(()=>{this.activeSession?.pauseRecording()})).with(["pause",!1],(()=>{this.activeSession?.resumeRecording()})).with(["activate",!1],(()=>{this.terminateSession()})).otherwise((()=>{})):this.showCourseModal=!0}render(){if(!this.isActive)return Ef;const A=Sa(this.state).with(Pa.LOADING,(()=>Qf`<obi-dot-loader></obi-dot-loader>`)).with(Pa.RESEARCHING,(()=>Qf`<obi-searching-loader></obi-searching-loader>`)).with(ka.union(Pa.USER_SPEAKING,Pa.AGENT_SPEAKING),(()=>Qf`<obi-audio-equalizer .volume=${this.volume}></obi-audio-equalizer>`)).with(Pa.PAUSED,(()=>sB)).otherwise((()=>sB));return Qf`
|
|
409
409
|
<div
|
|
410
410
|
class="widget-container ${this.state===Pa.USER_SPEAKING||this.state===Pa.AGENT_SPEAKING?"pulse":""} ${this.state!==Pa.READY||this.navVisible?"rounded":""} ${this.state===Pa.RESEARCHING?"researching":""} ${this.state===Pa.USER_SPEAKING?"user-speaking":""}"
|
|
411
411
|
@mouseenter=${this.handleMouseEnter}
|