orb-ui 0.5.0 → 0.6.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 CHANGED
@@ -9,7 +9,7 @@ React voice agent UI components for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI R
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <a href="https://orb-ui.com">Live Demo</a> · <a href="https://orb-ui.com/docs/guides/voice-agent-ui">Voice Agent UI Guide</a> · <a href="https://www.npmjs.com/package/orb-ui">npm</a> · <a href="https://github.com/alexanderqchen/orb-ui">GitHub</a>
12
+ <a href="https://orb-ui.com">Live Demo</a> · <a href="https://orb-ui.com/docs/adapters/overview">Adapter Guide</a> · <a href="https://orb-ui.com/docs/guides/signal-based-voice-agent-ui">Signal Architecture</a> · <a href="https://www.npmjs.com/package/orb-ui">npm</a> · <a href="https://github.com/alexanderqchen/orb-ui">GitHub</a>
13
13
  </p>
14
14
 
15
15
  ```jsx
@@ -225,32 +225,51 @@ function App() {
225
225
  }
226
226
  ```
227
227
 
228
+ ### External session controls
229
+
230
+ Keep the orb as a passive visual when start and stop controls belong elsewhere in your layout.
231
+ Provider adapters already expose the matching lifecycle methods.
232
+
233
+ ```jsx
234
+ function VoiceExperience({ adapter }) {
235
+ return (
236
+ <>
237
+ <Orb adapter={adapter} theme="cloud" interactive={false} />
238
+ <button onClick={() => void adapter.start?.()}>Start conversation</button>
239
+ <button onClick={() => void adapter.stop?.()}>End conversation</button>
240
+ </>
241
+ )
242
+ }
243
+ ```
244
+
228
245
  ## Themes
229
246
 
230
247
  | Theme | Description |
231
248
  | -------- | ----------------------------------------------------------------------------- |
249
+ | `cloud` | Atmospheric sphere with inverse listening scale and faster speaking motion. |
232
250
  | `debug` | State + volume display with start/stop. Use to verify your integration works. |
233
251
  | `circle` | Pulsing circle that reacts to volume. |
234
252
  | `bars` | Five bars that animate with voice. |
235
253
 
236
- When an adapter or `onStart`/`onStop` handler is provided, `circle` and `bars` render as keyboard-accessible `<button type="button">` controls. Pass an `aria-label` when the surrounding UI does not already label the control.
254
+ When an adapter or `onStart`/`onStop` handler is provided, visual themes render as keyboard-accessible `<button type="button">` controls. Pass `interactive={false}` to keep the theme passive and call `adapter.start()` or `adapter.stop()` from external controls instead.
237
255
 
238
256
  ## Props
239
257
 
240
- | Prop | Type | Default | Description |
241
- | ------------ | ------------------------------- | --------- | ----------------------------------------------------------- |
242
- | `theme` | `'debug' \| 'circle' \| 'bars'` | `'debug'` | Visual theme |
243
- | `signal` | `OrbSignal` | — | Rich controlled signal with state/input/output volume |
244
- | `state` | `OrbState` | `'idle'` | Conversation state (controlled mode) |
245
- | `volume` | `number` | `0` | Audio volume, 0–1. Overrides signal/adapter volume. |
246
- | `adapter` | `OrbAdapter` | — | Provider adapter (manages signal updates automatically) |
247
- | `size` | `number` | `200` | Size in pixels |
248
- | `className` | `string` | — | Optional class name for the rendered theme |
249
- | `style` | `React.CSSProperties` | — | Optional inline styles for the rendered theme |
250
- | `disabled` | `boolean` | `false` | Disables clickable themes and debug start/stop controls |
251
- | `aria-label` | `string` | generated | Accessible label for clickable `circle` and `bars` controls |
252
- | `onStart` | `() => void` | — | Custom start handler (overrides adapter.start()) |
253
- | `onStop` | `() => void` | — | Custom stop handler (overrides adapter.stop()) |
258
+ | Prop | Type | Default | Description |
259
+ | ------------- | ------------------------------------------ | --------- | ------------------------------------------------------- |
260
+ | `theme` | `'debug' \| 'circle' \| 'bars' \| 'cloud'` | `'debug'` | Visual theme |
261
+ | `signal` | `OrbSignal` | — | Rich controlled signal with state/input/output volume |
262
+ | `state` | `OrbState` | `'idle'` | Conversation state (controlled mode) |
263
+ | `volume` | `number` | `0` | Audio volume, 0–1. Overrides signal/adapter volume. |
264
+ | `adapter` | `OrbAdapter` | — | Provider adapter (manages signal updates automatically) |
265
+ | `size` | `number` | `200` | Size in pixels |
266
+ | `className` | `string` | — | Optional class name for the rendered theme |
267
+ | `style` | `React.CSSProperties` | — | Optional inline styles for the rendered theme |
268
+ | `disabled` | `boolean` | `false` | Disables clickable themes and debug start/stop controls |
269
+ | `interactive` | `boolean` | `true` | Allows the orb itself to start and stop a session |
270
+ | `aria-label` | `string` | generated | Accessible label for clickable visual themes |
271
+ | `onStart` | `() => void` | — | Custom start handler (overrides adapter.start()) |
272
+ | `onStop` | `() => void` | — | Custom stop handler (overrides adapter.stop()) |
254
273
 
255
274
  ## States
256
275
 
@@ -1,2 +1,2 @@
1
1
  import { OrbProps } from './Orb.types.js';
