import {html} from "lit" import {MagicElement, mixinCss} from "@chasemoskal/magical" import {styles} from "./styles.css.js" import {printVector2} from "./parts/printing.js" import {RecentKeyStats, Stats} from "./parts/types.js" import {setupListeningToEffectsAndRecordingStats} from "./parts/setup-listening-to-effects-and-recording-stats.js" @mixinCss(styles) export class NubVisualizer extends MagicElement { realize() { const {use} = this const [recentKeyStats, setRecentKeyStats, getRecentKeyStats] = ( use.state({}) ) const [statsForPointer, setStatsForPointer] = ( use.state(() => ({ movement: [0, 0], position: [0, 0], })) ) const [statsForStick, setStatsForStick] = ( use.state(() => ({ vector: [0, 0], })) ) use.setup(setupListeningToEffectsAndRecordingStats({ eventTarget: window, getRecentKeyStats, setRecentKeyStats, setStatsForPointer, setStatsForStick, })) return html`

pointer ${printVector2(statsForPointer.movement)} ${printVector2(statsForPointer.position)}

stick ${printVector2(statsForStick.vector)}

    ${Object .entries(recentKeyStats) .filter(([,stats]) => stats.detail.pressed) .map(([effect, stats]) => html`
  • ${effect} ${stats.detail.cause}
  • `)}
` } }