orb-ui 0.6.1 → 0.7.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
@@ -247,30 +247,38 @@ function VoiceExperience({ adapter }) {
247
247
 
248
248
  | Theme | Description |
249
249
  | -------- | ----------------------------------------------------------------------------- |
250
+ | `radial` | Four-lobe radial field with input-reactive rim and output-reactive twisting. |
250
251
  | `cloud` | Atmospheric sphere with inverse listening scale and faster speaking motion. |
251
252
  | `debug` | State + volume display with start/stop. Use to verify your integration works. |
252
253
  | `circle` | Pulsing circle that reacts to volume. |
253
254
  | `bars` | Five bars that animate with voice. |
254
255
 
255
- 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.
256
+ When an adapter or `onStart`/`onStop` handler is provided, visual themes include keyboard-accessible `<button type="button">` controls. `radial` places its phone control below the artwork while the other clickable themes use the visual itself. Pass `interactive={false}` to keep the theme passive and call `adapter.start()` or `adapter.stop()` from external controls instead.
257
+
258
+ The radial phone control uses a small cutout that defaults to white. Match it to the surface behind
259
+ the orb with the typed style variable:
260
+
261
+ ```tsx
262
+ <Orb adapter={adapter} theme="radial" style={{ '--orb-ui-radial-control-surround': '#101010' }} />
263
+ ```
256
264
 
257
265
  ## Props
258
266
 
259
- | Prop | Type | Default | Description |
260
- | ------------- | ------------------------------------------ | --------- | ------------------------------------------------------- |
261
- | `theme` | `'debug' \| 'circle' \| 'bars' \| 'cloud'` | `'debug'` | Visual theme |
262
- | `signal` | `OrbSignal` | — | Rich controlled signal with state/input/output volume |
263
- | `state` | `OrbState` | `'idle'` | Conversation state (controlled mode) |
264
- | `volume` | `number` | `0` | Audio volume, 0–1. Overrides signal/adapter volume. |
265
- | `adapter` | `OrbAdapter` | — | Provider adapter (manages signal updates automatically) |
266
- | `size` | `number` | `200` | Size in pixels |
267
- | `className` | `string` | — | Optional class name for the rendered theme |
268
- | `style` | `React.CSSProperties` | — | Optional inline styles for the rendered theme |
269
- | `disabled` | `boolean` | `false` | Disables clickable themes and debug start/stop controls |
270
- | `interactive` | `boolean` | `true` | Allows the orb itself to start and stop a session |
271
- | `aria-label` | `string` | generated | Accessible label for clickable visual themes |
272
- | `onStart` | `() => void` | — | Custom start handler (overrides adapter.start()) |
273
- | `onStop` | `() => void` | — | Custom stop handler (overrides adapter.stop()) |
267
+ | Prop | Type | Default | Description |
268
+ | ------------- | ------------------------------------------------------ | --------- | ------------------------------------------------------- |
269
+ | `theme` | `'debug' \| 'circle' \| 'bars' \| 'cloud' \| 'radial'` | `'debug'` | Visual theme |
270
+ | `signal` | `OrbSignal` | — | Rich controlled signal with state/input/output volume |
271
+ | `state` | `OrbState` | `'idle'` | Conversation state (controlled mode) |
272
+ | `volume` | `number` | `0` | Audio volume, 0–1. Overrides signal/adapter volume. |
273
+ | `adapter` | `OrbAdapter` | — | Provider adapter (manages signal updates automatically) |
274
+ | `size` | `number` | `200` | Size in pixels |
275
+ | `className` | `string` | — | Optional class name for the rendered theme |
276
+ | `style` | `OrbStyle` | — | Inline styles, including radial control surround color |
277
+ | `disabled` | `boolean` | `false` | Disables clickable themes and debug start/stop controls |
278
+ | `interactive` | `boolean` | `true` | Allows the theme control to start and stop a session |
279
+ | `aria-label` | `string` | generated | Accessible label for clickable visual themes |
280
+ | `onStart` | `() => void` | — | Custom start handler (overrides adapter.start()) |
281
+ | `onStop` | `() => void` | — | Custom stop handler (overrides adapter.stop()) |
274
282
 
275
283
  ## States
276
284
 
@@ -1,6 +1,10 @@
1
1
  import { AriaAttributes, CSSProperties } from 'react';
2
+ export type OrbStyle = CSSProperties & {
3
+ /** Background color revealed around the radial theme's floating phone control. */
4
+ '--orb-ui-radial-control-surround'?: string;
5
+ };
2
6
  export type OrbState = 'idle' | 'connecting' | 'listening' | 'thinking' | 'speaking' | 'error';
3
- export type OrbTheme = 'debug' | 'circle' | 'bars' | 'cloud';
7
+ export type OrbTheme = 'debug' | 'circle' | 'bars' | 'cloud' | 'radial';
4
8
  export interface OrbSignal {
5
9
  state: OrbState;
6
10
  volume?: number;
@@ -61,11 +65,11 @@ export interface OrbProps extends OrbHtmlAttributes {
61
65
  /** Optional class name for the rendered orb container/control. */
62
66
  className?: string;
63
67
  /** Optional inline styles for the rendered orb container/control. */
64
- style?: CSSProperties;
65
- /** Disable clickable themes and debug start/stop controls. */
68
+ style?: OrbStyle;
69
+ /** Disable interactive theme and debug start/stop controls. */
66
70
  disabled?: boolean;
67
71
  /**
68
- * Allow the orb itself to start and stop an adapter-backed session.
72
+ * Allow the rendered theme control to start and stop an adapter-backed session.
69
73
  * Set this to false when session controls live elsewhere in your UI.
70
74
  */
71
75
  interactive?: boolean;
@@ -1,2 +1,2 @@
1
1
  export { Orb } from './Orb.js';
2
- export type { OrbAdapter, OrbProps, OrbSignal, OrbSignalListener, OrbState, OrbTheme, } from './Orb.types.js';
2
+ export type { OrbAdapter, OrbProps, OrbSignal, OrbSignalListener, OrbState, OrbStyle, OrbTheme, } from './Orb.types.js';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Orb } from './components/Orb/index.js';
2
- export type { OrbAdapter, OrbProps, OrbSignal, OrbSignalListener, OrbState, OrbTheme, } from './components/Orb/index.js';
2
+ export type { OrbAdapter, OrbProps, OrbSignal, OrbSignalListener, OrbState, OrbStyle, OrbTheme, } from './components/Orb/index.js';
3
3
  export { Orb as VoiceOrb } from './components/Orb/index.js';
4
4
  export type { OrbProps as VoiceOrbProps } from './components/Orb/index.js';
package/dist/orb-ui.cjs CHANGED
@@ -108,4 +108,96 @@ void main() {
108
108
 
109
109
  gl_FragColor = vec4(color, edge);
110
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=$;
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,ee=480;function H(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function U(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function W(e){return 1-(1-e)**3}function G(e,t,n){return e+(t-e)*n}function K(e,t,n){let r=H((e-t)/(n-t));return r*r*(3-2*r)}function q(e){return e===`listening`||e===`speaking`||e===`thinking`}function J(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 Y(e,t){let n=e.getContext(`webgl`,{alpha:!0,antialias:!0,premultipliedAlpha:!0});if(!n)return;let r=J(n,n.VERTEX_SHADER,O),i=J(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 te(e){if(e<=I)return N;if(e<=480)return G(N,F,W((e-I)/L));let t=e-I-L;if(t>=R)return 1;let n=H(t/R);return 1+(F-1)*(1-n)**2}function ne({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=Y(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=q(c)?s:void 0,u=H(h.current),y=1,b=+!!q(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&&(q(d)&&!q(c)&&(l=r),(d===`idle`||d===`error`)&&(l=void 0),c=d);let p=H(h.current);u=f?0:U(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:U(y,v,T,i);let E=q(d),D=d===`idle`&&g.current,O=E||D?1:0;b=f?O:U(b,O,14,i);let k=E||D?1:.92;x=f?k:U(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=te(e),n=H((e-I-L)/R);A=t*G(1,y,n),P=K(e,z,B),F=b*(1-K(e,V,ee)),e>=1830&&(l=void 0)}let W=+(d===`connecting`);S=f?W:U(S,W,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 J=.24,Y=.1;d===`listening`?(J=.72+u*.78,Y=.28+u*.32):d===`speaking`&&(J=1.65+u*1.55,Y=.66+u*.34),f||(C+=i*J),a?.draw(C,Y),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})}var re=typeof window<`u`?e.useLayoutEffect:e.useEffect,ie=`
112
+ attribute vec2 a_position;
113
+
114
+ void main() {
115
+ gl_Position = vec4(a_position, 0.0, 1.0);
116
+ }
117
+ `,ae=`
118
+ precision highp float;
119
+
120
+ uniform vec2 u_resolution;
121
+ uniform float u_time;
122
+ uniform float u_rotation;
123
+ uniform float u_listen;
124
+ uniform float u_speak;
125
+
126
+ void main() {
127
+ vec2 uv = gl_FragCoord.xy / u_resolution;
128
+ vec2 p = (uv - 0.5) * 2.0;
129
+ float radius = length(p);
130
+ float edge = 1.0 - smoothstep(0.993, 1.0, radius);
131
+
132
+ if (edge <= 0.0) discard;
133
+
134
+ float angle = atan(p.y, p.x);
135
+ float warpStrength = 0.026 + u_speak * 0.105;
136
+ float angularWarp =
137
+ sin(angle * 3.0 - u_time * 0.54 + radius * 2.1) +
138
+ 0.48 * sin(angle * 5.0 + u_time * 0.31 - radius * 3.7) +
139
+ 0.22 * sin(angle * 8.0 - u_time * 0.19 + radius * 5.2);
140
+ float phase =
141
+ angle - 1.78 - u_rotation + angularWarp * warpStrength * (0.2 + radius * 0.8);
142
+
143
+ // Two opposing dark lobes and two opposing aqua lobes form the main pinwheel.
144
+ float lobeField = cos(phase * 2.0);
145
+ float darkMix = smoothstep(-0.04, 0.38, lobeField);
146
+
147
+ vec3 deepBlue = vec3(0.004, 0.105, 0.37);
148
+ vec3 cobalt = vec3(0.015, 0.34, 0.76);
149
+ vec3 aqua = vec3(0.24, 0.76, 0.79);
150
+ vec3 paleAqua = vec3(0.77, 0.96, 0.95);
151
+
152
+ float radialLight = 0.5 + 0.5 * sin(radius * 3.0 - u_time * 0.16);
153
+ vec3 darkColor = mix(cobalt, deepBlue, 0.42 + 0.38 * radius);
154
+ float darkRay = pow(max(lobeField, 0.0), 11.0);
155
+ darkColor = mix(darkColor, aqua, darkRay * (0.18 + radialLight * 0.16));
156
+
157
+ vec3 lightColor = mix(paleAqua, aqua, 0.5 + 0.2 * sin(radius * 3.4 + phase * 2.0));
158
+ float lightRay = pow(max(-lobeField, 0.0), 5.0);
159
+ lightColor = mix(lightColor, vec3(0.04, 0.42, 0.64), lightRay * 0.28);
160
+
161
+ vec3 color = mix(lightColor, darkColor, darkMix);
162
+
163
+ // Soft secondary streaks make each of the four lobes feel layered rather than flat.
164
+ float secondaryRay = 0.5 + 0.5 * sin(phase * 6.0 + radius * 1.8 - u_time * 0.42);
165
+ float rayStrength = (0.055 + u_speak * 0.045) * (0.25 + radius * 0.75);
166
+ color = mix(color, vec3(0.26, 0.76, 0.8), secondaryRay * rayStrength);
167
+
168
+ // The outer membrane keeps a circular perimeter while independent traveling waves
169
+ // continuously reshape its inner boundary.
170
+ float rimWave =
171
+ 0.063 * sin(angle * 3.0 + u_time * 1.34) +
172
+ 0.036 * sin(angle * 5.0 - u_time * 0.91 + 1.4) +
173
+ 0.021 * sin(angle * 7.0 + u_time * 0.63 - 0.8) +
174
+ 0.012 * sin(angle * 11.0 - u_time * 1.72 + sin(angle * 2.0 + u_time * 0.58));
175
+ rimWave *= 1.0 + u_listen * 0.38;
176
+ float rimInner = 0.82 + rimWave - u_listen * 0.2;
177
+ float rim = smoothstep(rimInner - 0.02, rimInner + 0.015, radius);
178
+ float rimStrength = rim * (0.3 + u_listen * 0.3);
179
+ vec3 membrane = mix(
180
+ vec3(0.47, 0.84, 0.84),
181
+ vec3(0.76, 0.93, 0.92),
182
+ smoothstep(0.78, 1.0, radius)
183
+ );
184
+ color = mix(color, membrane, clamp(rimStrength, 0.0, 0.72));
185
+
186
+ // Only one transition direction becomes a bright seam, producing two opposing ribbons.
187
+ float seamDirection = max(0.0, -sin(phase * 2.0));
188
+ float seamExponent = mix(30.0, 3.2, smoothstep(0.05, 1.0, radius));
189
+ float seam = pow(seamDirection, seamExponent) * (0.78 + radius * 0.25);
190
+ color = mix(color, vec3(0.985, 0.995, 0.995), clamp(seam, 0.0, 0.96));
191
+
192
+ // The drawing buffer uses premultiplied alpha. Premultiply the antialiased
193
+ // perimeter so translucent edge pixels cannot become a bright outline.
194
+ gl_FragColor = vec4(color * edge, edge);
195
+ }
196
+ `,oe=`
197
+ @keyframes orb-radial-spinner {
198
+ to { transform: rotate(360deg); }
199
+ }
200
+ @media (prefers-reduced-motion: reduce) {
201
+ [data-radial-spinner] { animation: none !important; }
202
+ }
203
+ `,se=.66,ce=.2;function X(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function Z(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function Q(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 le(e,t){let n=e.getContext(`webgl`,{alpha:!0,antialias:!0,premultipliedAlpha:!0});if(!n)return;let r=Q(n,n.VERTEX_SHADER,ie),i=Q(n,n.FRAGMENT_SHADER,ae);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_rotation`),d=n.getUniformLocation(a,`u_listen`),f=n.getUniformLocation(a,`u_speak`);if(s<0||!c||!l||!u||!d||!f){n.deleteProgram(a),n.deleteBuffer(o),n.deleteShader(r),n.deleteShader(i);return}let p=Math.min(window.devicePixelRatio||1,2),m=Math.max(1,Math.round(t*p));return e.width=m,e.height=m,n.viewport(0,0,m,m),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,m,m),{draw(e,t,r,i){n.uniform1f(l,e),n.uniform1f(u,t),n.uniform1f(d,r),n.uniform1f(f,i),n.drawArrays(n.TRIANGLES,0,6)},destroy(){n.deleteProgram(a),n.deleteBuffer(o),n.deleteShader(r),n.deleteShader(i)}}}function ue(e){return e!==`idle`&&e!==`connecting`&&e!==`error`}function de({active:e}){return(0,t.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 24 24`,style:{display:`block`,width:`50%`,height:`50%`,transform:`rotate(${e?132:-8}deg)`,transformOrigin:`center`,transition:`transform 180ms ease`},children:(0,t.jsx)(`path`,{d:`M6.7 3.8 9.1 7a1.6 1.6 0 0 1-.2 2.1l-1.4 1.3a13.1 13.1 0 0 0 6.1 6.1l1.3-1.4a1.6 1.6 0 0 1 2.1-.2l3.2 2.4a1.6 1.6 0 0 1 .5 1.9l-.7 1.7c-.3.8-1.1 1.3-2 1.2C9.7 21.2 2.8 14.3 1.9 6c-.1-.9.4-1.7 1.2-2l1.7-.7a1.6 1.6 0 0 1 1.9.5Z`,fill:`currentColor`})})}function fe({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)(n),p=(0,e.useRef)(r),m=(0,e.useRef)(!1);re(()=>{f.current=n,p.current=r},[n,r]);let h=i*se,g=h*ce;(0,e.useEffect)(()=>{let e=`orb-radial-keyframes`;if(!document.getElementById(e)){let t=document.createElement(`style`);t.id=e,t.textContent=oe,document.head.appendChild(t)}},[]),(0,e.useEffect)(()=>{let e=d.current;if(!e)return;let t=window.matchMedia(`(prefers-reduced-motion: reduce)`),n=()=>{m.current=t.matches};n(),t.addEventListener(`change`,n);let r=le(e,h),i=0,a=performance.now(),o=0,s=.36,c=.62,l=.15,u=0,g=0,_=0,v=0,y=+(f.current===`speaking`),b=X(p.current),x=f.current===`listening`?b:0,S=f.current===`speaking`?b:0,C=e=>{let t=Math.min((e-a)/1e3,.05);a=e;let n=f.current,d=m.current,h=X(p.current);b=d?0:Z(b,h,h>b?15:7,t);let w=n===`listening`?b:0,T=n===`speaking`?b:0;x=d?0:Z(x,w,w>x?17:7,t),S=d?0:Z(S,T,T>S?12:5,t);let E=.36,D=.62,O=.15;if(n===`connecting`?(E=.42,D=.68,O=.13):n===`listening`?(E=.54+x*.26,D=.78+x*.18,O=.18+x*.04):n===`thinking`?(E=.46,D=.72,O=.16):n===`speaking`&&(E=1.05+S*1.15),!d){s=Z(s,E,3.6,t),c=Z(c,D,3.6,t),l=Z(l,O,3.6,t),y=Z(y,+(n===`speaking`),n===`speaking`?3.8:3,t),o+=t*s,_+=t*c;let e=1.2+S*1.35+Math.sin(o*1.73)*.34+Math.sin(o*.61+.8)*.18;v+=t*Math.max(.65,e);let r=Math.sin(_)*l+Math.sin(_*.47+1.1)*.032,i=Math.sin(v*1.08),a=Math.sin(v*2.47+.9),d=Math.sin(v*.43-.5),f=r+(i*(.13+S*.17)+a*(.035+S*.035)+d*.055-r)*y,p=4.2+y*3,m=p*p,h=2*p;g+=((f-u)*m-g*h)*t,u+=g*t}r?.draw(o,u,x,S),i=requestAnimationFrame(C)};return i=requestAnimationFrame(C),()=>{cancelAnimationFrame(i),t.removeEventListener(`change`,n),r?.destroy()}},[h]);let _=ue(n),v=n===`connecting`,y=h+(c?g*.5:0),b={"--orb-ui-radial-control-surround":`#fff`,width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...o},x=(0,t.jsxs)(`span`,{style:{position:`relative`,display:`block`,width:h,height:y,lineHeight:0},children:[(0,t.jsx)(`canvas`,{ref:d,"aria-hidden":`true`,"data-radial-surface":``,style:{position:`absolute`,left:0,top:0,display:`block`,width:h,height:h,borderRadius:`50%`,background:`conic-gradient(from 12deg, #06358d 0deg, #0b65b5 72deg, #c7f1ef 92deg, #45c2c8 172deg, #06358d 196deg, #0b65b5 254deg, #c7f1ef 278deg, #45c2c8 360deg)`}}),c?(0,t.jsx)(`button`,{...u,type:`button`,"data-radial-control":``,disabled:s,onClick:s?void 0:l,style:{appearance:`none`,WebkitAppearance:`none`,position:`absolute`,left:`50%`,top:h-g*.52,width:g,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`,boxSizing:`border-box`,padding:0,margin:0,border:0,borderRadius:`50%`,background:v?`#9da1aa`:_?`#ef4146`:`#080808`,color:`#fff`,boxShadow:`0 0 0 ${Math.max(3,g*.085)}px var(--orb-ui-radial-control-surround), 0 2px 5px rgba(0, 0, 0, 0.18)`,cursor:s?`not-allowed`:`pointer`,opacity:s?.52:1,transform:`translateX(-50%)`,transition:`background 160ms ease, opacity 160ms ease, transform 160ms ease`,font:`inherit`},children:v?(0,t.jsx)(`span`,{"aria-hidden":`true`,"data-radial-spinner":``,style:{width:`42%`,height:`42%`,boxSizing:`border-box`,border:`${Math.max(1.5,g*.055)}px solid rgba(255, 255, 255, 0.38)`,borderTopColor:`#fff`,borderRightColor:`#fff`,borderRadius:`50%`,animation:`orb-radial-spinner 760ms linear infinite`}}):(0,t.jsx)(de,{active:_})}):null]});return c?(0,t.jsx)(`div`,{className:a,style:b,children:x}):(0,t.jsx)(`div`,{...u,className:a,style:b,children:x})}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)(ne,{...j,onClick:k});case`radial`:return(0,t.jsx)(fe,{...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
@@ -472,27 +472,27 @@ function j({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
472
472
  }
473
473
  //#endregion
474
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) {
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, ee = 246, te = 420, ne = 354, re = 480;
476
+ function W(e, t = 0, n = 1) {
477
477
  return Math.min(n, Math.max(t, e));
478
478
  }
479
- function J(e, t, n, r) {
479
+ function G(e, t, n, r) {
480
480
  return e + (t - e) * (1 - Math.exp(-n * r));
481
481
  }
482
- function te(e) {
482
+ function ie(e) {
483
483
  return 1 - (1 - e) ** 3;
484
484
  }
485
- function Y(e, t, n) {
485
+ function K(e, t, n) {
486
486
  return e + (t - e) * n;
487
487
  }
488
- function X(e, t, n) {
489
- let r = q((e - t) / (n - t));
488
+ function q(e, t, n) {
489
+ let r = W((e - t) / (n - t));
490
490
  return r * r * (3 - 2 * r);
491
491
  }
492
- function Z(e) {
492
+ function J(e) {
493
493
  return e === "listening" || e === "speaking" || e === "thinking";
494
494
  }
495
- function Q(e, t, n) {
495
+ function Y(e, t, n) {
496
496
  let r = e.createShader(t);
497
497
  if (r) {
498
498
  if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
@@ -502,14 +502,14 @@ function Q(e, t, n) {
502
502
  return r;
503
503
  }
504
504
  }
505
- function ne(e, t) {
505
+ function ae(e, t) {
506
506
  let n = e.getContext("webgl", {
507
507
  alpha: !0,
508
508
  antialias: !0,
509
509
  premultipliedAlpha: !0
510
510
  });
511
511
  if (!n) return;
512
- let r = Q(n, n.VERTEX_SHADER, N), i = Q(n, n.FRAGMENT_SHADER, P);
512
+ let r = Y(n, n.VERTEX_SHADER, N), i = Y(n, n.FRAGMENT_SHADER, P);
513
513
  if (!r || !i) {
514
514
  r && n.deleteShader(r), i && n.deleteShader(i);
515
515
  return;
@@ -551,15 +551,15 @@ function ne(e, t) {
551
551
  }
552
552
  };
553
553
  }
554
- function re(e) {
554
+ function oe(e) {
555
555
  if (e <= V) return R;
556
- if (e <= 480) return Y(R, B, te((e - V) / H));
556
+ if (e <= 480) return K(R, B, ie((e - V) / H));
557
557
  let t = e - V - H;
558
558
  if (t >= U) return 1;
559
- let n = q(t / U);
559
+ let n = W(t / U);
560
560
  return 1 + (B - 1) * (1 - n) ** 2;
561
561
  }
562
- function ie({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
562
+ function se({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
563
563
  let p = r(null), m = r(null), h = r(null), g = r(e), _ = r(n), v = r(u), y = r(!1);
564
564
  M(() => {
565
565
  g.current = e, _.current = n, v.current = u;
@@ -576,32 +576,32 @@ function ie({ state: e, volume: n, size: i, className: s, style: c, disabled: l
576
576
  y.current = r.matches;
577
577
  };
578
578
  i(), r.addEventListener("change", i);
579
- let a = ne(e, b);
579
+ let a = ae(e, b);
580
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) => {
581
+ let o = 0, s = performance.now(), c = g.current, l = J(c) ? s : void 0, u = W(_.current), d = 1, f = +!!J(c), x = 1, S = +(c === "connecting"), C = 0, w = (r) => {
582
582
  let i = Math.min((r - s) / 1e3, .05);
583
583
  s = r;
584
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);
585
+ p !== c && (J(p) && !J(c) && (l = r), (p === "idle" || p === "error") && (l = void 0), c = p);
586
+ let h = W(_.current);
587
+ u = m ? 0 : G(u, h, h > u ? 11 : 6, i);
588
588
  let b = 1;
589
589
  p === "listening" && (b = 1 - u * I), p === "speaking" && (b = 1 + u * L);
590
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);
591
+ d = m ? 1 : G(d, b, T, i);
592
+ let E = J(p), D = p === "idle" && v.current, O = E || D ? 1 : 0;
593
+ f = m ? O : G(f, O, 14, i);
594
594
  let k = E || D ? 1 : .92;
595
- x = m ? k : J(x, k, 12, i);
595
+ x = m ? k : G(x, k, 12, i);
596
596
  let A = d * x;
597
597
  D && (A = R);
598
598
  let j = +!D, M = D ? f : 0;
599
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);
600
+ let e = r - l, t = oe(e), n = W((e - V - H) / U);
601
+ A = t * K(1, d, n), j = q(e, ee, te), M = f * (1 - q(e, ne, re)), e >= 1830 && (l = void 0);
602
602
  }
603
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)`;
604
+ S = m ? N : G(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
605
  let P = .24, F = .1;
606
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
607
  };
@@ -711,6 +711,225 @@ function ie({ state: e, volume: n, size: i, className: s, style: c, disabled: l
711
711
  });
712
712
  }
713
713
  //#endregion
714
+ //#region src/themes/radial/RadialTheme.tsx
715
+ var ce = typeof window < "u" ? n : t, le = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", ue = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_rotation;\nuniform float u_listen;\nuniform float u_speak;\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 p = (uv - 0.5) * 2.0;\n float radius = length(p);\n float edge = 1.0 - smoothstep(0.993, 1.0, radius);\n\n if (edge <= 0.0) discard;\n\n float angle = atan(p.y, p.x);\n float warpStrength = 0.026 + u_speak * 0.105;\n float angularWarp =\n sin(angle * 3.0 - u_time * 0.54 + radius * 2.1) +\n 0.48 * sin(angle * 5.0 + u_time * 0.31 - radius * 3.7) +\n 0.22 * sin(angle * 8.0 - u_time * 0.19 + radius * 5.2);\n float phase =\n angle - 1.78 - u_rotation + angularWarp * warpStrength * (0.2 + radius * 0.8);\n\n // Two opposing dark lobes and two opposing aqua lobes form the main pinwheel.\n float lobeField = cos(phase * 2.0);\n float darkMix = smoothstep(-0.04, 0.38, lobeField);\n\n vec3 deepBlue = vec3(0.004, 0.105, 0.37);\n vec3 cobalt = vec3(0.015, 0.34, 0.76);\n vec3 aqua = vec3(0.24, 0.76, 0.79);\n vec3 paleAqua = vec3(0.77, 0.96, 0.95);\n\n float radialLight = 0.5 + 0.5 * sin(radius * 3.0 - u_time * 0.16);\n vec3 darkColor = mix(cobalt, deepBlue, 0.42 + 0.38 * radius);\n float darkRay = pow(max(lobeField, 0.0), 11.0);\n darkColor = mix(darkColor, aqua, darkRay * (0.18 + radialLight * 0.16));\n\n vec3 lightColor = mix(paleAqua, aqua, 0.5 + 0.2 * sin(radius * 3.4 + phase * 2.0));\n float lightRay = pow(max(-lobeField, 0.0), 5.0);\n lightColor = mix(lightColor, vec3(0.04, 0.42, 0.64), lightRay * 0.28);\n\n vec3 color = mix(lightColor, darkColor, darkMix);\n\n // Soft secondary streaks make each of the four lobes feel layered rather than flat.\n float secondaryRay = 0.5 + 0.5 * sin(phase * 6.0 + radius * 1.8 - u_time * 0.42);\n float rayStrength = (0.055 + u_speak * 0.045) * (0.25 + radius * 0.75);\n color = mix(color, vec3(0.26, 0.76, 0.8), secondaryRay * rayStrength);\n\n // The outer membrane keeps a circular perimeter while independent traveling waves\n // continuously reshape its inner boundary.\n float rimWave =\n 0.063 * sin(angle * 3.0 + u_time * 1.34) +\n 0.036 * sin(angle * 5.0 - u_time * 0.91 + 1.4) +\n 0.021 * sin(angle * 7.0 + u_time * 0.63 - 0.8) +\n 0.012 * sin(angle * 11.0 - u_time * 1.72 + sin(angle * 2.0 + u_time * 0.58));\n rimWave *= 1.0 + u_listen * 0.38;\n float rimInner = 0.82 + rimWave - u_listen * 0.2;\n float rim = smoothstep(rimInner - 0.02, rimInner + 0.015, radius);\n float rimStrength = rim * (0.3 + u_listen * 0.3);\n vec3 membrane = mix(\n vec3(0.47, 0.84, 0.84),\n vec3(0.76, 0.93, 0.92),\n smoothstep(0.78, 1.0, radius)\n );\n color = mix(color, membrane, clamp(rimStrength, 0.0, 0.72));\n\n // Only one transition direction becomes a bright seam, producing two opposing ribbons.\n float seamDirection = max(0.0, -sin(phase * 2.0));\n float seamExponent = mix(30.0, 3.2, smoothstep(0.05, 1.0, radius));\n float seam = pow(seamDirection, seamExponent) * (0.78 + radius * 0.25);\n color = mix(color, vec3(0.985, 0.995, 0.995), clamp(seam, 0.0, 0.96));\n\n // The drawing buffer uses premultiplied alpha. Premultiply the antialiased\n // perimeter so translucent edge pixels cannot become a bright outline.\n gl_FragColor = vec4(color * edge, edge);\n}\n", de = "\n@keyframes orb-radial-spinner {\n to { transform: rotate(360deg); }\n}\n@media (prefers-reduced-motion: reduce) {\n [data-radial-spinner] { animation: none !important; }\n}\n", fe = .66, pe = .2;
716
+ function X(e, t = 0, n = 1) {
717
+ return Math.min(n, Math.max(t, e));
718
+ }
719
+ function Z(e, t, n, r) {
720
+ return e + (t - e) * (1 - Math.exp(-n * r));
721
+ }
722
+ function Q(e, t, n) {
723
+ let r = e.createShader(t);
724
+ if (r) {
725
+ if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
726
+ e.deleteShader(r);
727
+ return;
728
+ }
729
+ return r;
730
+ }
731
+ }
732
+ function me(e, t) {
733
+ let n = e.getContext("webgl", {
734
+ alpha: !0,
735
+ antialias: !0,
736
+ premultipliedAlpha: !0
737
+ });
738
+ if (!n) return;
739
+ let r = Q(n, n.VERTEX_SHADER, le), i = Q(n, n.FRAGMENT_SHADER, ue);
740
+ if (!r || !i) {
741
+ r && n.deleteShader(r), i && n.deleteShader(i);
742
+ return;
743
+ }
744
+ let a = n.createProgram(), o = n.createBuffer();
745
+ if (!a || !o) {
746
+ a && n.deleteProgram(a), o && n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
747
+ return;
748
+ }
749
+ if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) {
750
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
751
+ return;
752
+ }
753
+ let s = n.getAttribLocation(a, "a_position"), c = n.getUniformLocation(a, "u_resolution"), l = n.getUniformLocation(a, "u_time"), u = n.getUniformLocation(a, "u_rotation"), d = n.getUniformLocation(a, "u_listen"), f = n.getUniformLocation(a, "u_speak");
754
+ if (s < 0 || !c || !l || !u || !d || !f) {
755
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
756
+ return;
757
+ }
758
+ let p = Math.min(window.devicePixelRatio || 1, 2), m = Math.max(1, Math.round(t * p));
759
+ return e.width = m, e.height = m, n.viewport(0, 0, m, m), n.useProgram(a), n.bindBuffer(n.ARRAY_BUFFER, o), n.bufferData(n.ARRAY_BUFFER, new Float32Array([
760
+ -1,
761
+ -1,
762
+ 1,
763
+ -1,
764
+ -1,
765
+ 1,
766
+ -1,
767
+ 1,
768
+ 1,
769
+ -1,
770
+ 1,
771
+ 1
772
+ ]), n.STATIC_DRAW), n.enableVertexAttribArray(s), n.vertexAttribPointer(s, 2, n.FLOAT, !1, 0, 0), n.uniform2f(c, m, m), {
773
+ draw(e, t, r, i) {
774
+ n.uniform1f(l, e), n.uniform1f(u, t), n.uniform1f(d, r), n.uniform1f(f, i), n.drawArrays(n.TRIANGLES, 0, 6);
775
+ },
776
+ destroy() {
777
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
778
+ }
779
+ };
780
+ }
781
+ function he(e) {
782
+ return e !== "idle" && e !== "connecting" && e !== "error";
783
+ }
784
+ function ge({ active: e }) {
785
+ return /* @__PURE__ */ a("svg", {
786
+ "aria-hidden": "true",
787
+ fill: "none",
788
+ viewBox: "0 0 24 24",
789
+ style: {
790
+ display: "block",
791
+ width: "50%",
792
+ height: "50%",
793
+ transform: `rotate(${e ? 132 : -8}deg)`,
794
+ transformOrigin: "center",
795
+ transition: "transform 180ms ease"
796
+ },
797
+ children: /* @__PURE__ */ a("path", {
798
+ d: "M6.7 3.8 9.1 7a1.6 1.6 0 0 1-.2 2.1l-1.4 1.3a13.1 13.1 0 0 0 6.1 6.1l1.3-1.4a1.6 1.6 0 0 1 2.1-.2l3.2 2.4a1.6 1.6 0 0 1 .5 1.9l-.7 1.7c-.3.8-1.1 1.3-2 1.2C9.7 21.2 2.8 14.3 1.9 6c-.1-.9.4-1.7 1.2-2l1.7-.7a1.6 1.6 0 0 1 1.9.5Z",
799
+ fill: "currentColor"
800
+ })
801
+ });
802
+ }
803
+ function _e({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
804
+ let p = r(null), m = r(e), h = r(n), g = r(!1);
805
+ ce(() => {
806
+ m.current = e, h.current = n;
807
+ }, [e, n]);
808
+ let _ = i * fe, v = _ * pe;
809
+ t(() => {
810
+ let e = "orb-radial-keyframes";
811
+ if (!document.getElementById(e)) {
812
+ let t = document.createElement("style");
813
+ t.id = e, t.textContent = de, document.head.appendChild(t);
814
+ }
815
+ }, []), t(() => {
816
+ let e = p.current;
817
+ if (!e) return;
818
+ let t = window.matchMedia("(prefers-reduced-motion: reduce)"), n = () => {
819
+ g.current = t.matches;
820
+ };
821
+ n(), t.addEventListener("change", n);
822
+ let r = me(e, _), i = 0, a = performance.now(), o = 0, s = .36, c = .62, l = .15, u = 0, d = 0, f = 0, v = 0, y = +(m.current === "speaking"), b = X(h.current), x = m.current === "listening" ? b : 0, S = m.current === "speaking" ? b : 0, C = (e) => {
823
+ let t = Math.min((e - a) / 1e3, .05);
824
+ a = e;
825
+ let n = m.current, p = g.current, _ = X(h.current);
826
+ b = p ? 0 : Z(b, _, _ > b ? 15 : 7, t);
827
+ let w = n === "listening" ? b : 0, T = n === "speaking" ? b : 0;
828
+ x = p ? 0 : Z(x, w, w > x ? 17 : 7, t), S = p ? 0 : Z(S, T, T > S ? 12 : 5, t);
829
+ let E = .36, D = .62, O = .15;
830
+ if (n === "connecting" ? (E = .42, D = .68, O = .13) : n === "listening" ? (E = .54 + x * .26, D = .78 + x * .18, O = .18 + x * .04) : n === "thinking" ? (E = .46, D = .72, O = .16) : n === "speaking" && (E = 1.05 + S * 1.15), !p) {
831
+ s = Z(s, E, 3.6, t), c = Z(c, D, 3.6, t), l = Z(l, O, 3.6, t), y = Z(y, +(n === "speaking"), n === "speaking" ? 3.8 : 3, t), o += t * s, f += t * c;
832
+ let e = 1.2 + S * 1.35 + Math.sin(o * 1.73) * .34 + Math.sin(o * .61 + .8) * .18;
833
+ v += t * Math.max(.65, e);
834
+ let r = Math.sin(f) * l + Math.sin(f * .47 + 1.1) * .032, i = Math.sin(v * 1.08), a = Math.sin(v * 2.47 + .9), p = Math.sin(v * .43 - .5), m = r + (i * (.13 + S * .17) + a * (.035 + S * .035) + p * .055 - r) * y, h = 4.2 + y * 3, g = h * h, _ = 2 * h;
835
+ d += ((m - u) * g - d * _) * t, u += d * t;
836
+ }
837
+ r?.draw(o, u, x, S), i = requestAnimationFrame(C);
838
+ };
839
+ return i = requestAnimationFrame(C), () => {
840
+ cancelAnimationFrame(i), t.removeEventListener("change", n), r?.destroy();
841
+ };
842
+ }, [_]);
843
+ let y = he(e), b = e === "connecting", x = _ + (u ? v * .5 : 0), S = {
844
+ "--orb-ui-radial-control-surround": "#fff",
845
+ width: i,
846
+ height: i,
847
+ display: "flex",
848
+ alignItems: "center",
849
+ justifyContent: "center",
850
+ position: "relative",
851
+ ...c
852
+ }, C = /* @__PURE__ */ o("span", {
853
+ style: {
854
+ position: "relative",
855
+ display: "block",
856
+ width: _,
857
+ height: x,
858
+ lineHeight: 0
859
+ },
860
+ children: [/* @__PURE__ */ a("canvas", {
861
+ ref: p,
862
+ "aria-hidden": "true",
863
+ "data-radial-surface": "",
864
+ style: {
865
+ position: "absolute",
866
+ left: 0,
867
+ top: 0,
868
+ display: "block",
869
+ width: _,
870
+ height: _,
871
+ borderRadius: "50%",
872
+ background: "conic-gradient(from 12deg, #06358d 0deg, #0b65b5 72deg, #c7f1ef 92deg, #45c2c8 172deg, #06358d 196deg, #0b65b5 254deg, #c7f1ef 278deg, #45c2c8 360deg)"
873
+ }
874
+ }), u ? /* @__PURE__ */ a("button", {
875
+ ...f,
876
+ type: "button",
877
+ "data-radial-control": "",
878
+ disabled: l,
879
+ onClick: l ? void 0 : d,
880
+ style: {
881
+ appearance: "none",
882
+ WebkitAppearance: "none",
883
+ position: "absolute",
884
+ left: "50%",
885
+ top: _ - v * .52,
886
+ width: v,
887
+ height: v,
888
+ display: "flex",
889
+ alignItems: "center",
890
+ justifyContent: "center",
891
+ boxSizing: "border-box",
892
+ padding: 0,
893
+ margin: 0,
894
+ border: 0,
895
+ borderRadius: "50%",
896
+ background: b ? "#9da1aa" : y ? "#ef4146" : "#080808",
897
+ color: "#fff",
898
+ boxShadow: `0 0 0 ${Math.max(3, v * .085)}px var(--orb-ui-radial-control-surround), 0 2px 5px rgba(0, 0, 0, 0.18)`,
899
+ cursor: l ? "not-allowed" : "pointer",
900
+ opacity: l ? .52 : 1,
901
+ transform: "translateX(-50%)",
902
+ transition: "background 160ms ease, opacity 160ms ease, transform 160ms ease",
903
+ font: "inherit"
904
+ },
905
+ children: b ? /* @__PURE__ */ a("span", {
906
+ "aria-hidden": "true",
907
+ "data-radial-spinner": "",
908
+ style: {
909
+ width: "42%",
910
+ height: "42%",
911
+ boxSizing: "border-box",
912
+ border: `${Math.max(1.5, v * .055)}px solid rgba(255, 255, 255, 0.38)`,
913
+ borderTopColor: "#fff",
914
+ borderRightColor: "#fff",
915
+ borderRadius: "50%",
916
+ animation: "orb-radial-spinner 760ms linear infinite"
917
+ }
918
+ }) : /* @__PURE__ */ a(ge, { active: y })
919
+ }) : null]
920
+ });
921
+ return u ? /* @__PURE__ */ a("div", {
922
+ className: s,
923
+ style: S,
924
+ children: C
925
+ }) : /* @__PURE__ */ a("div", {
926
+ ...f,
927
+ className: s,
928
+ style: S,
929
+ children: C
930
+ });
931
+ }
932
+ //#endregion
714
933
  //#region src/components/Orb/Orb.tsx
715
934
  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
935
  let [b, x] = i({ state: "idle" });
@@ -747,7 +966,11 @@ function $({ signal: n, state: r, volume: o, adapter: l, theme: u = "debug", siz
747
966
  ...N,
748
967
  onClick: A
749
968
  });
750
- case "cloud": return /* @__PURE__ */ a(ie, {
969
+ case "cloud": return /* @__PURE__ */ a(se, {
970
+ ...N,
971
+ onClick: A
972
+ });
973
+ case "radial": return /* @__PURE__ */ a(_e, {
751
974
  ...N,
752
975
  onClick: A
753
976
  });
@@ -2,3 +2,4 @@ export { DebugTheme } from './debug/index.js';
2
2
  export { CircleTheme } from './circle/index.js';
3
3
  export { BarsTheme } from './bars/index.js';
4
4
  export { CloudTheme } from './cloud/index.js';
5
+ export { RadialTheme } from './radial/index.js';
@@ -0,0 +1,13 @@
1
+ import { OrbHtmlAttributes, OrbState, OrbStyle } from '../../components/Orb/Orb.types.js';
2
+ interface RadialThemeProps extends OrbHtmlAttributes {
3
+ state: OrbState;
4
+ volume: number;
5
+ size: number;
6
+ className?: string;
7
+ style?: OrbStyle;
8
+ disabled?: boolean;
9
+ interactive?: boolean;
10
+ onClick?: () => void;
11
+ }
12
+ export declare function RadialTheme({ state, volume, size, className, style, disabled, interactive, onClick, ...controlProps }: RadialThemeProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1 @@
1
+ export { RadialTheme } from './RadialTheme.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orb-ui",
3
- "version": "0.6.1",
3
+ "version": "0.7.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",