kodeui 0.0.0-stage → 0.1.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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/bin/kodeui.mjs +89 -0
  4. package/package.json +37 -4
  5. package/skill/kodeui/SKILL.md +105 -0
  6. package/skill/kodeui/assets/tokens.css +40 -0
  7. package/skill/kodeui/components/aurora-input/AuroraInput.tsx +153 -0
  8. package/skill/kodeui/components/aurora-input/aurora-input.css +218 -0
  9. package/skill/kodeui/components/aurora-input/index.ts +2 -0
  10. package/skill/kodeui/components/bloom-wall/BloomWall.tsx +90 -0
  11. package/skill/kodeui/components/bloom-wall/bloom-wall.css +10 -0
  12. package/skill/kodeui/components/bloom-wall/engine.ts +1022 -0
  13. package/skill/kodeui/components/bloom-wall/icons/icons-a.ts +818 -0
  14. package/skill/kodeui/components/bloom-wall/icons/icons-b.ts +827 -0
  15. package/skill/kodeui/components/bloom-wall/icons/index.ts +25 -0
  16. package/skill/kodeui/components/bloom-wall/icons/types.ts +8 -0
  17. package/skill/kodeui/components/bloom-wall/index.ts +12 -0
  18. package/skill/kodeui/components/bloom-wall/paint.ts +113 -0
  19. package/skill/kodeui/components/bloom-wall/palettes.ts +32 -0
  20. package/skill/kodeui/components/blur-in-text/BlurInText.tsx +53 -0
  21. package/skill/kodeui/components/blur-in-text/blur-in-text.css +14 -0
  22. package/skill/kodeui/components/blur-in-text/index.ts +2 -0
  23. package/skill/kodeui/components/glass-reveal/GlassReveal.tsx +108 -0
  24. package/skill/kodeui/components/glass-reveal/glass-reveal.css +126 -0
  25. package/skill/kodeui/components/glass-reveal/index.ts +2 -0
  26. package/skill/kodeui/components/glow-card/GlowCard.tsx +67 -0
  27. package/skill/kodeui/components/glow-card/glow-card.css +134 -0
  28. package/skill/kodeui/components/glow-card/index.ts +2 -0
  29. package/skill/kodeui/components/launch-chip/LaunchChip.tsx +180 -0
  30. package/skill/kodeui/components/launch-chip/icons.tsx +119 -0
  31. package/skill/kodeui/components/launch-chip/index.ts +3 -0
  32. package/skill/kodeui/components/launch-chip/launch-chip.css +345 -0
  33. package/skill/kodeui/components/ring-reveal/RingReveal.tsx +84 -0
  34. package/skill/kodeui/components/ring-reveal/index.ts +4 -0
  35. package/skill/kodeui/components/ring-reveal/ring-reveal.css +10 -0
  36. package/skill/kodeui/components/ring-reveal/ring.ts +298 -0
  37. package/skill/kodeui/components/rolling-text/RollingText.tsx +121 -0
  38. package/skill/kodeui/components/rolling-text/index.ts +4 -0
  39. package/skill/kodeui/components/rolling-text/roll.ts +94 -0
  40. package/skill/kodeui/components/rolling-text/rolling-text.css +43 -0
  41. package/skill/kodeui/components/use-live-transcript/index.ts +2 -0
  42. package/skill/kodeui/components/use-live-transcript/useLiveTranscript.ts +215 -0
  43. package/skill/kodeui/components/voice-input/VoiceInput.tsx +273 -0
  44. package/skill/kodeui/components/voice-input/icons.tsx +27 -0
  45. package/skill/kodeui/components/voice-input/index.ts +4 -0
  46. package/skill/kodeui/components/voice-input/useVoiceRecorder.ts +289 -0
  47. package/skill/kodeui/components/voice-input/voice-input.css +34 -0
  48. package/skill/kodeui/components/voice-note/VoiceNote.tsx +170 -0
  49. package/skill/kodeui/components/voice-note/index.ts +3 -0
  50. package/skill/kodeui/components/voice-note/noteFile.ts +25 -0
  51. package/skill/kodeui/components/voice-note/voice-note.css +45 -0
  52. package/skill/kodeui/references/aurora-input.md +44 -0
  53. package/skill/kodeui/references/bloom-wall.md +59 -0
  54. package/skill/kodeui/references/blur-in-text.md +17 -0
  55. package/skill/kodeui/references/frameworks.md +46 -0
  56. package/skill/kodeui/references/glass-reveal.md +40 -0
  57. package/skill/kodeui/references/glow-card.md +48 -0
  58. package/skill/kodeui/references/launch-chip.md +37 -0
  59. package/skill/kodeui/references/recipes.md +77 -0
  60. package/skill/kodeui/references/ring-reveal.md +35 -0
  61. package/skill/kodeui/references/rolling-text.md +19 -0
  62. package/skill/kodeui/references/theming.md +45 -0
  63. package/skill/kodeui/references/use-live-transcript.md +28 -0
  64. package/skill/kodeui/references/voice-input.md +60 -0
  65. package/skill/kodeui/references/voice-note.md +22 -0
  66. package/skill/kodeui/scripts/add.mjs +192 -0
  67. package/skill/kodeui/scripts/manifest.json +92 -0
