mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 03:14:00 +00:00
feat(voice): render the voice control from a presenter
createVoiceControl now returns a presenter instead of building the control with innerHTML: the session, cost, input, card and panel owners write its state by part and listen for interactions, and VoiceControl.vue renders it in the command dock, between the location bar and the visual presets as before. Focus moves wait for the render; the waveform's bars publish apart from the control and only when they change; the minutes field keeps a draft until its owner writes it. Owner tests use a real presenter on their own store, and view tests render the control.
This commit is contained in:
1 parent
2ffd7a4afd
commit
1de4f635ca
47 files changed
+1691
-1645
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
|
||||
/**
|
||||
* The voice control as the command dock renders it. The voice control
|
||||
* presenter (src/voice/control.js) holds the control's state for the session
|
||||
* owners and publishes it here; the view sends clicks, keys and form changes
|
||||
* back to the connected presenter.
|
||||
*/
|
||||
export const useVoiceStore = defineStore('gev-voice', () => {
|
||||
/** The presented control; null while no voice session owns one. */
|
||||
const view = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
||||
function publish(next) {
|
||||
view.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/** The presenter the view calls, or null while none is wired. */
|
||||
const controls = shallowRef(null);
|
||||
|
||||
/** @param {?object} next The presenter, or null to disconnect. */
|
||||
function connect(next) {
|
||||
controls.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/**
|
||||
* The waveform's bars, apart from the view: they change every animation
|
||||
* frame while voice is live, and only the visualizer renders them.
|
||||
*/
|
||||
const bars = shallowRef(null);
|
||||
|
||||
/** @param {?Array<{level: string, opacity: string}>} next */
|
||||
function publishBars(next) {
|
||||
bars.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
return { view, publish, controls, connect, bars, publishBars };
|
||||
});
|
||||
Reference in new issue
Block a user