/** * Audio Level Component * * Visual audio level indicator that renders real-time audio levels from a MediaStream * via Web Audio API. Displays configurable number of bars with color transitions * based on audio intensity. * * Input precedence (most specific wins): `.stream` > `.call` (uses `localStream`) * > context (uses `localStream`). * * @example * ```html * * * * ``` * * @cssprop [--interactive-status-success=#22c55e] - Color for low audio levels. * @cssprop [--interactive-status-warning=#ffd700] - Color for medium audio levels. * @cssprop [--interactive-button-destructive-bg=#dc2626] - Color for high audio levels. * @cssprop [--sw-audio-bar-width=4px] - Width of each audio level bar. * @cssprop [--sw-audio-bar-gap=2px] - Gap between audio level bars. * @cssprop [--sw-audio-bar-radius=2px] - Border radius of each bar. * @cssprop [--sw-audio-bar-background=#404040] - Background color of inactive bars. */ import { LitElement } from 'lit'; import type { Call } from '../types/index.js'; export declare class SwAudioLevel extends LitElement { static styles: import("lit").CSSResult; /** * Explicit MediaStream to analyze — highest precedence. */ stream?: MediaStream; /** * Explicit Call — when set, analyzes the call's `localStream`. * Bypassed by `.stream` if both are set. */ call?: Call; private _callState?; private _directLocalStream; private _directSubscriptions; private get _effectiveStream(); /** * Number of bars to display (default: 5) */ bars: number; /** * Orientation of the bars: 'vertical' or 'horizontal' */ orientation: 'vertical' | 'horizontal'; /** * When true, automatically calls getUserMedia({ audio: true }) to acquire * a microphone stream instead of requiring the consumer to set `.stream`. */ autoRequest: boolean; /** * Maximum height/width of bars in pixels */ maxSize: number; /** * Current audio levels for each bar (0-1) */ private _levels; /** * Web Audio API context */ private _audioContext?; /** * Analyser node for frequency data */ private _analyser?; /** * Source node connected to the MediaStream */ private _source?; /** * Animation frame ID for cleanup */ private _animationFrameId?; /** * Frequency data buffer */ private _dataArray?; /** * Whether we own the stream and must stop its tracks on cleanup. */ private _ownsStream; /** Guard against concurrent getUserMedia calls (connectedCallback + first updated both fire). */ private _micRequested; /** * Lifecycle: Component connected to DOM */ connectedCallback(): void; /** Stream currently wired to the analyser — used to detect real changes. */ private _activeStream?; /** * Lifecycle: React to property changes */ protected updated(changedProperties: Map): void; /** * Lifecycle: Component disconnected from DOM */ disconnectedCallback(): void; /** * Public method to release all audio resources immediately * Call this before stopping the MediaStream tracks to ensure proper cleanup */ releaseResources(): void; /** * Request a microphone stream via getUserMedia for auto-request mode. */ private _requestMicStream; /** * Setup Web Audio API for audio level analysis */ private setupAudioAnalysis; /** * Cleanup Web Audio API resources */ private cleanupAudioAnalysis; /** * Start the animation loop for updating levels */ private startAnimationLoop; /** * Get the color class based on level */ private getLevelClass; /** * Get the active class if level is above threshold */ private isActive; /** * Render the component */ render(): import("lit-html").TemplateResult<1>; } /** * Declare global type for TypeScript */ declare global { interface HTMLElementTagNameMap { 'sw-audio-level': SwAudioLevel; } } //# sourceMappingURL=sw-audio-level.d.ts.map