@mrksbnc/livekit-vue 0.0.1 → 0.0.2

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