2
- export declare function Orb({ signal: signalProp, state: stateProp, volume: volumeProp, adapter, theme, size, className, style, disabled, onStart, onStop, ...htmlProps }: OrbProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function Orb({ signal: signalProp, state: stateProp, volume: volumeProp, adapter, theme, size, className, style, disabled, interactive: interactiveProp, onStart, onStop, ...htmlProps }: OrbProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { AriaAttributes, CSSProperties } from 'react';
2
2
  export type OrbState = 'idle' | 'connecting' | 'listening' | 'thinking' | 'speaking' | 'error';
3
- export type OrbTheme = 'debug' | 'circle' | 'bars';
3
+ export type OrbTheme = 'debug' | 'circle' | 'bars' | 'cloud';
4
4
  export interface OrbSignal {
5
5
  state: OrbState;
6
6
  volume?: number;
@@ -64,6 +64,11 @@ export interface OrbProps extends OrbHtmlAttributes {
64
64
  style?: CSSProperties;
65
65
  /** Disable clickable themes and debug start/stop controls. */
66
66
  disabled?: boolean;
67
+ /**
68
+ * Allow the orb itself to start and stop an adapter-backed session.
69
+ * Set this to false when session controls live elsewhere in your UI.
70
+ */
71
+ interactive?: boolean;
67
72
  /**
68
73
  * Called when a clickable theme is activated while idle/error.
69
74
  * Overrides adapter.start() when provided.
package/dist/orb-ui.cjs CHANGED
@@ -8,4 +8,104 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
8
8
  50% { opacity: 0.6; transform: scale(0.95); }
9
9
  100% { opacity: 1; transform: scale(1); }
10
10
  }
11
- `,d=.95,f=.08,p=.82,m=.18,h=24,g=0,_=.55,v=.12,y=.002;function b({state:n,volume:r,size:i,className:a,style:o,disabled:b=!1,interactive:x=!1,onClick:S,...C}){let w=(0,e.useRef)(null),T=(0,e.useRef)(null),E=(0,e.useRef)(null),D=(0,e.useRef)(0),O=(0,e.useRef)(r);s(()=>{O.current=r},[r]);let k=(0,e.useRef)(1),A=(0,e.useRef)(0),j=(0,e.useRef)(c(l.idle)),M=.06,N=(0,e.useRef)(p),P=(0,e.useRef)(m);(0,e.useEffect)(()=>{let e=`orb-circle-keyframes`;if(!document.getElementById(e)){let t=document.createElement(`style`);t.id=e,t.textContent=u,document.head.appendChild(t)}},[]),(0,e.useEffect)(()=>{let e=w.current;if(e)if(n===`listening`||n===`speaking`){let t=n===`speaking`?d:p,r=n===`speaking`?f:m,i=n===`speaking`?h:g,a=()=>{let o=O.current;N.current+=(t-N.current)*M,P.current+=(r-P.current)*M;let s=N.current+o*P.current,u=o*i;n===`listening`?(k.current+=(s-k.current)*_,A.current+=(u-A.current)*_):(k.current=s,A.current=u);let d=c(l[n]),[f,p,m]=j.current;j.current=[f+(d[0]-f)*.05,p+(d[1]-p)*.05,m+(d[2]-m)*.05];let[h,g,v]=j.current.map(Math.round);e.style.transform=`scale(${k.current})`,e.style.background=`rgb(${h},${g},${v})`,e.style.boxShadow=`none`,e.style.animation=`none`;let y=T.current;if(y){let e=A.current;y.style.transform=`scale(${k.current})`,y.style.boxShadow=e>.5?`0 0 ${e}px ${e*.4}px rgb(${h},${g},${v})`:`none`}D.current=requestAnimationFrame(a)};return D.current=requestAnimationFrame(a),()=>{cancelAnimationFrame(D.current)}}else{cancelAnimationFrame(D.current);let t=l[n]??l.idle,r=c(t),i=()=>{k.current+=(1-k.current)*v,A.current+=(0-A.current)*v;let[a,o,s]=j.current;j.current=[a+(r[0]-a)*v,o+(r[1]-o)*v,s+(r[2]-s)*v];let[c,l,u]=j.current.map(Math.round);e.style.transform=`scale(${k.current})`,e.style.background=`rgb(${c},${l},${u})`,e.style.boxShadow=`none`,e.style.animation=`none`,T.current&&(T.current.style.transform=`scale(${k.current})`,T.current.style.boxShadow=`none`);let d=Math.abs(k.current-1)<y,f=A.current<.1,p=j.current.every((e,t)=>Math.abs(e-r[t])<1);if(d&&f&&p){k.current=1,A.current=0,j.current=r,e.style.transform=``,e.style.boxShadow=`none`,e.style.background=t,T.current&&(T.current.style.transform=`scale(1)`,T.current.style.boxShadow=`none`),n===`idle`?e.style.animation=`orb-circle-idle-pulse 3s ease-in-out infinite alternate`:n===`connecting`||n===`thinking`?e.style.animation=`orb-circle-connecting-pulse 1.5s ease-in-out infinite`:e.style.animation=`none`;return}D.current=requestAnimationFrame(i)};return D.current=requestAnimationFrame(i),()=>cancelAnimationFrame(D.current)}},[n]);let F=i*.55,I={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...o},L=(0,t.jsxs)(`span`,{ref:E,onMouseEnter:()=>{E.current&&!b&&(E.current.style.transform=`scale(1.06)`,E.current.style.filter=`brightness(1.12)`)},onMouseLeave:()=>{E.current&&(E.current.style.transform=`scale(1)`,E.current.style.filter=`brightness(1)`)},onTouchEnd:()=>{setTimeout(()=>{E.current&&(E.current.style.transform=`scale(1)`,E.current.style.filter=`brightness(1)`)},200)},style:{position:`relative`,display:`inline-block`,transition:`transform 0.3s ease, filter 0.3s ease`,cursor:x?b?`not-allowed`:`pointer`:`default`,borderRadius:`50%`,lineHeight:0},children:[(0,t.jsx)(`span`,{ref:T,style:{position:`absolute`,display:`block`,width:F,height:F,borderRadius:`50%`,pointerEvents:`none`}}),(0,t.jsx)(`span`,{ref:w,style:{position:`relative`,display:`block`,width:F,height:F,borderRadius:`50%`,background:l[n]}})]});return x?(0,t.jsx)(`button`,{...C,type:`button`,className:a,disabled:b,onClick:b?void 0:S,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:b?`not-allowed`:`pointer`,...I},children:L}):(0,t.jsx)(`div`,{...C,className:a,style:I,children:L})}var x=5,S=1.4,C=Math.PI*2/x,w={idle:`#cccccc`,connecting:`#cccccc`,listening:`#999999`,thinking:`#d8d8d8`,speaking:`#e8e8e8`,error:`#f87171`};function T(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function E({state:n,volume:r,size:i,className:a,style:o,disabled:s=!1,interactive:c=!1,onClick:l,...u}){let d=(0,e.useRef)([]),f=(0,e.useRef)(null),p=(0,e.useRef)(0),m=(0,e.useRef)(Array(x).fill(0)),h=(0,e.useRef)(r),g=(0,e.useRef)(!1),_=(0,e.useRef)(0),v=(0,e.useRef)(T(w.idle)),y=(0,e.useRef)(null),b=(0,e.useRef)(Array(x).fill(0)),E=(0,e.useRef)(n);(0,e.useEffect)(()=>{n!==E.current&&(b.current=[...m.current],y.current=Date.now(),E.current=n)},[n]),(0,e.useEffect)(()=>{h.current=r},[r]),(0,e.useEffect)(()=>{let e=i*.55,t=i*.06,r=w[n]??w.idle,a=i*.1,o=Array.from({length:x},(e,t)=>{let n=(x-1)/2;return 1-.7*(Math.abs(t-n)/n)}),s=()=>{let e=g.current?a:0;_.current+=(e-_.current)*.15},c=(t,r)=>{s();let i=T(r),[a,c,l]=v.current;v.current=[a+(i[0]-a)*.08,c+(i[1]-c)*.08,l+(i[2]-l)*.08];let[u,f,p]=v.current.map(Math.round),m=`rgb(${u},${f},${p})`;for(let r=0;r<x;r++){let i=d.current[r];if(!i)continue;let a=n===`idle`?o[r]:1,s=_.current*a;i.style.height=`${Math.min(t[r]+s,e)}px`,i.style.background=m,i.style.animation=`none`}};if(n===`listening`||n===`speaking`){let i=n===`speaking`?1:.4,a=()=>{let o=h.current,s=Date.now()/1e3;for(let r=0;r<x;r++){let a=.5+.15*Math.sin(s*S*i*Math.PI*2+r*C),c=t+(e-t)*o*a;if(y.current!==null){let e=Date.now()-y.current,t=Math.min(e/300,1),n=1-(1-t)*(1-t);c=b.current[r]+(c-b.current[r])*n,t>=1&&(y.current=null)}let l=n===`listening`?.45:1;m.current[r]+=(c-m.current[r])*l}c(m.current,r),p.current=requestAnimationFrame(a)};return p.current=requestAnimationFrame(a),()=>cancelAnimationFrame(p.current)}if(n===`connecting`||n===`thinking`){let n=Date.now(),i=()=>{let a=(Date.now()-n)/1e3;s();for(let n=0;n<x;n++){let r=(a*.6+n/x*.5)%1,i=r<.5?Math.sin(r/.5*Math.PI):0,o=t+(e*.4-t)*i;m.current[n]+=(o-m.current[n])*.15}c(m.current,r),p.current=requestAnimationFrame(i)};return p.current=requestAnimationFrame(i),()=>cancelAnimationFrame(p.current)}cancelAnimationFrame(p.current);let l=()=>{s();for(let e=0;e<x;e++)m.current[e]+=(t-m.current[e])*.16;c(m.current,r),p.current=requestAnimationFrame(l)};return p.current=requestAnimationFrame(l),()=>cancelAnimationFrame(p.current)},[n,i]);let D=i*.055,O=i*.035,k=i*.03,A=i*.55,j=i*.06,M={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...o},N=(0,t.jsx)(`span`,{ref:f,onMouseEnter:()=>{s||(g.current=!0,f.current&&(f.current.style.filter=`brightness(1.35)`))},onMouseLeave:()=>{g.current=!1,f.current&&(f.current.style.filter=`brightness(1)`)},onTouchEnd:()=>{setTimeout(()=>{g.current=!1,f.current&&(f.current.style.filter=`brightness(1)`)},200)},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:O,transition:`filter 0.3s ease`,cursor:c?s?`not-allowed`:`pointer`:`default`},children:Array.from({length:x},(e,r)=>(0,t.jsx)(`span`,{ref:e=>{d.current[r]=e},style:{width:D,minHeight:j,maxHeight:A,height:j,borderRadius:k,background:w[n]??w.idle}},r))});return c?(0,t.jsx)(`button`,{...u,type:`button`,className:a,disabled:s,onClick:s?void 0:l,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:s?`not-allowed`:`pointer`,...M},children:N}):(0,t.jsx)(`div`,{...u,className:a,style:M,children:N})}function D({signal:i,state:a,volume:s,adapter:c,theme:l=`debug`,size:u=200,className:d,style:f,disabled:p=!1,onStart:m,onStop:h,...g}){let[_,v]=(0,e.useState)({state:`idle`});(0,e.useEffect)(()=>{if(v({state:`idle`}),c)return c.subscribe(v)},[c]);let y=i??_,x=n(a,i,_),S=r(s,x,y),C=x!==`idle`&&x!==`error`,w=(0,e.useCallback)(()=>{p||(C?h?h():c?.stop?.():m?m():c?.start?.())},[c,p,C,m,h]),T=C?!!(c?.stop||h):!!(c?.start||m),D=T&&!p?w:void 0,O={state:x,volume:S,size:u,className:d,style:f,disabled:p,...g,"aria-label":g[`aria-label`]??(T?`${C?`Stop`:`Start`} voice session`:void 0)},k={...O,interactive:T};switch(l){case`circle`:return(0,t.jsx)(b,{...k,onClick:D});case`bars`:return(0,t.jsx)(E,{...k,onClick:D});default:return(0,t.jsx)(o,{...O,onStart:p?void 0:m??(()=>c?.start?.()),onStop:p?void 0:h??(()=>c?.stop?.())})}}exports.Orb=D,exports.VoiceOrb=D;
11
+ `,d=.95,f=.08,p=.82,m=.18,h=24,g=0,_=.55,v=.12,y=.002;function b({state:n,volume:r,size:i,className:a,style:o,disabled:b=!1,interactive:x=!1,onClick:S,...C}){let w=(0,e.useRef)(null),T=(0,e.useRef)(null),E=(0,e.useRef)(null),D=(0,e.useRef)(0),O=(0,e.useRef)(r);s(()=>{O.current=r},[r]);let k=(0,e.useRef)(1),A=(0,e.useRef)(0),j=(0,e.useRef)(c(l.idle)),M=.06,N=(0,e.useRef)(p),P=(0,e.useRef)(m);(0,e.useEffect)(()=>{let e=`orb-circle-keyframes`;if(!document.getElementById(e)){let t=document.createElement(`style`);t.id=e,t.textContent=u,document.head.appendChild(t)}},[]),(0,e.useEffect)(()=>{let e=w.current;if(e)if(n===`listening`||n===`speaking`){let t=n===`speaking`?d:p,r=n===`speaking`?f:m,i=n===`speaking`?h:g,a=()=>{let o=O.current;N.current+=(t-N.current)*M,P.current+=(r-P.current)*M;let s=N.current+o*P.current,u=o*i;n===`listening`?(k.current+=(s-k.current)*_,A.current+=(u-A.current)*_):(k.current=s,A.current=u);let d=c(l[n]),[f,p,m]=j.current;j.current=[f+(d[0]-f)*.05,p+(d[1]-p)*.05,m+(d[2]-m)*.05];let[h,g,v]=j.current.map(Math.round);e.style.transform=`scale(${k.current})`,e.style.background=`rgb(${h},${g},${v})`,e.style.boxShadow=`none`,e.style.animation=`none`;let y=T.current;if(y){let e=A.current;y.style.transform=`scale(${k.current})`,y.style.boxShadow=e>.5?`0 0 ${e}px ${e*.4}px rgb(${h},${g},${v})`:`none`}D.current=requestAnimationFrame(a)};return D.current=requestAnimationFrame(a),()=>{cancelAnimationFrame(D.current)}}else{cancelAnimationFrame(D.current);let t=l[n]??l.idle,r=c(t),i=()=>{k.current+=(1-k.current)*v,A.current+=(0-A.current)*v;let[a,o,s]=j.current;j.current=[a+(r[0]-a)*v,o+(r[1]-o)*v,s+(r[2]-s)*v];let[c,l,u]=j.current.map(Math.round);e.style.transform=`scale(${k.current})`,e.style.background=`rgb(${c},${l},${u})`,e.style.boxShadow=`none`,e.style.animation=`none`,T.current&&(T.current.style.transform=`scale(${k.current})`,T.current.style.boxShadow=`none`);let d=Math.abs(k.current-1)<y,f=A.current<.1,p=j.current.every((e,t)=>Math.abs(e-r[t])<1);if(d&&f&&p){k.current=1,A.current=0,j.current=r,e.style.transform=``,e.style.boxShadow=`none`,e.style.background=t,T.current&&(T.current.style.transform=`scale(1)`,T.current.style.boxShadow=`none`),n===`idle`?e.style.animation=`orb-circle-idle-pulse 3s ease-in-out infinite alternate`:n===`connecting`||n===`thinking`?e.style.animation=`orb-circle-connecting-pulse 1.5s ease-in-out infinite`:e.style.animation=`none`;return}D.current=requestAnimationFrame(i)};return D.current=requestAnimationFrame(i),()=>cancelAnimationFrame(D.current)}},[n]);let F=i*.55,I={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...o},L=(0,t.jsxs)(`span`,{ref:E,onMouseEnter:()=>{E.current&&x&&!b&&(E.current.style.transform=`scale(1.06)`,E.current.style.filter=`brightness(1.12)`)},onMouseLeave:()=>{E.current&&(E.current.style.transform=`scale(1)`,E.current.style.filter=`brightness(1)`)},onTouchEnd:()=>{setTimeout(()=>{E.current&&(E.current.style.transform=`scale(1)`,E.current.style.filter=`brightness(1)`)},200)},style:{position:`relative`,display:`inline-block`,transition:`transform 0.3s ease, filter 0.3s ease`,cursor:x?b?`not-allowed`:`pointer`:`default`,borderRadius:`50%`,lineHeight:0},children:[(0,t.jsx)(`span`,{ref:T,style:{position:`absolute`,display:`block`,width:F,height:F,borderRadius:`50%`,pointerEvents:`none`}}),(0,t.jsx)(`span`,{ref:w,style:{position:`relative`,display:`block`,width:F,height:F,borderRadius:`50%`,background:l[n]}})]});return x?(0,t.jsx)(`button`,{...C,type:`button`,className:a,disabled:b,onClick:b?void 0:S,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:b?`not-allowed`:`pointer`,...I},children:L}):(0,t.jsx)(`div`,{...C,className:a,style:I,children:L})}var x=5,S=1.4,C=Math.PI*2/x,w={idle:`#cccccc`,connecting:`#cccccc`,listening:`#999999`,thinking:`#d8d8d8`,speaking:`#e8e8e8`,error:`#f87171`};function T(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function E({state:n,volume:r,size:i,className:a,style:o,disabled:s=!1,interactive:c=!1,onClick:l,...u}){let d=(0,e.useRef)([]),f=(0,e.useRef)(null),p=(0,e.useRef)(0),m=(0,e.useRef)(Array(x).fill(0)),h=(0,e.useRef)(r),g=(0,e.useRef)(!1),_=(0,e.useRef)(0),v=(0,e.useRef)(T(w.idle)),y=(0,e.useRef)(null),b=(0,e.useRef)(Array(x).fill(0)),E=(0,e.useRef)(n);(0,e.useEffect)(()=>{n!==E.current&&(b.current=[...m.current],y.current=Date.now(),E.current=n)},[n]),(0,e.useEffect)(()=>{h.current=r},[r]),(0,e.useEffect)(()=>{let e=i*.55,t=i*.06,r=w[n]??w.idle,a=i*.1,o=Array.from({length:x},(e,t)=>{let n=(x-1)/2;return 1-.7*(Math.abs(t-n)/n)}),l=()=>{let e=c&&!s,t=g.current&&e?a:0;_.current+=(t-_.current)*.15},u=(t,r)=>{l();let i=T(r),[a,s,c]=v.current;v.current=[a+(i[0]-a)*.08,s+(i[1]-s)*.08,c+(i[2]-c)*.08];let[u,f,p]=v.current.map(Math.round),m=`rgb(${u},${f},${p})`;for(let r=0;r<x;r++){let i=d.current[r];if(!i)continue;let a=n===`idle`?o[r]:1,s=_.current*a;i.style.height=`${Math.min(t[r]+s,e)}px`,i.style.background=m,i.style.animation=`none`}};if(n===`listening`||n===`speaking`){let i=n===`speaking`?1:.4,a=()=>{let o=h.current,s=Date.now()/1e3;for(let r=0;r<x;r++){let a=.5+.15*Math.sin(s*S*i*Math.PI*2+r*C),c=t+(e-t)*o*a;if(y.current!==null){let e=Date.now()-y.current,t=Math.min(e/300,1),n=1-(1-t)*(1-t);c=b.current[r]+(c-b.current[r])*n,t>=1&&(y.current=null)}let l=n===`listening`?.45:1;m.current[r]+=(c-m.current[r])*l}u(m.current,r),p.current=requestAnimationFrame(a)};return p.current=requestAnimationFrame(a),()=>cancelAnimationFrame(p.current)}if(n===`connecting`||n===`thinking`){let n=Date.now(),i=()=>{let a=(Date.now()-n)/1e3;l();for(let n=0;n<x;n++){let r=(a*.6+n/x*.5)%1,i=r<.5?Math.sin(r/.5*Math.PI):0,o=t+(e*.4-t)*i;m.current[n]+=(o-m.current[n])*.15}u(m.current,r),p.current=requestAnimationFrame(i)};return p.current=requestAnimationFrame(i),()=>cancelAnimationFrame(p.current)}cancelAnimationFrame(p.current);let f=()=>{l();for(let e=0;e<x;e++)m.current[e]+=(t-m.current[e])*.16;u(m.current,r),p.current=requestAnimationFrame(f)};return p.current=requestAnimationFrame(f),()=>cancelAnimationFrame(p.current)},[n,i]);let D=i*.055,O=i*.035,k=i*.03,A=i*.55,j=i*.06,M={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...o},N=(0,t.jsx)(`span`,{ref:f,onMouseEnter:()=>{!c||s||(g.current=!0,f.current&&(f.current.style.filter=`brightness(1.35)`))},onMouseLeave:()=>{g.current=!1,f.current&&(f.current.style.filter=`brightness(1)`)},onTouchEnd:()=>{setTimeout(()=>{g.current=!1,f.current&&(f.current.style.filter=`brightness(1)`)},200)},style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:O,transition:`filter 0.3s ease`,cursor:c?s?`not-allowed`:`pointer`:`default`},children:Array.from({length:x},(e,r)=>(0,t.jsx)(`span`,{ref:e=>{d.current[r]=e},style:{width:D,minHeight:j,maxHeight:A,height:j,borderRadius:k,background:w[n]??w.idle}},r))});return c?(0,t.jsx)(`button`,{...u,type:`button`,className:a,disabled:s,onClick:s?void 0:l,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:s?`not-allowed`:`pointer`,...M},children:N}):(0,t.jsx)(`div`,{...u,className:a,style:M,children:N})}var D=typeof window<`u`?e.useLayoutEffect:e.useEffect,O=`
12
+ attribute vec2 a_position;
13
+
14
+ void main() {
15
+ gl_Position = vec4(a_position, 0.0, 1.0);
16
+ }
17
+ `,k=`
18
+ precision highp float;
19
+
20
+ uniform vec2 u_resolution;
21
+ uniform float u_time;
22
+ uniform float u_activity;
23
+
24
+ float hash(vec2 p) {
25
+ p = fract(p * vec2(123.34, 456.21));
26
+ p += dot(p, p + 45.32);
27
+ return fract(p.x * p.y);
28
+ }
29
+
30
+ float noise(vec2 p) {
31
+ vec2 i = floor(p);
32
+ vec2 f = fract(p);
33
+ vec2 u = f * f * (3.0 - 2.0 * f);
34
+
35
+ return mix(
36
+ mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),
37
+ mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),
38
+ u.y
39
+ );
40
+ }
41
+
42
+ float fbm(vec2 p) {
43
+ float value = 0.0;
44
+ float amplitude = 0.52;
45
+ mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);
46
+
47
+ for (int octave = 0; octave < 5; octave++) {
48
+ value += amplitude * noise(p);
49
+ p = rotation * p * 1.92 + vec2(9.7, 4.3);
50
+ amplitude *= 0.5;
51
+ }
52
+
53
+ return value;
54
+ }
55
+
56
+ void main() {
57
+ vec2 uv = gl_FragCoord.xy / u_resolution;
58
+ vec2 centered = uv - 0.5;
59
+ float radius = length(centered);
60
+ float edge = 1.0 - smoothstep(0.488, 0.5, radius);
61
+
62
+ if (edge <= 0.0) discard;
63
+
64
+ vec2 p = centered * 2.0;
65
+ float t = u_time;
66
+
67
+ vec2 warp = vec2(
68
+ fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),
69
+ fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))
70
+ );
71
+ vec2 curl = vec2(
72
+ sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),
73
+ cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)
74
+ );
75
+ vec2 warped =
76
+ p +
77
+ (warp - 0.5) * (1.18 + u_activity * 0.38) +
78
+ curl * (0.035 + u_activity * 0.07);
79
+ float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));
80
+ float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);
81
+ float field = mix(broad, folded, 0.3 + u_activity * 0.14);
82
+
83
+ float horizon =
84
+ 0.46 +
85
+ 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +
86
+ 0.16 * (broad - 0.5);
87
+ float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);
88
+ float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));
89
+ float cloud = smoothstep(0.24, 0.79, field);
90
+
91
+ vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);
92
+ vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);
93
+ vec3 lowerLavender = vec3(0.72, 0.78, 0.975);
94
+ vec3 milk = vec3(0.89, 0.92, 0.995);
95
+
96
+ vec3 color = mix(lowerLavender, upperPeriwinkle, upper);
97
+ float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);
98
+ color = mix(color, deepPeriwinkle, upperDepth);
99
+
100
+ float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);
101
+ color = mix(color, milk, milkAmount);
102
+
103
+ float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;
104
+ color = mix(color, milk, lowerMist);
105
+
106
+ float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;
107
+ color += grain;
108
+
109
+ gl_FragColor = vec4(color, edge);
110
+ }
111
+ `,A=.55,j=.204,M=.2145,N=.063,P=`#5659dc`,F=1.178,I=180,L=300,R=1350,z=246,B=420,V=354,H=480;function U(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function W(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function G(e){return 1-(1-e)**3}function K(e,t,n){return e+(t-e)*n}function q(e,t,n){let r=U((e-t)/(n-t));return r*r*(3-2*r)}function J(e){return e===`listening`||e===`speaking`||e===`thinking`}function Y(e,t,n){let r=e.createShader(t);if(r){if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){e.deleteShader(r);return}return r}}function X(e,t){let n=e.getContext(`webgl`,{alpha:!0,antialias:!0,premultipliedAlpha:!0});if(!n)return;let r=Y(n,n.VERTEX_SHADER,O),i=Y(n,n.FRAGMENT_SHADER,k);if(!r||!i){r&&n.deleteShader(r),i&&n.deleteShader(i);return}let a=n.createProgram(),o=n.createBuffer();if(!a||!o){a&&n.deleteProgram(a),o&&n.deleteBuffer(o),n.deleteShader(r),n.deleteShader(i);return}if(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS)){n.deleteProgram(a),n.deleteBuffer(o),n.deleteShader(r),n.deleteShader(i);return}let s=n.getAttribLocation(a,`a_position`),c=n.getUniformLocation(a,`u_resolution`),l=n.getUniformLocation(a,`u_time`),u=n.getUniformLocation(a,`u_activity`);if(s<0||!c||!l||!u){n.deleteProgram(a),n.deleteBuffer(o),n.deleteShader(r),n.deleteShader(i);return}let d=Math.min(window.devicePixelRatio||1,2),f=Math.max(1,Math.round(t*d));return e.width=f,e.height=f,n.viewport(0,0,f,f),n.useProgram(a),n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),n.STATIC_DRAW),n.enableVertexAttribArray(s),n.vertexAttribPointer(s,2,n.FLOAT,!1,0,0),n.uniform2f(c,f,f),{draw(e,t){n.uniform1f(l,e),n.uniform1f(u,t),n.drawArrays(n.TRIANGLES,0,6)},destroy(){n.deleteProgram(a),n.deleteBuffer(o),n.deleteShader(r),n.deleteShader(i)}}}function Z(e){if(e<=I)return N;if(e<=480)return K(N,F,G((e-I)/L));let t=e-I-L;if(t>=R)return 1;let n=U(t/R);return 1+(F-1)*(1-n)**2}function Q({state:n,volume:r,size:i,className:a,style:o,disabled:s=!1,interactive:c=!1,onClick:l,...u}){let d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=(0,e.useRef)(null),m=(0,e.useRef)(n),h=(0,e.useRef)(r),g=(0,e.useRef)(c),_=(0,e.useRef)(!1);D(()=>{m.current=n,h.current=r,g.current=c},[c,n,r]);let v=i*A;(0,e.useEffect)(()=>{let e=d.current,t=f.current,n=p.current;if(!e||!t||!n)return;let r=window.matchMedia(`(prefers-reduced-motion: reduce)`),i=()=>{_.current=r.matches};i(),r.addEventListener(`change`,i);let a=X(e,v);a||(e.style.background=`linear-gradient(180deg, #626afb 2%, #8f9dfb 32%, #dde6fd 52%, #c9d3fb 84%)`);let o=0,s=performance.now(),c=m.current,l=J(c)?s:void 0,u=U(h.current),y=1,b=+!!J(c),x=1,S=+(c===`connecting`),C=0,w=r=>{let i=Math.min((r-s)/1e3,.05);s=r;let d=m.current,f=_.current;d!==c&&(J(d)&&!J(c)&&(l=r),(d===`idle`||d===`error`)&&(l=void 0),c=d);let p=U(h.current);u=f?0:W(u,p,p>u?11:6,i);let v=1;d===`listening`&&(v=1-u*j),d===`speaking`&&(v=1+u*M);let T=Math.abs(v-1)>Math.abs(y-1)?12:6;y=f?1:W(y,v,T,i);let E=J(d),D=d===`idle`&&g.current,O=E||D?1:0;b=f?O:W(b,O,14,i);let k=E||D?1:.92;x=f?k:W(x,k,12,i);let A=y*x;D&&(A=N);let P=+!D,F=D?b:0;if(E&&l!==void 0&&!f){let e=r-l,t=Z(e),n=U((e-I-L)/R);A=t*K(1,y,n),P=q(e,z,B),F=b*(1-q(e,V,H)),e>=1830&&(l=void 0)}let G=+(d===`connecting`);S=f?G:W(S,G,18,i),e.style.opacity=String(b*P),e.style.transform=`scale(${A})`,t.style.opacity=String(F),t.style.transform=`scale(${A})`,n.style.opacity=String(S),n.style.transform=`rotate(${f?45:r*.34}deg)`;let Y=.24,X=.1;d===`listening`?(Y=.72+u*.78,X=.28+u*.32):d===`speaking`&&(Y=1.65+u*1.55,X=.66+u*.34),f||(C+=i*Y),a?.draw(C,X),o=requestAnimationFrame(w)};return o=requestAnimationFrame(w),()=>{cancelAnimationFrame(o),r.removeEventListener(`change`,i),a?.destroy()}},[v]);let y={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...o},b=(0,t.jsxs)(`span`,{style:{position:`relative`,display:`block`,width:v,height:v,borderRadius:`50%`,lineHeight:0,cursor:c?s?`not-allowed`:`pointer`:`default`},children:[(0,t.jsx)(`span`,{ref:f,"data-cloud-launch-dot":``,"aria-hidden":`true`,style:{position:`absolute`,inset:0,display:`block`,borderRadius:`50%`,background:P,opacity:0,transform:`scale(${N})`,transformOrigin:`center`,willChange:`opacity, transform`}}),(0,t.jsx)(`canvas`,{ref:d,"aria-hidden":`true`,style:{position:`absolute`,inset:0,display:`block`,width:v,height:v,borderRadius:`50%`,opacity:0,transform:`scale(${N})`,transformOrigin:`center`,willChange:`opacity, transform`}}),(0,t.jsx)(`span`,{ref:p,"aria-hidden":`true`,style:{position:`absolute`,left:`50%`,top:`50%`,width:v*.105,height:v*.105,boxSizing:`border-box`,border:`${Math.max(1.5,v*.012)}px solid rgba(113, 120, 245, 0.24)`,borderTopColor:`#777ff6`,borderRightColor:`#777ff6`,borderRadius:`50%`,opacity:0,transform:`rotate(0deg)`,transformOrigin:`center`,marginLeft:v*-.0525,marginTop:v*-.0525,willChange:`opacity, transform`}})]});return c?(0,t.jsx)(`button`,{...u,type:`button`,className:a,disabled:s,onClick:s?void 0:l,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:s?`not-allowed`:`pointer`,...y},children:b}):(0,t.jsx)(`div`,{...u,className:a,style:y,children:b})}function $({signal:i,state:a,volume:s,adapter:c,theme:l=`debug`,size:u=200,className:d,style:f,disabled:p=!1,interactive:m=!0,onStart:h,onStop:g,..._}){let[v,y]=(0,e.useState)({state:`idle`});(0,e.useEffect)(()=>{if(y({state:`idle`}),c)return c.subscribe(y)},[c]);let x=i??v,S=n(a,i,v),C=r(s,S,x),w=S!==`idle`&&S!==`error`,T=(0,e.useCallback)(()=>{p||(w?g?g():c?.stop?.():h?h():c?.start?.())},[c,p,w,h,g]),D=w?!!(c?.stop||g):!!(c?.start||h),O=m&&D,k=O&&!p?T:void 0,A={state:S,volume:C,size:u,className:d,style:f,disabled:p,..._,"aria-label":_[`aria-label`]??(O?`${w?`Stop`:`Start`} voice session`:void 0)},j={...A,interactive:O};switch(l){case`circle`:return(0,t.jsx)(b,{...j,onClick:k});case`bars`:return(0,t.jsx)(E,{...j,onClick:k});case`cloud`:return(0,t.jsx)(Q,{...j,onClick:k});default:return(0,t.jsx)(o,{...A,disabled:p||!m,onStart:p||!m?void 0:h??(()=>c?.start?.()),onStop:p||!m?void 0:g??(()=>c?.stop?.())})}}exports.Orb=$,exports.VoiceOrb=$;
package/dist/orb-ui.js CHANGED
@@ -253,7 +253,7 @@ function T({ state: e, volume: n, size: i, className: s, style: c, disabled: l =
253
253
  }, z = /* @__PURE__ */ o("span", {
254
254
  ref: O,
255
255
  onMouseEnter: () => {
256
- O.current && !l && (O.current.style.transform = "scale(1.06)", O.current.style.filter = "brightness(1.12)");
256
+ O.current && u && !l && (O.current.style.transform = "scale(1.06)", O.current.style.filter = "brightness(1.12)");
257
257
  },
258
258
  onMouseLeave: () => {
259
259
  O.current && (O.current.style.transform = "scale(1)", O.current.style.filter = "brightness(1)");
@@ -347,9 +347,9 @@ function j({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
347
347
  let n = (E - 1) / 2;
348
348
  return 1 - .7 * (Math.abs(t - n) / n);
349
349
  }), s = () => {
350
- let e = _.current ? a : 0;
351
- v.current += (e - v.current) * .15;
352
- }, c = (n, r) => {
350
+ let e = l && !c, t = _.current && e ? a : 0;
351
+ v.current += (t - v.current) * .15;
352
+ }, u = (n, r) => {
353
353
  s();
354
354
  let i = A(r), [a, c, l] = y.current;
355
355
  y.current = [
@@ -377,7 +377,7 @@ function j({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
377
377
  let l = e === "listening" ? .45 : 1;
378
378
  h.current[r] += (c - h.current[r]) * l;
379
379
  }
380
- c(h.current, r), m.current = requestAnimationFrame(a);
380
+ u(h.current, r), m.current = requestAnimationFrame(a);
381
381
  };
382
382
  return m.current = requestAnimationFrame(a), () => cancelAnimationFrame(m.current);
383
383
  }
@@ -389,17 +389,17 @@ function j({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
389
389
  let r = (a * .6 + e / E * .5) % 1, i = r < .5 ? Math.sin(r / .5 * Math.PI) : 0, o = n + (t * .4 - n) * i;
390
390
  h.current[e] += (o - h.current[e]) * .15;
391
391
  }
392
- c(h.current, r), m.current = requestAnimationFrame(i);
392
+ u(h.current, r), m.current = requestAnimationFrame(i);
393
393
  };
394
394
  return m.current = requestAnimationFrame(i), () => cancelAnimationFrame(m.current);
395
395
  }
396
396
  cancelAnimationFrame(m.current);
397
- let l = () => {
397
+ let d = () => {
398
398
  s();
399
399
  for (let e = 0; e < E; e++) h.current[e] += (n - h.current[e]) * .16;
400
- c(h.current, r), m.current = requestAnimationFrame(l);
400
+ u(h.current, r), m.current = requestAnimationFrame(d);
401
401
  };
402
- return m.current = requestAnimationFrame(l), () => cancelAnimationFrame(m.current);
402
+ return m.current = requestAnimationFrame(d), () => cancelAnimationFrame(m.current);
403
403
  }, [e, i]);
404
404
  let C = i * .055, w = i * .035, T = i * .03, j = i * .55, M = i * .06, N = {
405
405
  width: i,
@@ -412,7 +412,7 @@ function j({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
412
412
  }, P = /* @__PURE__ */ a("span", {
413
413
  ref: p,
414
414
  onMouseEnter: () => {
415
- c || (_.current = !0, p.current && (p.current.style.filter = "brightness(1.35)"));
415
+ !l || c || (_.current = !0, p.current && (p.current.style.filter = "brightness(1.35)"));
416
416
  },
417
417
  onMouseLeave: () => {
418
418
  _.current = !1, p.current && (p.current.style.filter = "brightness(1)");
@@ -471,48 +471,293 @@ function j({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
471
471
  });
472
472
  }
473
473
  //#endregion
474
+ //#region src/themes/cloud/CloudTheme.tsx
475
+ var M = typeof window < "u" ? n : t, N = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", P = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_activity;\n\nfloat hash(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.52;\n mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);\n\n for (int octave = 0; octave < 5; octave++) {\n value += amplitude * noise(p);\n p = rotation * p * 1.92 + vec2(9.7, 4.3);\n amplitude *= 0.5;\n }\n\n return value;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 centered = uv - 0.5;\n float radius = length(centered);\n float edge = 1.0 - smoothstep(0.488, 0.5, radius);\n\n if (edge <= 0.0) discard;\n\n vec2 p = centered * 2.0;\n float t = u_time;\n\n vec2 warp = vec2(\n fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),\n fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))\n );\n vec2 curl = vec2(\n sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),\n cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)\n );\n vec2 warped =\n p +\n (warp - 0.5) * (1.18 + u_activity * 0.38) +\n curl * (0.035 + u_activity * 0.07);\n float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));\n float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);\n float field = mix(broad, folded, 0.3 + u_activity * 0.14);\n\n float horizon =\n 0.46 +\n 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +\n 0.16 * (broad - 0.5);\n float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);\n float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));\n float cloud = smoothstep(0.24, 0.79, field);\n\n vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);\n vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);\n vec3 lowerLavender = vec3(0.72, 0.78, 0.975);\n vec3 milk = vec3(0.89, 0.92, 0.995);\n\n vec3 color = mix(lowerLavender, upperPeriwinkle, upper);\n float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);\n color = mix(color, deepPeriwinkle, upperDepth);\n\n float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);\n color = mix(color, milk, milkAmount);\n\n float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;\n color = mix(color, milk, lowerMist);\n\n float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;\n color += grain;\n\n gl_FragColor = vec4(color, edge);\n}\n", F = .55, I = .204, L = .2145, R = .063, z = "#5659dc", B = 1.178, V = 180, H = 300, U = 1350, W = 246, G = 420, K = 354, ee = 480;
476
+ function q(e, t = 0, n = 1) {
477
+ return Math.min(n, Math.max(t, e));
478
+ }
479
+ function J(e, t, n, r) {
480
+ return e + (t - e) * (1 - Math.exp(-n * r));
481
+ }
482
+ function te(e) {
483
+ return 1 - (1 - e) ** 3;
484
+ }
485
+ function Y(e, t, n) {
486
+ return e + (t - e) * n;
487
+ }
488
+ function X(e, t, n) {
489
+ let r = q((e - t) / (n - t));
490
+ return r * r * (3 - 2 * r);
491
+ }
492
+ function Z(e) {
493
+ return e === "listening" || e === "speaking" || e === "thinking";
494
+ }
495
+ function Q(e, t, n) {
496
+ let r = e.createShader(t);
497
+ if (r) {
498
+ if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
499
+ e.deleteShader(r);
500
+ return;
501
+ }
502
+ return r;
503
+ }
504
+ }
505
+ function ne(e, t) {
506
+ let n = e.getContext("webgl", {
507
+ alpha: !0,
508
+ antialias: !0,
509
+ premultipliedAlpha: !0
510
+ });
511
+ if (!n) return;
512
+ let r = Q(n, n.VERTEX_SHADER, N), i = Q(n, n.FRAGMENT_SHADER, P);
513
+ if (!r || !i) {
514
+ r && n.deleteShader(r), i && n.deleteShader(i);
515
+ return;
516
+ }
517
+ let a = n.createProgram(), o = n.createBuffer();
518
+ if (!a || !o) {
519
+ a && n.deleteProgram(a), o && n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
520
+ return;
521
+ }
522
+ if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) {
523
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
524
+ return;
525
+ }
526
+ let s = n.getAttribLocation(a, "a_position"), c = n.getUniformLocation(a, "u_resolution"), l = n.getUniformLocation(a, "u_time"), u = n.getUniformLocation(a, "u_activity");
527
+ if (s < 0 || !c || !l || !u) {
528
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
529
+ return;
530
+ }
531
+ let d = Math.min(window.devicePixelRatio || 1, 2), f = Math.max(1, Math.round(t * d));
532
+ return e.width = f, e.height = f, n.viewport(0, 0, f, f), n.useProgram(a), n.bindBuffer(n.ARRAY_BUFFER, o), n.bufferData(n.ARRAY_BUFFER, new Float32Array([
533
+ -1,
534
+ -1,
535
+ 1,
536
+ -1,
537
+ -1,
538
+ 1,
539
+ -1,
540
+ 1,
541
+ 1,
542
+ -1,
543
+ 1,
544
+ 1
545
+ ]), n.STATIC_DRAW), n.enableVertexAttribArray(s), n.vertexAttribPointer(s, 2, n.FLOAT, !1, 0, 0), n.uniform2f(c, f, f), {
546
+ draw(e, t) {
547
+ n.uniform1f(l, e), n.uniform1f(u, t), n.drawArrays(n.TRIANGLES, 0, 6);
548
+ },
549
+ destroy() {
550
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
551
+ }
552
+ };
553
+ }
554
+ function re(e) {
555
+ if (e <= V) return R;
556
+ if (e <= 480) return Y(R, B, te((e - V) / H));
557
+ let t = e - V - H;
558
+ if (t >= U) return 1;
559
+ let n = q(t / U);
560
+ return 1 + (B - 1) * (1 - n) ** 2;
561
+ }
562
+ function ie({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
563
+ let p = r(null), m = r(null), h = r(null), g = r(e), _ = r(n), v = r(u), y = r(!1);
564
+ M(() => {
565
+ g.current = e, _.current = n, v.current = u;
566
+ }, [
567
+ u,
568
+ e,
569
+ n
570
+ ]);
571
+ let b = i * F;
572
+ t(() => {
573
+ let e = p.current, t = m.current, n = h.current;
574
+ if (!e || !t || !n) return;
575
+ let r = window.matchMedia("(prefers-reduced-motion: reduce)"), i = () => {
576
+ y.current = r.matches;
577
+ };
578
+ i(), r.addEventListener("change", i);
579
+ let a = ne(e, b);
580
+ a || (e.style.background = "linear-gradient(180deg, #626afb 2%, #8f9dfb 32%, #dde6fd 52%, #c9d3fb 84%)");
581
+ let o = 0, s = performance.now(), c = g.current, l = Z(c) ? s : void 0, u = q(_.current), d = 1, f = +!!Z(c), x = 1, S = +(c === "connecting"), C = 0, w = (r) => {
582
+ let i = Math.min((r - s) / 1e3, .05);
583
+ s = r;
584
+ let p = g.current, m = y.current;
585
+ p !== c && (Z(p) && !Z(c) && (l = r), (p === "idle" || p === "error") && (l = void 0), c = p);
586
+ let h = q(_.current);
587
+ u = m ? 0 : J(u, h, h > u ? 11 : 6, i);
588
+ let b = 1;
589
+ p === "listening" && (b = 1 - u * I), p === "speaking" && (b = 1 + u * L);
590
+ let T = Math.abs(b - 1) > Math.abs(d - 1) ? 12 : 6;
591
+ d = m ? 1 : J(d, b, T, i);
592
+ let E = Z(p), D = p === "idle" && v.current, O = E || D ? 1 : 0;
593
+ f = m ? O : J(f, O, 14, i);
594
+ let k = E || D ? 1 : .92;
595
+ x = m ? k : J(x, k, 12, i);
596
+ let A = d * x;
597
+ D && (A = R);
598
+ let j = +!D, M = D ? f : 0;
599
+ if (E && l !== void 0 && !m) {
600
+ let e = r - l, t = re(e), n = q((e - V - H) / U);
601
+ A = t * Y(1, d, n), j = X(e, W, G), M = f * (1 - X(e, K, ee)), e >= 1830 && (l = void 0);
602
+ }
603
+ let N = +(p === "connecting");
604
+ S = m ? N : J(S, N, 18, i), e.style.opacity = String(f * j), e.style.transform = `scale(${A})`, t.style.opacity = String(M), t.style.transform = `scale(${A})`, n.style.opacity = String(S), n.style.transform = `rotate(${m ? 45 : r * .34}deg)`;
605
+ let P = .24, F = .1;
606
+ p === "listening" ? (P = .72 + u * .78, F = .28 + u * .32) : p === "speaking" && (P = 1.65 + u * 1.55, F = .66 + u * .34), m || (C += i * P), a?.draw(C, F), o = requestAnimationFrame(w);
607
+ };
608
+ return o = requestAnimationFrame(w), () => {
609
+ cancelAnimationFrame(o), r.removeEventListener("change", i), a?.destroy();
610
+ };
611
+ }, [b]);
612
+ let x = {
613
+ width: i,
614
+ height: i,
615
+ display: "flex",
616
+ alignItems: "center",
617
+ justifyContent: "center",
618
+ position: "relative",
619
+ ...c
620
+ }, S = /* @__PURE__ */ o("span", {
621
+ style: {
622
+ position: "relative",
623
+ display: "block",
624
+ width: b,
625
+ height: b,
626
+ borderRadius: "50%",
627
+ lineHeight: 0,
628
+ cursor: u ? l ? "not-allowed" : "pointer" : "default"
629
+ },
630
+ children: [
631
+ /* @__PURE__ */ a("span", {
632
+ ref: m,
633
+ "data-cloud-launch-dot": "",
634
+ "aria-hidden": "true",
635
+ style: {
636
+ position: "absolute",
637
+ inset: 0,
638
+ display: "block",
639
+ borderRadius: "50%",
640
+ background: z,
641
+ opacity: 0,
642
+ transform: `scale(${R})`,
643
+ transformOrigin: "center",
644
+ willChange: "opacity, transform"
645
+ }
646
+ }),
647
+ /* @__PURE__ */ a("canvas", {
648
+ ref: p,
649
+ "aria-hidden": "true",
650
+ style: {
651
+ position: "absolute",
652
+ inset: 0,
653
+ display: "block",
654
+ width: b,
655
+ height: b,
656
+ borderRadius: "50%",
657
+ opacity: 0,
658
+ transform: `scale(${R})`,
659
+ transformOrigin: "center",
660
+ willChange: "opacity, transform"
661
+ }
662
+ }),
663
+ /* @__PURE__ */ a("span", {
664
+ ref: h,
665
+ "aria-hidden": "true",
666
+ style: {
667
+ position: "absolute",
668
+ left: "50%",
669
+ top: "50%",
670
+ width: b * .105,
671
+ height: b * .105,
672
+ boxSizing: "border-box",
673
+ border: `${Math.max(1.5, b * .012)}px solid rgba(113, 120, 245, 0.24)`,
674
+ borderTopColor: "#777ff6",
675
+ borderRightColor: "#777ff6",
676
+ borderRadius: "50%",
677
+ opacity: 0,
678
+ transform: "rotate(0deg)",
679
+ transformOrigin: "center",
680
+ marginLeft: b * -.0525,
681
+ marginTop: b * -.0525,
682
+ willChange: "opacity, transform"
683
+ }
684
+ })
685
+ ]
686
+ });
687
+ return u ? /* @__PURE__ */ a("button", {
688
+ ...f,
689
+ type: "button",
690
+ className: s,
691
+ disabled: l,
692
+ onClick: l ? void 0 : d,
693
+ style: {
694
+ appearance: "none",
695
+ WebkitAppearance: "none",
696
+ border: 0,
697
+ padding: 0,
698
+ margin: 0,
699
+ background: "transparent",
700
+ color: "inherit",
701
+ font: "inherit",
702
+ cursor: l ? "not-allowed" : "pointer",
703
+ ...x
704
+ },
705
+ children: S
706
+ }) : /* @__PURE__ */ a("div", {
707
+ ...f,
708
+ className: s,
709
+ style: x,
710
+ children: S
711
+ });
712
+ }
713
+ //#endregion
474
714
  //#region src/components/Orb/Orb.tsx
475
- function M({ signal: n, state: r, volume: o, adapter: l, theme: u = "debug", size: f = 200, className: p, style: m, disabled: h = !1, onStart: g, onStop: _, ...v }) {
476
- let [y, b] = i({ state: "idle" });
715
+ function $({ signal: n, state: r, volume: o, adapter: l, theme: u = "debug", size: f = 200, className: p, style: m, disabled: h = !1, interactive: g = !0, onStart: _, onStop: v, ...y }) {
716
+ let [b, x] = i({ state: "idle" });
477
717
  t(() => {
478
- if (b({ state: "idle" }), l) return l.subscribe(b);
718
+ if (x({ state: "idle" }), l) return l.subscribe(x);
479
719
  }, [l]);
480
- let x = n ?? y, S = s(r, n, y), C = c(o, S, x), w = S !== "idle" && S !== "error", E = e(() => {
481
- h || (w ? _ ? _() : l?.stop?.() : g ? g() : l?.start?.());
720
+ let S = n ?? b, C = s(r, n, b), w = c(o, C, S), E = C !== "idle" && C !== "error", D = e(() => {
721
+ h || (E ? v ? v() : l?.stop?.() : _ ? _() : l?.start?.());
482
722
  }, [
483
723
  l,
484
724
  h,
485
- w,
486
- g,
487
- _
488
- ]), D = w ? !!(l?.stop || _) : !!(l?.start || g), O = D && !h ? E : void 0, k = {
489
- state: S,
490
- volume: C,
725
+ E,
726
+ _,
727
+ v
728
+ ]), O = E ? !!(l?.stop || v) : !!(l?.start || _), k = g && O, A = k && !h ? D : void 0, M = {
729
+ state: C,
730
+ volume: w,
491
731
  size: f,
492
732
  className: p,
493
733
  style: m,
494
734
  disabled: h,
495
- ...v,
496
- "aria-label": v["aria-label"] ?? (D ? `${w ? "Stop" : "Start"} voice session` : void 0)
497
- }, A = {
498
- ...k,
499
- interactive: D
735
+ ...y,
736
+ "aria-label": y["aria-label"] ?? (k ? `${E ? "Stop" : "Start"} voice session` : void 0)
737
+ }, N = {
738
+ ...M,
739
+ interactive: k
500
740
  };
501
741
  switch (u) {
502
742
  case "circle": return /* @__PURE__ */ a(T, {
503
- ...A,
504
- onClick: O
743
+ ...N,
744
+ onClick: A
505
745
  });
506
746
  case "bars": return /* @__PURE__ */ a(j, {
507
- ...A,
508
- onClick: O
747
+ ...N,
748
+ onClick: A
749
+ });
750
+ case "cloud": return /* @__PURE__ */ a(ie, {
751
+ ...N,
752
+ onClick: A
509
753
  });
510
754
  default: return /* @__PURE__ */ a(d, {
511
- ...k,
512
- onStart: h ? void 0 : g ?? (() => l?.start?.()),
513
- onStop: h ? void 0 : _ ?? (() => l?.stop?.())
755
+ ...M,
756
+ disabled: h || !g,
757
+ onStart: h || !g ? void 0 : _ ?? (() => l?.start?.()),
758
+ onStop: h || !g ? void 0 : v ?? (() => l?.stop?.())
514
759
  });
515
760
  }
516
761
  }
517
762
  //#endregion
518
- export { M as Orb, M as VoiceOrb };
763
+ export { $ as Orb, $ as VoiceOrb };
@@ -0,0 +1,14 @@
1
+ import { CSSProperties } from 'react';
2
+ import { OrbHtmlAttributes, OrbState } from '../../components/Orb/Orb.types.js';
3
+ interface CloudThemeProps extends OrbHtmlAttributes {
4
+ state: OrbState;
5
+ volume: number;
6
+ size: number;
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ disabled?: boolean;
10
+ interactive?: boolean;
11
+ onClick?: () => void;
12
+ }
13
+ export declare function CloudTheme({ state, volume, size, className, style, disabled, interactive, onClick, ...controlProps }: CloudThemeProps): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1 @@
1
+ export { CloudTheme } from './CloudTheme.js';
@@ -1,3 +1,4 @@
1
1
  export { DebugTheme } from './debug/index.js';
2
2
  export { CircleTheme } from './circle/index.js';
3
3
  export { BarsTheme } from './bars/index.js';
4
+ export { CloudTheme } from './cloud/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orb-ui",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "React voice agent UI components with audio-reactive adapters for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI Realtime, Gemini Live, and custom voice AI apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/orb-ui.cjs",