@kitn.ai/ui 0.19.0 → 0.20.1

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.
Files changed (236) hide show
  1. package/LICENSE +6 -0
  2. package/NOTICE +54 -0
  3. package/dist/components/audio-visualizer/audio-visualizer.voice-fixture.d.ts +59 -0
  4. package/dist/components/audio-visualizer/aurora.glsl.d.ts +114 -0
  5. package/dist/components/audio-visualizer/index.d.ts +155 -0
  6. package/dist/components/audio-visualizer/shader-canvas.d.ts +130 -0
  7. package/dist/components/audio-visualizer/sizes.d.ts +25 -0
  8. package/dist/components/audio-visualizer/variant-aurora.d.ts +89 -0
  9. package/dist/components/audio-visualizer/variant-bar.d.ts +46 -0
  10. package/dist/components/audio-visualizer/variant-custom.d.ts +73 -0
  11. package/dist/components/audio-visualizer/variant-grid.d.ts +22 -0
  12. package/dist/components/audio-visualizer/variant-radial.d.ts +13 -0
  13. package/dist/components/audio-visualizer/variant-wave.d.ts +11 -0
  14. package/dist/components/audio-visualizer/wave.glsl.d.ts +16 -0
  15. package/dist/create-tween-hvpmSuwW.js +7 -0
  16. package/dist/custom-elements.json +282 -0
  17. package/dist/elements/agent-card.js +1 -1
  18. package/dist/elements/artifact.js +1 -1
  19. package/dist/elements/attachments.js +1 -1
  20. package/dist/elements/audio-visualizer.d.ts +1 -0
  21. package/dist/elements/audio-visualizer.js +1 -0
  22. package/dist/elements/autoloader.js +1 -1
  23. package/dist/elements/avatar.js +1 -1
  24. package/dist/elements/badge.js +1 -1
  25. package/dist/elements/button.js +1 -1
  26. package/dist/elements/card.js +1 -1
  27. package/dist/elements/cards.js +1 -1
  28. package/dist/elements/chain-of-thought.js +1 -1
  29. package/dist/elements/chat-scope-picker.js +1 -1
  30. package/dist/elements/chat-workspace.js +1 -1
  31. package/dist/elements/chat.js +1 -1
  32. package/dist/elements/checkpoint.js +1 -1
  33. package/dist/elements/choice.js +1 -1
  34. package/dist/elements/chunks/{Icon-11SRdjJ4.js → Icon-Tj58ES_d.js} +1 -1
  35. package/dist/elements/chunks/{action-icons-CtRg17uX.js → action-icons-ns1Fnedj.js} +1 -1
  36. package/dist/elements/chunks/arrow-left-DQocUFvy.js +1 -0
  37. package/dist/elements/chunks/{attachments-CBqQRh60.js → attachments-mCB5F1Fq.js} +1 -1
  38. package/dist/elements/chunks/audio-visualizer-BqNy7dfm.js +1 -0
  39. package/dist/elements/chunks/{badge-CxklEXQm.js → badge-B4Zuajl2.js} +1 -1
  40. package/dist/elements/chunks/{button-BD7lUvVB.js → button-ZWNif3--.js} +1 -1
  41. package/dist/elements/chunks/{card-B-PRGXdj.js → card-BkHbp4BA.js} +1 -1
  42. package/dist/elements/chunks/{chat-thread-DIZbRIKG.js → chat-thread-CkRN6pZ7.js} +1 -1
  43. package/dist/elements/chunks/check-B9-gn6SS.js +1 -0
  44. package/dist/elements/chunks/chevron-down-BNsxc2hk.js +1 -0
  45. package/dist/elements/chunks/chevron-right-Hv00StBO.js +1 -0
  46. package/dist/elements/chunks/circle-0e3KJTDr.js +1 -0
  47. package/dist/elements/chunks/circle-check-BNAS0JEy.js +1 -0
  48. package/dist/elements/chunks/{circle-x-mtjCO_Ok.js → circle-x-B7faJFlY.js} +1 -1
  49. package/dist/elements/chunks/{code-block-BeWVttmU.js → code-block-BFUHn6Va.js} +1 -1
  50. package/dist/elements/chunks/collapsible-DM1Ckd4e.js +1 -0
  51. package/dist/elements/chunks/{composer-CavJww3d.js → composer-BguS0QL_.js} +2 -2
  52. package/dist/elements/chunks/{context-CnlsNJSJ.js → context-Cb7k4F-v.js} +1 -1
  53. package/dist/elements/chunks/{conversation-list-5O_KdI_I.js → conversation-list-CvoAkWhN.js} +1 -1
  54. package/dist/elements/chunks/create-tween-oVvAIG8r.js +7 -0
  55. package/dist/elements/chunks/{default-input-CB46cJJ1.js → default-input-Cqqilg9t.js} +1 -1
  56. package/dist/elements/chunks/define-D1din7Ld.js +1 -0
  57. package/dist/elements/chunks/{disclosure-BtFK3a-M.js → disclosure-CIZ5c8nO.js} +1 -1
  58. package/dist/elements/chunks/{download-qJv1dS3M.js → download-Dsbg3ste.js} +1 -1
  59. package/dist/elements/chunks/{dropdown-UhtAueYR.js → dropdown-BDd1-Zgi.js} +1 -1
  60. package/dist/elements/chunks/{ellipsis-B1sOOqiJ.js → ellipsis-Dw6qrss-.js} +1 -1
  61. package/dist/elements/chunks/{external-link-DToP_VKE.js → external-link-Vt74zAoL.js} +1 -1
  62. package/dist/elements/chunks/{file-text-BwUs_Pj4.js → file-text-CZrZF6_v.js} +1 -1
  63. package/dist/elements/chunks/{file-tree-C6RhmSnX.js → file-tree-DF4okKyo.js} +1 -1
  64. package/dist/elements/chunks/{folder-H_Xp0GYP.js → folder-glP5rha4.js} +1 -1
  65. package/dist/elements/chunks/{hover-card-Dn3yrk1l.js → hover-card-Cmm6Q53m.js} +1 -1
  66. package/dist/elements/chunks/{icon-BrxJQXzC.js → icon-BLb8beoi.js} +1 -1
  67. package/dist/elements/chunks/{info-11eT2q5H.js → info-CIsv92JK.js} +1 -1
  68. package/dist/elements/chunks/{input-B9oZKDfb.js → input-Dds1kFyt.js} +1 -1
  69. package/dist/elements/chunks/{kbd-D2fx3rWh.js → kbd-De_xbgi9.js} +1 -1
  70. package/dist/elements/chunks/{link-B-RNYWNw.js → link-i4r_k7z4.js} +1 -1
  71. package/dist/elements/chunks/{loader-BJh_aRlp.js → loader-BmQH4s3V.js} +1 -1
  72. package/dist/elements/chunks/{markdown-BIpjrDFv.js → markdown-Zi21WhUz.js} +7 -7
  73. package/dist/elements/chunks/{message-CPfqj8Gi.js → message-BqyXDN3-.js} +1 -1
  74. package/dist/elements/chunks/{message-feedback-8uj0aVYh.js → message-feedback-Djr3z6Yb.js} +1 -1
  75. package/dist/elements/chunks/message-square-vFAgbDaX.js +1 -0
  76. package/dist/elements/chunks/{minimize-2-C9qkiTJg.js → minimize-2--ifeCGrl.js} +1 -1
  77. package/dist/elements/chunks/{model-switcher-DRrMcRXH.js → model-switcher-B94YAKsM.js} +1 -1
  78. package/dist/elements/chunks/{overlay-C8_FUL8q.js → overlay-kD8dwRv_.js} +1 -1
  79. package/dist/elements/chunks/{paperclip-MA9hxLhW.js → paperclip-q21dYOSK.js} +1 -1
  80. package/dist/elements/chunks/{progress-bar-y5G6HDjg.js → progress-bar-BrAIIaaJ.js} +1 -1
  81. package/dist/elements/chunks/{prompt-suggestion-LalWvCJy.js → prompt-suggestion-Bjn2K-fR.js} +1 -1
  82. package/dist/elements/chunks/reasoning-DTpCGtnY.js +1 -0
  83. package/dist/elements/chunks/{resizable-xhYF5lCQ.js → resizable-Dp4JExql.js} +1 -1
  84. package/dist/elements/chunks/{rotate-cw-2ndEXjgS.js → rotate-cw-CFWWkpj2.js} +1 -1
  85. package/dist/elements/chunks/{scroll-area-BzOPDXrZ.js → scroll-area-Bb0kHH1j.js} +1 -1
  86. package/dist/elements/chunks/scroll-button-B0cH5fXf.js +1 -0
  87. package/dist/elements/chunks/{separator-CPvL5Xdl.js → separator-9kRgr1X9.js} +1 -1
  88. package/dist/elements/chunks/{settings-hmzIuNXD.js → settings-B8lmec4D.js} +1 -1
  89. package/dist/elements/chunks/{settings-group-BiIym17O.js → settings-group-I0hEuXiN.js} +1 -1
  90. package/dist/elements/chunks/{share-BbziTAzn.js → share-C3lTiYGt.js} +1 -1
  91. package/dist/elements/chunks/{skeleton-Bxhs1thL.js → skeleton-DSXW5Yya.js} +1 -1
  92. package/dist/elements/chunks/{star-BHL3Va5p.js → star-CSJtGxgv.js} +1 -1
  93. package/dist/elements/chunks/{store-tpnnWlxY.js → store-CHyW95TP.js} +1 -1
  94. package/dist/elements/chunks/{text-shimmer-1DCKivKx.js → text-shimmer-Cn9TmNpI.js} +1 -1
  95. package/dist/elements/chunks/{textarea-Czaowo9F.js → textarea-CUwqAX0G.js} +1 -1
  96. package/dist/elements/chunks/{thumbs-up-CdLqA13R.js → thumbs-up-PNVVThEF.js} +1 -1
  97. package/dist/elements/chunks/{toast-store-BvBquUFA.js → toast-store-DKbQn3Wn.js} +1 -1
  98. package/dist/elements/chunks/{tool-4P_ne8Go.js → tool-DjTRpIpl.js} +1 -1
  99. package/dist/elements/chunks/tooltip-CgBZCVKp.js +1 -0
  100. package/dist/elements/chunks/{triangle-alert-BllqxXq8.js → triangle-alert-DsHTHCPm.js} +1 -1
  101. package/dist/elements/chunks/{use-card-resolution-73xiddIW.js → use-card-resolution-BSu_XHjH.js} +1 -1
  102. package/dist/elements/chunks/variant-aurora-Dc4nQUia.js +218 -0
  103. package/dist/elements/chunks/variant-custom-y_3kVQhS.js +1 -0
  104. package/dist/elements/chunks/variant-wave-D5OR1-9Z.js +116 -0
  105. package/dist/elements/chunks/{video-O9rA6k7S.js → video-B7vmenoC.js} +1 -1
  106. package/dist/elements/chunks/x-GRUeeQFT.js +1 -0
  107. package/dist/elements/coachmark.js +1 -1
  108. package/dist/elements/code-block.js +1 -1
  109. package/dist/elements/command.js +1 -1
  110. package/dist/elements/compare.js +1 -1
  111. package/dist/elements/composer.js +1 -1
  112. package/dist/elements/confirm-card.js +1 -1
  113. package/dist/elements/context-meter.js +1 -1
  114. package/dist/elements/conversation-list.js +1 -1
  115. package/dist/elements/define.d.ts +11 -0
  116. package/dist/elements/dialog.js +1 -1
  117. package/dist/elements/editable-label.js +1 -1
  118. package/dist/elements/embed.js +1 -1
  119. package/dist/elements/empty.js +1 -1
  120. package/dist/elements/feedback-bar.js +1 -1
  121. package/dist/elements/file-tree.js +1 -1
  122. package/dist/elements/file-upload.js +1 -1
  123. package/dist/elements/form.js +1 -1
  124. package/dist/elements/hover-card.js +1 -1
  125. package/dist/elements/icon.js +1 -1
  126. package/dist/elements/image.js +1 -1
  127. package/dist/elements/input.js +1 -1
  128. package/dist/elements/kbd.js +1 -1
  129. package/dist/elements/link-preview.js +1 -1
  130. package/dist/elements/loader.js +1 -1
  131. package/dist/elements/markdown.js +1 -1
  132. package/dist/elements/menu.js +1 -1
  133. package/dist/elements/message-skills.js +1 -1
  134. package/dist/elements/message.js +1 -1
  135. package/dist/elements/model-switcher.js +1 -1
  136. package/dist/elements/nav.js +1 -1
  137. package/dist/elements/notice.js +1 -1
  138. package/dist/elements/pane-group.js +1 -1
  139. package/dist/elements/pane.js +1 -1
  140. package/dist/elements/popover.js +1 -1
  141. package/dist/elements/progress-bar.js +1 -1
  142. package/dist/elements/prompt-dock.js +1 -1
  143. package/dist/elements/prompt-input.js +1 -1
  144. package/dist/elements/prompt-suggestions.js +1 -1
  145. package/dist/elements/reasoning.js +1 -1
  146. package/dist/elements/remote.js +1 -1
  147. package/dist/elements/resizable.js +1 -1
  148. package/dist/elements/response-stream.js +1 -1
  149. package/dist/elements/screen.js +1 -1
  150. package/dist/elements/scroll-area.js +1 -1
  151. package/dist/elements/scroll-button.js +1 -1
  152. package/dist/elements/search.js +1 -1
  153. package/dist/elements/segmented.js +1 -1
  154. package/dist/elements/separator.js +1 -1
  155. package/dist/elements/setting-item.js +1 -1
  156. package/dist/elements/settings-group.js +1 -1
  157. package/dist/elements/skeleton.js +1 -1
  158. package/dist/elements/slots.d.ts +12 -0
  159. package/dist/elements/source.js +1 -1
  160. package/dist/elements/status.js +1 -1
  161. package/dist/elements/switch.js +1 -1
  162. package/dist/elements/tabs.js +1 -1
  163. package/dist/elements/tasks.js +1 -1
  164. package/dist/elements/text-shimmer.js +1 -1
  165. package/dist/elements/thinking-bar.js +1 -1
  166. package/dist/elements/thread.js +1 -1
  167. package/dist/elements/toast.js +1 -1
  168. package/dist/elements/tool.js +1 -1
  169. package/dist/elements/tooltip.js +1 -1
  170. package/dist/elements/voice-input.js +1 -1
  171. package/dist/elements/voice-output.js +1 -1
  172. package/dist/elements.d.ts +38 -0
  173. package/dist/index.js +18 -17
  174. package/dist/index.server.js +16404 -0
  175. package/dist/kai.es.js +1 -1
  176. package/dist/llms/llms-full.txt +40 -4
  177. package/dist/llms/llms.txt +3 -3
  178. package/dist/primitives/audio-bands.d.ts +106 -0
  179. package/dist/primitives/create-tween.d.ts +33 -0
  180. package/dist/primitives/use-audio-analysis.d.ts +149 -0
  181. package/dist/primitives/use-sequencer.d.ts +13 -0
  182. package/dist/primitives/use-voice-recorder.d.ts +1 -0
  183. package/dist/primitives/visualizer-sequences.d.ts +39 -0
  184. package/dist/react/index.d.ts +41 -0
  185. package/dist/react.js +159 -153
  186. package/dist/register-impl-DQyejdfb.js +145 -0
  187. package/dist/test-utils/fake-clock.d.ts +45 -0
  188. package/dist/variant-aurora-DVtGqVH6.js +218 -0
  189. package/dist/variant-custom-Dif-IV4u.js +1 -0
  190. package/dist/variant-wave-DbfNdvSi.js +116 -0
  191. package/frameworks/react/index.tsx +42 -0
  192. package/llms-full.txt +40 -4
  193. package/llms.txt +3 -3
  194. package/package.json +11 -3
  195. package/src/components/audio-visualizer/audio-visualizer.voice-fixture.ts +257 -0
  196. package/src/components/audio-visualizer/aurora.glsl.ts +330 -0
  197. package/src/components/audio-visualizer/index.tsx +442 -0
  198. package/src/components/audio-visualizer/shader-canvas.tsx +846 -0
  199. package/src/components/audio-visualizer/sizes.ts +54 -0
  200. package/src/components/audio-visualizer/variant-aurora.tsx +299 -0
  201. package/src/components/audio-visualizer/variant-bar.tsx +143 -0
  202. package/src/components/audio-visualizer/variant-custom.tsx +338 -0
  203. package/src/components/audio-visualizer/variant-grid.tsx +170 -0
  204. package/src/components/audio-visualizer/variant-radial.tsx +158 -0
  205. package/src/components/audio-visualizer/variant-wave.tsx +125 -0
  206. package/src/components/audio-visualizer/wave.glsl.ts +130 -0
  207. package/src/components/component-meta.json +24 -24
  208. package/src/elements/audio-visualizer.tsx +183 -0
  209. package/src/elements/compiled.css +1 -1
  210. package/src/elements/define.tsx +12 -1
  211. package/src/elements/element-manifest.json +4 -0
  212. package/src/elements/element-meta.json +170 -0
  213. package/src/elements/element-types.d.ts +38 -0
  214. package/src/elements/register-impl.ts +1 -0
  215. package/src/elements/slots.ts +35 -0
  216. package/src/primitives/audio-bands.ts +174 -0
  217. package/src/primitives/create-tween.ts +214 -0
  218. package/src/primitives/use-audio-analysis.ts +321 -0
  219. package/src/primitives/use-sequencer.ts +53 -0
  220. package/src/primitives/use-voice-recorder.ts +16 -4
  221. package/src/primitives/visualizer-sequences.ts +350 -0
  222. package/src/test-utils/fake-clock.ts +88 -0
  223. package/dist/elements/chunks/arrow-left-CifsGq8x.js +0 -1
  224. package/dist/elements/chunks/check-CUKS495w.js +0 -1
  225. package/dist/elements/chunks/chevron-down-AELmYT1j.js +0 -1
  226. package/dist/elements/chunks/chevron-right-C8g26oKh.js +0 -1
  227. package/dist/elements/chunks/circle-DGcI8Cft.js +0 -1
  228. package/dist/elements/chunks/circle-check-DuU0IcBQ.js +0 -1
  229. package/dist/elements/chunks/collapsible-DGjADCN6.js +0 -1
  230. package/dist/elements/chunks/define-DfTe4zwZ.js +0 -1
  231. package/dist/elements/chunks/message-square-CCSQ4M9g.js +0 -1
  232. package/dist/elements/chunks/reasoning-CW3SDdb4.js +0 -1
  233. package/dist/elements/chunks/scroll-button-B1x4cYqM.js +0 -1
  234. package/dist/elements/chunks/tooltip-CBeFqJKk.js +0 -1
  235. package/dist/elements/chunks/x-DeS3rQhx.js +0 -1
  236. package/dist/register-impl-CaaHJcea.js +0 -145
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Size scales for the audio visualizer variants.
3
+ *
4
+ * Values carried from livekit/components-js `packages/shadcn/components/agents-ui/`
5
+ * (Apache License 2.0). Kept as numbers rather than Tailwind classes so bar
6
+ * counts and radii can be interpolated: upstream hardcodes arbitrary values
7
+ * (`w-[4px]`) in cva variants, which cannot vary with a runtime count.
8
+ */
9
+
10
+ export type VisualizerSize = 'icon' | 'sm' | 'md' | 'lg' | 'xl';
11
+
12
+ export const SIZES: readonly VisualizerSize[] = ['icon', 'sm', 'md', 'lg', 'xl'];
13
+
14
+ /** Overall height of the bar and radial containers, in px. */
15
+ export const CONTAINER_HEIGHT: Record<VisualizerSize, number> = {
16
+ icon: 24, sm: 56, md: 112, lg: 224, xl: 448,
17
+ };
18
+
19
+ /** Gap between bars, in px. */
20
+ export const GAP: Record<VisualizerSize, number> = {
21
+ icon: 2, sm: 4, md: 8, lg: 16, xl: 32,
22
+ };
23
+
24
+ /** Bar width, in px. Doubles as the bar's min-height so a dot shows at zero. */
25
+ export const BAR_WIDTH: Record<VisualizerSize, number> = {
26
+ icon: 4, sm: 8, md: 16, lg: 32, xl: 64,
27
+ };
28
+
29
+ /** Grid cell diameter, in px. */
30
+ export const GRID_CELL: Record<VisualizerSize, number> = {
31
+ icon: 2, sm: 4, md: 8, lg: 12, xl: 16,
32
+ };
33
+
34
+ /** Grid gap, in px. Note this diverges from GAP above at lg and xl. */
35
+ export const GRID_GAP: Record<VisualizerSize, number> = {
36
+ icon: 2, sm: 4, md: 8, lg: 12, xl: 16,
37
+ };
38
+
39
+ /** Distance from center to the radial ring, in px. */
40
+ export const RADIAL_RADIUS: Record<VisualizerSize, number> = {
41
+ icon: 6, sm: 16, md: 32, lg: 64, xl: 128,
42
+ };
43
+
44
+ export function defaultBarCount(size: VisualizerSize): number {
45
+ return size === 'icon' || size === 'sm' ? 3 : 5;
46
+ }
47
+
48
+ export function defaultRadialBarCount(size: VisualizerSize): number {
49
+ return size === 'icon' || size === 'sm' ? 12 : 24;
50
+ }
51
+
52
+ export function defaultGridCount(size: VisualizerSize): number {
53
+ return size === 'icon' ? 3 : 5;
54
+ }
@@ -0,0 +1,299 @@
1
+ import { createEffect, createSignal, onCleanup, type Accessor, type JSX } from 'solid-js';
2
+ import { ShaderCanvas, hexToRgb, DEFAULT_SHADER_COLOR } from './shader-canvas';
3
+ import { createTween } from '../../primitives/create-tween';
4
+ import type { VisualizerState } from '../../primitives/visualizer-sequences';
5
+ import { CONTAINER_HEIGHT } from './sizes';
6
+ import type { ShaderVariantProps } from './index';
7
+ import auroraShader from './aurora.glsl';
8
+
9
+ /**
10
+ * Per-state uniform targets, straight from fact sheet section 5's measured
11
+ * table (`.superpowers/sdd/2026-08-07-audio-visualizers/reference/
12
+ * aura-prototype/lk-aura-factsheet.md`) and reconciled against `aurora.glsl.ts`'s
13
+ * own module doc / the Task 14 report's "Uniform list for Task 15" table.
14
+ *
15
+ * ATTRIBUTION: these same values are upstream's, and upstream's copy is
16
+ * Apache-2.0. They live in `packages/shadcn/hooks/agents-ui/
17
+ * use-agent-audio-visualizer-aura.ts` -- the aura DRIVING hook, which carries
18
+ * no Polyform header and is ordinary Apache-2.0 code, unlike the aura
19
+ * COMPONENT and its inline shader. Every row below matches that hook: the
20
+ * four state rows, the listening spring (1.0s, bounce 0.35), the tween and
21
+ * pulse cadences, and the analyser settings the visualizer feeds from
22
+ * (fftSize 512, smoothingTimeConstant 0.55). Recorded in `packages/ui/NOTICE`
23
+ * as an attribution rather than a port, since no code was copied. This is
24
+ * the BEHAVIOUR layer only -- `aurora.glsl.ts` (the rendering) is original
25
+ * work and owes the hook nothing. See `docs/provenance/aurora-clean-room.md`
26
+ * section 7 for the license map that separates the two upstream files.
27
+ *
28
+ * Deliberately NOT `shaderTargets()` (primitives/visualizer-sequences.ts):
29
+ * that helper only carries two axes -- a 0..1 "energy" intensity and a 1..4
30
+ * speed -- built for the OLD custom/aura convention. This shader's real table
31
+ * is non-monotonic across those same two axes (thinking/connecting has LOWER
32
+ * amplitude than idle despite HIGHER brightness) and every value below is a
33
+ * direct fact-sheet pass-through, not a normalized knob, so reusing that
34
+ * helper cannot reproduce it. The Task 14 report calls this out explicitly
35
+ * and asks for this shader's own mapping, parallel to how `waveTargets()`
36
+ * already exists alongside `shaderTargets()` for the wave shader.
37
+ *
38
+ * `speed` here is fact sheet section 5's `S / 20` (state speed 10..70,
39
+ * divided by 20) -- NOT the raw 10..70 value. `complexity` is `freqParam`
40
+ * directly.
41
+ *
42
+ * `rotation` (deg/s, positive = clockwise ON SCREEN) is NOT from the fact
43
+ * sheet: it is this port's own solid-body trim on top of the wind's
44
+ * emergent angular drift, calibrated offline (campaign task #6's probe,
45
+ * replicating scripts/aurora-audit.mjs's estimator at its capture cadence)
46
+ * so the audit-measured per-state rotation lands on the reference values:
47
+ * speaking ~+17 (their +12.9, Rob's reference ~20 CW), listening ~+4.6,
48
+ * thinking ~+9. The wind supplies most of the apparent motion (post-flip
49
+ * it reads ~+22 CW at speaking, ~0 elsewhere); these trims close the
50
+ * per-state gaps. Like `speed`, rotation is never tweened.
51
+ *
52
+ * Connecting originally carried the probe's -4.7 CCW as a -5.5 trim,
53
+ * flipped to the clockwise equivalent (same magnitude) 2026-08-10
54
+ * (supervisor call, Rob delegated): the direction split came from the
55
+ * screenshot-cadence estimator later shown unreliable (closing-sweep
56
+ * finding: IQR swamps the medians), upstream's hook drives thinking and
57
+ * connecting with identical dynamics, and opposite spins on adjacent
58
+ * transitional states read inconsistent. Single-line revert (connecting's
59
+ * `rotation` below) if the eye test ever disagrees.
60
+ */
61
+ function auroraTargets(state: VisualizerState): {
62
+ intensity: number | [number, number];
63
+ speed: number;
64
+ complexity: number;
65
+ amplitude: number;
66
+ scale: number;
67
+ rotation: number;
68
+ } {
69
+ switch (state) {
70
+ case 'listening':
71
+ return {
72
+ intensity: [1.5, 2.0], speed: 1.0, complexity: 0.7, amplitude: 1.0, scale: 0.3,
73
+ rotation: 5.3,
74
+ };
75
+ case 'thinking':
76
+ return {
77
+ intensity: [0.5, 2.5], speed: 1.5, complexity: 1.0, amplitude: 0.5, scale: 0.3,
78
+ rotation: 9.4,
79
+ };
80
+ case 'connecting':
81
+ return {
82
+ intensity: [0.5, 2.5], speed: 1.5, complexity: 1.0, amplitude: 0.5, scale: 0.3,
83
+ // Clockwise like every other transitional state -- see the doc note
84
+ // above for the 2026-08-10 direction-unify rationale.
85
+ rotation: 5.5,
86
+ };
87
+ case 'speaking':
88
+ // The pre-voice base. While actually speaking with volume > 0, the
89
+ // scale is driven through the tween by the live-volume override
90
+ // effect below.
91
+ return {
92
+ intensity: 1.5, speed: 3.5, complexity: 1.25, amplitude: 0.75, scale: 0.3,
93
+ rotation: -3.5,
94
+ };
95
+ // Dead-connection look: mirrors idle's resting targets for now. A
96
+ // dedicated arm so the pending LiveKit measurement (their aura may dim
97
+ // differently at disconnected) can adjust it in one line.
98
+ case 'disconnected':
99
+ return {
100
+ intensity: 1.0, speed: 0.5, complexity: 0.4, amplitude: 1.2, scale: 0.2,
101
+ rotation: 0,
102
+ };
103
+ case 'idle':
104
+ default:
105
+ return {
106
+ intensity: 1.0, speed: 0.5, complexity: 0.4, amplitude: 1.2, scale: 0.2,
107
+ rotation: 0,
108
+ };
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Live `prefers-color-scheme`, used ONLY as the fallback when no caller
114
+ * supplies `props.dark` -- see `AuroraVisualizer`'s `resolvedDark` below.
115
+ * That is the standalone case (this component mounted directly, with no
116
+ * facade resolving a `theme` attribute above it), and it is also why this
117
+ * defaults to light (matching `usePrefersReducedMotion` and
118
+ * `createDarkMode`'s own `false`-until-resolved default elsewhere in this
119
+ * package) until `matchMedia` resolves, and is a no-op under SSR or in an
120
+ * environment without it (jsdom included: it does not implement
121
+ * `matchMedia` at all).
122
+ *
123
+ * `<kai-audio-visualizer theme="light">` on a dark OS needs to render the
124
+ * LIGHT pipeline. This hook alone cannot know that (it only ever sees the
125
+ * OS preference, never an explicit override) -- `define.tsx`'s
126
+ * `createDarkMode` is what resolves `theme="light"|"dark"|"auto"` against
127
+ * the media query correctly (explicit wins, `auto` follows the query), one
128
+ * layer up. `props.dark` is meant to carry that ALREADY-RESOLVED boolean
129
+ * down from there; this hook only fills the gap when nothing does.
130
+ */
131
+ function usePrefersDark(): Accessor<boolean> {
132
+ const [dark, setDark] = createSignal(false);
133
+ if (typeof matchMedia === 'function') {
134
+ const mq = matchMedia('(prefers-color-scheme: dark)');
135
+ setDark(mq.matches);
136
+ const onChange = (e: MediaQueryListEvent) => setDark(e.matches);
137
+ mq.addEventListener?.('change', onChange);
138
+ onCleanup(() => mq.removeEventListener?.('change', onChange));
139
+ }
140
+ return dark;
141
+ }
142
+
143
+ /**
144
+ * A glowing, drifting aura: 36 phase-offset rings folded through a warp
145
+ * cascade into soft veils. See `aurora.glsl.ts`'s module doc for the shader
146
+ * itself and its provenance.
147
+ *
148
+ * The uniform contract is a direct pass-through of fact sheet section 5's
149
+ * measured per-state table (`auroraTargets` above), NOT the 0..1 convention
150
+ * `wave` and `custom` use. There is deliberately no `uVolume` uniform: the
151
+ * shader would double-apply voice-driven growth if it read one itself on top
152
+ * of whatever this component also does at the state layer, so the live
153
+ * volume drives the scale TWEEN here, in exactly one place (the
154
+ * volume-override effect below), and nowhere else.
155
+ *
156
+ * `dark` is an extra field on top of `ShaderVariantProps`, not yet a member
157
+ * of that shared type: it is meant to carry the FACADE's already-resolved
158
+ * `theme="light"|"dark"|"auto"` decision (see `define.tsx`'s
159
+ * `createDarkMode`), threaded down through the dispatcher, once that wiring
160
+ * lands (see the task report for the exact shape requested). Optional, with
161
+ * a live `prefers-color-scheme` fallback, so this component still works
162
+ * correctly when mounted standalone (no facade above it resolving a
163
+ * `theme` attribute at all).
164
+ */
165
+ export default function AuroraVisualizer(props: ShaderVariantProps & { dark?: boolean }): JSX.Element {
166
+ const intensity = createTween(1.0);
167
+ const speed = createTween(0.5);
168
+ const complexity = createTween(0.4);
169
+ const amplitude = createTween(1.2);
170
+ const scale = createTween(0.2);
171
+ // Fallback only -- see usePrefersDark's and resolvedDark's own docs.
172
+ const systemDark = usePrefersDark();
173
+ // An explicit `props.dark` (the facade's already-resolved theme) always
174
+ // wins; falling back to the system media query is only correct when
175
+ // nothing upstream resolved a theme at all (the standalone case).
176
+ const resolvedDark = () => props.dark ?? systemDark();
177
+
178
+ createEffect(() => {
179
+ const t = auroraTargets(props.state);
180
+ // Fact sheet section 5: "0.5 s ease-out unless noted." Frozen (reduced
181
+ // motion) settles on every target immediately instead.
182
+ const landing = props.frozen ? { duration: 0 } : { duration: 0.5, ease: 'easeOut' as const };
183
+ // Pulses (an array target, see createTween's ping-pong) run at fact
184
+ // sheet section 5's stated 0.35 s ease-out cadence -- faster than every
185
+ // other target's 0.5 s landing tween, and distinct from wave/custom's
186
+ // flat 0.5 s pulse. Frozen collapses a pulse to its first value instead
187
+ // of animating it at all.
188
+ const pulsing = props.frozen ? { duration: 0 } : { duration: 0.35, ease: 'easeOut' as const };
189
+ const intensityTarget = Array.isArray(t.intensity) && props.frozen ? t.intensity[0] : t.intensity;
190
+ intensity.to(intensityTarget, Array.isArray(t.intensity) ? pulsing : landing);
191
+
192
+ complexity.to(t.complexity, landing);
193
+ amplitude.to(t.amplitude, landing);
194
+
195
+ // Listening's scale landing is the one springy target -- the Apache
196
+ // driving hook's "perk up" (fact sheet section 5: spring 1.0 s, bounce
197
+ // 0.35; audit target 7). Every other state keeps the plain 0.5 s
198
+ // ease-out landing, and frozen collapses the spring like any tween.
199
+ scale.to(
200
+ t.scale,
201
+ props.state === 'listening' && !props.frozen
202
+ ? { type: 'spring', duration: 1.0, bounce: 0.35 }
203
+ : landing,
204
+ );
205
+
206
+ // Fact sheet section 5: "Speed is NOT tweened and multiplies absolute
207
+ // time -> every state change teleports the phase." Frozen pins it at 0
208
+ // rather than merely snapping to the state's raw target: uSpeed is the
209
+ // only thing driving the aura's continuous "wind" motion at all (there
210
+ // is no separate amplitude/opacity axis to freeze it through, unlike
211
+ // wave), so zeroing it is what actually holds the shape still.
212
+ speed.to(props.frozen ? 0 : t.speed, { duration: 0 });
213
+ });
214
+
215
+ // Voice-driven radius: "0.2 + 0.2 x volume", speaking only, instant (fact
216
+ // sheet section 5 -- measured lag in the reference capture is at or under
217
+ // 33ms). This drives the scale TWEEN imperatively, deliberately NOT a
218
+ // pure derivation, because upstream's two guard semantics live in what
219
+ // this effect does NOT do (audit targets 6 + 7):
220
+ // - `scale.animating()`: while the 0.5 s state landing (or the
221
+ // listening spring) is in flight, volume ticks are ignored -- the
222
+ // landing finishes first. Because `animating` is a signal this effect
223
+ // tracks, it re-runs the moment the landing settles and applies the
224
+ // CURRENT volume immediately, so a volume that arrived mid-landing is
225
+ // not lost until the next tick.
226
+ // - `volume > 0`: silence stops DRIVING the scale rather than reverting
227
+ // it, so a mid-speech pause holds the last voice-driven radius
228
+ // (silence-hold) until the voice resumes or the state changes -- a
229
+ // state change re-targets the tween through the effect above.
230
+ // Reads scale.animating() but never scale.value(): reading the tween's
231
+ // own value here would wire the self-retriggering effect loop
232
+ // create-tween's doc warns about.
233
+ createEffect(() => {
234
+ if (props.state !== 'speaking') return;
235
+ const volume = props.volume;
236
+ if (!(volume > 0)) return;
237
+ if (scale.animating()) return;
238
+ scale.to(0.2 + 0.2 * volume);
239
+ });
240
+
241
+ // Solid-body rotation trim (deg/s -> rad/s for the shader), never
242
+ // tweened, pinned to 0 under frozen exactly like uSpeed -- it multiplies
243
+ // absolute time in the shader, so a nonzero value would keep the figure
244
+ // spinning through reduced motion.
245
+ const rotationValue = () =>
246
+ props.frozen ? 0 : (auroraTargets(props.state).rotation * Math.PI) / 180;
247
+
248
+ // uTheme: 0 selects the shader's DARK colour pipeline, 1 selects LIGHT
249
+ // (aurora.glsl.ts, fact sheet section 4 -- a real branch in the colour
250
+ // math, not just a compositing background). Named and isolated here,
251
+ // deliberately not inlined into the uniforms object below: inverting this
252
+ // one line silently swaps the two pipelines, and both render something
253
+ // plausible, so the mapping needs to stay obvious at a glance rather than
254
+ // buried in a longer expression.
255
+ const uThemeValue = () => (resolvedDark() ? 0 : 1);
256
+
257
+ return (
258
+ <div
259
+ data-kai-state={props.state}
260
+ class={props.class}
261
+ style={{ height: `${CONTAINER_HEIGHT[props.size]}px`, 'aspect-ratio': '1' }}
262
+ >
263
+ <ShaderCanvas
264
+ fragment={auroraShader}
265
+ // Shaders are expensive on phones; mediump halves the cost. Matches
266
+ // wave/custom's identical size cutoff.
267
+ precision={props.size === 'icon' || props.size === 'sm' ? 'mediump' : 'highp'}
268
+ uniforms={{
269
+ uColor: { type: '3fv', value: hexToRgb(props.color ?? DEFAULT_SHADER_COLOR) },
270
+ uIntensity: { type: '1f', value: intensity.value() },
271
+ uSpeed: { type: '1f', value: speed.value() },
272
+ uComplexity: { type: '1f', value: complexity.value() },
273
+ uAmplitude: { type: '1f', value: amplitude.value() },
274
+ uScale: { type: '1f', value: scale.value() },
275
+ uTheme: { type: '1f', value: uThemeValue() },
276
+ uRotation: { type: '1f', value: rotationValue() },
277
+ }}
278
+ animateWhenNotVisible={props.animateWhenNotVisible}
279
+ onError={(message) => {
280
+ // "not available" is ShaderCanvas's literal wording for a missing
281
+ // WebGL context (see its own doc) -- an expected environment
282
+ // limitation, so it logs quietly. Anything else is a compile or
283
+ // link failure in this SHIPPED shader, which is a kit bug, so it
284
+ // logs loudly. `onUnavailable` fires unconditionally either way --
285
+ // no branching on whether to call it, only on how loud to log.
286
+ const missingContext = /not available/i.test(message);
287
+ if (missingContext) {
288
+ console.warn('<kai-audio-visualizer variant="aurora">: shader unavailable', message);
289
+ } else {
290
+ console.error('<kai-audio-visualizer variant="aurora">: shader error', message);
291
+ }
292
+ props.onUnavailable();
293
+ }}
294
+ />
295
+ </div>
296
+ );
297
+ }
298
+
299
+ export { auroraTargets };
@@ -0,0 +1,143 @@
1
+ import { Index, type JSX } from 'solid-js';
2
+ import { cn } from '../../utils/cn';
3
+ import { normalizeVolumeBands } from '../../primitives/audio-bands';
4
+ import { useSequencer } from '../../primitives/use-sequencer';
5
+ import { barSequence, barInterval, type VisualizerState } from '../../primitives/visualizer-sequences';
6
+ import { CONTAINER_HEIGHT, GAP, BAR_WIDTH, defaultBarCount, type VisualizerSize } from './sizes';
7
+
8
+ /** Props every DOM variant takes. The dispatcher supplies all of them. */
9
+ export interface VariantProps {
10
+ state: VisualizerState;
11
+ size: VisualizerSize;
12
+ /** Multiband levels, 0..1. Only read while `state === 'speaking'`. */
13
+ bands: number[];
14
+ /** `prefers-reduced-motion`: pin the sequencer at its first frame. */
15
+ frozen: boolean;
16
+ /** Overrides the inherited `currentColor` the bars are painted with. */
17
+ color?: string;
18
+ class?: string;
19
+ /**
20
+ * Render each element yourself. Receives the element's static index plus
21
+ * `highlighted` and `value` as live accessors, not plain values: the
22
+ * markup is only mapped once per position (see the `<Index>` note below),
23
+ * so you must CALL `highlighted()` and `value()` from inside your own JSX
24
+ * for them to stay live. Destructuring them into a plain variable freezes
25
+ * them at that moment. `::part(bar)` / `::part(bar highlighted)` (or
26
+ * `cell`) handle restyling from outside; this render-prop is for replacing
27
+ * the markup outright.
28
+ *
29
+ * In bar and grid, your returned element IS the drawn item. Radial is the
30
+ * exception: it always wraps whatever you return in its own positioning
31
+ * element, because each spoke must be absolutely placed around the ring.
32
+ * You still control the markup inside that wrapper, just not its position.
33
+ */
34
+ children?: (item: { index: number; highlighted: () => boolean; value: () => number }) => JSX.Element;
35
+ }
36
+
37
+ /**
38
+ * Vertical bars that rise with the audio while speaking, and run a scripted
39
+ * pattern in every other state.
40
+ *
41
+ * Ported from livekit/components-js
42
+ * `packages/shadcn/components/agents-ui/agent-audio-visualizer-bar.tsx`
43
+ * (Apache License 2.0).
44
+ */
45
+ export function BarVisualizer(props: VariantProps & { barCount?: number }): JSX.Element {
46
+ const count = () => props.barCount ?? defaultBarCount(props.size);
47
+
48
+ // Frozen (reduced motion) parks the sequence on frame 0 rather than stopping
49
+ // the component: the shape still reads, it just does not move.
50
+ const tick = useSequencer(() => (props.frozen ? Infinity : barInterval(props.state, count())));
51
+
52
+ const sequence = () => barSequence(props.state, count());
53
+ const highlighted = () => sequence()[tick() % sequence().length] ?? [];
54
+
55
+ // Bands only mean anything while speaking. Everywhere else the sequence is
56
+ // the whole story, so a stale level never leaks into a scripted state.
57
+ const levels = () =>
58
+ props.state === 'speaking'
59
+ ? normalizeVolumeBands(props.bands, count())
60
+ : new Array(count()).fill(0);
61
+
62
+ return (
63
+ <div
64
+ data-kai-state={props.state}
65
+ class={cn('relative flex items-center justify-center', props.class)}
66
+ style={{
67
+ height: `${CONTAINER_HEIGHT[props.size]}px`,
68
+ gap: `${GAP[props.size]}px`,
69
+ ...(props.color ? { color: props.color } : {}),
70
+ }}
71
+ >
72
+ {/*
73
+ <Index>, not <For>: Solid's <For> keys nodes by `===` on the array
74
+ VALUE, and `levels()` is an array of plain numbers that changes on
75
+ nearly every frame while speaking. That would tear down and recreate
76
+ every bar node each frame instead of patching it in place, which both
77
+ churns the DOM on the hottest path here and defeats the height/colour
78
+ transition below right at the listening -> speaking boundary (a
79
+ freshly created node has no prior value to transition from). <Index>
80
+ maps by POSITION instead, so each bar's DOM node is created once and
81
+ its `level` accessor updates in place.
82
+ */}
83
+ <Index each={levels()}>
84
+ {(level, i) => {
85
+ // `index` is a plain number (stable per position under <Index>).
86
+ // `highlighted`/`value` are live accessors, not plain values: the
87
+ // callback below runs once per position, so anything a consumer's
88
+ // render-prop wants to stay current must call these itself rather
89
+ // than close over a one-time snapshot.
90
+ const item = {
91
+ index: i,
92
+ highlighted: () => highlighted().includes(i),
93
+ value: () => level(),
94
+ };
95
+ return (
96
+ props.children?.(item) ?? (
97
+ // The lit state is a SECOND part TOKEN (`part(bar highlighted)`),
98
+ // not a `data-*` attribute selector on `::part(bar)`: a CSS
99
+ // attribute selector cannot follow a pseudo-element, so
100
+ // `::part(bar)[data-kai-highlighted="true"]` never matches
101
+ // anything from outside the shadow root. `data-kai-highlighted`
102
+ // stays on the element for the render-prop and for styling from
103
+ // inside the shadow root; `part` is the external seam.
104
+ <div
105
+ part={item.highlighted() ? 'bar highlighted' : 'bar'}
106
+ data-kai-index={item.index}
107
+ data-kai-highlighted={item.highlighted()}
108
+ class={cn(
109
+ 'rounded-full bg-current/10',
110
+ 'data-[kai-highlighted=true]:bg-current',
111
+ )}
112
+ style={{
113
+ width: `${BAR_WIDTH[props.size]}px`,
114
+ 'min-height': `${BAR_WIDTH[props.size]}px`,
115
+ height: `${level() * 100}%`,
116
+ // Deliberate, approved divergence from upstream: LiveKit's
117
+ // source only transitions colour, never height. That is
118
+ // byte-faithful but reads as visibly stepped once the
119
+ // demo runs at the real ~32ms analyser cadence -- the
120
+ // audio measurement itself stays instantaneous (bands are
121
+ // applied with no smoothing upstream of this component),
122
+ // so the choppiness is purely the DOM snapping straight to
123
+ // each new frame's value. 100ms is short enough to stay
124
+ // well inside the "feels instant" range for a live control
125
+ // (it only interpolates BETWEEN frames, not behind them)
126
+ // while smoothing the inter-frame step. `frozen` (prefers-
127
+ // reduced-motion) disables the transition entirely rather
128
+ // than just skipping it for the sequencer, so a reduced-
129
+ // motion user gets an instant, static picture instead of a
130
+ // smoothed one. Anyone diffing this file against upstream:
131
+ // this is intentional, not a port slip.
132
+ transition: props.frozen
133
+ ? 'none'
134
+ : 'height 100ms ease-linear, background-color 250ms ease-linear',
135
+ }}
136
+ />
137
+ )
138
+ );
139
+ }}
140
+ </Index>
141
+ </div>
142
+ );
143
+ }