@signalwire/web-components 4.0.0-beta.2 → 4.0.0-beta.4
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.
- package/README.md +3 -1
- package/dist/components/audio-level.d.ts +106 -0
- package/dist/components/audio-level.d.ts.map +1 -0
- package/dist/components/audio-level.js +203 -0
- package/dist/components/audio-level.js.map +1 -0
- package/dist/components/call-controls.d.ts +163 -0
- package/dist/components/call-controls.d.ts.map +1 -0
- package/dist/components/call-controls.js +606 -0
- package/dist/components/call-controls.js.map +1 -0
- package/dist/components/call-media.d.ts +114 -0
- package/dist/components/call-media.d.ts.map +1 -0
- package/dist/components/call-media.js +215 -0
- package/dist/components/call-media.js.map +1 -0
- package/dist/components/call-status.d.ts +71 -0
- package/dist/components/call-status.d.ts.map +1 -0
- package/dist/components/call-status.js +251 -0
- package/dist/components/call-status.js.map +1 -0
- package/dist/components/click-to-call.d.ts +123 -0
- package/dist/components/click-to-call.d.ts.map +1 -0
- package/dist/components/click-to-call.js +428 -0
- package/dist/components/click-to-call.js.map +1 -0
- package/dist/components/device-selector.d.ts +250 -0
- package/dist/components/device-selector.d.ts.map +1 -0
- package/dist/components/device-selector.js +685 -0
- package/dist/components/device-selector.js.map +1 -0
- package/dist/components/dialpad.d.ts +60 -0
- package/dist/components/dialpad.d.ts.map +1 -0
- package/dist/components/dialpad.js +372 -0
- package/dist/components/dialpad.js.map +1 -0
- package/dist/components/directory.d.ts +103 -0
- package/dist/components/directory.d.ts.map +1 -0
- package/dist/components/directory.js +503 -0
- package/dist/components/directory.js.map +1 -0
- package/dist/components/example-button.d.ts +20 -0
- package/dist/components/example-button.d.ts.map +1 -0
- package/dist/components/example-button.js +74 -0
- package/dist/components/example-button.js.map +1 -0
- package/dist/components/participant-controls.d.ts +94 -0
- package/dist/components/participant-controls.d.ts.map +1 -0
- package/dist/components/participant-controls.js +468 -0
- package/dist/components/participant-controls.js.map +1 -0
- package/dist/components/participants.d.ts +116 -0
- package/dist/components/participants.d.ts.map +1 -0
- package/dist/components/participants.js +394 -0
- package/dist/components/participants.js.map +1 -0
- package/dist/components/self-media.d.ts +78 -0
- package/dist/components/self-media.d.ts.map +1 -0
- package/dist/components/self-media.js +128 -0
- package/dist/components/self-media.js.map +1 -0
- package/dist/context/call-context.d.ts +13 -0
- package/dist/context/call-context.d.ts.map +1 -0
- package/dist/context/call-context.js +6 -0
- package/dist/context/call-context.js.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -5645
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +101 -0
- package/dist/types/index.d.ts +67 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/debounce.d.ts +10 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/debounce.js +13 -0
- package/dist/utils/debounce.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/video.d.ts +34 -0
- package/dist/utils/video.d.ts.map +1 -0
- package/dist/utils/video.js +26 -0
- package/dist/utils/video.js.map +1 -0
- package/package.json +70 -3
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Selector Component
|
|
3
|
+
*
|
|
4
|
+
* Dropdown-based selector for choosing audio/video devices. Displays device lists from
|
|
5
|
+
* DeviceController observables with labeled dropdowns for microphone, camera, and speaker.
|
|
6
|
+
* Includes inline preview for video (camera) and audio level (microphone) using browser API.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```html
|
|
10
|
+
* <sw-device-selector .deviceController=${deviceController} show-preview></sw-device-selector>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import { LitElement } from 'lit';
|
|
14
|
+
import type { Observable } from 'rxjs';
|
|
15
|
+
import './audio-level.js';
|
|
16
|
+
/**
|
|
17
|
+
* DeviceController interface for observing device lists
|
|
18
|
+
*/
|
|
19
|
+
export interface DeviceController {
|
|
20
|
+
readonly audioInputDevices$: Observable<MediaDeviceInfo[]>;
|
|
21
|
+
readonly audioOutputDevices$: Observable<MediaDeviceInfo[]>;
|
|
22
|
+
readonly videoInputDevices$: Observable<MediaDeviceInfo[]>;
|
|
23
|
+
readonly selectedAudioInputDevice$: Observable<MediaDeviceInfo | null>;
|
|
24
|
+
readonly selectedAudioOutputDevice$: Observable<MediaDeviceInfo | null>;
|
|
25
|
+
readonly selectedVideoInputDevice$: Observable<MediaDeviceInfo | null>;
|
|
26
|
+
readonly selectedAudioInputDevice: MediaDeviceInfo | null;
|
|
27
|
+
readonly selectedAudioOutputDevice: MediaDeviceInfo | null;
|
|
28
|
+
readonly selectedVideoInputDevice: MediaDeviceInfo | null;
|
|
29
|
+
readonly audioInputDevices: MediaDeviceInfo[];
|
|
30
|
+
readonly audioOutputDevices: MediaDeviceInfo[];
|
|
31
|
+
readonly videoInputDevices: MediaDeviceInfo[];
|
|
32
|
+
readonly selectedAudioInputDeviceConstraints: MediaTrackConstraints;
|
|
33
|
+
readonly selectedVideoInputDeviceConstraints: MediaTrackConstraints;
|
|
34
|
+
MediaDeviceInfoToConstraints(MediaDeviceInfo: MediaDeviceInfo | null): MediaTrackConstraints;
|
|
35
|
+
selectAudioInputDevice(device: MediaDeviceInfo | null): void;
|
|
36
|
+
selectVideoInputDevice(device: MediaDeviceInfo | null): void;
|
|
37
|
+
selectAudioOutputDevice(device: MediaDeviceInfo | null): void;
|
|
38
|
+
enableDeviceMonitoring(): void;
|
|
39
|
+
disableDeviceMonitoring(): void;
|
|
40
|
+
getLocalStream?: () => Promise<MediaStream>;
|
|
41
|
+
}
|
|
42
|
+
export declare class DeviceSelector extends LitElement {
|
|
43
|
+
static styles: import("lit").CSSResult;
|
|
44
|
+
/**
|
|
45
|
+
* Device controller with observables for device lists
|
|
46
|
+
*/
|
|
47
|
+
deviceController?: DeviceController;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to show the preview panel
|
|
50
|
+
*/
|
|
51
|
+
showPreview: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Audio input devices
|
|
54
|
+
*/
|
|
55
|
+
private _audioInputDevices;
|
|
56
|
+
/**
|
|
57
|
+
* Video input devices
|
|
58
|
+
*/
|
|
59
|
+
private _videoInputDevices;
|
|
60
|
+
/**
|
|
61
|
+
* Audio output devices
|
|
62
|
+
*/
|
|
63
|
+
private _audioOutputDevices;
|
|
64
|
+
/**
|
|
65
|
+
* Selected audio input device
|
|
66
|
+
*/
|
|
67
|
+
private _selectedAudioInput;
|
|
68
|
+
/**
|
|
69
|
+
* Selected video input device
|
|
70
|
+
*/
|
|
71
|
+
private _selectedVideoInput;
|
|
72
|
+
/**
|
|
73
|
+
* Selected audio output device
|
|
74
|
+
*/
|
|
75
|
+
private _selectedAudioOutput;
|
|
76
|
+
/**
|
|
77
|
+
* Video preview stream from camera
|
|
78
|
+
*/
|
|
79
|
+
private _videoPreviewStream;
|
|
80
|
+
/**
|
|
81
|
+
* Audio preview stream from microphone
|
|
82
|
+
*/
|
|
83
|
+
private _audioPreviewStream;
|
|
84
|
+
/**
|
|
85
|
+
* Is test audio playing
|
|
86
|
+
*/
|
|
87
|
+
private _isTestingAudio;
|
|
88
|
+
/**
|
|
89
|
+
* Whether the component is currently visible (combines all visibility factors)
|
|
90
|
+
*/
|
|
91
|
+
private _isComponentVisible;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the component is in the viewport (IntersectionObserver)
|
|
94
|
+
*/
|
|
95
|
+
private _isInViewport;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the document/tab is visible
|
|
98
|
+
*/
|
|
99
|
+
private _isDocumentVisible;
|
|
100
|
+
/**
|
|
101
|
+
* Whether the component is CSS-visible (display, visibility, opacity)
|
|
102
|
+
*/
|
|
103
|
+
private _isCSSVisible;
|
|
104
|
+
/**
|
|
105
|
+
* Video element reference
|
|
106
|
+
*/
|
|
107
|
+
private _videoElement?;
|
|
108
|
+
/**
|
|
109
|
+
* RxJS subscriptions for cleanup
|
|
110
|
+
*/
|
|
111
|
+
private subscriptions;
|
|
112
|
+
/**
|
|
113
|
+
* Audio element for speaker test
|
|
114
|
+
*/
|
|
115
|
+
private _testAudioElement?;
|
|
116
|
+
/**
|
|
117
|
+
* IntersectionObserver for viewport visibility
|
|
118
|
+
*/
|
|
119
|
+
private _intersectionObserver?;
|
|
120
|
+
/**
|
|
121
|
+
* Bound handler for document visibility change
|
|
122
|
+
*/
|
|
123
|
+
private _boundHandleDocumentVisibility;
|
|
124
|
+
/**
|
|
125
|
+
* Interval ID for CSS visibility polling
|
|
126
|
+
*/
|
|
127
|
+
private _cssVisibilityCheckInterval?;
|
|
128
|
+
/**
|
|
129
|
+
* Flag to prevent concurrent preview initialization
|
|
130
|
+
*/
|
|
131
|
+
private _isInitializingPreviews;
|
|
132
|
+
/**
|
|
133
|
+
* Interval in milliseconds for checking CSS visibility changes
|
|
134
|
+
*/
|
|
135
|
+
private static readonly CSS_VISIBILITY_CHECK_INTERVAL_MS;
|
|
136
|
+
/**
|
|
137
|
+
* Lifecycle: Component connected to DOM
|
|
138
|
+
*/
|
|
139
|
+
connectedCallback(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Lifecycle: React to property changes
|
|
142
|
+
*/
|
|
143
|
+
protected updated(changedProperties: Map<string, unknown>): void;
|
|
144
|
+
/**
|
|
145
|
+
* Lifecycle: Component disconnected from DOM
|
|
146
|
+
*/
|
|
147
|
+
disconnectedCallback(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Setup all visibility observers (IntersectionObserver, document visibility, CSS polling)
|
|
150
|
+
*/
|
|
151
|
+
private setupVisibilityObservers;
|
|
152
|
+
/**
|
|
153
|
+
* Cleanup all visibility observers
|
|
154
|
+
*/
|
|
155
|
+
private cleanupVisibilityObservers;
|
|
156
|
+
/**
|
|
157
|
+
* Handle document visibility change (tab switching)
|
|
158
|
+
*/
|
|
159
|
+
private handleDocumentVisibilityChange;
|
|
160
|
+
/**
|
|
161
|
+
* Check if the component is visible via CSS (display, visibility, opacity)
|
|
162
|
+
* Traverses the DOM tree including shadow DOM boundaries
|
|
163
|
+
*/
|
|
164
|
+
private checkCSSVisibility;
|
|
165
|
+
/**
|
|
166
|
+
* Update the combined visibility state and manage preview streams accordingly
|
|
167
|
+
*/
|
|
168
|
+
private updateVisibilityState;
|
|
169
|
+
/**
|
|
170
|
+
* Subscribe to device controller observables
|
|
171
|
+
*/
|
|
172
|
+
private setupSubscriptions;
|
|
173
|
+
/**
|
|
174
|
+
* Cleanup all subscriptions
|
|
175
|
+
*/
|
|
176
|
+
private cleanupSubscriptions;
|
|
177
|
+
/**
|
|
178
|
+
* Cleanup video preview stream
|
|
179
|
+
* Best practice from SDK: Pause video, clear srcObject, remove tracks from stream, then stop tracks
|
|
180
|
+
* @see https://webrtchacks.com/srcobject-intervention/
|
|
181
|
+
*/
|
|
182
|
+
private cleanupVideoPreviewStream;
|
|
183
|
+
/**
|
|
184
|
+
* Cleanup audio preview stream
|
|
185
|
+
* Best practice from SDK: Release audio components, remove tracks from stream, then stop tracks
|
|
186
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/stop
|
|
187
|
+
*/
|
|
188
|
+
private cleanupAudioPreviewStream;
|
|
189
|
+
/**
|
|
190
|
+
* Get video preview stream from browser API
|
|
191
|
+
*/
|
|
192
|
+
private getVideoPreviewStream;
|
|
193
|
+
/**
|
|
194
|
+
* Get audio preview stream from browser API
|
|
195
|
+
*/
|
|
196
|
+
private getAudioPreviewStream;
|
|
197
|
+
/**
|
|
198
|
+
* Update video element with current stream
|
|
199
|
+
*/
|
|
200
|
+
private updateVideoElement;
|
|
201
|
+
/**
|
|
202
|
+
* Initialize previews when show-preview is enabled
|
|
203
|
+
*/
|
|
204
|
+
private initializePreviews;
|
|
205
|
+
/**
|
|
206
|
+
* Handle device selection change from dropdown
|
|
207
|
+
*/
|
|
208
|
+
private handleDeviceChange;
|
|
209
|
+
/**
|
|
210
|
+
* Test speaker by playing a test tone
|
|
211
|
+
*/
|
|
212
|
+
private testSpeaker;
|
|
213
|
+
/**
|
|
214
|
+
* Stop test audio
|
|
215
|
+
*/
|
|
216
|
+
private stopTestAudio;
|
|
217
|
+
/**
|
|
218
|
+
* Render device icon
|
|
219
|
+
*/
|
|
220
|
+
private renderDeviceIcon;
|
|
221
|
+
/**
|
|
222
|
+
* Render dropdown arrow icon
|
|
223
|
+
*/
|
|
224
|
+
private renderSelectArrow;
|
|
225
|
+
/**
|
|
226
|
+
* Render a device selection section
|
|
227
|
+
*/
|
|
228
|
+
private renderDeviceSection;
|
|
229
|
+
/**
|
|
230
|
+
* Render video preview for camera section
|
|
231
|
+
*/
|
|
232
|
+
private renderVideoPreview;
|
|
233
|
+
/**
|
|
234
|
+
* Render audio level preview for microphone section
|
|
235
|
+
*/
|
|
236
|
+
private renderAudioPreview;
|
|
237
|
+
/**
|
|
238
|
+
* Render the component
|
|
239
|
+
*/
|
|
240
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Declare global type for TypeScript
|
|
244
|
+
*/
|
|
245
|
+
declare global {
|
|
246
|
+
interface HTMLElementTagNameMap {
|
|
247
|
+
'sw-device-selector': DeviceSelector;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=device-selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-selector.d.ts","sourceRoot":"","sources":["../../src/components/device-selector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAE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