@@ -0,0 +1,215 @@
1
+ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
2
+
3
+ /*
4
+ * useLiveTranscript: speech to text while you talk, with the browser's own
5
+ * speech recognition (the Web Speech API).
6
+ *
7
+ * Privacy: the recognition is done by the browser's speech service, not on
8
+ * this page. Chrome sends the audio to Google's servers and Edge sends it to
9
+ * Microsoft's. Safari uses Apple's service. Firefox has no service, so
10
+ * `supported` is false there. Only start it when the person has asked for it.
11
+ */
12
+
13
+ // The Web Speech API is not in TypeScript's DOM types, so here is the part we use.
14
+ interface SpeechResultEvent extends Event {
15
+ readonly resultIndex: number;
16
+ readonly results: SpeechRecognitionResultList;
17
+ }
18
+ interface SpeechErrorEvent extends Event {
19
+ readonly error: string;
20
+ }
21
+ interface SpeechEngine extends EventTarget {
22
+ continuous: boolean;
23
+ interimResults: boolean;
24
+ lang: string;
25
+ onresult: ((ev: SpeechResultEvent) => void) | null;
26
+ onerror: ((ev: SpeechErrorEvent) => void) | null;
27
+ onend: ((ev: Event) => void) | null;
28
+ start(): void;
29
+ stop(): void;
30
+ abort(): void;
31
+ }
32
+ type SpeechEngineClass = new () => SpeechEngine;
33
+
34
+ /** The browser's speech recognition class, or null where there is none (and on the server). */
35
+ export function getSpeechRecognition(): SpeechEngineClass | null {
36
+ if (typeof window === 'undefined') return null;
37
+ const w = window as unknown as { SpeechRecognition?: SpeechEngineClass; webkitSpeechRecognition?: SpeechEngineClass };
38
+ return w.SpeechRecognition ?? w.webkitSpeechRecognition ?? null;
39
+ }
40
+
41
+ export interface LiveTranscriptOptions {
42
+ /** BCP 47 language, e.g. 'en-GB'. Default: the browser's language, else 'en-US'. */
43
+ lang?: string;
44
+ /** Keep listening through pauses (and start again when the service ends a session). Default true. */
45
+ continuous?: boolean;
46
+ /** Report words that are still being worked out, in `interim`. Default true. */
47
+ interim?: boolean;
48
+ }
49
+
50
+ export interface LiveTranscript {
51
+ /** false where the browser has no speech recognition (Firefox) and while rendering on the server. */
52
+ supported: boolean;
53
+ listening: boolean;
54
+ /** Every final word since the last reset(), across start() / stop() cycles. */
55
+ text: string;
56
+ /** Words not final yet. Show them greyed out after `text`. */
57
+ interim: string;
58
+ /** A plain sentence when something went wrong, else null. */
59
+ error: string | null;
60
+ start(): void;
61
+ /** Stop listening; words already heard still arrive in `text`. */
62
+ stop(): void;
63
+ /** Stop at once and drop the words not final yet. */
64
+ abort(): void;
65
+ /** Clear `text`, `interim` and `error`. */
66
+ reset(): void;
67
+ }
68
+
69
+ // errors after which starting again would only fail again
70
+ const FATAL = new Set(['not-allowed', 'service-not-allowed', 'audio-capture', 'network', 'language-not-supported', 'bad-grammar']);
71
+
72
+ function describeError(code: string): string {
73
+ switch (code) {
74
+ case 'not-allowed': return 'Microphone blocked: allow it in the address bar.';
75
+ case 'service-not-allowed': return 'Speech to text is turned off in this browser.';
76
+ case 'audio-capture': return 'No microphone found.';
77
+ case 'network': return 'The speech service could not be reached.';
78
+ case 'language-not-supported': return 'This language is not supported by the speech service.';
79
+ default: return `Speech to text stopped (${code}).`;
80
+ }
81
+ }
82
+
83
+ const noSubscribe = () => () => {};
84
+ const hasSpeech = () => getSpeechRecognition() !== null;
85
+ const onServer = () => false;
86
+
87
+ export function useLiveTranscript(opts: LiveTranscriptOptions = {}): LiveTranscript {
88
+ const supported = useSyncExternalStore(noSubscribe, hasSpeech, onServer);
89
+ const [listening, setListening] = useState(false);
90
+ const [text, setText] = useState('');
91
+ const [interim, setInterim] = useState('');
92
+ const [error, setError] = useState<string | null>(null);
93
+
94
+ const optsRef = useRef(opts);
95
+ optsRef.current = opts;
96
+
97
+ // live session: the engine, whether the caller still wants it running, the final words so far
98
+ const live = useRef({ engine: null as SpeechEngine | null, wanted: false, heard: '', shortRuns: 0, startedAt: 0, alive: true });
99
+
100
+ const detach = (engine: SpeechEngine) => {
101
+ engine.onresult = null;
102
+ engine.onerror = null;
103
+ engine.onend = null;
104
+ };
105
+
106
+ const start = useCallback(() => {
107
+ const s = live.current;
108
+ const Engine = getSpeechRecognition();
109
+ if (!Engine) { setError('This browser cannot turn speech into text.'); return; }
110
+ if (s.engine) { s.wanted = true; return; }
111
+
112
+ const { lang, continuous = true, interim: wantInterim = true } = optsRef.current;
113
+ const engine = new Engine();
114
+ engine.continuous = continuous;
115
+ engine.interimResults = wantInterim;
116
+ engine.lang = lang || (typeof navigator !== 'undefined' && navigator.language) || 'en-US';
117
+
118
+ engine.onresult = (ev) => {
119
+ if (live.current.engine !== engine) return;
120
+ let finals = '';
121
+ let pending = '';
122
+ for (let i = ev.resultIndex; i < ev.results.length; i++) {
123
+ const r = ev.results[i];
124
+ if (r.isFinal) finals += r[0].transcript;
125
+ else pending += r[0].transcript;
126
+ }
127
+ if (finals) { s.heard += finals; setText(s.heard); }
128
+ setInterim(pending);
129
+ };
130
+ engine.onerror = (ev) => {
131
+ if (live.current.engine !== engine) return;
132
+ if (ev.error === 'no-speech' || ev.error === 'aborted') return; // a quiet room, or our own abort
133
+ setError(describeError(ev.error));
134
+ if (FATAL.has(ev.error)) s.wanted = false;
135
+ };
136
+ engine.onend = () => {
137
+ if (live.current.engine !== engine) return;
138
+ // the service ends a session after a pause; start a new one while the caller still wants it
139
+ if (s.wanted && continuous) {
140
+ const ran = performance.now() - s.startedAt;
141
+ s.shortRuns = ran < 300 ? s.shortRuns + 1 : 0;
142
+ if (s.shortRuns < 4) {
143
+ try { s.startedAt = performance.now(); engine.start(); return; } catch { /* fall through */ }
144
+ }
145
+ }
146
+ detach(engine);
147
+ s.engine = null;
148
+ s.wanted = false;
149
+ setInterim('');
150
+ setListening(false);
151
+ };
152
+
153
+ s.engine = engine;
154
+ s.wanted = true;
155
+ s.shortRuns = 0;
156
+ s.startedAt = performance.now();
157
+ setError(null);
158
+ setListening(true);
159
+ try {
160
+ engine.start();
161
+ } catch {
162
+ detach(engine);
163
+ s.engine = null;
164
+ s.wanted = false;
165
+ setListening(false);
166
+ setError('Speech to text could not start.');
167
+ }
168
+ }, []);
169
+
170
+ const stop = useCallback(() => {
171
+ const s = live.current;
172
+ s.wanted = false;
173
+ if (!s.engine) return;
174
+ try { s.engine.stop(); } catch { /* already stopped */ }
175
+ }, []);
176
+
177
+ const abort = useCallback(() => {
178
+ const s = live.current;
179
+ s.wanted = false;
180
+ const engine = s.engine;
181
+ s.engine = null;
182
+ if (engine) {
183
+ detach(engine);
184
+ try { engine.abort(); } catch { /* already stopped */ }
185
+ }
186
+ setInterim('');
187
+ setListening(false);
188
+ }, []);
189
+
190
+ const reset = useCallback(() => {
191
+ live.current.heard = '';
192
+ setText('');
193
+ setInterim('');
194
+ setError(null);
195
+ }, []);
196
+
197
+ useEffect(() => {
198
+ const s = live.current;
199
+ s.alive = true;
200
+ return () => {
201
+ s.alive = false;
202
+ s.wanted = false;
203
+ const engine = s.engine;
204
+ s.engine = null;
205
+ if (engine) {
206
+ detach(engine);
207
+ try { engine.abort(); } catch { /* already stopped */ }
208
+ }
209
+ setListening(false);
210
+ setInterim('');
211
+ };
212
+ }, []);
213
+
214
+ return { supported, listening, text, interim, error, start, stop, abort, reset };
215
+ }
@@ -0,0 +1,273 @@
1
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import type { ReactNode } from 'react';
3
+ import { VoiceBeam, getAudioContext, LOBE_SPAN } from 'voice-glow';
4
+ import type { VoiceBeamMotion } from 'voice-glow';
5
+ import { AuroraInput, AuroraInputAction } from '../aurora-input';
6
+ import type { AuroraInputProps } from '../aurora-input';
7
+ import { VoiceNote } from '../voice-note';
8
+ import type { VoiceNoteHandle } from '../voice-note';
9
+ import { useLiveTranscript } from '../use-live-transcript';
10
+ import { useVoiceRecorder } from './useVoiceRecorder';
11
+ import type { VoiceNoteInfo, VoiceRecorderState } from './useVoiceRecorder';
12
+ import { CloseIcon, MicIcon, StopIcon } from './icons';
13
+ import './voice-input.css';
14
+
15
+ /*
16
+ * VoiceInput: the Aurora Input with a microphone.
17
+ *
18
+ * Click the mic the glow rises from the bottom of the box with your voice while it records,
19
+ * and (where the browser can) your words are typed into the box as you speak.
20
+ * Click it again the glow gathers into one beam that sweeps side to side ("Thinking…") for at
21
+ * least 1.6 s while the recording is finished, then a voice note appears.
22
+ * ✕ or Escape cancels: nothing is kept and the text goes back to what it was.
23
+ * Play the note the glow listens to the recording while it plays.
24
+ *
25
+ * Privacy: the recording itself never leaves the page. The live words (`transcribe`, on by default)
26
+ * come from the browser's speech service, which sends the audio away: Chrome to Google, Edge to
27
+ * Microsoft. Pass transcribe={false} to keep everything on the device.
28
+ */
29
+
30
+ /** Seconds for one left → right → left pass of the thinking sweep. */
31
+ export const SWEEP_PERIOD = 1.9;
32
+
33
+ /** The glow's lobe colours, centre first, then the pairs outward: fern, lagoon, bloom, sea glass, amber, aurora, firefly. */
34
+ export const NATURE_GLOW_COLORS: readonly string[] = ['#5ee08a', '#4da8ff', '#ff8fc8', '#3cd6c4', '#ffc14d', '#9d8bf7', '#e6f36a'];
35
+
36
+ const easeOut3 = (x: number) => 1 - Math.pow(1 - Math.min(1, Math.max(0, x)), 3);
37
+
38
+ /** The glow is tuned for a ~350 px input; wider boxes scale it up, from 1 at 440 px to at most 1.5. */
39
+ export function glowScaleFor(boxWidth: number): number {
40
+ return Math.min(1.5, Math.max(1, boxWidth / 440));
41
+ }
42
+
43
+ /**
44
+ * The thinking sweep at `t` seconds: the lobes gather into one beam in 0.35 s, and the beam swings
45
+ * across the box (reaching full swing in 0.5 s), a little wider where it moves fastest.
46
+ */
47
+ export function sweepMotion(t: number, boxWidth: number): VoiceBeamMotion {
48
+ const s = glowScaleFor(boxWidth);
49
+ const halfRing = (LOBE_SPAN / 2) * s; // offset is measured in half-widths of the scaled lobe ring
50
+ const swing = Math.max(0.6, (boxWidth / 2 - 90 * s) / halfRing);
51
+ const phase = (t / SWEEP_PERIOD) * Math.PI * 2;
52
+ return {
53
+ gather: easeOut3(t / 0.35),
54
+ offset: swing * Math.sin(phase) * easeOut3(t / 0.5),
55
+ stretch: 0.45 * Math.abs(Math.cos(phase)),
56
+ heldLevel: 0.55,
57
+ cornerFollow: 0,
58
+ };
59
+ }
60
+
61
+ export interface VoiceInputProps extends Omit<AuroraInputProps, 'overlay' | 'top'> {
62
+ /**
63
+ * Live words while you speak, from the browser's speech service. Default true.
64
+ * Privacy: Chrome sends that audio to Google and Edge to Microsoft; false keeps it on the device.
65
+ */
66
+ transcribe?: boolean;
67
+ /** Language for the live words, e.g. 'en-GB'. Default: the browser's language. */
68
+ lang?: string;
69
+ /** voice-glow lobe colours, centre first. Default NATURE_GLOW_COLORS. */
70
+ glowColors?: readonly string[];
71
+ /** A recording is ready. The url is revoked when the note is removed or replaced. */
72
+ onVoiceNote?: (note: VoiceNoteInfo) => void;
73
+ /** Buttons after the mic and cancel buttons (rightActions come before them). */
74
+ trailingActions?: ReactNode;
75
+ /** 1 = real time. Scales the thinking time and the sweep. */
76
+ timeScale?: number;
77
+ }
78
+
79
+ export interface VoiceInputHandle {
80
+ start(): void;
81
+ finish(): void;
82
+ cancel(): void;
83
+ /** Clear the voice note from the box (e.g. after you sent it). */
84
+ removeNote(): void;
85
+ readonly state: VoiceRecorderState;
86
+ }
87
+
88
+ export const VoiceInput = forwardRef<VoiceInputHandle, VoiceInputProps>(function VoiceInput(props, ref) {
89
+ const {
90
+ transcribe = true, lang, glowColors = NATURE_GLOW_COLORS, onVoiceNote, trailingActions, timeScale = 1,
91
+ value, defaultValue, onChange, placeholder = '', rightActions, className, disabled, ...rest
92
+ } = props;
93
+
94
+ // ---- the text: controlled when `value` is given
95
+ const [ownText, setOwnText] = useState(defaultValue ?? '');
96
+ const controlled = value !== undefined;
97
+ const text = controlled ? value : ownText;
98
+ const live = useRef({ text, controlled, onChange, onVoiceNote, transcribe });
99
+ live.current = { text, controlled, onChange, onVoiceNote, transcribe };
100
+ const setText = useCallback((next: string) => {
101
+ live.current.text = next;
102
+ if (!live.current.controlled) setOwnText(next);
103
+ live.current.onChange?.(next);
104
+ }, []);
105
+
106
+ // ---- live words: added after the text that was there when recording began
107
+ const speech = useLiveTranscript({ lang, continuous: true, interim: true });
108
+ const speechRef = useRef(speech);
109
+ speechRef.current = speech;
110
+ const session = useRef<{ base: string; text: string; interim: string } | null>(null);
111
+
112
+ const noteRef = useRef<VoiceNoteHandle>(null);
113
+ const rec = useVoiceRecorder({
114
+ timeScale,
115
+ onListen: () => {
116
+ session.current = null;
117
+ const sp = speechRef.current;
118
+ if (!live.current.transcribe || !sp.supported) return;
119
+ sp.reset();
120
+ session.current = { base: live.current.text.trim(), text: '', interim: '' };
121
+ sp.start();
122
+ },
123
+ onMicClosed: (kept) => {
124
+ const s = session.current;
125
+ if (!s) return;
126
+ if (kept) {
127
+ speechRef.current.stop(); // words still on their way are added when they arrive
128
+ } else {
129
+ speechRef.current.abort();
130
+ session.current = null;
131
+ setText(s.base);
132
+ }
133
+ },
134
+ onVoiceNote: (note) => live.current.onVoiceNote?.(note),
135
+ onStopPlayback: () => noteRef.current?.stop(),
136
+ });
137
+
138
+ useEffect(() => {
139
+ const s = session.current;
140
+ if (!s || (s.text === speech.text && s.interim === speech.interim)) return;
141
+ s.text = speech.text;
142
+ s.interim = speech.interim;
143
+ const said = (speech.text + speech.interim).trim();
144
+ setText(s.base ? (said ? s.base + ' ' + said : s.base) : said);
145
+ }, [speech.text, speech.interim, setText]);
146
+
147
+ // ---- Escape cancels a recording (or the open microphone prompt)
148
+ useEffect(() => {
149
+ const onKey = (e: KeyboardEvent) => {
150
+ const st = rec.getState();
151
+ if (e.key === 'Escape' && (st === 'listening' || st === 'requesting')) rec.cancel();
152
+ };
153
+ window.addEventListener('keydown', onKey);
154
+ return () => window.removeEventListener('keydown', onKey);
155
+ }, [rec.getState, rec.cancel]);
156
+
157
+ useImperativeHandle(ref, () => ({
158
+ start: () => { void rec.start(); },
159
+ finish: () => { void rec.finish(); },
160
+ cancel: rec.cancel,
161
+ removeNote: rec.removeNote,
162
+ get state() { return rec.getState(); },
163
+ }), [rec.start, rec.finish, rec.cancel, rec.removeNote, rec.getState]);
164
+
165
+ // ---- the glow: scaled with the box, gathered into a sweeping beam while thinking
166
+ const hostRef = useRef<HTMLDivElement>(null);
167
+ const boxWidth = useRef(0);
168
+ const [scale, setScale] = useState(1);
169
+ useEffect(() => {
170
+ const el = hostRef.current;
171
+ if (!el) return;
172
+ let first = true;
173
+ const measure = () => {
174
+ boxWidth.current = el.clientWidth;
175
+ const next = glowScaleFor(el.clientWidth);
176
+ setScale((prev) => (first || Math.abs(next - prev) > 0.02 ? next : prev));
177
+ first = false;
178
+ };
179
+ measure();
180
+ if (typeof ResizeObserver === 'undefined') {
181
+ window.addEventListener('resize', measure);
182
+ return () => window.removeEventListener('resize', measure);
183
+ }
184
+ const ro = new ResizeObserver(measure);
185
+ ro.observe(el);
186
+ return () => ro.disconnect();
187
+ }, []);
188
+
189
+ const level = useCallback(() => (rec.getState() === 'thinking' ? 0.5 : 0), [rec.getState]);
190
+ const motion = useCallback(() => {
191
+ const t = rec.sweepTime();
192
+ return t === null ? null : sweepMotion(t, boxWidth.current || hostRef.current?.clientWidth || 0);
193
+ }, [rec.sweepTime]);
194
+
195
+ const { state } = rec;
196
+ const listening = state === 'listening';
197
+ const hearing = listening || state === 'playing';
198
+ const shownPlaceholder = listening ? 'Listening…' : state === 'thinking' ? 'Thinking…' : (rec.message ?? placeholder);
199
+ const status = listening ? 'Listening' : state === 'thinking' ? 'Finishing the voice note' : (rec.message ?? '');
200
+
201
+ const overlay = (
202
+ <div className="ku-voice-glow" ref={hostRef} data-state={state}>
203
+ <VoiceBeam
204
+ stream={hearing ? rec.stream : null}
205
+ level={level}
206
+ motion={motion}
207
+ active={hearing || state === 'thinking'}
208
+ borderRadius={24}
209
+ scale={scale}
210
+ colors={glowColors as string[]}
211
+ style={{ position: 'absolute', inset: 0 }}
212
+ >
213
+ <div className="ku-voice-glow-host" />
214
+ </VoiceBeam>
215
+ </div>
216
+ );
217
+
218
+ const note = rec.note && (
219
+ <VoiceNote
220
+ key={rec.note.url}
221
+ ref={noteRef}
222
+ src={rec.note.url}
223
+ seconds={rec.note.seconds}
224
+ fileName={rec.note.fileName}
225
+ playable={state === 'idle' || state === 'playing'}
226
+ onBeforePlay={getAudioContext}
227
+ onPlayingChange={rec.setPlaying}
228
+ onRemove={rec.removeNote}
229
+ />
230
+ );
231
+
232
+ const actions = (
233
+ <>
234
+ {rightActions}
235
+ <AuroraInputAction
236
+ round
237
+ className={'ku-voice-btn ku-voice-mic' + (listening ? ' is-recording' : '')}
238
+ aria-pressed={listening}
239
+ aria-label={listening ? 'Stop and keep the recording' : 'Record your voice'}
240
+ disabled={disabled || state === 'requesting' || state === 'thinking'}
241
+ onClick={rec.toggle}
242
+ >
243
+ {listening ? <StopIcon /> : <MicIcon />}
244
+ </AuroraInputAction>
245
+ <AuroraInputAction
246
+ round
247
+ className="ku-voice-btn ku-voice-cancel"
248
+ aria-label="Cancel the recording"
249
+ hidden={!(listening || state === 'requesting')}
250
+ onClick={rec.cancel}
251
+ >
252
+ <CloseIcon />
253
+ </AuroraInputAction>
254
+ {trailingActions}
255
+ <span className="ku-voice-status" role="status" aria-live="polite">{status}</span>
256
+ </>
257
+ );
258
+
259
+ const busy = state !== 'idle' && state !== 'playing';
260
+ return (
261
+ <AuroraInput
262
+ {...rest}
263
+ value={text}
264
+ onChange={setText}
265
+ placeholder={shownPlaceholder}
266
+ disabled={disabled}
267
+ className={'ku-voice-input' + (busy ? ' is-voice' : '') + (className ? ' ' + className : '')}
268
+ overlay={overlay}
269
+ top={note || undefined}
270
+ rightActions={actions}
271
+ />
272
+ );
273
+ });
@@ -0,0 +1,27 @@
1
+ /** The voice buttons' icons, drawn for KodeUI on a 24 px grid. */
2
+
3
+ export function MicIcon() {
4
+ return (
5
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" aria-hidden="true">
6
+ <rect x="9.2" y="3.4" width="5.6" height="10.2" rx="2.8" />
7
+ <path d="M6.2 11.2a5.8 5.8 0 0 0 11.6 0" />
8
+ <path d="M12 17v3.4M9.4 20.4h5.2" />
9
+ </svg>
10
+ );
11
+ }
12
+
13
+ export function StopIcon() {
14
+ return (
15
+ <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
16
+ <rect x="7.3" y="7.3" width="9.4" height="9.4" rx="2.3" />
17
+ </svg>
18
+ );
19
+ }
20
+
21
+ export function CloseIcon() {
22
+ return (
23
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" aria-hidden="true">
24
+ <path d="M7.6 7.6l8.8 8.8M16.4 7.6l-8.8 8.8" />
25
+ </svg>
26
+ );
27
+ }
@@ -0,0 +1,4 @@
1
+ export { VoiceInput, SWEEP_PERIOD, NATURE_GLOW_COLORS, glowScaleFor, sweepMotion } from './VoiceInput';
2
+ export type { VoiceInputProps, VoiceInputHandle } from './VoiceInput';
3
+ export { useVoiceRecorder, THINK_MIN } from './useVoiceRecorder';
4
+ export type { VoiceRecorder, VoiceRecorderState, VoiceNoteInfo, UseVoiceRecorderOptions } from './useVoiceRecorder';