@rapidmx/meet-plugin 0.13.1 → 0.14.1
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 +55 -55
- package/apps/meet/[token].tsx +341 -341
- package/apps/meet/_CallControls.tsx +463 -394
- package/apps/meet/_CallView.tsx +891 -848
- package/apps/meet/_DiagnosticsWindow.tsx +80 -0
- package/apps/meet/_MeetLobby.tsx +224 -224
- package/apps/meet/_ParticipantTile.tsx +169 -169
- package/apps/meet/_ParticipantsDrawer.tsx +10 -104
- package/apps/meet/_SettingsModal.tsx +152 -0
- package/apps/meet/_icons.tsx +80 -82
- package/apps/meet/_meetApi.ts +212 -212
- package/apps/shared/media/filters/VideoFilterProcessor.ts +408 -408
- package/apps/shared/media/filters/mlModels.ts +174 -174
- package/apps/shared/push/GuestSignalingClient.ts +359 -359
- package/apps/shared/relay/RelayClient.ts +7 -2
- package/apps/shared/webrtc/MeshConnectionManager.ts +949 -795
- package/apps/shared/webrtc/types.ts +247 -222
- package/dist/apps/meet/_CallControls.d.ts +19 -9
- package/dist/apps/meet/_CallControls.js +28 -10
- package/dist/apps/meet/_CallView.d.ts +14 -2
- package/dist/apps/meet/_CallView.js +27 -2
- package/dist/apps/meet/_DiagnosticsWindow.d.ts +25 -0
- package/dist/apps/meet/_DiagnosticsWindow.js +45 -0
- package/dist/apps/meet/_ParticipantsDrawer.d.ts +10 -21
- package/dist/apps/meet/_ParticipantsDrawer.js +9 -39
- package/dist/apps/meet/_SettingsModal.d.ts +28 -0
- package/dist/apps/meet/_SettingsModal.js +59 -0
- package/dist/apps/meet/_icons.d.ts +1 -1
- package/dist/apps/meet/_icons.js +1 -1
- package/dist/apps/shared/relay/RelayClient.d.ts +6 -1
- package/dist/apps/shared/relay/RelayClient.js +7 -2
- package/dist/apps/shared/webrtc/MeshConnectionManager.d.ts +55 -2
- package/dist/apps/shared/webrtc/MeshConnectionManager.js +153 -9
- package/dist/apps/shared/webrtc/types.d.ts +25 -1
- package/dist/lib/util/RedisRelayBus.js +61 -5
- package/dist/lib/util/RedisRelayBus.js.map +1 -1
- package/dist/lib/util/RelayHub.js +10 -3
- package/dist/lib/util/RelayHub.js.map +1 -1
- package/dist/types/util/RedisRelayBus.d.ts +45 -6
- package/dist/types/util/RelayHub.d.ts +9 -2
- package/package.json +208 -208
package/apps/meet/_CallView.tsx
CHANGED
|
@@ -1,848 +1,891 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz. All rights reserved.
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
/**
|
|
6
|
-
* The in-call view: connects the full-mesh `MeshConnectionManager` to the meeting's signaling channel
|
|
7
|
-
* (`GuestSignalingClient`), mirrors its events into React state, and renders the grid/focused/presentation
|
|
8
|
-
* layouts - see `apps/shared/webrtc/MeshConnectionManager.ts`'s doc comment for the who-calls-whom and
|
|
9
|
-
* single-presenter rules this view relies on rather than re-deciding. These reusable, non-UI modules live under
|
|
10
|
-
* `apps/shared/` rather than this plugin's backend `src/` - `tsconfig.apps.json` builds `apps/` as its own
|
|
11
|
-
* program rooted at `apps/`, which cannot reference files outside it (`TS6059`), matching `booking-plugin`'s own
|
|
12
|
-
* identical `apps/shared/` convention for reusable frontend-only code.
|
|
13
|
-
*
|
|
14
|
-
* ## Fitting the window
|
|
15
|
-
*
|
|
16
|
-
* The call fills the viewport (`fixed inset-0`) as three rows - a slim header, the tiles (which take whatever room
|
|
17
|
-
* is left and never scroll the page), and the control bar pinned to the bottom - instead of being laid out inside
|
|
18
|
-
* the branded page shell, whose header, footer and padding pushed it off the screen. The local participant's own
|
|
19
|
-
* tile is a small tile in the bottom-right corner while anyone else is in the call (above the control bar on a narrower
|
|
20
|
-
* window, and at the top on a phone, where the bar wraps onto a second row), and fills the tile area while they are
|
|
21
|
-
* alone.
|
|
22
|
-
*
|
|
23
|
-
* ## Who is heard
|
|
24
|
-
*
|
|
25
|
-
* A tile never plays sound. Each remote stream is played by its own hidden `<audio>` element, so a participant is
|
|
26
|
-
* heard whether or not their camera is on and whichever layout is showing. If the browser refuses to start the
|
|
27
|
-
* audio (an autoplay policy), a banner asks for a click, which is the gesture that allows it.
|
|
28
|
-
*
|
|
29
|
-
* ## Layout precedence
|
|
30
|
-
*
|
|
31
|
-
* `computeMainUid()` decides who is shown large, in this order: an active presenter always wins (presentation
|
|
32
|
-
* mode, forcing a focused-like layout regardless of `viewMode`); otherwise a manually pinned participant; else the
|
|
33
|
-
* auto-detected active speaker (silently ignored while presenting, so it never fights the presenter for the main
|
|
34
|
-
* slot); else, in focus mode with nobody yet speaking, the first other participant - so focus mode never shows an
|
|
35
|
-
* empty main slot once someone else has joined.
|
|
36
|
-
*
|
|
37
|
-
* ## Talking stick mode
|
|
38
|
-
*
|
|
39
|
-
* A host-only navbar toggle (`handleToggleTalkingStick()`) that, once on, lets at most one participant's microphone
|
|
40
|
-
* be unmuted at a time - the host assigns who from the participants drawer (`handleGiveTalkingStick()`), everyone
|
|
41
|
-
* else sees a header chip naming who currently holds it. Purely an in-call runtime state signaled peer-to-peer over
|
|
42
|
-
* the mesh (`MeshConnectionManager.setTalkingStick()`/`"talking-stick-changed"`), the same shape as `mute-request`/
|
|
43
|
-
* `kicked`: no `VideoMeeting` field, no backend route, and only as "enforced" as a cooperating client makes it (see
|
|
44
|
-
* `types.ts`'s `SignalMessage` doc comment on why the signaling layer has no host identity to check against). What
|
|
45
|
-
* *is* new here versus `mute-request`'s one-time nudge: becoming or ceasing to be the holder force-toggles this
|
|
46
|
-
* tab's own mic to match (`selfHasTalkingStick`'s effect, below), and the mic button itself is disabled
|
|
47
|
-
* (`micLocked`, passed to `CallControls`) the whole time a non-holder would otherwise be able to tap it straight
|
|
48
|
-
* back on - a real restriction for as long as this tab's own UI is the one in front of the participant, not just a
|
|
49
|
-
* suggestion. Turning the mode off touches nobody's mic state, matching every other host toggle's "never
|
|
50
|
-
* retroactive" posture. A holder who leaves the call is not specially reassigned - see
|
|
51
|
-
* `MeshConnectionManager`'s own doc comment on why that needs no extra code - the header chip then says nobody has
|
|
52
|
-
* the floor, until the host picks someone (or themselves) again.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
import
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} from "
|
|
78
|
-
import
|
|
79
|
-
import
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const [
|
|
200
|
-
const [
|
|
201
|
-
const [
|
|
202
|
-
const [
|
|
203
|
-
const [
|
|
204
|
-
const [
|
|
205
|
-
const [
|
|
206
|
-
const [
|
|
207
|
-
const [
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
useEffect(() => {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
function
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
*
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
*
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
function
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
{
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
className="absolute
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
}
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz. All rights reserved.
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
/**
|
|
6
|
+
* The in-call view: connects the full-mesh `MeshConnectionManager` to the meeting's signaling channel
|
|
7
|
+
* (`GuestSignalingClient`), mirrors its events into React state, and renders the grid/focused/presentation
|
|
8
|
+
* layouts - see `apps/shared/webrtc/MeshConnectionManager.ts`'s doc comment for the who-calls-whom and
|
|
9
|
+
* single-presenter rules this view relies on rather than re-deciding. These reusable, non-UI modules live under
|
|
10
|
+
* `apps/shared/` rather than this plugin's backend `src/` - `tsconfig.apps.json` builds `apps/` as its own
|
|
11
|
+
* program rooted at `apps/`, which cannot reference files outside it (`TS6059`), matching `booking-plugin`'s own
|
|
12
|
+
* identical `apps/shared/` convention for reusable frontend-only code.
|
|
13
|
+
*
|
|
14
|
+
* ## Fitting the window
|
|
15
|
+
*
|
|
16
|
+
* The call fills the viewport (`fixed inset-0`) as three rows - a slim header, the tiles (which take whatever room
|
|
17
|
+
* is left and never scroll the page), and the control bar pinned to the bottom - instead of being laid out inside
|
|
18
|
+
* the branded page shell, whose header, footer and padding pushed it off the screen. The local participant's own
|
|
19
|
+
* tile is a small tile in the bottom-right corner while anyone else is in the call (above the control bar on a narrower
|
|
20
|
+
* window, and at the top on a phone, where the bar wraps onto a second row), and fills the tile area while they are
|
|
21
|
+
* alone.
|
|
22
|
+
*
|
|
23
|
+
* ## Who is heard
|
|
24
|
+
*
|
|
25
|
+
* A tile never plays sound. Each remote stream is played by its own hidden `<audio>` element, so a participant is
|
|
26
|
+
* heard whether or not their camera is on and whichever layout is showing. If the browser refuses to start the
|
|
27
|
+
* audio (an autoplay policy), a banner asks for a click, which is the gesture that allows it.
|
|
28
|
+
*
|
|
29
|
+
* ## Layout precedence
|
|
30
|
+
*
|
|
31
|
+
* `computeMainUid()` decides who is shown large, in this order: an active presenter always wins (presentation
|
|
32
|
+
* mode, forcing a focused-like layout regardless of `viewMode`); otherwise a manually pinned participant; else the
|
|
33
|
+
* auto-detected active speaker (silently ignored while presenting, so it never fights the presenter for the main
|
|
34
|
+
* slot); else, in focus mode with nobody yet speaking, the first other participant - so focus mode never shows an
|
|
35
|
+
* empty main slot once someone else has joined.
|
|
36
|
+
*
|
|
37
|
+
* ## Talking stick mode
|
|
38
|
+
*
|
|
39
|
+
* A host-only navbar toggle (`handleToggleTalkingStick()`) that, once on, lets at most one participant's microphone
|
|
40
|
+
* be unmuted at a time - the host assigns who from the participants drawer (`handleGiveTalkingStick()`), everyone
|
|
41
|
+
* else sees a header chip naming who currently holds it. Purely an in-call runtime state signaled peer-to-peer over
|
|
42
|
+
* the mesh (`MeshConnectionManager.setTalkingStick()`/`"talking-stick-changed"`), the same shape as `mute-request`/
|
|
43
|
+
* `kicked`: no `VideoMeeting` field, no backend route, and only as "enforced" as a cooperating client makes it (see
|
|
44
|
+
* `types.ts`'s `SignalMessage` doc comment on why the signaling layer has no host identity to check against). What
|
|
45
|
+
* *is* new here versus `mute-request`'s one-time nudge: becoming or ceasing to be the holder force-toggles this
|
|
46
|
+
* tab's own mic to match (`selfHasTalkingStick`'s effect, below), and the mic button itself is disabled
|
|
47
|
+
* (`micLocked`, passed to `CallControls`) the whole time a non-holder would otherwise be able to tap it straight
|
|
48
|
+
* back on - a real restriction for as long as this tab's own UI is the one in front of the participant, not just a
|
|
49
|
+
* suggestion. Turning the mode off touches nobody's mic state, matching every other host toggle's "never
|
|
50
|
+
* retroactive" posture. A holder who leaves the call is not specially reassigned - see
|
|
51
|
+
* `MeshConnectionManager`'s own doc comment on why that needs no extra code - the header chip then says nobody has
|
|
52
|
+
* the floor, until the host picks someone (or themselves) again.
|
|
53
|
+
*
|
|
54
|
+
* ## Diagnostics, connection method and settings
|
|
55
|
+
*
|
|
56
|
+
* All three are opened from `_CallControls.tsx`'s own "…" menu (its doc comment covers the menu itself) via
|
|
57
|
+
* callback props, but owned here: `diagnosticsOpen` renders `_DiagnosticsWindow.tsx` (a persistent, draggable
|
|
58
|
+
* window - not a popover like the menus in the control bar, since troubleshooting a connection is something a
|
|
59
|
+
* participant wants to keep open while they poke at the rest of the call, not something that closes the moment
|
|
60
|
+
* they click elsewhere); `transportMode`/`handleSetTransportMode()` forces how *this tab's* media reaches everyone
|
|
61
|
+
* else (`TransportMode` - see `MeshConnectionManager.setTransportMode()`'s own doc comment), independent of what
|
|
62
|
+
* anyone else has chosen; `settingsOpen` renders `_SettingsModal.tsx`, which used to be the participants drawer's
|
|
63
|
+
* own header (mute-on-join, the join password, the waiting-room toggle) - moved out because none of those are
|
|
64
|
+
* about *who* is in the call, which is what the drawer is for.
|
|
65
|
+
*/
|
|
66
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
67
|
+
import { playRaisedHandChime } from "../shared/media/chime.js";
|
|
68
|
+
import { pickActiveSpeaker } from "../shared/media/activeSpeaker.js";
|
|
69
|
+
import { startLevelMeter, type LevelMeterHandle } from "../shared/media/levelMeter.js";
|
|
70
|
+
import { requestDisplayMedia, stopStream } from "../shared/media/deviceMedia.js";
|
|
71
|
+
import { NO_SCREEN_TRANSFORM, ScreenTransformProcessor, rotateClockwise, type ScreenTransformState } from "../shared/media/filters/ScreenTransform.js";
|
|
72
|
+
import type { LocalMedia } from "../shared/media/useLocalMedia.js";
|
|
73
|
+
import { createBrowserPeerConnection } from "../shared/webrtc/realPeerConnection.js";
|
|
74
|
+
import { MeshConnectionManager } from "../shared/webrtc/MeshConnectionManager.js";
|
|
75
|
+
import type { MeshParticipant, RelayTransportLike, TransportMode } from "../shared/webrtc/types.js";
|
|
76
|
+
import { createRelayTransport } from "../shared/relay/RelayTransport.js";
|
|
77
|
+
import { GuestSignalingClient } from "../shared/push/GuestSignalingClient.js";
|
|
78
|
+
import CallControls, { type CallViewMode } from "./_CallControls.js";
|
|
79
|
+
import { BatonIcon } from "./_icons.js";
|
|
80
|
+
import {
|
|
81
|
+
admitParticipant,
|
|
82
|
+
denyParticipant,
|
|
83
|
+
kickParticipant,
|
|
84
|
+
listWaitingParticipants,
|
|
85
|
+
setForceMuteOnJoin as apiSetForceMuteOnJoin,
|
|
86
|
+
setMeetingPassword,
|
|
87
|
+
setWaitingRoomEnabled as apiSetWaitingRoomEnabled,
|
|
88
|
+
type WaitingParticipant,
|
|
89
|
+
} from "./_meetApi.js";
|
|
90
|
+
import DiagnosticsPanel from "./_DiagnosticsPanel.js";
|
|
91
|
+
import DiagnosticsWindow from "./_DiagnosticsWindow.js";
|
|
92
|
+
import ParticipantTile from "./_ParticipantTile.js";
|
|
93
|
+
import ParticipantsDrawer from "./_ParticipantsDrawer.js";
|
|
94
|
+
import SettingsModal from "./_SettingsModal.js";
|
|
95
|
+
|
|
96
|
+
export interface CallViewProps {
|
|
97
|
+
channel: string;
|
|
98
|
+
/** Omitted when the caller already authenticated as a real RapidMX identity in `join()` - there is then no
|
|
99
|
+
* guest token to hand `GuestSignalingClient`, which relies entirely on the browser's own already-existing
|
|
100
|
+
* `jwt` session cookie instead (see its own doc comment). */
|
|
101
|
+
token?: string;
|
|
102
|
+
selfUid: string;
|
|
103
|
+
selfName: string;
|
|
104
|
+
meetingTitle: string;
|
|
105
|
+
iceServers: RTCIceServer[];
|
|
106
|
+
/** Whether the server offers the WebSocket media relay, the last-resort path for a participant neither a direct
|
|
107
|
+
* connection nor the TURN server can reach - `VideoMeetingJoinResult.relayEnabled`. Off when absent. */
|
|
108
|
+
relayEnabled?: boolean;
|
|
109
|
+
/** The meeting's host account uid (`PublicVideoMeeting.hostUid`) - this client's only source of a "host"
|
|
110
|
+
* identity, purely for deciding which controls to show (see `BaseVideoMeetingRoute`'s class doc comment on why
|
|
111
|
+
* this is a client-side-only check, not a server-enforced one for every moderation action). Absent when the
|
|
112
|
+
* server couldn't resolve one, in which case nobody sees host controls. */
|
|
113
|
+
hostUid?: string;
|
|
114
|
+
/** `PublicVideoMeeting.forceMuteOnJoin` as of this call's own `join()` - the starting value for the host's
|
|
115
|
+
* toggle in the settings modal, which this view then owns and keeps current itself (see
|
|
116
|
+
* `handleToggleForceMuteOnJoin()`). Does not update if changed elsewhere while this view is mounted - there is
|
|
117
|
+
* no signal for that today, matching every other meeting-settings field's lack of live sync. */
|
|
118
|
+
initialForceMuteOnJoin?: boolean;
|
|
119
|
+
/** `PublicVideoMeeting.hasPassword` as of this call's own `join()` - the starting value for the host's password
|
|
120
|
+
* section in the settings modal, same "owned and kept current by this view" shape as
|
|
121
|
+
* `initialForceMuteOnJoin`. */
|
|
122
|
+
initialHasPassword?: boolean;
|
|
123
|
+
/** `PublicVideoMeeting.waitingRoomEnabled` as of this call's own `join()` - the starting value for the host's
|
|
124
|
+
* waiting-room toggle, same "owned and kept current by this view" shape as `initialForceMuteOnJoin`. */
|
|
125
|
+
initialWaitingRoomEnabled?: boolean;
|
|
126
|
+
/** The camera and microphone, owned by the page (`[token].tsx`) - the lobby's tracks carried into the call. */
|
|
127
|
+
media: LocalMedia;
|
|
128
|
+
/** Called once the participant leaves, for any reason. `reason` is set only when the call ended without the
|
|
129
|
+
* participant's own action - currently, being kicked by the host - so the caller can show a distinct message
|
|
130
|
+
* instead of the ordinary "you left" one; omitted for an ordinary voluntary leave. */
|
|
131
|
+
onLeave: (reason?: string) => void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** How long a reaction floats on screen. */
|
|
135
|
+
const REACTION_MS = 4_000;
|
|
136
|
+
/** The most reactions shown at once - a burst beyond this drops the oldest. */
|
|
137
|
+
const MAX_REACTIONS = 12;
|
|
138
|
+
/** How often the host's drawer refreshes its own waiting-room list while open. */
|
|
139
|
+
const DEFAULT_WAITING_POLL_MS = 3_000;
|
|
140
|
+
|
|
141
|
+
interface Reaction {
|
|
142
|
+
id: number;
|
|
143
|
+
emoji: string;
|
|
144
|
+
name: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Who is shown large - see this module's doc comment. `undefined` when nobody but the local participant has
|
|
148
|
+
* joined yet (the grid/focus toggle still works, there's just nobody else to focus on). */
|
|
149
|
+
export function computeMainUid(options: {
|
|
150
|
+
presenterUid?: string;
|
|
151
|
+
pinnedUid?: string;
|
|
152
|
+
activeSpeakerUid?: string;
|
|
153
|
+
otherUids: readonly string[];
|
|
154
|
+
}): string | undefined {
|
|
155
|
+
if (options.presenterUid) {
|
|
156
|
+
return options.presenterUid;
|
|
157
|
+
}
|
|
158
|
+
if (options.pinnedUid) {
|
|
159
|
+
return options.pinnedUid;
|
|
160
|
+
}
|
|
161
|
+
if (options.activeSpeakerUid) {
|
|
162
|
+
return options.activeSpeakerUid;
|
|
163
|
+
}
|
|
164
|
+
return options.otherUids[0];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** This tab's identity in the call: the account (or guest) uid plus a random suffix, so the same account joining
|
|
168
|
+
* from two devices - or two tabs - is two participants rather than one that ignores itself. It travels as the
|
|
169
|
+
* `peer` of each message; `from` stays the exact authenticated uid, which the server requires. */
|
|
170
|
+
export function newPeerId(selfUid: string): string {
|
|
171
|
+
return `${selfUid}~${globalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2)}`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** The real, server-enforced account uid behind a participant's tab-scoped `MeshParticipant.uid` (`newPeerId()`'s
|
|
175
|
+
* `<account uid>~<random>` shape) - what the kick route's ACL grant is actually keyed by, unlike the tab-scoped id
|
|
176
|
+
* this view otherwise addresses a specific tab with. Neither a real account uid nor a minted guest uid (see
|
|
177
|
+
* `GUEST_UID_PREFIX`/`mintGuestToken()` on the backend) can itself contain "~", so the last one found is always
|
|
178
|
+
* exactly this suffix's own separator. */
|
|
179
|
+
export function accountUidOf(peerUid: string): string {
|
|
180
|
+
const i = peerUid.lastIndexOf("~");
|
|
181
|
+
return i === -1 ? peerUid : peerUid.slice(0, i);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export default function CallView({
|
|
185
|
+
channel,
|
|
186
|
+
token,
|
|
187
|
+
selfUid,
|
|
188
|
+
selfName,
|
|
189
|
+
meetingTitle,
|
|
190
|
+
iceServers,
|
|
191
|
+
relayEnabled,
|
|
192
|
+
hostUid,
|
|
193
|
+
initialForceMuteOnJoin,
|
|
194
|
+
initialHasPassword,
|
|
195
|
+
initialWaitingRoomEnabled,
|
|
196
|
+
media,
|
|
197
|
+
onLeave,
|
|
198
|
+
}: CallViewProps) {
|
|
199
|
+
const [peerId] = useState(() => newPeerId(selfUid));
|
|
200
|
+
const [connectError, setConnectError] = useState<string | null>(null);
|
|
201
|
+
const [participants, setParticipants] = useState<MeshParticipant[]>([]);
|
|
202
|
+
const [remoteStreams, setRemoteStreams] = useState<Record<string, MediaStream>>({});
|
|
203
|
+
const [levels, setLevels] = useState<Record<string, number>>({});
|
|
204
|
+
const [presenterUid, setPresenterUid] = useState<string | undefined>(undefined);
|
|
205
|
+
const [screenStream, setScreenStream] = useState<MediaStream | null>(null);
|
|
206
|
+
const [screenTransform, setScreenTransform] = useState<ScreenTransformState>(NO_SCREEN_TRANSFORM);
|
|
207
|
+
const [handRaised, setHandRaised] = useState(false);
|
|
208
|
+
const [viewMode, setViewMode] = useState<CallViewMode>("grid");
|
|
209
|
+
const [pinnedUid, setPinnedUid] = useState<string | undefined>(undefined);
|
|
210
|
+
const [activeSpeakerUid, setActiveSpeakerUid] = useState<string | undefined>(undefined);
|
|
211
|
+
const [reactions, setReactions] = useState<Reaction[]>([]);
|
|
212
|
+
const [announcement, setAnnouncement] = useState("");
|
|
213
|
+
const [audioBlocked, setAudioBlocked] = useState(false);
|
|
214
|
+
const [audioNonce, setAudioNonce] = useState(0);
|
|
215
|
+
const [signalingReady, setSignalingReady] = useState(false);
|
|
216
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
217
|
+
const [forceMuteOnJoin, setForceMuteOnJoinState] = useState(!!initialForceMuteOnJoin);
|
|
218
|
+
const [hasPassword, setHasPassword] = useState(!!initialHasPassword);
|
|
219
|
+
const [waitingRoomEnabled, setWaitingRoomEnabledState] = useState(!!initialWaitingRoomEnabled);
|
|
220
|
+
const [waitingParticipants, setWaitingParticipants] = useState<WaitingParticipant[]>([]);
|
|
221
|
+
const [talkingStickActive, setTalkingStickActive] = useState(false);
|
|
222
|
+
const [talkingStickHolder, setTalkingStickHolder] = useState<string | undefined>(undefined);
|
|
223
|
+
const [diagnosticsOpen, setDiagnosticsOpen] = useState(false);
|
|
224
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
225
|
+
const [transportMode, setTransportModeState] = useState<TransportMode>("auto");
|
|
226
|
+
|
|
227
|
+
const managerRef = useRef<MeshConnectionManager | null>(null);
|
|
228
|
+
/** The raw capture from `getDisplayMedia()` - only ever used to stop it (releasing the OS's own share
|
|
229
|
+
* indicator) and to notice the participant ending the share from the browser's own UI (`track.onended`). What's
|
|
230
|
+
* actually shown and sent is `screenTransformRef`'s output (`screenStream` state) - see `handleToggleShare()`. */
|
|
231
|
+
const screenStreamRef = useRef<MediaStream | null>(null);
|
|
232
|
+
const screenTransformRef = useRef<ScreenTransformProcessor | null>(null);
|
|
233
|
+
const levelMetersRef = useRef<Record<string, LevelMeterHandle>>({});
|
|
234
|
+
const reactionSeqRef = useRef(0);
|
|
235
|
+
const reactionTimersRef = useRef(new Set<ReturnType<typeof setTimeout>>());
|
|
236
|
+
/** The latest `media`, for the mesh-event handler below - that effect runs once at mount (see its own comment),
|
|
237
|
+
* so it would otherwise see only the mic state/toggle function from that first render. */
|
|
238
|
+
const mediaRef = useRef(media);
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
mediaRef.current = media;
|
|
241
|
+
}, [media]);
|
|
242
|
+
const isPresenting = !!screenStream;
|
|
243
|
+
|
|
244
|
+
const showReaction = useCallback((emoji: string, name: string) => {
|
|
245
|
+
const id = ++reactionSeqRef.current;
|
|
246
|
+
setReactions((prev) => [...prev.slice(-(MAX_REACTIONS - 1)), { id, emoji, name }]);
|
|
247
|
+
const timer = setTimeout(() => {
|
|
248
|
+
reactionTimersRef.current.delete(timer);
|
|
249
|
+
setReactions((prev) => prev.filter((reaction) => reaction.id !== id));
|
|
250
|
+
}, REACTION_MS);
|
|
251
|
+
reactionTimersRef.current.add(timer);
|
|
252
|
+
}, []);
|
|
253
|
+
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
let cancelled = false;
|
|
256
|
+
const client = new GuestSignalingClient({ channel, token });
|
|
257
|
+
const manager = new MeshConnectionManager({
|
|
258
|
+
selfUid,
|
|
259
|
+
peerId,
|
|
260
|
+
selfName,
|
|
261
|
+
iceServers,
|
|
262
|
+
channel: client,
|
|
263
|
+
createPeerConnection: createBrowserPeerConnection,
|
|
264
|
+
relay: relayEnabled ? createRelay(channel, peerId) : undefined,
|
|
265
|
+
localAudioTrack: media.audioTrack,
|
|
266
|
+
localVideoTrack: media.videoTrack,
|
|
267
|
+
localState: { audioOn: media.micOn, videoOn: media.cameraOn },
|
|
268
|
+
});
|
|
269
|
+
managerRef.current = manager;
|
|
270
|
+
|
|
271
|
+
const unsubscribe = manager.onEvent((event) => {
|
|
272
|
+
switch (event.type) {
|
|
273
|
+
case "participant-joined":
|
|
274
|
+
setParticipants((prev) => [...prev.filter((p) => p.uid !== event.participant.uid), event.participant]);
|
|
275
|
+
return;
|
|
276
|
+
case "participant-updated":
|
|
277
|
+
setParticipants((prev) => prev.map((p) => (p.uid === event.participant.uid ? event.participant : p)));
|
|
278
|
+
return;
|
|
279
|
+
case "participant-left":
|
|
280
|
+
setParticipants((prev) => prev.filter((p) => p.uid !== event.uid));
|
|
281
|
+
setRemoteStreams((prev) => {
|
|
282
|
+
const { [event.uid]: _removed, ...rest } = prev;
|
|
283
|
+
return rest;
|
|
284
|
+
});
|
|
285
|
+
stopLevelMeter(levelMetersRef, event.uid);
|
|
286
|
+
setLevels((prev) => {
|
|
287
|
+
const { [event.uid]: _removed, ...rest } = prev;
|
|
288
|
+
return rest;
|
|
289
|
+
});
|
|
290
|
+
setPinnedUid((prev) => (prev === event.uid ? undefined : prev));
|
|
291
|
+
return;
|
|
292
|
+
case "remote-stream":
|
|
293
|
+
setRemoteStreams((prev) => ({ ...prev, [event.uid]: event.stream }));
|
|
294
|
+
startTrackingLevel(levelMetersRef, event.uid, event.stream, (level) =>
|
|
295
|
+
setLevels((prev) => ({ ...prev, [event.uid]: level })),
|
|
296
|
+
);
|
|
297
|
+
return;
|
|
298
|
+
case "hand-raised":
|
|
299
|
+
playRaisedHandChime();
|
|
300
|
+
setAnnouncement(`${event.name} raised a hand`);
|
|
301
|
+
return;
|
|
302
|
+
case "reaction":
|
|
303
|
+
showReaction(event.emoji, event.name);
|
|
304
|
+
return;
|
|
305
|
+
case "presenter-changed":
|
|
306
|
+
setPresenterUid(event.uid);
|
|
307
|
+
if (event.uid !== peerId && screenStreamRef.current) {
|
|
308
|
+
// Lost a presenter-claim collision (see `MeshConnectionManager`'s doc comment) - stop our
|
|
309
|
+
// own capture without re-sending a release the manager already handled internally.
|
|
310
|
+
stopLocalPresentation(false);
|
|
311
|
+
}
|
|
312
|
+
return;
|
|
313
|
+
case "mute-requested":
|
|
314
|
+
if (mediaRef.current.micOn) {
|
|
315
|
+
void mediaRef.current.toggleMic();
|
|
316
|
+
}
|
|
317
|
+
return;
|
|
318
|
+
case "kicked":
|
|
319
|
+
onLeave("The host removed you from this call.");
|
|
320
|
+
return;
|
|
321
|
+
case "talking-stick-changed":
|
|
322
|
+
setTalkingStickActive(event.active);
|
|
323
|
+
setTalkingStickHolder(event.holder);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
client
|
|
329
|
+
.connect()
|
|
330
|
+
.then(() => {
|
|
331
|
+
if (!cancelled) {
|
|
332
|
+
manager.start();
|
|
333
|
+
setSignalingReady(true);
|
|
334
|
+
}
|
|
335
|
+
})
|
|
336
|
+
.catch((err: Error) => {
|
|
337
|
+
if (!cancelled) {
|
|
338
|
+
setConnectError(err.message);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
// A closing tab doesn't unmount React, so say goodbye explicitly - otherwise everyone else keeps a tile for a
|
|
343
|
+
// participant who is gone.
|
|
344
|
+
const onPageHide = () => manager.stop();
|
|
345
|
+
window.addEventListener("pagehide", onPageHide);
|
|
346
|
+
|
|
347
|
+
const timers = reactionTimersRef.current;
|
|
348
|
+
return () => {
|
|
349
|
+
cancelled = true;
|
|
350
|
+
window.removeEventListener("pagehide", onPageHide);
|
|
351
|
+
unsubscribe();
|
|
352
|
+
manager.stop();
|
|
353
|
+
client.close();
|
|
354
|
+
for (const handle of Object.values(levelMetersRef.current)) {
|
|
355
|
+
handle.stop();
|
|
356
|
+
}
|
|
357
|
+
levelMetersRef.current = {};
|
|
358
|
+
// Only the screen capture is this view's to stop - the camera and microphone belong to the page, which
|
|
359
|
+
// releases them when the participant leaves.
|
|
360
|
+
stopStream(screenStreamRef.current);
|
|
361
|
+
screenTransformRef.current?.stop();
|
|
362
|
+
for (const timer of timers) {
|
|
363
|
+
clearTimeout(timer);
|
|
364
|
+
}
|
|
365
|
+
timers.clear();
|
|
366
|
+
};
|
|
367
|
+
// Deliberately runs once - the call's identity (channel/token/selfUid) never changes for the life of this
|
|
368
|
+
// component; a real identity change is a new call, which unmounts/remounts this view from `[token].tsx`.
|
|
369
|
+
}, []);
|
|
370
|
+
|
|
371
|
+
// What is sent follows what the participant has: the camera or the shared screen, and the microphone.
|
|
372
|
+
useEffect(() => {
|
|
373
|
+
managerRef.current?.setLocalTrack("audio", media.audioTrack);
|
|
374
|
+
}, [media.audioTrack]);
|
|
375
|
+
useEffect(() => {
|
|
376
|
+
managerRef.current?.setLocalTrack("video", screenStream?.getVideoTracks()[0] ?? media.videoTrack);
|
|
377
|
+
}, [media.videoTrack, screenStream]);
|
|
378
|
+
useEffect(() => {
|
|
379
|
+
managerRef.current?.setLocalState({ audioOn: media.micOn, videoOn: media.cameraOn || isPresenting, handRaised });
|
|
380
|
+
}, [media.micOn, media.cameraOn, isPresenting, handRaised]);
|
|
381
|
+
|
|
382
|
+
// Talking-stick mode forces exactly one microphone on at a time: whoever just became the holder (including the
|
|
383
|
+
// host, on activation) is unmuted; everyone else is muted. Unlike `mute-requested`'s one-time nudge, this is
|
|
384
|
+
// paired with disabling the mic button itself (`micLocked`, passed to `CallControls` below) while it applies,
|
|
385
|
+
// so it isn't merely a suggestion - though still cooperative at the signaling layer, like every other
|
|
386
|
+
// moderation feature here (see `MeshConnectionManager`'s doc comment). Turning the mode off touches nobody's
|
|
387
|
+
// mic - states are left exactly as they are, the same "never retroactive" posture as every other host toggle.
|
|
388
|
+
const selfHasTalkingStick = talkingStickActive && talkingStickHolder === peerId;
|
|
389
|
+
const micLocked = talkingStickActive && !selfHasTalkingStick;
|
|
390
|
+
useEffect(() => {
|
|
391
|
+
if (!talkingStickActive) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (selfHasTalkingStick && !mediaRef.current.micOn) {
|
|
395
|
+
void mediaRef.current.toggleMic();
|
|
396
|
+
} else if (!selfHasTalkingStick && mediaRef.current.micOn) {
|
|
397
|
+
void mediaRef.current.toggleMic();
|
|
398
|
+
}
|
|
399
|
+
}, [talkingStickActive, selfHasTalkingStick]);
|
|
400
|
+
|
|
401
|
+
useEffect(() => {
|
|
402
|
+
if (!presenterUid) {
|
|
403
|
+
setActiveSpeakerUid((prev) => pickActiveSpeaker(levels, prev));
|
|
404
|
+
}
|
|
405
|
+
}, [levels, presenterUid]);
|
|
406
|
+
|
|
407
|
+
function stopLocalPresentation(alsoRelease: boolean): void {
|
|
408
|
+
if (alsoRelease) {
|
|
409
|
+
managerRef.current?.releasePresenter();
|
|
410
|
+
}
|
|
411
|
+
stopStream(screenStreamRef.current);
|
|
412
|
+
screenStreamRef.current = null;
|
|
413
|
+
screenTransformRef.current?.stop();
|
|
414
|
+
screenTransformRef.current = null;
|
|
415
|
+
// The sync effect above swaps the camera back in as the outgoing video track. The rotation/flip is reset
|
|
416
|
+
// for the next share - each share starts from the capture the browser hands back, not the last one's fix.
|
|
417
|
+
setScreenStream(null);
|
|
418
|
+
setScreenTransform(NO_SCREEN_TRANSFORM);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async function handleToggleShare() {
|
|
422
|
+
if (screenStreamRef.current) {
|
|
423
|
+
stopLocalPresentation(true);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const result = await requestDisplayMedia();
|
|
427
|
+
if (!result.ok) {
|
|
428
|
+
setConnectError(result.error.message);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const claimed = managerRef.current?.claimPresenter() ?? false;
|
|
432
|
+
if (!claimed) {
|
|
433
|
+
stopStream(result.value);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
screenStreamRef.current = result.value;
|
|
437
|
+
const rawTrack = result.value.getVideoTracks()[0];
|
|
438
|
+
rawTrack.onended = () => stopLocalPresentation(true);
|
|
439
|
+
try {
|
|
440
|
+
// Runs the capture through the rotate/flip processor before anyone (presenter included) sees it - see
|
|
441
|
+
// ScreenTransform.ts's doc comment on why window capture sometimes needs this correction.
|
|
442
|
+
const processor = new ScreenTransformProcessor({ source: rawTrack, state: screenTransform });
|
|
443
|
+
screenTransformRef.current = processor;
|
|
444
|
+
setScreenStream(new MediaStream([processor.track]));
|
|
445
|
+
} catch {
|
|
446
|
+
// This browser can't draw the correction - share the raw capture rather than not sharing at all; the
|
|
447
|
+
// rotate/flip buttons simply won't do anything (screenTransformRef stays null).
|
|
448
|
+
setScreenStream(result.value);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function handleRotateScreen() {
|
|
453
|
+
setScreenTransform((prev) => {
|
|
454
|
+
const next = rotateClockwise(prev);
|
|
455
|
+
screenTransformRef.current?.setState(next);
|
|
456
|
+
return next;
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function handleFlipScreen() {
|
|
461
|
+
setScreenTransform((prev) => {
|
|
462
|
+
const next = { ...prev, flipped: !prev.flipped };
|
|
463
|
+
screenTransformRef.current?.setState(next);
|
|
464
|
+
return next;
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function handleToggleHand() {
|
|
469
|
+
setHandRaised((prev) => !prev);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function handleReaction(emoji: string) {
|
|
473
|
+
if (managerRef.current?.sendReaction(emoji)) {
|
|
474
|
+
showReaction(emoji, "You");
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function togglePin(uid: string) {
|
|
479
|
+
setPinnedUid((prev) => (prev === uid ? undefined : uid));
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** Asks `peerUid`'s participant to mute - the host-only button in the participants drawer calls this
|
|
483
|
+
* directly, with no confirmation (unlike removing someone, muting is easily undone by the participant
|
|
484
|
+
* themselves). */
|
|
485
|
+
function handleMuteParticipant(peerUid: string) {
|
|
486
|
+
managerRef.current?.sendMuteRequest(peerUid);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** Removes `peerUid`'s participant from the call: the cooperative signal (immediate, so a cooperating client
|
|
490
|
+
* leaves without waiting on the network round trip below) and the enforced server-side revoke together - see
|
|
491
|
+
* `kickParticipant()`'s own doc comment for why both matter. The REST call's failure is swallowed rather than
|
|
492
|
+
* surfaced: the host already asked them to leave, and there is no useful recovery action to offer from here
|
|
493
|
+
* for what is almost always a transient network issue. */
|
|
494
|
+
function handleKickParticipant(peerUid: string) {
|
|
495
|
+
managerRef.current?.sendKick(peerUid);
|
|
496
|
+
kickParticipant(channel, accountUidOf(peerUid)).catch(() => undefined);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/** Flips the host's "mute new participants on join" setting: applied optimistically (the toggle itself is the
|
|
500
|
+
* only feedback this small a control needs) and reverted if the save fails, so the drawer never keeps claiming
|
|
501
|
+
* a setting that isn't actually persisted. Takes effect for whoever joins next - never retroactive, see
|
|
502
|
+
* `setForceMuteOnJoin()`'s own doc comment. */
|
|
503
|
+
function handleToggleForceMuteOnJoin() {
|
|
504
|
+
const next = !forceMuteOnJoin;
|
|
505
|
+
setForceMuteOnJoinState(next);
|
|
506
|
+
apiSetForceMuteOnJoin(channel, next).catch(() => setForceMuteOnJoinState(!next));
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/** Sets, changes, or removes (`password: null`) the host's join password - unlike the force-mute toggle, this
|
|
510
|
+
* is not applied optimistically: the drawer's own `PasswordSection` awaits the result itself (clearing its
|
|
511
|
+
* input on success, showing an inline error on failure), so there is nothing here to revert. `hasPassword`
|
|
512
|
+
* updates only once the save actually succeeds. */
|
|
513
|
+
async function handleSetPassword(password: string | null): Promise<void> {
|
|
514
|
+
await setMeetingPassword(channel, password);
|
|
515
|
+
setHasPassword(!!password);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/** Flips the host's waiting-room setting - same optimistic-and-revert shape as `handleToggleForceMuteOnJoin()`,
|
|
519
|
+
* for the same reason. Takes effect for whoever joins next; nobody already admitted is retroactively gated. */
|
|
520
|
+
function handleToggleWaitingRoomEnabled() {
|
|
521
|
+
const next = !waitingRoomEnabled;
|
|
522
|
+
setWaitingRoomEnabledState(next);
|
|
523
|
+
apiSetWaitingRoomEnabled(channel, next).catch(() => setWaitingRoomEnabledState(!next));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/** Starts or stops talking-stick mode - host-only, see this module's doc comment. Starting makes the host the
|
|
527
|
+
* initial holder; stopping clears the holder too, leaving mic states exactly as they are rather than
|
|
528
|
+
* retroactively unmuting anyone. */
|
|
529
|
+
function handleToggleTalkingStick() {
|
|
530
|
+
managerRef.current?.setTalkingStick(!talkingStickActive, talkingStickActive ? undefined : peerId);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** Hands the talking stick to `uid` (a participant's `MeshParticipant.uid`, or this tab's own `peerId` for the
|
|
534
|
+
* host taking it back) - host-only, called from the participants drawer's per-row "Give stick" button. */
|
|
535
|
+
function handleGiveTalkingStick(uid: string) {
|
|
536
|
+
managerRef.current?.setTalkingStick(true, uid);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** Forces this tab's own transport policy - see `MeshConnectionManager.setTransportMode()`'s doc comment for
|
|
540
|
+
* what each mode actually does, and `_CallControls.tsx`'s doc comment on its "…" menu for why this is a
|
|
541
|
+
* personal, per-tab choice rather than a meeting setting. */
|
|
542
|
+
function handleSetTransportMode(mode: TransportMode) {
|
|
543
|
+
setTransportModeState(mode);
|
|
544
|
+
managerRef.current?.setTransportMode(mode);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** Admits one pending request - optimistically removed from the drawer's own list (the next poll would drop it
|
|
548
|
+
* anyway, once the requester's own next poll completes their join; removing it here just avoids the visible
|
|
549
|
+
* delay). Re-added if the save itself fails, so a failure doesn't silently lose the request from the list. */
|
|
550
|
+
function handleAdmitParticipant(uid: string) {
|
|
551
|
+
setWaitingParticipants((prev) => prev.filter((p) => p.uid !== uid));
|
|
552
|
+
admitParticipant(channel, uid).catch(() => void listWaitingParticipants(channel).then(setWaitingParticipants, () => undefined));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** Denies one pending request - same optimistic-removal shape as `handleAdmitParticipant()`. */
|
|
556
|
+
function handleDenyParticipant(uid: string) {
|
|
557
|
+
setWaitingParticipants((prev) => prev.filter((p) => p.uid !== uid));
|
|
558
|
+
denyParticipant(channel, uid).catch(() => void listWaitingParticipants(channel).then(setWaitingParticipants, () => undefined));
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function handleAudioBlocked() {
|
|
562
|
+
setAudioBlocked(true);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function handleResumeAudio() {
|
|
566
|
+
setAudioBlocked(false);
|
|
567
|
+
setAudioNonce((prev) => prev + 1);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// A participant's `uid` is their tab-scoped peer id (`<account uid>~<random>` - see `newPeerId()`), while
|
|
571
|
+
// `hostUid` is the plain account uid `PublicVideoMeeting.hostUid` names - so telling the host's own tab(s) apart
|
|
572
|
+
// needs the prefix match, not equality. Purely a client-side check (see `hostUid`'s own doc comment on this
|
|
573
|
+
// prop): nobody's tab is prevented from claiming it, only from being shown host controls for it.
|
|
574
|
+
const isHost = !!hostUid && selfUid === hostUid;
|
|
575
|
+
const isParticipantHost = (uid: string): boolean => !!hostUid && uid.startsWith(`${hostUid}~`);
|
|
576
|
+
|
|
577
|
+
// Refreshes the drawer's own waiting-room list while the host has the drawer open - there is no push signal
|
|
578
|
+
// for a newly filed admission request, so polling is the only way the list stays current without the host
|
|
579
|
+
// having to close and reopen the drawer. Stops (and the list is dropped) the moment either condition ends.
|
|
580
|
+
useEffect(() => {
|
|
581
|
+
if (!isHost || !drawerOpen) {
|
|
582
|
+
setWaitingParticipants([]);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
let cancelled = false;
|
|
586
|
+
const poll = () => {
|
|
587
|
+
listWaitingParticipants(channel).then((list) => {
|
|
588
|
+
if (!cancelled) {
|
|
589
|
+
setWaitingParticipants(list);
|
|
590
|
+
}
|
|
591
|
+
}, () => undefined);
|
|
592
|
+
};
|
|
593
|
+
poll();
|
|
594
|
+
const interval = setInterval(poll, DEFAULT_WAITING_POLL_MS);
|
|
595
|
+
return () => {
|
|
596
|
+
cancelled = true;
|
|
597
|
+
clearInterval(interval);
|
|
598
|
+
};
|
|
599
|
+
}, [isHost, drawerOpen, channel]);
|
|
600
|
+
const otherUids = participants.map((p) => p.uid);
|
|
601
|
+
// A pin or an active-speaker pick can name someone who has just left, until the state catches up.
|
|
602
|
+
const stillHere = (uid: string | undefined) => (uid && otherUids.includes(uid) ? uid : undefined);
|
|
603
|
+
const showFocusLayout = !!presenterUid || viewMode === "focus";
|
|
604
|
+
const mainUid = showFocusLayout
|
|
605
|
+
? computeMainUid({ presenterUid, pinnedUid: stillHere(pinnedUid), activeSpeakerUid: stillHere(activeSpeakerUid), otherUids })
|
|
606
|
+
: undefined;
|
|
607
|
+
const presenterName = presenterUid ? (presenterUid === peerId ? selfName : (participants.find((p) => p.uid === presenterUid)?.name ?? "Someone")) : undefined;
|
|
608
|
+
const raisedNames = [...(handRaised ? ["You"] : []), ...participants.filter((p) => p.handRaised).map((p) => p.name)];
|
|
609
|
+
// Absent (not "Someone") once the holder has left the call - see `MeshConnectionManager`'s doc comment on why
|
|
610
|
+
// nothing reassigns it automatically; the header then says so rather than naming someone no longer here.
|
|
611
|
+
const talkingStickHolderName = !talkingStickActive
|
|
612
|
+
? undefined
|
|
613
|
+
: selfHasTalkingStick
|
|
614
|
+
? "You"
|
|
615
|
+
: participants.find((p) => p.uid === talkingStickHolder)?.name;
|
|
616
|
+
const alone = participants.length === 0;
|
|
617
|
+
// This participant has no working link yet: the signaling channel is still opening, or there is someone in the call
|
|
618
|
+
// and every connection to them is still being made. Once any one is up (or nobody else is here) it is not shown,
|
|
619
|
+
// so someone already in the call is not told they are "connecting" each time a newcomer arrives.
|
|
620
|
+
const selfConnecting = !connectError && (!signalingReady || (!alone && participants.every((p) => p.transport === "connecting")));
|
|
621
|
+
|
|
622
|
+
const remoteTile = (p: MeshParticipant, className?: string) => (
|
|
623
|
+
<ParticipantTile
|
|
624
|
+
key={p.uid}
|
|
625
|
+
name={p.name}
|
|
626
|
+
stream={remoteStreams[p.uid] ?? null}
|
|
627
|
+
cameraOff={!p.videoOn}
|
|
628
|
+
micMuted={!p.audioOn}
|
|
629
|
+
handRaised={p.handRaised}
|
|
630
|
+
transport={p.transport}
|
|
631
|
+
status={p.transport === "connecting" ? "Awaiting connection…" : undefined}
|
|
632
|
+
isFocused={mainUid === p.uid}
|
|
633
|
+
contain={presenterUid === p.uid}
|
|
634
|
+
className={className}
|
|
635
|
+
onClick={() => togglePin(p.uid)}
|
|
636
|
+
/>
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
const selfTile = (className?: string) => (
|
|
640
|
+
<ParticipantTile
|
|
641
|
+
name={selfName}
|
|
642
|
+
stream={media.videoStream}
|
|
643
|
+
isLocal
|
|
644
|
+
cameraOff={!media.cameraOn}
|
|
645
|
+
micMuted={!media.micOn}
|
|
646
|
+
handRaised={handRaised}
|
|
647
|
+
status={selfConnecting ? "Connecting…" : undefined}
|
|
648
|
+
// A custom background is a fixed picture, not a live reflection - mirroring it would show it backwards
|
|
649
|
+
// to no one but the participant themselves (see `_ParticipantTile.tsx`'s doc comment).
|
|
650
|
+
mirrored={media.filters.background !== "image"}
|
|
651
|
+
className={className}
|
|
652
|
+
/>
|
|
653
|
+
);
|
|
654
|
+
|
|
655
|
+
const mainParticipant = participants.find((p) => p.uid === mainUid);
|
|
656
|
+
const thumbnails = participants.filter((p) => p.uid !== mainUid);
|
|
657
|
+
|
|
658
|
+
let stage: React.ReactNode;
|
|
659
|
+
if (alone) {
|
|
660
|
+
// Nobody else yet: the local participant fills the tile area, presenting or not.
|
|
661
|
+
stage = isPresenting ? (
|
|
662
|
+
<ParticipantTile name={selfName} stream={screenStream} isLocal contain isFocused className="h-full" />
|
|
663
|
+
) : (
|
|
664
|
+
selfTile("h-full")
|
|
665
|
+
);
|
|
666
|
+
} else if (showFocusLayout && (mainParticipant || isPresenting)) {
|
|
667
|
+
stage = (
|
|
668
|
+
<div className="h-full flex flex-col gap-2">
|
|
669
|
+
<div className="flex-1 min-h-0" data-testid="main-tile">
|
|
670
|
+
{mainParticipant ? (
|
|
671
|
+
remoteTile(mainParticipant, "h-full")
|
|
672
|
+
) : (
|
|
673
|
+
<ParticipantTile name={selfName} stream={screenStream} isLocal contain isFocused className="h-full" />
|
|
674
|
+
)}
|
|
675
|
+
</div>
|
|
676
|
+
{thumbnails.length > 0 && (
|
|
677
|
+
<div className="flex gap-2 overflow-x-auto h-24 shrink-0" data-testid="thumbnails">
|
|
678
|
+
{thumbnails.map((p) => (
|
|
679
|
+
<div key={p.uid} className="w-36 shrink-0">
|
|
680
|
+
{remoteTile(p, "h-full")}
|
|
681
|
+
</div>
|
|
682
|
+
))}
|
|
683
|
+
</div>
|
|
684
|
+
)}
|
|
685
|
+
</div>
|
|
686
|
+
);
|
|
687
|
+
} else {
|
|
688
|
+
stage = (
|
|
689
|
+
<div className="h-full grid gap-2 auto-rows-fr [grid-template-columns:repeat(auto-fit,minmax(min(100%,320px),1fr))]">
|
|
690
|
+
{participants.map((p) => remoteTile(p, "h-full"))}
|
|
691
|
+
</div>
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
return (
|
|
696
|
+
<div className="fixed inset-0 z-50 flex bg-[#202124] text-white overflow-hidden">
|
|
697
|
+
<style>{`@keyframes meet-float { 0% { transform: translateY(0) scale(.6); opacity: 0; } 12% { opacity: 1; transform: translateY(-4vh) scale(1); } 100% { transform: translateY(-45vh) scale(1); opacity: 0; } }`}</style>
|
|
698
|
+
<div className="relative flex-1 min-w-0 flex flex-col overflow-hidden">
|
|
699
|
+
<header className="shrink-0 flex items-center justify-between gap-3 px-4 py-3">
|
|
700
|
+
<h1 className="min-w-0 truncate text-base font-medium">{meetingTitle}</h1>
|
|
701
|
+
<div className="flex items-center gap-2 shrink-0">
|
|
702
|
+
{raisedNames.length > 0 && (
|
|
703
|
+
<span className="max-w-[45vw] truncate px-3 py-1.5 rounded-full bg-[#a8c7fa] text-[#062e6f] text-sm font-medium" data-testid="raised-hands">
|
|
704
|
+
✋ {raisedNames.join(", ")}
|
|
705
|
+
</span>
|
|
706
|
+
)}
|
|
707
|
+
{talkingStickActive && (
|
|
708
|
+
<span className="max-w-[45vw] truncate px-3 py-1.5 rounded-full bg-[#a8c7fa] text-[#062e6f] text-sm font-medium" data-testid="talking-stick-status">
|
|
709
|
+
🎙️ {talkingStickHolderName ? `${talkingStickHolderName} ${talkingStickHolderName === "You" ? "have" : "has"} the floor` : "Waiting for the host to choose a speaker"}
|
|
710
|
+
</span>
|
|
711
|
+
)}
|
|
712
|
+
{isHost && (
|
|
713
|
+
<button
|
|
714
|
+
type="button"
|
|
715
|
+
className={`w-9 h-9 flex items-center justify-center rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-white/80 ${talkingStickActive ? "bg-[#a8c7fa] text-[#062e6f] hover:bg-[#8ab4f8]" : "bg-[#3c4043] hover:bg-[#4b4f53]"}`}
|
|
716
|
+
aria-label={talkingStickActive ? "End talking stick" : "Talking stick"}
|
|
717
|
+
aria-pressed={talkingStickActive}
|
|
718
|
+
title={talkingStickActive ? "End talking stick" : "Start talking stick mode"}
|
|
719
|
+
onClick={handleToggleTalkingStick}
|
|
720
|
+
>
|
|
721
|
+
<BatonIcon />
|
|
722
|
+
</button>
|
|
723
|
+
)}
|
|
724
|
+
<button
|
|
725
|
+
type="button"
|
|
726
|
+
className="px-3 py-1.5 rounded-full bg-[#3c4043] hover:bg-[#4b4f53] text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-white/80"
|
|
727
|
+
aria-label={`${participants.length + 1} participants`}
|
|
728
|
+
aria-haspopup="dialog"
|
|
729
|
+
aria-expanded={drawerOpen}
|
|
730
|
+
onClick={() => setDrawerOpen((prev) => !prev)}
|
|
731
|
+
>
|
|
732
|
+
{participants.length + 1}
|
|
733
|
+
</button>
|
|
734
|
+
</div>
|
|
735
|
+
</header>
|
|
736
|
+
{connectError && (
|
|
737
|
+
<div role="alert" className="shrink-0 mx-3 mb-2 px-3 py-2 rounded-lg bg-[#601410] text-[#f9dedc] text-sm">
|
|
738
|
+
{connectError}
|
|
739
|
+
</div>
|
|
740
|
+
)}
|
|
741
|
+
{audioBlocked && (
|
|
742
|
+
<button
|
|
743
|
+
type="button"
|
|
744
|
+
className="shrink-0 mx-3 mb-2 px-3 py-2 rounded-lg bg-[#a8c7fa] text-[#062e6f] text-sm font-medium"
|
|
745
|
+
onClick={handleResumeAudio}
|
|
746
|
+
>
|
|
747
|
+
Click here to turn on sound
|
|
748
|
+
</button>
|
|
749
|
+
)}
|
|
750
|
+
<main className="relative flex-1 min-h-0 px-3 pb-3">
|
|
751
|
+
{stage}
|
|
752
|
+
{presenterName && presenterUid !== peerId && (
|
|
753
|
+
<p className="absolute top-2 left-5 px-2 py-0.5 rounded bg-black/60 text-sm">{presenterName} is presenting</p>
|
|
754
|
+
)}
|
|
755
|
+
</main>
|
|
756
|
+
<footer className="shrink-0 pt-1 pb-[max(0.75rem,env(safe-area-inset-bottom))]">
|
|
757
|
+
<CallControls
|
|
758
|
+
media={media}
|
|
759
|
+
participants={participants}
|
|
760
|
+
isPresenting={isPresenting}
|
|
761
|
+
presentingElsewhereName={presenterUid && presenterUid !== peerId ? presenterName : undefined}
|
|
762
|
+
onToggleShare={() => void handleToggleShare()}
|
|
763
|
+
screenTransform={screenTransform}
|
|
764
|
+
onRotateScreen={handleRotateScreen}
|
|
765
|
+
onFlipScreen={handleFlipScreen}
|
|
766
|
+
handRaised={handRaised}
|
|
767
|
+
onToggleHand={handleToggleHand}
|
|
768
|
+
onReaction={handleReaction}
|
|
769
|
+
viewMode={viewMode}
|
|
770
|
+
onToggleViewMode={() => setViewMode((prev) => (prev === "grid" ? "focus" : "grid"))}
|
|
771
|
+
micLocked={micLocked}
|
|
772
|
+
isHost={isHost}
|
|
773
|
+
transportMode={transportMode}
|
|
774
|
+
onSetTransportMode={handleSetTransportMode}
|
|
775
|
+
onOpenDiagnostics={() => setDiagnosticsOpen(true)}
|
|
776
|
+
onOpenSettings={() => setSettingsOpen(true)}
|
|
777
|
+
onLeave={onLeave}
|
|
778
|
+
/>
|
|
779
|
+
</footer>
|
|
780
|
+
|
|
781
|
+
{!alone && (
|
|
782
|
+
<div
|
|
783
|
+
className="absolute z-10 right-3 top-14 w-28 sm:top-auto sm:bottom-24 sm:w-52 aspect-video shadow-xl xl:right-4 xl:bottom-4"
|
|
784
|
+
data-testid="self-view"
|
|
785
|
+
>
|
|
786
|
+
{selfTile("h-full")}
|
|
787
|
+
</div>
|
|
788
|
+
)}
|
|
789
|
+
|
|
790
|
+
<div className="pointer-events-none absolute left-4 bottom-28 w-40 h-[45vh]" aria-hidden="true">
|
|
791
|
+
{reactions.map((reaction) => (
|
|
792
|
+
<div
|
|
793
|
+
key={reaction.id}
|
|
794
|
+
className="absolute bottom-0 flex flex-col items-center"
|
|
795
|
+
style={{ left: `${(reaction.id % 4) * 36}px`, animation: `meet-float ${REACTION_MS}ms ease-out forwards` }}
|
|
796
|
+
data-testid="reaction"
|
|
797
|
+
>
|
|
798
|
+
<span className="text-4xl leading-none">{reaction.emoji}</span>
|
|
799
|
+
<span className="mt-1 px-1.5 rounded-full bg-[#a8c7fa] text-[#062e6f] text-xs">{reaction.name}</span>
|
|
800
|
+
</div>
|
|
801
|
+
))}
|
|
802
|
+
</div>
|
|
803
|
+
|
|
804
|
+
{participants.map((p) => {
|
|
805
|
+
const stream = remoteStreams[p.uid];
|
|
806
|
+
return stream ? <RemoteAudio key={`${p.uid}:${audioNonce}`} stream={stream} onBlocked={handleAudioBlocked} /> : null;
|
|
807
|
+
})}
|
|
808
|
+
<div role="status" aria-live="polite" className="sr-only">
|
|
809
|
+
{announcement}
|
|
810
|
+
</div>
|
|
811
|
+
</div>
|
|
812
|
+
|
|
813
|
+
{drawerOpen && (
|
|
814
|
+
<ParticipantsDrawer
|
|
815
|
+
selfName={selfName}
|
|
816
|
+
micOn={media.micOn}
|
|
817
|
+
handRaised={handRaised}
|
|
818
|
+
participants={participants}
|
|
819
|
+
isSelfHost={isHost}
|
|
820
|
+
isParticipantHost={isParticipantHost}
|
|
821
|
+
onMute={handleMuteParticipant}
|
|
822
|
+
onKick={handleKickParticipant}
|
|
823
|
+
waitingRoomEnabled={waitingRoomEnabled}
|
|
824
|
+
waitingParticipants={waitingParticipants}
|
|
825
|
+
onAdmit={handleAdmitParticipant}
|
|
826
|
+
onDeny={handleDenyParticipant}
|
|
827
|
+
talkingStickActive={talkingStickActive}
|
|
828
|
+
selfPeerId={peerId}
|
|
829
|
+
talkingStickHolder={talkingStickHolder}
|
|
830
|
+
onGiveTalkingStick={handleGiveTalkingStick}
|
|
831
|
+
onClose={() => setDrawerOpen(false)}
|
|
832
|
+
/>
|
|
833
|
+
)}
|
|
834
|
+
|
|
835
|
+
{diagnosticsOpen && (
|
|
836
|
+
<DiagnosticsWindow onClose={() => setDiagnosticsOpen(false)}>
|
|
837
|
+
<DiagnosticsPanel selfName={selfName} micOn={media.micOn} cameraOn={media.cameraOn} participants={participants} />
|
|
838
|
+
</DiagnosticsWindow>
|
|
839
|
+
)}
|
|
840
|
+
|
|
841
|
+
{settingsOpen && isHost && (
|
|
842
|
+
<SettingsModal
|
|
843
|
+
forceMuteOnJoin={forceMuteOnJoin}
|
|
844
|
+
onToggleForceMuteOnJoin={handleToggleForceMuteOnJoin}
|
|
845
|
+
hasPassword={hasPassword}
|
|
846
|
+
onSetPassword={handleSetPassword}
|
|
847
|
+
waitingRoomEnabled={waitingRoomEnabled}
|
|
848
|
+
onToggleWaitingRoomEnabled={handleToggleWaitingRoomEnabled}
|
|
849
|
+
onClose={() => setSettingsOpen(false)}
|
|
850
|
+
/>
|
|
851
|
+
)}
|
|
852
|
+
</div>
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/** Plays one remote participant's stream through a hidden `<audio>` element. `onBlocked` fires if the browser
|
|
857
|
+
* refuses to start it (an autoplay policy) - the view then asks for a click. */
|
|
858
|
+
function RemoteAudio({ stream, onBlocked }: { stream: MediaStream; onBlocked: () => void }) {
|
|
859
|
+
const audioRef = useRef<HTMLAudioElement>(null);
|
|
860
|
+
useEffect(() => {
|
|
861
|
+
const element = audioRef.current!;
|
|
862
|
+
element.srcObject = stream;
|
|
863
|
+
void Promise.resolve(element.play()).catch(onBlocked);
|
|
864
|
+
}, [stream, onBlocked]);
|
|
865
|
+
return <audio ref={audioRef} autoPlay data-testid="remote-audio" />;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/** The WebSocket media relay for this call, or `undefined` when this browser cannot run it (no WebCodecs) - the
|
|
869
|
+
* mesh then never falls back to it, and says so by marking an unreachable participant `"failed"`. */
|
|
870
|
+
function createRelay(meetingUid: string, peerId: string): RelayTransportLike | undefined {
|
|
871
|
+
const relay = createRelayTransport({ meetingUid, peerId });
|
|
872
|
+
return relay.supported ? relay : undefined;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
function stopLevelMeter(ref: React.MutableRefObject<Record<string, LevelMeterHandle>>, uid: string): void {
|
|
876
|
+
ref.current[uid]?.stop();
|
|
877
|
+
delete ref.current[uid];
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
function startTrackingLevel(
|
|
881
|
+
ref: React.MutableRefObject<Record<string, LevelMeterHandle>>,
|
|
882
|
+
uid: string,
|
|
883
|
+
stream: MediaStream,
|
|
884
|
+
onLevel: (level: number) => void,
|
|
885
|
+
): void {
|
|
886
|
+
stopLevelMeter(ref, uid);
|
|
887
|
+
const handle = startLevelMeter(stream, onLevel);
|
|
888
|
+
if (handle) {
|
|
889
|
+
ref.current[uid] = handle;
|
|
890
|
+
}
|
|
891
|
+
}
|