@mrksbnc/livekit-vue 0.0.0

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.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/dist/components.cjs +2 -0
  4. package/dist/components.cjs.map +1 -0
  5. package/dist/components.d.ts +1 -0
  6. package/dist/components.mjs +213 -0
  7. package/dist/components.mjs.map +1 -0
  8. package/dist/composables.cjs +2 -0
  9. package/dist/composables.cjs.map +1 -0
  10. package/dist/composables.d.ts +1 -0
  11. package/dist/composables.mjs +913 -0
  12. package/dist/composables.mjs.map +1 -0
  13. package/dist/contexts-BGR-EyiF.mjs +227 -0
  14. package/dist/contexts-BGR-EyiF.mjs.map +1 -0
  15. package/dist/favicon.ico +0 -0
  16. package/dist/index.cjs +2 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.css +1 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.mjs +74 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/shared-B72lPzrj.cjs +2 -0
  23. package/dist/shared-B72lPzrj.cjs.map +1 -0
  24. package/dist/shared-Bt-fJtlk.cjs +2 -0
  25. package/dist/shared-Bt-fJtlk.cjs.map +1 -0
  26. package/dist/shared-UqxyWhFA.cjs +2 -0
  27. package/dist/shared-UqxyWhFA.cjs.map +1 -0
  28. package/package.json +78 -0
  29. package/src/App.vue +16 -0
  30. package/src/assets/icons/chevron-down.svg +4 -0
  31. package/src/assets/icons/chevron-up.svg +4 -0
  32. package/src/assets/icons/frown.svg +7 -0
  33. package/src/assets/icons/heart.svg +6 -0
  34. package/src/assets/icons/mic-off.svg +8 -0
  35. package/src/assets/icons/mic.svg +7 -0
  36. package/src/assets/icons/phone-hang-up.svg +9 -0
  37. package/src/assets/icons/share-screen-off.svg +6 -0
  38. package/src/assets/icons/share-screen.svg +7 -0
  39. package/src/assets/icons/smile.svg +7 -0
  40. package/src/assets/icons/thumbs-down.svg +6 -0
  41. package/src/assets/icons/thumbs-up.svg +6 -0
  42. package/src/assets/icons/video-off.svg +5 -0
  43. package/src/assets/icons/video.svg +5 -0
  44. package/src/assets/index.ts +1 -0
  45. package/src/assets/placeholders/participant.svg +8 -0
  46. package/src/components/controls/TrackToggle.vue +27 -0
  47. package/src/components/controls/buttons.ts +5 -0
  48. package/src/components/controls/index.ts +3 -0
  49. package/src/components/controls/track_toggle.ts +13 -0
  50. package/src/components/icons/ParticipantPlaceholderIcon.vue +7 -0
  51. package/src/components/icons/TrackIcon.vue +55 -0
  52. package/src/components/index.ts +3 -0
  53. package/src/components/participant/AudioTrack.vue +17 -0
  54. package/src/components/participant/audio_track.ts +8 -0
  55. package/src/composables/index.ts +89 -0
  56. package/src/composables/private/useObservableState.ts +44 -0
  57. package/src/composables/useAudioPlayback.ts +42 -0
  58. package/src/composables/useClearPinButton.ts +41 -0
  59. package/src/composables/useConnectionQualityIndicator.ts +39 -0
  60. package/src/composables/useConnectionState.ts +21 -0
  61. package/src/composables/useDataChannel.ts +56 -0
  62. package/src/composables/useDisconnectButton.ts +28 -0
  63. package/src/composables/useFacingMode.ts +28 -0
  64. package/src/composables/useFocusToggle.ts +38 -0
  65. package/src/composables/useGridLayout.ts +44 -0
  66. package/src/composables/useIsEncrypted.ts +34 -0
  67. package/src/composables/useIsMuted.ts +56 -0
  68. package/src/composables/useIsRecording.ts +30 -0
  69. package/src/composables/useIsSpeaking.ts +23 -0
  70. package/src/composables/useLiveKitRoom.ts +219 -0
  71. package/src/composables/useLocalParticipant.ts +64 -0
  72. package/src/composables/useParticipantTile.ts +68 -0
  73. package/src/composables/useParticipantTracks.ts +36 -0
  74. package/src/composables/useParticipants.ts +25 -0
  75. package/src/composables/usePersistentUserChoices.ts +64 -0
  76. package/src/composables/usePinnedTracks.ts +16 -0
  77. package/src/composables/useRemoteParticipant.ts +42 -0
  78. package/src/composables/useRemoteParticipants.ts +27 -0
  79. package/src/composables/useRoomInfo.ts +42 -0
  80. package/src/composables/useSortedParticipants.ts +21 -0
  81. package/src/composables/useSpeakingParticipants.ts +22 -0
  82. package/src/composables/useStartAudio.ts +53 -0
  83. package/src/composables/useStartVideo.ts +53 -0
  84. package/src/composables/useToken.ts +40 -0
  85. package/src/composables/useTrack.ts +11 -0
  86. package/src/composables/useTrackByName.ts +11 -0
  87. package/src/composables/useTrackMutedIndicator.ts +34 -0
  88. package/src/composables/useTrackRefBySourceOrName.ts +39 -0
  89. package/src/composables/useTrackSyncTime.ts +32 -0
  90. package/src/composables/useTrackToggle.ts +113 -0
  91. package/src/composables/useTrackVolume.ts +268 -0
  92. package/src/composables/useTracks.ts +122 -0
  93. package/src/composables/useVisualStableUpdate.ts +57 -0
  94. package/src/context/index.ts +6 -0
  95. package/src/context/layout.context.ts +46 -0
  96. package/src/context/participant.context.ts +33 -0
  97. package/src/context/pin.context.ts +50 -0
  98. package/src/context/room.context.ts +31 -0
  99. package/src/context/track_reference.context.ts +29 -0
  100. package/src/context/widget.context.ts +17 -0
  101. package/src/index.css +1 -0
  102. package/src/index.ts +5 -0
  103. package/src/main.ts +6 -0
  104. package/src/types/livekit_room.types.ts +78 -0
  105. package/src/utils/room.utils.ts +9 -0
