@signalwire/web-components 4.0.0-beta.0 → 4.0.0-beta.10
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 +106 -101
- 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 +219 -0
- package/dist/components/call-media.js.map +1 -0
- package/dist/components/call-status.d.ts +68 -0
- package/dist/components/call-status.d.ts.map +1 -0
- package/dist/components/call-status.js +254 -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 +224 -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 +129 -0
- package/dist/components/self-media.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/constants.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 +35 -5644
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +101 -0
- package/dist/types/index.d.ts +44 -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
package/README.md
CHANGED
|
@@ -24,12 +24,14 @@ npm install @signalwire/web-components
|
|
|
24
24
|
import '@signalwire/web-components';
|
|
25
25
|
|
|
26
26
|
// Or import specific components
|
|
27
|
-
import
|
|
27
|
+
import '@signalwire/web-components/call-status';
|
|
28
|
+
import '@signalwire/web-components/call-media';
|
|
29
|
+
import '@signalwire/web-components/self-media';
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
```html
|
|
31
33
|
<!-- Basic video call layout -->
|
|
32
|
-
<sw-call-media .call
|
|
34
|
+
<sw-call-media .call="${call}">
|
|
33
35
|
<sw-participants>
|
|
34
36
|
<sw-self-media mirror></sw-self-media>
|
|
35
37
|
</sw-participants>
|
|
@@ -51,6 +53,7 @@ Root container component that renders the remote video stream and provides call
|
|
|
51
53
|
| `call` | `Call` | - | Call object with streams and layout data |
|
|
52
54
|
|
|
53
55
|
**CSS Custom Properties:**
|
|
56
|
+
|
|
54
57
|
```css
|
|
55
58
|
sw-call-media {
|
|
56
59
|
--sw-color-primary: #044cf6;
|
|
@@ -62,12 +65,13 @@ sw-call-media {
|
|
|
62
65
|
**CSS Parts:** `container`, `video`, `layers`
|
|
63
66
|
|
|
64
67
|
**Usage:**
|
|
68
|
+
|
|
65
69
|
```html
|
|
66
70
|
<!-- Basic usage -->
|
|
67
|
-
<sw-call-media .call
|
|
71
|
+
<sw-call-media .call="${call}"></sw-call-media>
|
|
68
72
|
|
|
69
73
|
<!-- With child components -->
|
|
70
|
-
<sw-call-media .call
|
|
74
|
+
<sw-call-media .call="${call}">
|
|
71
75
|
<sw-participants>
|
|
72
76
|
<sw-self-media></sw-self-media>
|
|
73
77
|
</sw-participants>
|
|
@@ -96,6 +100,7 @@ Renders the local video stream as an overlay with positioning from layout layers
|
|
|
96
100
|
**Context:** Consumes `callContext` from parent `sw-call-media`
|
|
97
101
|
|
|
98
102
|
**Usage:**
|
|
103
|
+
|
|
99
104
|
```html
|
|
100
105
|
<!-- Basic usage (inside sw-participants) -->
|
|
101
106
|
<sw-participants>
|
|
@@ -119,14 +124,15 @@ Renders overlay containers for all remote participants based on layout layer dat
|
|
|
119
124
|
**Context:** Consumes `callContext` from parent `sw-call-media`
|
|
120
125
|
|
|
121
126
|
**Usage:**
|
|
127
|
+
|
|
122
128
|
```html
|
|
123
129
|
<!-- Basic usage -->
|
|
124
|
-
<sw-call-media .call
|
|
130
|
+
<sw-call-media .call="${call}">
|
|
125
131
|
<sw-participants></sw-participants>
|
|
126
132
|
</sw-call-media>
|
|
127
133
|
|
|
128
134
|
<!-- With local video as child -->
|
|
129
|
-
<sw-call-media .call
|
|
135
|
+
<sw-call-media .call="${call}">
|
|
130
136
|
<sw-participants>
|
|
131
137
|
<sw-self-media mirror></sw-self-media>
|
|
132
138
|
</sw-participants>
|
|
@@ -155,6 +161,7 @@ Responsive button bar for call actions: mute audio, mute video, screen share, an
|
|
|
155
161
|
| `sw-hangup` | - | Call ended |
|
|
156
162
|
|
|
157
163
|
**CSS Custom Properties:**
|
|
164
|
+
|
|
158
165
|
```css
|
|
159
166
|
sw-call-controls {
|
|
160
167
|
--sw-color-primary: #044cf6;
|
|
@@ -168,15 +175,16 @@ sw-call-controls {
|
|
|
168
175
|
**CSS Parts:** `container`, `button`, `button-active`, `button-disabled`, `tooltip`
|
|
169
176
|
|
|
170
177
|
**Usage:**
|
|
178
|
+
|
|
171
179
|
```html
|
|
172
180
|
<!-- Basic usage (uses context from sw-call-media) -->
|
|
173
|
-
<sw-call-media .call
|
|
181
|
+
<sw-call-media .call="${call}">
|
|
174
182
|
<!-- ... -->
|
|
175
183
|
</sw-call-media>
|
|
176
184
|
<sw-call-controls></sw-call-controls>
|
|
177
185
|
|
|
178
186
|
<!-- With explicit call property -->
|
|
179
|
-
<sw-call-controls .call
|
|
187
|
+
<sw-call-controls .call="${call}" orientation="vertical"></sw-call-controls>
|
|
180
188
|
|
|
181
189
|
<!-- Without tooltips -->
|
|
182
190
|
<sw-call-controls show-tooltips="false"></sw-call-controls>
|
|
@@ -206,9 +214,10 @@ Displays call state, status text, and duration timer.
|
|
|
206
214
|
|----------|------|---------|-------------|
|
|
207
215
|
| `call` | `CallStatusCall` | - | Call with status$ observable |
|
|
208
216
|
|
|
209
|
-
**Status Values:** `
|
|
217
|
+
**Status Values:** `new`, `trying`, `ringing`, `connecting`, `connected`, `disconnecting`, `disconnected`, `failed`, `destroyed`
|
|
210
218
|
|
|
211
219
|
**CSS Custom Properties:**
|
|
220
|
+
|
|
212
221
|
```css
|
|
213
222
|
sw-call-status {
|
|
214
223
|
--sw-color-primary: #044cf6;
|
|
@@ -221,12 +230,13 @@ sw-call-status {
|
|
|
221
230
|
**CSS Parts:** `container`, `status-text`, `duration`
|
|
222
231
|
|
|
223
232
|
**Usage:**
|
|
233
|
+
|
|
224
234
|
```html
|
|
225
235
|
<!-- Basic usage (uses context) -->
|
|
226
236
|
<sw-call-status></sw-call-status>
|
|
227
237
|
|
|
228
238
|
<!-- With explicit call -->
|
|
229
|
-
<sw-call-status .call
|
|
239
|
+
<sw-call-status .call="${call}"></sw-call-status>
|
|
230
240
|
```
|
|
231
241
|
|
|
232
242
|
---
|
|
@@ -250,6 +260,7 @@ sw-call-status {
|
|
|
250
260
|
| `sw-dial` | `{ digits: string }` | Call button clicked |
|
|
251
261
|
|
|
252
262
|
**CSS Custom Properties:**
|
|
263
|
+
|
|
253
264
|
```css
|
|
254
265
|
sw-dialpad {
|
|
255
266
|
--sw-color-primary: #044cf6;
|
|
@@ -262,6 +273,7 @@ sw-dialpad {
|
|
|
262
273
|
**CSS Parts:** `container`, `display`, `keypad`, `key`, `key-pressed`, `call-button`
|
|
263
274
|
|
|
264
275
|
**Usage:**
|
|
276
|
+
|
|
265
277
|
```html
|
|
266
278
|
<!-- Basic DTMF dialpad (uses context) -->
|
|
267
279
|
<sw-dialpad></sw-dialpad>
|
|
@@ -270,7 +282,7 @@ sw-dialpad {
|
|
|
270
282
|
<sw-dialpad show-call-button placeholder="Phone number"></sw-dialpad>
|
|
271
283
|
|
|
272
284
|
<!-- With explicit call -->
|
|
273
|
-
<sw-dialpad .call
|
|
285
|
+
<sw-dialpad .call="${call}"></sw-dialpad>
|
|
274
286
|
```
|
|
275
287
|
|
|
276
288
|
```typescript
|
|
@@ -302,10 +314,11 @@ Dropdown for selecting audio/video input and output devices.
|
|
|
302
314
|
| Event | Detail | Description |
|
|
303
315
|
|-------|--------|-------------|
|
|
304
316
|
| `sw-tab-change` | `{ tab: 'microphone' \| 'camera' \| 'speaker' }` | Tab changed |
|
|
305
|
-
| `sw-device-change` | `{ device:
|
|
317
|
+
| `sw-device-change` | `{ device: MediaDeviceInfo }` | Device selected |
|
|
306
318
|
| `sw-test-speaker` | - | Speaker test triggered |
|
|
307
319
|
|
|
308
320
|
**CSS Custom Properties:**
|
|
321
|
+
|
|
309
322
|
```css
|
|
310
323
|
sw-device-selector {
|
|
311
324
|
--sw-color-primary: #044cf6;
|
|
@@ -317,15 +330,13 @@ sw-device-selector {
|
|
|
317
330
|
**CSS Parts:** `container`, `tabs`, `device-list`, `device-item`, `device-item-selected`, `preview`
|
|
318
331
|
|
|
319
332
|
**Usage:**
|
|
333
|
+
|
|
320
334
|
```html
|
|
321
335
|
<!-- Basic usage -->
|
|
322
|
-
<sw-device-selector .deviceController
|
|
336
|
+
<sw-device-selector .deviceController="${deviceController}"></sw-device-selector>
|
|
323
337
|
|
|
324
338
|
<!-- With preview panel -->
|
|
325
|
-
<sw-device-selector
|
|
326
|
-
.deviceController=${deviceController}
|
|
327
|
-
show-preview>
|
|
328
|
-
</sw-device-selector>
|
|
339
|
+
<sw-device-selector .deviceController="${deviceController}" show-preview> </sw-device-selector>
|
|
329
340
|
```
|
|
330
341
|
|
|
331
342
|
```typescript
|
|
@@ -353,6 +364,7 @@ Real-time audio level indicator using Web Audio API.
|
|
|
353
364
|
| `maxSize` | `number` | `32` | Maximum bar height/width in pixels |
|
|
354
365
|
|
|
355
366
|
**CSS Custom Properties:**
|
|
367
|
+
|
|
356
368
|
```css
|
|
357
369
|
sw-audio-level {
|
|
358
370
|
--sw-color-success: #10b981;
|
|
@@ -368,16 +380,13 @@ sw-audio-level {
|
|
|
368
380
|
**CSS Parts:** `container`, `bar`, `bar-active`
|
|
369
381
|
|
|
370
382
|
**Usage:**
|
|
383
|
+
|
|
371
384
|
```html
|
|
372
385
|
<!-- Basic usage -->
|
|
373
|
-
<sw-audio-level .stream
|
|
386
|
+
<sw-audio-level .stream="${localStream}"></sw-audio-level>
|
|
374
387
|
|
|
375
388
|
<!-- Horizontal with more bars -->
|
|
376
|
-
<sw-audio-level
|
|
377
|
-
.stream=${localStream}
|
|
378
|
-
orientation="horizontal"
|
|
379
|
-
bars="10"
|
|
380
|
-
maxSize="48">
|
|
389
|
+
<sw-audio-level .stream="${localStream}" orientation="horizontal" bars="10" maxSize="48">
|
|
381
390
|
</sw-audio-level>
|
|
382
391
|
```
|
|
383
392
|
|
|
@@ -403,6 +412,7 @@ Single button widget for calling a preconfigured destination.
|
|
|
403
412
|
| `sw-hangup` | - | Call ended |
|
|
404
413
|
|
|
405
414
|
**CSS Custom Properties:**
|
|
415
|
+
|
|
406
416
|
```css
|
|
407
417
|
sw-click-to-call {
|
|
408
418
|
--sw-color-primary: #044cf6;
|
|
@@ -414,20 +424,19 @@ sw-click-to-call {
|
|
|
414
424
|
**CSS Parts:** `container`, `button`, `controls`, `status`, `duration`
|
|
415
425
|
|
|
416
426
|
**Usage:**
|
|
427
|
+
|
|
417
428
|
```html
|
|
418
429
|
<!-- Basic click-to-call button -->
|
|
419
|
-
<sw-click-to-call
|
|
420
|
-
.client=${client}
|
|
421
|
-
destination="sip:support@example.com"
|
|
422
|
-
label="Contact Support">
|
|
430
|
+
<sw-click-to-call .client="${client}" destination="sip:support@example.com" label="Contact Support">
|
|
423
431
|
</sw-click-to-call>
|
|
424
432
|
|
|
425
433
|
<!-- Audio/video call -->
|
|
426
434
|
<sw-click-to-call
|
|
427
|
-
.client
|
|
435
|
+
.client="${client}"
|
|
428
436
|
destination="+15551234567"
|
|
429
437
|
label="Call Sales"
|
|
430
|
-
audio-only="false"
|
|
438
|
+
audio-only="false"
|
|
439
|
+
>
|
|
431
440
|
</sw-click-to-call>
|
|
432
441
|
```
|
|
433
442
|
|
|
@@ -461,6 +470,7 @@ Searchable list of directory addresses for selecting call destinations.
|
|
|
461
470
|
| `sw-dial` | `{ address: Address }` | Address dialed (double-click) |
|
|
462
471
|
|
|
463
472
|
**CSS Custom Properties:**
|
|
473
|
+
|
|
464
474
|
```css
|
|
465
475
|
sw-directory {
|
|
466
476
|
--sw-color-primary: #044cf6;
|
|
@@ -472,9 +482,10 @@ sw-directory {
|
|
|
472
482
|
**CSS Parts:** `container`, `search`, `list`, `item`, `item-selected`, `item-name`, `item-type`, `item-channels`
|
|
473
483
|
|
|
474
484
|
**Usage:**
|
|
485
|
+
|
|
475
486
|
```html
|
|
476
487
|
<!-- Basic directory list -->
|
|
477
|
-
<sw-directory .directory
|
|
488
|
+
<sw-directory .directory="${directoryService}"></sw-directory>
|
|
478
489
|
```
|
|
479
490
|
|
|
480
491
|
```typescript
|
|
@@ -517,6 +528,7 @@ Control panel for individual participant actions (mute, volume, pin, remove).
|
|
|
517
528
|
**CSS Parts:** `container`, `action-button`, `slider`
|
|
518
529
|
|
|
519
530
|
**Usage:**
|
|
531
|
+
|
|
520
532
|
```html
|
|
521
533
|
<!-- Basic participant controls -->
|
|
522
534
|
<sw-participant-controls
|
|
@@ -564,6 +576,7 @@ Simple example button component for demonstration purposes.
|
|
|
564
576
|
**CSS Parts:** `button`
|
|
565
577
|
|
|
566
578
|
**Usage:**
|
|
579
|
+
|
|
567
580
|
```html
|
|
568
581
|
<!-- Primary button -->
|
|
569
582
|
<sw-example-button>Click Me</sw-example-button>
|
|
@@ -580,7 +593,7 @@ The components use Lit context (`@lit/context`) to share call state. The `sw-cal
|
|
|
580
593
|
|
|
581
594
|
```html
|
|
582
595
|
<!-- sw-call-media provides context -->
|
|
583
|
-
<sw-call-media .call
|
|
596
|
+
<sw-call-media .call="${call}">
|
|
584
597
|
<!-- These components consume context automatically -->
|
|
585
598
|
<sw-participants>
|
|
586
599
|
<sw-self-media></sw-self-media>
|
|
@@ -588,8 +601,8 @@ The components use Lit context (`@lit/context`) to share call state. The `sw-cal
|
|
|
588
601
|
</sw-call-media>
|
|
589
602
|
|
|
590
603
|
<!-- Components outside sw-call-media need explicit call property -->
|
|
591
|
-
<sw-call-controls .call
|
|
592
|
-
<sw-call-status .call
|
|
604
|
+
<sw-call-controls .call="${call}"></sw-call-controls>
|
|
605
|
+
<sw-call-status .call="${call}"></sw-call-status>
|
|
593
606
|
```
|
|
594
607
|
|
|
595
608
|
---
|
|
@@ -655,12 +668,7 @@ sw-call-media::part(video) {
|
|
|
655
668
|
## TypeScript Interfaces
|
|
656
669
|
|
|
657
670
|
```typescript
|
|
658
|
-
import type {
|
|
659
|
-
Call,
|
|
660
|
-
LayoutLayer,
|
|
661
|
-
DeviceInfo,
|
|
662
|
-
Address
|
|
663
|
-
} from '@signalwire/web-components';
|
|
671
|
+
import type { Call, CallSelf, DeviceController, LayoutLayer, Participant } from '@signalwire/web-components';
|
|
664
672
|
|
|
665
673
|
// Call object interface
|
|
666
674
|
interface Call {
|
|
@@ -686,12 +694,9 @@ interface LayoutLayer {
|
|
|
686
694
|
height: number;
|
|
687
695
|
}
|
|
688
696
|
|
|
689
|
-
//
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
label: string;
|
|
693
|
-
kind: 'audioinput' | 'audiooutput' | 'videoinput';
|
|
694
|
-
}
|
|
697
|
+
// DeviceController is imported from @signalwire/js via @signalwire/web-components
|
|
698
|
+
// It provides observables for device lists and selection methods.
|
|
699
|
+
// See @signalwire/js documentation for the full DeviceController interface.
|
|
695
700
|
|
|
696
701
|
// Directory address
|
|
697
702
|
interface Address {
|
|
@@ -714,68 +719,68 @@ interface Address {
|
|
|
714
719
|
```html
|
|
715
720
|
<!DOCTYPE html>
|
|
716
721
|
<html>
|
|
717
|
-
<head>
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
</head>
|
|
740
|
-
<body>
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
722
|
+
<head>
|
|
723
|
+
<style>
|
|
724
|
+
.call-container {
|
|
725
|
+
display: flex;
|
|
726
|
+
flex-direction: column;
|
|
727
|
+
height: 100vh;
|
|
728
|
+
background: #000;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
.video-area {
|
|
732
|
+
flex: 1;
|
|
733
|
+
position: relative;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.controls-bar {
|
|
737
|
+
padding: 16px;
|
|
738
|
+
display: flex;
|
|
739
|
+
justify-content: center;
|
|
740
|
+
gap: 16px;
|
|
741
|
+
background: rgba(0, 0, 0, 0.8);
|
|
742
|
+
}
|
|
743
|
+
</style>
|
|
744
|
+
</head>
|
|
745
|
+
<body>
|
|
746
|
+
<div class="call-container">
|
|
747
|
+
<sw-call-status></sw-call-status>
|
|
748
|
+
|
|
749
|
+
<div class="video-area">
|
|
750
|
+
<sw-call-media id="call-media">
|
|
751
|
+
<sw-participants>
|
|
752
|
+
<sw-self-media mirror></sw-self-media>
|
|
753
|
+
</sw-participants>
|
|
754
|
+
</sw-call-media>
|
|
755
|
+
</div>
|
|
756
|
+
|
|
757
|
+
<div class="controls-bar">
|
|
758
|
+
<sw-call-controls></sw-call-controls>
|
|
759
|
+
<sw-dialpad></sw-dialpad>
|
|
760
|
+
</div>
|
|
755
761
|
</div>
|
|
756
|
-
</div>
|
|
757
762
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
763
|
+
<script type="module">
|
|
764
|
+
import '@signalwire/web-components';
|
|
765
|
+
import { SignalWire } from '@signalwire/js';
|
|
761
766
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
767
|
+
const client = new SignalWire({
|
|
768
|
+
host: 'your-signalwire-space.signalwire.com',
|
|
769
|
+
token: 'your-token'
|
|
770
|
+
});
|
|
766
771
|
|
|
767
|
-
|
|
772
|
+
await client.connect();
|
|
768
773
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
+
const call = await client.call({
|
|
775
|
+
destination: 'sip:room@example.com',
|
|
776
|
+
audio: true,
|
|
777
|
+
video: true
|
|
778
|
+
});
|
|
774
779
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
</body>
|
|
780
|
+
// Set the call on the media component (provides context)
|
|
781
|
+
document.getElementById('call-media').call = call;
|
|
782
|
+
</script>
|
|
783
|
+
</body>
|
|
779
784
|
</html>
|
|
780
785
|
```
|
|
781
786
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audio Level Component
|
|
3
|
+
*
|
|
4
|
+
* Visual audio level indicator that renders real-time audio levels from a MediaStream
|
|
5
|
+
* via Web Audio API. Displays configurable number of bars with color transitions
|
|
6
|
+
* based on audio intensity.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```html
|
|
10
|
+
* <sw-audio-level .stream=${mediaStream} bars="5" orientation="vertical"></sw-audio-level>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import { LitElement } from 'lit';
|
|
14
|
+
export declare class AudioLevel extends LitElement {
|
|
15
|
+
static styles: import("lit").CSSResult;
|
|
16
|
+
/**
|
|
17
|
+
* MediaStream to analyze for audio levels
|
|
18
|
+
*/
|
|
19
|
+
stream?: MediaStream;
|
|
20
|
+
/**
|
|
21
|
+
* Number of bars to display (default: 5)
|
|
22
|
+
*/
|
|
23
|
+
bars: number;
|
|
24
|
+
/**
|
|
25
|
+
* Orientation of the bars: 'vertical' or 'horizontal'
|
|
26
|
+
*/
|
|
27
|
+
orientation: 'vertical' | 'horizontal';
|
|
28
|
+
/**
|
|
29
|
+
* Maximum height/width of bars in pixels
|
|
30
|
+
*/
|
|
31
|
+
maxSize: number;
|
|
32
|
+
/**
|
|
33
|
+
* Current audio levels for each bar (0-1)
|
|
34
|
+
*/
|
|
35
|
+
private _levels;
|
|
36
|
+
/**
|
|
37
|
+
* Web Audio API context
|
|
38
|
+
*/
|
|
39
|
+
private _audioContext?;
|
|
40
|
+
/**
|
|
41
|
+
* Analyser node for frequency data
|
|
42
|
+
*/
|
|
43
|
+
private _analyser?;
|
|
44
|
+
/**
|
|
45
|
+
* Source node connected to the MediaStream
|
|
46
|
+
*/
|
|
47
|
+
private _source?;
|
|
48
|
+
/**
|
|
49
|
+
* Animation frame ID for cleanup
|
|
50
|
+
*/
|
|
51
|
+
private _animationFrameId?;
|
|
52
|
+
/**
|
|
53
|
+
* Frequency data buffer
|
|
54
|
+
*/
|
|
55
|
+
private _dataArray?;
|
|
56
|
+
/**
|
|
57
|
+
* Lifecycle: Component connected to DOM
|
|
58
|
+
*/
|
|
59
|
+
connectedCallback(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Lifecycle: React to property changes
|
|
62
|
+
*/
|
|
63
|
+
protected updated(changedProperties: Map<string, unknown>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Lifecycle: Component disconnected from DOM
|
|
66
|
+
*/
|
|
67
|
+
disconnectedCallback(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Public method to release all audio resources immediately
|
|
70
|
+
* Call this before stopping the MediaStream tracks to ensure proper cleanup
|
|
71
|
+
*/
|
|
72
|
+
releaseResources(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Setup Web Audio API for audio level analysis
|
|
75
|
+
*/
|
|
76
|
+
private setupAudioAnalysis;
|
|
77
|
+
/**
|
|
78
|
+
* Cleanup Web Audio API resources
|
|
79
|
+
*/
|
|
80
|
+
private cleanupAudioAnalysis;
|
|
81
|
+
/**
|
|
82
|
+
* Start the animation loop for updating levels
|
|
83
|
+
*/
|
|
84
|
+
private startAnimationLoop;
|
|
85
|
+
/**
|
|
86
|
+
* Get the color class based on level
|
|
87
|
+
*/
|
|
88
|
+
private getLevelClass;
|
|
89
|
+
/**
|
|
90
|
+
* Get the active class if level is above threshold
|
|
91
|
+
*/
|
|
92
|
+
private isActive;
|
|
93
|
+
/**
|
|
94
|
+
* Render the component
|
|
95
|
+
*/
|
|
96
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Declare global type for TypeScript
|
|
100
|
+
*/
|
|
101
|
+
declare global {
|
|
102
|
+
interface HTMLElementTagNameMap {
|
|
103
|
+
'sw-audio-level': AudioLevel;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=audio-level.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-level.d.ts","sourceRoot":"","sources":["../../src/components/audio-level.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,qBACa,UAAW,SAAQ,UAAU;IACxC,MAAM,CAAC,MAAM,0BAiEX;IAEF;;OAEG;IACyB,MAAM,CAAC,EAAE,WAAW,CAAC;IAEjD;;OAEG;IACyB,IAAI,SAAK;IAErC;;OAEG;IACwC,WAAW,EAAE,UAAU,GAAG,YAAY,CAAc;IAE/F;;OAEG;IACyB,OAAO,SAAM;IAEzC;;OAEG;IACM,OAAO,CAAC,OAAO,CAAgB;IAExC;;OAEG;IACH,OAAO,CAAC,aAAa,CAAC,CAAe;IAErC;;OAEG;IACH,OAAO,CAAC,SAAS,CAAC,CAAe;IAEjC;;OAEG;IACH,OAAO,CAAC,OAAO,CAAC,CAA6B;IAE7C;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAAC,CAAS;IAEnC;;OAEG;IACH,OAAO,CAAC,UAAU,CAAC,CAA0B;IAE7C;;OAEG;IACH,iBAAiB;IAQjB;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAehE;;OAEG;IACH,oBAAoB;IAKpB;;;OAGG;IACI,gBAAgB,IAAI,IAAI;IAK/B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkC1B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgC5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyC1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;OAEG;IACH,MAAM;CA0BP;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,UAAU,CAAC;KAC9B;CACF"}
|