@@ -0,0 +1,913 @@
1
+ import { t as _, u as w, a as K, b as R, c as L, d as ne, e as oe, f as Y, g as re, h as ue } from "./contexts-BGR-EyiF.mjs";
2
+ import { roomAudioPlaybackAllowedObservable as se, setupConnectionQualityIndicator as ce, connectionStateObserver as le, setupDataMessageHandler as ie, isTrackReferencePinned as ve, GRID_LAYOUTS as de, selectGridLayout as pe, encryptionStatusObservable as fe, getTrackReferenceId as be, mutedObserver as me, recordingStatusObservable as $, createIsSpeakingObserver as he, observeParticipantMedia as ye, connectedParticipantsObserver as ge, participantTracksObservable as ke, loadUserChoices as Se, saveUserChoices as Pe, connectedParticipantObserver as Ce, participantByIdentifierObserver as we, roomInfoObserver as Me, activeSpeakerObserver as Te, sortParticipants as H, setupStartAudio as Ae, setupStartVideo as Ee, getTrackByIdentifier as Ie, setupMediaTrack as Re, setupTrackMutedIndicator as We, isSourcesWithOptions as J, isSourceWitOptions as De, trackSyncTimeObserver as Oe, setupMediaToggle as Ve, setupManualToggle as Le, isTrackReference as Fe, updatePages as Ue } from "@livekit/components-core";
3
+ import "rxjs";
4
+ import { ref as d, shallowRef as X, computed as v, watch as g, toRefs as E, onWatcherCleanup as O, onMounted as Z, onBeforeUnmount as qe, onBeforeMount as Be } from "vue";
5
+ import { ConnectionQuality as xe, ConnectionState as ze, LocalTrackPublication as Ne, facingModeFromLocalTrack as je, Room as $e, RoomEvent as T, MediaDeviceFailure as He, Track as A, createAudioAnalyser as F } from "livekit-client";
6
+ function W(e, t) {
7
+ const a = d(void 0), n = e.subscribe({
8
+ next: (o) => a.value = o,
9
+ error: void 0
10
+ });
11
+ return _(() => {
12
+ n.unsubscribe();
13
+ }), a;
14
+ }
15
+ function D(e) {
16
+ _(() => {
17
+ e.unsubscribe();
18
+ });
19
+ }
20
+ function P(e) {
21
+ const t = X(e.startWith), a = v(() => e.observable), n = v(() => e.resetWhenObservableChanges ?? !1);
22
+ function o() {
23
+ n.value && (t.value = e.startWith), !(typeof window > "u" || !e.observable) && a.value && D(
24
+ a.value.subscribe((r) => {
25
+ t.value = r ?? e.startWith;
26
+ })
27
+ );
28
+ }
29
+ return g(a, o), g(t, o), t;
30
+ }
31
+ function vt(e) {
32
+ const t = w(e);
33
+ async function a() {
34
+ await t.value.startAudio();
35
+ }
36
+ const n = v(
37
+ () => se(t.value)
38
+ ), o = P({
39
+ observable: n.value,
40
+ startWith: {
41
+ canPlayAudio: t.value.canPlaybackVideo
42
+ }
43
+ }), { canPlayAudio: r } = E(o.value);
44
+ return {
45
+ canPlayAudio: r,
46
+ startAudio: a
47
+ };
48
+ }
49
+ function dt(e) {
50
+ const t = K(), a = v(() => t.value.pin), n = v(() => a.value.state), o = v(() => a.value.dispatch);
51
+ return {
52
+ elementProps: v(() => {
53
+ var s;
54
+ return {
55
+ ...e,
56
+ class: "lk-clear-pin-button",
57
+ disabled: !((s = n.value) != null && s.length),
58
+ onClick: () => {
59
+ o.value && o.value({ msg: "clear_pin" });
60
+ }
61
+ };
62
+ })
63
+ };
64
+ }
65
+ function pt(e = {}) {
66
+ const t = R(e.participant), a = v(
67
+ () => ce(t.value)
68
+ ), { className: n, connectionQualityObserver: o } = E(
69
+ a.value
70
+ ), r = P({
71
+ observable: o.value,
72
+ startWith: xe.Unknown
73
+ });
74
+ return {
75
+ className: n,
76
+ quality: r
77
+ };
78
+ }
79
+ function ee(e) {
80
+ const t = w(e), a = v(
81
+ () => le(t.value)
82
+ );
83
+ return P({
84
+ observable: a.value,
85
+ startWith: t.value.state
86
+ });
87
+ }
88
+ function ft(e, t) {
89
+ const a = typeof e == "function" ? e : t, n = typeof e == "string" ? e : void 0, o = w(), r = v(() => ie(o == null ? void 0 : o.value, n, a)), { send: s, messageObservable: u, isSendingObservable: c } = E(r.value), i = P({
90
+ observable: u,
91
+ startWith: void 0
92
+ }), f = P({
93
+ observable: c,
94
+ startWith: !1
95
+ });
96
+ return {
97
+ message: i,
98
+ send: s,
99
+ isSending: f
100
+ };
101
+ }
102
+ function bt(e) {
103
+ const t = w(), a = ee(t.value);
104
+ function n(r) {
105
+ t.value.disconnect(r);
106
+ }
107
+ return {
108
+ buttonProps: v(() => ({
109
+ ...e,
110
+ onClick: () => n(),
111
+ disabled: a.value === ze.Disconnected
112
+ }))
113
+ };
114
+ }
115
+ var te = /* @__PURE__ */ ((e) => (e.User = "user", e.Environment = "environment", e.Left = "left", e.Right = "right", e.Undefined = "undefined", e))(te || {});
116
+ function Qe(e) {
117
+ const t = d(
118
+ "undefined"
119
+ /* Undefined */
120
+ );
121
+ return g(e, () => {
122
+ if (e.publication instanceof Ne) {
123
+ const a = e.publication.track;
124
+ if (a) {
125
+ const { facingMode: n } = je(a);
126
+ t.value = te[n];
127
+ }
128
+ }
129
+ return t.value;
130
+ }), t;
131
+ }
132
+ function mt({ trackRef: e, props: t }) {
133
+ const a = L(e), n = ne(), o = "lk-focus-toggle-button", r = v(() => {
134
+ var u;
135
+ return ve(a.value, (u = n == null ? void 0 : n.value) == null ? void 0 : u.pin.state);
136
+ });
137
+ return {
138
+ elementProps: v(() => ({
139
+ ...t,
140
+ class: o,
141
+ "data-lk-toggle-focused": r.value
142
+ })),
143
+ inFocus: r
144
+ };
145
+ }
146
+ function ht(e, t, a = {}) {
147
+ const { width: n, height: o } = oe(e), r = v(() => a.gridLayouts ?? de), s = v(() => pe(r.value, t, n.value, o.value));
148
+ return g([e, s], () => {
149
+ var u, c;
150
+ e.value && s && (e.value.style.setProperty("--lk-col-count", (u = s.value) == null ? void 0 : u.columns.toString()), e.value.style.setProperty("--lk-row-count", (c = s.value) == null ? void 0 : c.rows.toString()));
151
+ }), {
152
+ layout: s,
153
+ containerWidth: n,
154
+ containerHeight: o
155
+ };
156
+ }
157
+ function yt(e, t = {}) {
158
+ var s;
159
+ const a = R(e), n = w(t.room), o = d(
160
+ fe(n.value, a.value)
161
+ );
162
+ return P({
163
+ observable: o.value,
164
+ startWith: a.value.isLocal ? a.value.isE2EEEnabled : !!((s = a.value) != null && s.isEncrypted)
165
+ });
166
+ }
167
+ function Q(e, t = {}) {
168
+ var s, u;
169
+ const a = v(
170
+ () => typeof e == "string" ? t.participant : e.participant
171
+ ), n = R(a.value), o = v(() => typeof e == "string" ? { participant: n.value, source: e } : e), r = d(
172
+ !!((s = o.value.publication) != null && s.isMuted || (u = n.value.getTrackPublication(o.value.source)) != null && u.isMuted)
173
+ );
174
+ return g(
175
+ () => be(o.value),
176
+ () => {
177
+ D(
178
+ me(o.value).subscribe((c) => {
179
+ r.value = c;
180
+ })
181
+ );
182
+ }
183
+ ), r;
184
+ }
185
+ function gt(e) {
186
+ const t = w(e), a = ee(t.value), n = d(
187
+ $(t.value)
188
+ ), o = P({
189
+ observable: n.value,
190
+ startWith: t.value.isRecording
191
+ });
192
+ return g([a, t], () => {
193
+ n.value = $(t.value);
194
+ }), o;
195
+ }
196
+ function Ge(e) {
197
+ const t = R(e), a = v(
198
+ () => he(t.value)
199
+ );
200
+ return P({
201
+ observable: a.value,
202
+ startWith: t.value.isSpeaking
203
+ });
204
+ }
205
+ function _e(e, t) {
206
+ return e === "processor" && t && typeof t == "object" && "name" in t ? t.name : e === "e2ee" && t ? "e2ee-enabled" : t;
207
+ }
208
+ const Ke = {
209
+ connect: !0,
210
+ audio: !1,
211
+ video: !1
212
+ };
213
+ function kt(e) {
214
+ var N;
215
+ const {
216
+ token: t,
217
+ serverUrl: a,
218
+ options: n,
219
+ room: o,
220
+ connectOptions: r,
221
+ connect: s,
222
+ audio: u,
223
+ video: c,
224
+ screen: i,
225
+ onConnected: f,
226
+ onDisconnected: b,
227
+ onError: l,
228
+ onMediaDeviceFailure: p,
229
+ onEncryptionError: m,
230
+ simulateParticipants: C,
231
+ htmlProps: y
232
+ } = E({ ...Ke, ...e }), k = d((s == null ? void 0 : s.value) ?? !1), S = d((o == null ? void 0 : o.value) ?? ((N = Y()) == null ? void 0 : N.value)), V = v(() => ({
233
+ ...y == null ? void 0 : y.value,
234
+ class: "lk-room-container"
235
+ }));
236
+ function U() {
237
+ var M;
238
+ const h = (M = S.value) == null ? void 0 : M.localParticipant;
239
+ console.debug("trying to publish local tracks"), Promise.all([
240
+ h == null ? void 0 : h.setMicrophoneEnabled(
241
+ !!(u != null && u.value),
242
+ typeof (u == null ? void 0 : u.value) != "boolean" ? u == null ? void 0 : u.value : void 0
243
+ ),
244
+ h == null ? void 0 : h.setCameraEnabled(
245
+ !!(c != null && c.value),
246
+ typeof (c == null ? void 0 : c.value) != "boolean" ? c == null ? void 0 : c.value : void 0
247
+ ),
248
+ h == null ? void 0 : h.setScreenShareEnabled(
249
+ !!(i != null && i.value),
250
+ typeof (i == null ? void 0 : i.value) != "boolean" ? i == null ? void 0 : i.value : void 0
251
+ )
252
+ ]).catch((I) => {
253
+ var j;
254
+ console.warn(I), (j = l == null ? void 0 : l.value) == null || j.call(l, I);
255
+ });
256
+ }
257
+ function q(h) {
258
+ var I;
259
+ const M = He.getFailure(h);
260
+ (I = p == null ? void 0 : p.value) == null || I.call(p, M);
261
+ }
262
+ function B(h) {
263
+ var M;
264
+ (M = m == null ? void 0 : m.value) == null || M.call(m, h);
265
+ }
266
+ function x(h) {
267
+ var M;
268
+ (M = b == null ? void 0 : b.value) == null || M.call(b, h);
269
+ }
270
+ function z() {
271
+ var h;
272
+ (h = f == null ? void 0 : f.value) == null || h.call(f);
273
+ }
274
+ return g(
275
+ [o, n, _e],
276
+ () => {
277
+ S.value = (o == null ? void 0 : o.value) ?? new $e(n == null ? void 0 : n.value);
278
+ },
279
+ {
280
+ deep: !0,
281
+ immediate: !0
282
+ }
283
+ ), g(
284
+ [
285
+ S,
286
+ u,
287
+ c,
288
+ i,
289
+ l,
290
+ m,
291
+ p,
292
+ f,
293
+ b
294
+ ],
295
+ () => {
296
+ S.value && (S.value.on(T.SignalConnected, U).on(T.MediaDevicesError, q).on(T.EncryptionError, B).on(T.Disconnected, x).on(T.Connected, z), O(() => {
297
+ S.value && S.value.off(T.SignalConnected, U).off(T.MediaDevicesError, q).off(T.EncryptionError, B).off(T.Disconnected, x).off(T.Connected, z);
298
+ }));
299
+ },
300
+ {
301
+ deep: !0
302
+ }
303
+ ), g(
304
+ [s, t, r, S, l, a, C],
305
+ () => {
306
+ var h;
307
+ if (S.value) {
308
+ if (C != null && C.value) {
309
+ S.value.simulateParticipants({
310
+ participants: {
311
+ count: C.value
312
+ },
313
+ publish: {
314
+ audio: !0,
315
+ useRealTracks: !0
316
+ }
317
+ });
318
+ return;
319
+ }
320
+ if (s != null && s.value) {
321
+ if (k.value = !0, console.debug("connecting"), !t.value) {
322
+ console.debug("no token yet");
323
+ return;
324
+ }
325
+ if (!a.value) {
326
+ console.warn("no livekit url provided"), (h = l == null ? void 0 : l.value) == null || h.call(l, Error("no livekit url provided"));
327
+ return;
328
+ }
329
+ S.value.connect(a.value, t.value, r == null ? void 0 : r.value).catch((M) => {
330
+ var I;
331
+ console.warn(M), k.value === !0 && ((I = l == null ? void 0 : l.value) == null || I.call(l, M));
332
+ });
333
+ } else
334
+ console.debug("disconnecting because connect is false"), k.value = !1, S.value.disconnect();
335
+ }
336
+ },
337
+ { deep: !0 }
338
+ ), Z(() => {
339
+ n != null && n.value && o && console.warn(
340
+ "when using a manually created room, the options object will be ignored. set the desired options directly when creating the room instead."
341
+ );
342
+ }), qe(() => {
343
+ S.value && (console.info("disconnecting before unmounting"), S.value.disconnect());
344
+ }), {
345
+ room: S,
346
+ elementProps: V
347
+ };
348
+ }
349
+ function Ye(e = {}) {
350
+ var b, l, p, m, C, y;
351
+ const t = w(e.room), a = d((b = t.value) == null ? void 0 : b.localParticipant), n = d(((l = a.value) == null ? void 0 : l.isMicrophoneEnabled) ?? !1), o = d(((p = a.value) == null ? void 0 : p.isCameraEnabled) ?? !1), r = d(((m = a.value) == null ? void 0 : m.isScreenShareEnabled) ?? !1), s = d((C = a.value) == null ? void 0 : C.lastMicrophoneError), u = d((y = a.value) == null ? void 0 : y.lastCameraError), c = d(void 0), i = d(void 0);
352
+ function f(k) {
353
+ o.value = k.isCameraEnabled, n.value = k.isMicrophoneEnabled, r.value = k.isScreenShareEnabled, i.value = k.cameraTrack, c.value = k.microphoneTrack, s.value = k.participant.lastMicrophoneError, u.value = k.participant.lastCameraError, a.value = k.participant;
354
+ }
355
+ return g(
356
+ t,
357
+ () => D(ye(t.value.localParticipant).subscribe(f))
358
+ ), {
359
+ isMicrophoneEnabled: n,
360
+ isScreenShareEnabled: r,
361
+ isCameraEnabled: o,
362
+ microphoneTrack: c,
363
+ cameraTrack: i,
364
+ lastMicrophoneError: s,
365
+ lastCameraError: u,
366
+ localParticipant: a
367
+ };
368
+ }
369
+ function Je(e = {}) {
370
+ const t = w(e.room), a = d([]);
371
+ return g([t, e.updateOnlyOn], () => {
372
+ D(
373
+ ge(t.value, {
374
+ additionalRoomEvents: e.updateOnlyOn
375
+ }).subscribe((n) => a.value = n)
376
+ );
377
+ }), a;
378
+ }
379
+ function St(e = {}) {
380
+ var o;
381
+ const t = Je(e), a = (o = Ye()) == null ? void 0 : o.localParticipant;
382
+ return v(() => [a.value, ...t.value]);
383
+ }
384
+ function Pt(e) {
385
+ const t = L(e.trackRef), a = v(() => ({
386
+ class: "lk-participant-tile",
387
+ onClick: (i) => {
388
+ var f, b;
389
+ if ((b = (f = e.htmlProps).onClick) == null || b.call(f, i), typeof e.onParticipantClick == "function") {
390
+ const l = t.value.publication ?? t.value.participant.getTrackPublication(t.value.source);
391
+ e.onParticipantClick({ participant: t.value.participant, track: l });
392
+ }
393
+ }
394
+ })), n = v(() => t.value.participant.getTrackPublication(A.Source.Microphone)), o = v(() => ({
395
+ participant: t.value.participant,
396
+ source: A.Source.Microphone,
397
+ publication: n.value
398
+ })), r = Q(t.value), s = Q(o.value), u = Ge(t.value.participant), c = Qe(t.value);
399
+ return {
400
+ elementProps: X({
401
+ "data-lk-audio-muted": s,
402
+ "data-lk-video-muted": r,
403
+ "data-lk-speaking": e.disableSpeakingIndicator === !0 ? !1 : u,
404
+ "data-lk-local-participant": t.value.participant.isLocal,
405
+ "data-lk-source": t.value.source,
406
+ "data-lk-facing-mode": c,
407
+ ...a.value
408
+ })
409
+ };
410
+ }
411
+ function Ct(e, t) {
412
+ const a = Y(), n = re(), o = v(
413
+ () => {
414
+ var u;
415
+ return t ? (u = a == null ? void 0 : a.value) == null ? void 0 : u.getParticipantByIdentity(t) : n == null ? void 0 : n.value;
416
+ }
417
+ ), r = v(() => o.value ? ke(o.value, { sources: e }) : void 0);
418
+ return P({
419
+ observable: r.value,
420
+ startWith: []
421
+ });
422
+ }
423
+ function wt(e = {}) {
424
+ const t = d(
425
+ Se(e.defaults, e.preventLoad ?? !1)
426
+ );
427
+ function a(u) {
428
+ t.value = { ...t.value, audioDeviceId: u };
429
+ }
430
+ function n(u) {
431
+ t.value = { ...t.value, videoDeviceId: u };
432
+ }
433
+ function o(u) {
434
+ t.value = { ...t.value, audioEnabled: u };
435
+ }
436
+ function r(u) {
437
+ t.value = { ...t.value, videoEnabled: u };
438
+ }
439
+ function s(u) {
440
+ t.value = { ...t.value, username: u };
441
+ }
442
+ return g(
443
+ [t, e.preventSave],
444
+ () => {
445
+ Pe(t.value, e.preventSave ?? !1);
446
+ },
447
+ {
448
+ deep: !0
449
+ }
450
+ ), {
451
+ userChoices: t,
452
+ saveAudioInputEnabled: o,
453
+ saveVideoInputEnabled: r,
454
+ saveAudioInputDeviceId: a,
455
+ saveVideoInputDeviceId: n,
456
+ saveUsername: s
457
+ };
458
+ }
459
+ function Mt(e) {
460
+ const t = K(e);
461
+ return v(() => {
462
+ var n;
463
+ return ((n = t.value) == null ? void 0 : n.pin.state) !== void 0 && t.value.pin.state.length >= 1 ? t.value.pin.state : [];
464
+ });
465
+ }
466
+ function Tt(e, t = {}) {
467
+ const a = w(), n = d(t.updateOnlyOn ?? []), o = d(void 0), r = v(() => typeof e == "string" ? Ce(a.value, e, {
468
+ additionalEvents: n.value
469
+ }) : we(a.value, e, {
470
+ additionalEvents: n.value
471
+ }));
472
+ return D(
473
+ r.value.subscribe((s) => {
474
+ o.value = s;
475
+ })
476
+ ), o;
477
+ }
478
+ function At(e = {}) {
479
+ const t = w(e.room), a = W(
480
+ Me(t.value)
481
+ ), n = P({
482
+ observable: a.value,
483
+ startWith: {
484
+ name: t.value.name,
485
+ metadata: t.value.metadata
486
+ }
487
+ }), { name: o, metadata: r } = E(n.value);
488
+ return {
489
+ name: o,
490
+ metadata: r
491
+ };
492
+ }
493
+ function Xe() {
494
+ const e = w(), t = W(
495
+ Te(e.value)
496
+ );
497
+ return P({
498
+ observable: t.value,
499
+ startWith: e.value.activeSpeakers
500
+ });
501
+ }
502
+ function Et(e) {
503
+ const t = Xe(), a = d(H(e));
504
+ return g(
505
+ [t, e],
506
+ () => {
507
+ a.value = H(e);
508
+ },
509
+ {
510
+ deep: !0
511
+ }
512
+ ), a;
513
+ }
514
+ function It({ room: e, props: t }) {
515
+ const a = w(e), n = v(() => Ae()), { className: o, roomAudioPlaybackAllowedObservable: r, handleStartAudioPlayback: s } = E(
516
+ n.value
517
+ ), u = W(
518
+ r.value(a.value)
519
+ ), c = P({
520
+ observable: u.value,
521
+ startWith: {
522
+ canPlayAudio: a.value.canPlaybackVideo
523
+ }
524
+ });
525
+ return {
526
+ canPlayAudio: d(c.value.canPlayAudio),
527
+ elementProps: {
528
+ ...t,
529
+ class: o.value,
530
+ onClick: () => {
531
+ s.value(a.value);
532
+ }
533
+ }
534
+ };
535
+ }
536
+ function Rt({ room: e, props: t }) {
537
+ const a = w(e), n = v(
538
+ () => Ee()
539
+ ), { className: o, roomVideoPlaybackAllowedObservable: r, handleStartVideoPlayback: s } = E(
540
+ n.value
541
+ ), u = W(
542
+ r.value(a.value)
543
+ ), c = P({
544
+ observable: u.value,
545
+ startWith: {
546
+ canPlayVideo: a.value.canPlaybackVideo
547
+ }
548
+ });
549
+ return {
550
+ canPlayVideo: d(c.value.canPlayVideo),
551
+ elementProps: {
552
+ ...t,
553
+ class: o.value,
554
+ onClick: () => {
555
+ s.value(a.value);
556
+ }
557
+ }
558
+ };
559
+ }
560
+ function Wt(e, t, a = {}) {
561
+ const n = d(void 0);
562
+ async function o() {
563
+ console.debug("fetching token");
564
+ const r = new URLSearchParams({ ...a.userInfo, roomName: t }), s = await fetch(`${e}?${r.toString()}`);
565
+ if (!s.ok) {
566
+ console.error(
567
+ `Could not fetch token. Server responded with status ${s.status}: ${s.statusText}`
568
+ );
569
+ return;
570
+ }
571
+ const { accessToken: u } = await s.json();
572
+ n.value = u;
573
+ }
574
+ return g([e, t, a.userInfo], o), n;
575
+ }
576
+ function ae(e) {
577
+ const t = d(Ie(e)), a = v(
578
+ () => Re(e)
579
+ ), { trackObserver: n } = E(a.value);
580
+ return D(
581
+ n.value.subscribe((r) => {
582
+ t.value = r;
583
+ })
584
+ ), v(() => ({
585
+ participant: e.participant,
586
+ source: e.source ?? A.Source.Unknown,
587
+ publication: t.value
588
+ }));
589
+ }
590
+ function Dt(e, t) {
591
+ const a = R(t);
592
+ return ae({ source: e, participant: a.value });
593
+ }
594
+ function Ot(e, t) {
595
+ const a = R(t);
596
+ return ae({ name: e, participant: a.value });
597
+ }
598
+ function Vt(e) {
599
+ var u, c;
600
+ const t = L(e), a = v(
601
+ () => We(t.value)
602
+ ), { className: n, mediaMutedObserver: o } = E(a.value), r = W(o.value);
603
+ return { isMuted: P({
604
+ observable: r.value,
605
+ startWith: !!((u = t.value.publication) != null && u.isMuted || (c = t.value.participant.getTrackPublication(t.value.source)) != null && c.isMuted)
606
+ }), className: n };
607
+ }
608
+ function Ze(e, t) {
609
+ const a = new Set(e);
610
+ for (const n of t)
611
+ a.delete(n);
612
+ return a;
613
+ }
614
+ function et(e, t) {
615
+ const a = /* @__PURE__ */ new Map();
616
+ if (J(e)) {
617
+ const n = e.filter((o) => o.withPlaceholder).map((o) => o.source);
618
+ t.forEach((o) => {
619
+ const r = o.getTrackPublications().map((u) => {
620
+ var c;
621
+ return (c = u.track) == null ? void 0 : c.source;
622
+ }).filter((u) => u !== void 0), s = Array.from(
623
+ Ze(new Set(n), new Set(r))
624
+ );
625
+ s.length > 0 && a.set(o.identity, s);
626
+ });
627
+ }
628
+ return a;
629
+ }
630
+ function Lt(e = [
631
+ A.Source.Camera,
632
+ A.Source.Microphone,
633
+ A.Source.ScreenShare,
634
+ A.Source.ScreenShareAudio,
635
+ A.Source.Unknown
636
+ ], t = {}) {
637
+ w(t.room);
638
+ const a = d([]), n = d([]);
639
+ return v(
640
+ () => e.map((r) => De(r) ? r.source : r)
641
+ ), v(() => {
642
+ if (J(e)) {
643
+ const r = et(e, n.value), s = Array.from(
644
+ a.value
645
+ );
646
+ for (const u of n.value)
647
+ if (r.has(u.identity)) {
648
+ const c = r.get(u.identity) ?? [];
649
+ for (const i of c) {
650
+ if (s.find(
651
+ ({ participant: b, publication: l }) => u.identity === b.identity && (l == null ? void 0 : l.source) === i
652
+ ))
653
+ continue;
654
+ console.debug(
655
+ `Add ${i} placeholder for participant ${u.identity}.`
656
+ );
657
+ const f = {
658
+ participant: u,
659
+ source: i
660
+ };
661
+ s.push(f);
662
+ }
663
+ }
664
+ return s;
665
+ } else
666
+ return a;
667
+ }).value;
668
+ }
669
+ function Ft(e) {
670
+ var n, o, r;
671
+ const t = (n = e == null ? void 0 : e.publication) != null && n.track ? (
672
+ // @ts-expect-error - Observer type mismatch
673
+ W(Oe(e == null ? void 0 : e.publication.track))
674
+ ) : void 0;
675
+ if (!t)
676
+ throw new Error("Please provide a valid observable when using `useTrackSyncTime`");
677
+ return P({
678
+ observable: t == null ? void 0 : t.value,
679
+ startWith: {
680
+ timestamp: Date.now(),
681
+ rtpTimestamp: (r = (o = e == null ? void 0 : e.publication) == null ? void 0 : o.track) == null ? void 0 : r.rtpTimestamp
682
+ }
683
+ });
684
+ }
685
+ function Ut(e) {
686
+ var l;
687
+ const t = ue(), a = d(!1), n = v(
688
+ () => {
689
+ var p, m;
690
+ return (m = (p = t == null ? void 0 : t.value) == null ? void 0 : p.localParticipant) == null ? void 0 : m.getTrackPublication(e.source);
691
+ }
692
+ ), o = v(
693
+ () => t ? Ve(
694
+ e.source,
695
+ t.value,
696
+ e.captureOptions,
697
+ e.publishOptions,
698
+ e.onDeviceError
699
+ ) : Le()
700
+ ), { className: r, enabledObserver: s, pendingObserver: u, toggle: c } = E(
701
+ o.value
702
+ ), i = P({
703
+ observable: u.value,
704
+ startWith: !1
705
+ }), f = P({
706
+ observable: s.value,
707
+ startWith: e.initialState ?? !!((l = n.value) != null && l.isEnabled)
708
+ });
709
+ function b(p) {
710
+ p.preventDefault(), p.stopPropagation(), a.value = !0, c == null || c.value().catch(() => a.value = !1), e.customOnClickHandler && e.customOnClickHandler(p);
711
+ }
712
+ return g(f, (p) => {
713
+ var m;
714
+ (m = e == null ? void 0 : e.onChange) == null || m.call(e, p, a.value), a.value = !1;
715
+ }), Z(() => {
716
+ e.initialState !== void 0 && (console.debug("forcing initial toggle state", e.source, e.initialState), c == null || c.value(e.initialState));
717
+ }), {
718
+ toggle: c,
719
+ enabled: f,
720
+ pending: i,
721
+ track: n,
722
+ buttonProps: {
723
+ "aria-pressed": f.value,
724
+ "data-lk-source": e.source,
725
+ "data-lk-enabled": f.value,
726
+ disabled: i.value ?? !1,
727
+ onClick: b
728
+ }
729
+ };
730
+ }
731
+ const tt = {
732
+ bands: 5,
733
+ loPass: 100,
734
+ hiPass: 600,
735
+ updateInterval: 32,
736
+ analyserOptions: { fftSize: 2048 }
737
+ }, at = {
738
+ barCount: 120,
739
+ volMultiplier: 5,
740
+ updateInterval: 20
741
+ };
742
+ function nt(e) {
743
+ const t = (a) => {
744
+ let r = 1 - Math.max(-100, Math.min(-10, a)) * -1 / 100;
745
+ return r = Math.sqrt(r), r;
746
+ };
747
+ return e.map((a) => a === -1 / 0 ? 0 : t(a));
748
+ }
749
+ function G(e) {
750
+ return e < 32 ? 32 : ot(e);
751
+ }
752
+ function ot(e) {
753
+ let t = 2;
754
+ for (; e >>= 1; )
755
+ t <<= 1;
756
+ return t;
757
+ }
758
+ function rt(e, t) {
759
+ const a = Math.floor(e.length / t), n = new Float32Array(t);
760
+ for (let o = 0; o < t; o++) {
761
+ const r = a * o;
762
+ let s = 0;
763
+ for (let u = 0; u < a; u++)
764
+ s = s + Math.abs(e[r + u]);
765
+ n[o] = s / a;
766
+ }
767
+ return n;
768
+ }
769
+ function qt(e, t = { fftSize: 32, smoothingTimeConstant: 0 }) {
770
+ const a = Fe(e) ? e.publication.track : e, n = d(0);
771
+ return g(
772
+ () => a,
773
+ (o) => {
774
+ if (!o || !o.mediaStream)
775
+ return;
776
+ const { cleanup: r, analyser: s } = F(o, t), u = s.frequencyBinCount, c = new Uint8Array(u);
777
+ function i() {
778
+ s.getByteFrequencyData(c);
779
+ let b = 0;
780
+ for (let l = 0; l < c.length; l++) {
781
+ const p = c[l];
782
+ b += p * p;
783
+ }
784
+ n.value = Math.sqrt(b / c.length) / 255;
785
+ }
786
+ const f = setInterval(i, 1e3 / 30);
787
+ O(() => {
788
+ r(), clearInterval(f);
789
+ });
790
+ },
791
+ { deep: !0 }
792
+ ), n;
793
+ }
794
+ function Bt(e, t = {}) {
795
+ var r;
796
+ const a = e instanceof A ? e : (r = e == null ? void 0 : e.publication) == null ? void 0 : r.track, n = { ...tt, ...t }, o = d(new Array(n.bands).fill(0));
797
+ return g(
798
+ [a, t],
799
+ () => {
800
+ if (!a || !(a != null && a.mediaStream))
801
+ return;
802
+ const { analyser: s, cleanup: u } = F(a, n.analyserOptions), c = s.frequencyBinCount, i = new Float32Array(c), b = setInterval(() => {
803
+ s.getFloatFrequencyData(i);
804
+ let l = new Float32Array(i.length);
805
+ for (let y = 0; y < i.length; y++)
806
+ l[y] = i[y];
807
+ l = l.slice(t.loPass, t.hiPass);
808
+ const p = [], m = nt(l), C = Math.ceil(m.length / n.bands);
809
+ for (let y = 0; y < n.bands; y++) {
810
+ const k = m.slice(y * C, (y + 1) * C).reduce((S, V) => S += V, 0);
811
+ p.push(k / C);
812
+ }
813
+ o.value = p;
814
+ }, n.updateInterval);
815
+ O(() => {
816
+ u(), clearInterval(b);
817
+ });
818
+ },
819
+ { deep: !0 }
820
+ ), o;
821
+ }
822
+ function xt(e, t = {}) {
823
+ var i;
824
+ const a = e instanceof A ? e : (i = e == null ? void 0 : e.publication) == null ? void 0 : i.track, n = { ...at, ...t }, o = d(new Float32Array()), r = d(performance.now()), s = d(0), u = d([]);
825
+ function c(f) {
826
+ u.value = Array.from(
827
+ rt(f, n.barCount).map((b) => Math.sqrt(b) * n.volMultiplier)
828
+ );
829
+ }
830
+ return g([a, t], () => {
831
+ if (!a || !(a != null && a.mediaStream))
832
+ return;
833
+ const { analyser: f, cleanup: b } = F(a, {
834
+ fftSize: G(n.barCount)
835
+ }), l = G(n.barCount), p = new Float32Array(l), m = () => {
836
+ if (C = requestAnimationFrame(m), f.getFloatTimeDomainData(p), o.value.map((y, k) => y + p[k]), s.value += 1, performance.now() - r.value >= n.updateInterval) {
837
+ const y = p.map((k) => k / s.value);
838
+ c(y), r.value = performance.now(), s.value = 0;
839
+ }
840
+ };
841
+ let C = requestAnimationFrame(m);
842
+ O(() => {
843
+ b(), cancelAnimationFrame(C);
844
+ });
845
+ }), Be(() => {
846
+ c(o.value);
847
+ }), {
848
+ bars: u
849
+ };
850
+ }
851
+ function zt(e, t, a = {}) {
852
+ const n = d(-1), o = d([]), r = v(() => t !== n.value), s = v(() => a.customSortFunction ? a.customSortFunction(e) : e), u = d([
853
+ ...s.value
854
+ ]);
855
+ function c() {
856
+ if (!r.value)
857
+ try {
858
+ u.value = Ue(
859
+ o.value,
860
+ s.value,
861
+ t
862
+ );
863
+ } catch (i) {
864
+ console.error("Error while running updatePages(): ", i);
865
+ }
866
+ r.value ? o.value = s.value : o.value = u.value, n.value = t;
867
+ }
868
+ return g(() => s, c), u;
869
+ }
870
+ export {
871
+ te as FacingMode,
872
+ et as requiredPlaceholders,
873
+ vt as useAudioPlayback,
874
+ xt as useAudioWaveform,
875
+ dt as useClearPinButton,
876
+ pt as useConnectionQualityIndicator,
877
+ ee as useConnectionState,
878
+ ft as useDataChannel,
879
+ bt as useDisconnectButton,
880
+ Qe as useFacingMode,
881
+ mt as useFocusToggle,
882
+ ht as useGridLayout,
883
+ yt as useIsEncrypted,
884
+ Q as useIsMuted,
885
+ gt as useIsRecording,
886
+ Ge as useIsSpeaking,
887
+ kt as useLiveKitRoom,
888
+ Ye as useLocalParticipant,
889
+ Bt as useMultibandTrackVolume,
890
+ Pt as useParticipantTile,
891
+ Ct as useParticipantTracks,
892
+ St as useParticipants,
893
+ wt as usePersistentUserChoices,
894
+ Mt as usePinnedTracks,
895
+ Tt as useRemoteParticipant,
896
+ Je as useRemoteParticipants,
897
+ At as useRoomInfo,
898
+ Et as useSortedParticipants,
899
+ Xe as useSpeakingParticipants,
900
+ It as useStartAudio,
901
+ Rt as useStartVideo,
902
+ Wt as useToken,
903
+ Dt as useTrack,
904
+ Ot as useTrackByName,
905
+ Vt as useTrackMutedIndicator,
906
+ ae as useTrackRefBySourceOrName,
907
+ Ft as useTrackSyncTime,
908
+ Ut as useTrackToggle,
909
+ qt as useTrackVolume,
910
+ Lt as useTracks,
911
+ zt as useVisualStableUpdate
912
+ };
913
+ //# sourceMappingURL=composables.mjs.map