@nivaro/react 0.2.55 → 0.3.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.
- package/dist/components/slots/TasksSlot.js +31 -29
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +101 -1
- package/dist/index.js +538 -525
- package/dist/shared/components/ItemEditForm.js +666 -658
- package/dist/shared/components/MyWorkView.js +47 -37
- package/dist/shared/components/ProfileView.js +163 -144
- package/dist/shared/components/ai/AiPlanCard.js +427 -0
- package/dist/shared/components/ai/AiPlanChanges.js +117 -0
- package/dist/shared/components/ai/TaskDo.js +1022 -0
- package/dist/shared/components/chat/ChatAnalyticsView.js +19 -17
- package/dist/shared/components/chat/ChatPanel.js +1356 -1317
- package/dist/shared/components/chat/HuddleAnalyticsTab.js +198 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +78 -65
- package/dist/shared/components/chat/chat-core.js +273 -264
- package/dist/shared/components/chat/huddle/HuddleAudioUi.js +397 -0
- package/dist/shared/components/chat/huddle/HuddleCallBar.js +296 -0
- package/dist/shared/components/chat/huddle/HuddleCallLayer.js +180 -0
- package/dist/shared/components/chat/huddle/HuddleCamera.js +124 -0
- package/dist/shared/components/chat/huddle/HuddleCollab.js +320 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +82 -121
- package/dist/shared/components/chat/huddle/HuddleDraw.js +231 -0
- package/dist/shared/components/chat/huddle/HuddleLiveBadge.js +52 -0
- package/dist/shared/components/chat/huddle/HuddlePeoplePicker.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleScheduleCard.js +190 -0
- package/dist/shared/components/chat/huddle/HuddleScheduleForm.js +188 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +184 -89
- package/dist/shared/components/chat/huddle/HuddleStageTools.js +197 -0
- package/dist/shared/components/chat/huddle/huddle-audio-logic.js +156 -0
- package/dist/shared/components/chat/huddle/huddle-audio.js +69 -0
- package/dist/shared/components/chat/huddle/huddle-calls.js +129 -0
- package/dist/shared/components/chat/huddle/huddle-camera.js +143 -0
- package/dist/shared/components/chat/huddle/huddle-collab-store.js +391 -0
- package/dist/shared/components/chat/huddle/huddle-device-prefs.js +55 -0
- package/dist/shared/components/chat/huddle/huddle-devices.js +99 -0
- package/dist/shared/components/chat/huddle/huddle-draw.js +226 -0
- package/dist/shared/components/chat/huddle/huddle-follow-bus.js +96 -0
- package/dist/shared/components/chat/huddle/huddle-hold.js +62 -0
- package/dist/shared/components/chat/huddle/huddle-link-quality.js +159 -0
- package/dist/shared/components/chat/huddle/huddle-live.js +82 -0
- package/dist/shared/components/chat/huddle/huddle-pip.js +343 -0
- package/dist/shared/components/chat/huddle/huddle-quality.js +22 -0
- package/dist/shared/components/chat/huddle/huddle-reactions.js +71 -0
- package/dist/shared/components/chat/huddle/huddle-ring-refused.js +34 -0
- package/dist/shared/components/chat/huddle/huddle-schedule.js +102 -0
- package/dist/shared/components/chat/huddle/huddle-sfu.js +176 -0
- package/dist/shared/components/chat/huddle/huddle-shortcuts.js +91 -0
- package/dist/shared/components/chat/huddle/huddle-speaking.js +100 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +431 -157
- package/dist/shared/components/chat/huddle/useHuddle.js +46 -38
- package/dist/shared/components/chat/huddle/useHuddleAudio.js +35 -0
- package/dist/shared/components/item-edit/GroupSection.js +1 -0
- package/dist/shared/components/item-edit/RecordChatActions.js +68 -59
- package/dist/shared/components/item-edit/UserChip.js +145 -142
- package/dist/shared/components/panels/TaskPanel.js +51 -49
- package/dist/shared/components/support/TicketDetailSheet.js +57 -42
- package/dist/shared/lib/notification-sound.js +25 -16
- package/dist/shared/lib/stale-chunk.js +60 -0
- package/package.json +2 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
var S = Object.defineProperty;
|
|
2
|
+
var b = (n, t, r) => t in n ? S(n, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[t] = r;
|
|
3
|
+
var u = (n, t, r) => b(n, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
function f(n, t) {
|
|
5
|
+
return n === "audio" ? t === "screen_share_audio" ? null : "mic" : n !== "video" ? null : t === "camera" ? "camera" : t === "screen_share" || t === "unknown" || !t ? "screen" : null;
|
|
6
|
+
}
|
|
7
|
+
function m(n) {
|
|
8
|
+
const t = n.lastIndexOf("#");
|
|
9
|
+
return t >= 0 ? n.slice(t + 1) : n;
|
|
10
|
+
}
|
|
11
|
+
const P = 3e3;
|
|
12
|
+
let p = null;
|
|
13
|
+
function w() {
|
|
14
|
+
return p || (p = import("livekit-client")), p;
|
|
15
|
+
}
|
|
16
|
+
async function T(n) {
|
|
17
|
+
if (!n) return [];
|
|
18
|
+
try {
|
|
19
|
+
const t = await n.getRTCStatsReport();
|
|
20
|
+
return t ? [...t.values()] : [];
|
|
21
|
+
} catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class M {
|
|
26
|
+
constructor() {
|
|
27
|
+
u(this, "room", null);
|
|
28
|
+
u(this, "lk", null);
|
|
29
|
+
u(this, "screen", null);
|
|
30
|
+
/** The camera as published: a clone, so pausing it never blanks my own preview. */
|
|
31
|
+
u(this, "camera", null);
|
|
32
|
+
u(this, "closed", !1);
|
|
33
|
+
}
|
|
34
|
+
async connect(t, r) {
|
|
35
|
+
const e = await w();
|
|
36
|
+
if (this.closed) return;
|
|
37
|
+
this.lk = e;
|
|
38
|
+
const c = new e.Room({ adaptiveStream: !0, dynacast: !0 });
|
|
39
|
+
this.room = c;
|
|
40
|
+
const s = (i) => i.identity === c.localParticipant.identity, l = (i, a) => {
|
|
41
|
+
const o = f(i.kind, i.source);
|
|
42
|
+
!o || s(a) || r.onTrack(
|
|
43
|
+
m(a.identity),
|
|
44
|
+
o,
|
|
45
|
+
new MediaStream([i.mediaStreamTrack])
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
c.on(e.RoomEvent.TrackSubscribed, (i, a, o) => l(i, o)).on(e.RoomEvent.TrackUnsubscribed, (i, a, o) => {
|
|
49
|
+
const h = f(i.kind, i.source);
|
|
50
|
+
h && r.onTrackEnd(m(o.identity), h);
|
|
51
|
+
}).on(e.RoomEvent.TrackMuted, (i, a) => {
|
|
52
|
+
if (i.kind !== e.Track.Kind.Video || s(a)) return;
|
|
53
|
+
const o = f(i.kind, i.source);
|
|
54
|
+
o && r.onTrackEnd(m(a.identity), o);
|
|
55
|
+
}).on(e.RoomEvent.TrackUnmuted, (i, a) => {
|
|
56
|
+
i.kind !== e.Track.Kind.Video || !i.track || l(i.track, a);
|
|
57
|
+
}).on(e.RoomEvent.Reconnecting, () => {
|
|
58
|
+
var i;
|
|
59
|
+
return (i = r.onReconnecting) == null ? void 0 : i.call(r);
|
|
60
|
+
}).on(e.RoomEvent.Disconnected, () => {
|
|
61
|
+
this.closed || r.onDisconnected();
|
|
62
|
+
}), await c.connect(t.url, t.token, { autoSubscribe: !0 }), this.closed && (await c.disconnect(), this.room = null);
|
|
63
|
+
}
|
|
64
|
+
get connected() {
|
|
65
|
+
return !!this.room && !!this.lk && this.room.state === this.lk.ConnectionState.Connected;
|
|
66
|
+
}
|
|
67
|
+
/** Publish the store's own microphone track (the one mute toggles). */
|
|
68
|
+
async publishMic(t) {
|
|
69
|
+
!this.room || !this.lk || await this.room.localParticipant.publishTrack(t, {
|
|
70
|
+
source: this.lk.Track.Source.Microphone,
|
|
71
|
+
dtx: !0,
|
|
72
|
+
red: !0
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Swap the published microphone for another device's track in place (#2847 device picker). */
|
|
76
|
+
async replaceMic(t) {
|
|
77
|
+
if (!this.room || !this.lk) return;
|
|
78
|
+
const r = this.room.localParticipant.getTrackPublication(this.lk.Track.Source.Microphone);
|
|
79
|
+
r != null && r.track ? await r.track.replaceTrack(t, { userProvidedTrack: !0 }) : await this.publishMic(t);
|
|
80
|
+
}
|
|
81
|
+
async publishScreen(t) {
|
|
82
|
+
!this.room || !this.lk || (await this.room.localParticipant.publishTrack(t, {
|
|
83
|
+
source: this.lk.Track.Source.ScreenShare,
|
|
84
|
+
simulcast: !1
|
|
85
|
+
}), this.screen = t);
|
|
86
|
+
}
|
|
87
|
+
async unpublishScreen() {
|
|
88
|
+
if (!this.room || !this.screen) return;
|
|
89
|
+
const t = this.screen;
|
|
90
|
+
this.screen = null, await this.room.localParticipant.unpublishTrack(t, !1);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Publish my camera as its own Camera-source track (#2858), simulcast so the SFU can
|
|
94
|
+
* send a small layer to small tiles. `paused` = past the live-camera limit: published
|
|
95
|
+
* muted, so nobody receives frames until a place frees up.
|
|
96
|
+
*/
|
|
97
|
+
async publishCamera(t, r) {
|
|
98
|
+
var c;
|
|
99
|
+
if (!this.room || !this.lk || this.camera) return;
|
|
100
|
+
const e = t.clone();
|
|
101
|
+
this.camera = e;
|
|
102
|
+
try {
|
|
103
|
+
const s = await this.room.localParticipant.publishTrack(e, {
|
|
104
|
+
source: this.lk.Track.Source.Camera,
|
|
105
|
+
simulcast: !0
|
|
106
|
+
});
|
|
107
|
+
if (this.camera !== e) {
|
|
108
|
+
await ((c = this.room) == null ? void 0 : c.localParticipant.unpublishTrack(e, !0));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
r && await s.mute();
|
|
112
|
+
} catch (s) {
|
|
113
|
+
throw this.camera === e && (this.camera = null), e.stop(), s;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async unpublishCamera() {
|
|
117
|
+
const t = this.camera;
|
|
118
|
+
if (this.camera = null, !!t)
|
|
119
|
+
try {
|
|
120
|
+
this.room && await this.room.localParticipant.unpublishTrack(t, !0);
|
|
121
|
+
} finally {
|
|
122
|
+
t.stop();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** The live-camera limit moved me in or out of line (#2858): mute or unmute the camera. */
|
|
126
|
+
async setCameraPaused(t) {
|
|
127
|
+
if (!this.room || !this.lk || !this.camera) return;
|
|
128
|
+
const r = this.room.localParticipant.getTrackPublication(this.lk.Track.Source.Camera);
|
|
129
|
+
r && (t ? await r.mute() : await r.unmute());
|
|
130
|
+
}
|
|
131
|
+
/** Mirror the mute state so the SFU stops forwarding silence frames. */
|
|
132
|
+
async setMicMuted(t) {
|
|
133
|
+
if (!this.room || !this.lk) return;
|
|
134
|
+
const r = this.room.localParticipant.getTrackPublication(this.lk.Track.Source.Microphone);
|
|
135
|
+
r && (t ? await r.mute() : await r.unmute());
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* One poll's worth of stats for the quality sampler (#2848/#2849): per remote person the
|
|
139
|
+
* receiver stats of their voice (else any track of theirs), my microphone's sender stats,
|
|
140
|
+
* and LiveKit's own connection grades. Null when not connected.
|
|
141
|
+
*/
|
|
142
|
+
async stats() {
|
|
143
|
+
var i, a;
|
|
144
|
+
const t = this.room, r = this.lk;
|
|
145
|
+
if (!t || !r || t.state !== r.ConnectionState.Connected) return null;
|
|
146
|
+
const e = [];
|
|
147
|
+
for (const o of t.remoteParticipants.values()) {
|
|
148
|
+
const h = [...o.trackPublications.values()].filter((d) => d.track), k = h.find((d) => d.source === r.Track.Source.Microphone) ?? h[0];
|
|
149
|
+
e.push({
|
|
150
|
+
socket: m(o.identity),
|
|
151
|
+
reports: await T(k == null ? void 0 : k.track),
|
|
152
|
+
grade: o.connectionQuality
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const c = t.localParticipant, s = (i = c.getTrackPublication(r.Track.Source.Microphone)) == null ? void 0 : i.track, l = (a = c.getTrackPublication(r.Track.Source.ScreenShare)) == null ? void 0 : a.track;
|
|
156
|
+
return {
|
|
157
|
+
peers: e,
|
|
158
|
+
local: { reports: await T(s), grade: c.connectionQuality },
|
|
159
|
+
screenSender: this.screen ? (l == null ? void 0 : l.sender) ?? null : null
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
disconnect() {
|
|
163
|
+
this.closed = !0;
|
|
164
|
+
const t = this.room;
|
|
165
|
+
this.room = null, this.screen = null;
|
|
166
|
+
for (const r of this.camera ? [this.camera] : []) r.stop();
|
|
167
|
+
this.camera = null, t && t.disconnect().catch(() => null);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export {
|
|
171
|
+
P as MESH_OVERLAP_MS,
|
|
172
|
+
M as SfuSession,
|
|
173
|
+
w as loadLiveKit,
|
|
174
|
+
f as routeSfuTrack,
|
|
175
|
+
m as socketFromIdentity
|
|
176
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var u = (i, e, t) => e in i ? h(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var s = (i, e, t) => u(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { toast as l } from "sonner";
|
|
5
|
+
import { shortcutFor as c, NO_FOCUS as f } from "./huddle-audio-logic.js";
|
|
6
|
+
import { huddleStore as o, huddleSupport as p } from "./huddle-store.js";
|
|
7
|
+
const a = { talking: !1, helpOpen: !1 }, d = 3e3, v = 'button, a[href], summary, [role="button"], [role="link"], [role="menuitem"], [role="option"], [role="tab"], [role="checkbox"], [role="radio"], [role="switch"], [role="slider"]', m = '[role="listbox"], [role="menu"], [role="grid"], [role="tree"], [cmdk-root]';
|
|
8
|
+
function b(i) {
|
|
9
|
+
if (!i || typeof i.closest != "function") return f;
|
|
10
|
+
const e = i, t = e.tagName, n = e.getAttribute("role");
|
|
11
|
+
return {
|
|
12
|
+
editable: t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || e.isContentEditable || n === "textbox" || n === "combobox" || n === "searchbox" || n === "spinbutton",
|
|
13
|
+
interactive: !!e.closest(v),
|
|
14
|
+
typeahead: !!e.closest(m),
|
|
15
|
+
inHuddleControls: !!e.closest("[data-huddle-controls]")
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
class y {
|
|
19
|
+
constructor() {
|
|
20
|
+
s(this, "state", a);
|
|
21
|
+
s(this, "listeners", /* @__PURE__ */ new Set());
|
|
22
|
+
s(this, "bound", !1);
|
|
23
|
+
s(this, "started", !1);
|
|
24
|
+
s(this, "leaveArmedUntil", 0);
|
|
25
|
+
s(this, "subscribe", (e) => (this.listeners.add(e), () => {
|
|
26
|
+
this.listeners.delete(e);
|
|
27
|
+
}));
|
|
28
|
+
s(this, "getSnapshot", () => this.state);
|
|
29
|
+
s(this, "onKeyDown", (e) => {
|
|
30
|
+
if (e.defaultPrevented && !this.state.talking) return;
|
|
31
|
+
const t = o.getSnapshot(), n = t.status === "live";
|
|
32
|
+
if (this.state.talking && (e.code === "Space" || e.key === " ")) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const r = c(e, b(document.activeElement), {
|
|
37
|
+
muted: t.muted,
|
|
38
|
+
canShare: n && p().screen
|
|
39
|
+
});
|
|
40
|
+
if (r) {
|
|
41
|
+
if (r === "ptt") {
|
|
42
|
+
if (e.repeat || !n) return;
|
|
43
|
+
e.preventDefault(), o.setMuted(!1), this.set({ talking: !0 });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
e.preventDefault(), r === "help" ? this.setHelpOpen(!this.state.helpOpen) : r === "mute" && n && this.state.talking ? this.set({ talking: !1 }) : r === "mute" && n ? o.setMuted(!t.muted) : r === "share" && n ? t.sharing ? o.stopShare() : o.startShare() : r === "leave" && this.leave(t.sharing);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
s(this, "onKeyUp", (e) => {
|
|
50
|
+
!this.state.talking || !(e.code === "Space" || e.key === " ") || (e.preventDefault(), this.release());
|
|
51
|
+
});
|
|
52
|
+
s(this, "onVisibility", () => {
|
|
53
|
+
document.visibilityState === "hidden" && this.release();
|
|
54
|
+
});
|
|
55
|
+
/** Space let go, window blurred or tab hidden: back to muted. */
|
|
56
|
+
s(this, "release", () => {
|
|
57
|
+
this.state.talking && (this.set({ talking: !1 }), o.getSnapshot().status === "live" && o.setMuted(!0));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
set(e) {
|
|
61
|
+
this.state = { ...this.state, ...e };
|
|
62
|
+
for (const t of this.listeners) t();
|
|
63
|
+
}
|
|
64
|
+
start() {
|
|
65
|
+
this.started || typeof window > "u" || (this.started = !0, o.subscribe(() => this.sync()), this.sync());
|
|
66
|
+
}
|
|
67
|
+
setHelpOpen(e) {
|
|
68
|
+
e !== this.state.helpOpen && this.set({ helpOpen: e });
|
|
69
|
+
}
|
|
70
|
+
sync() {
|
|
71
|
+
const e = o.getSnapshot(), t = e.status === "live" || e.status === "joining";
|
|
72
|
+
t && !this.bound ? (this.bound = !0, window.addEventListener("keydown", this.onKeyDown), window.addEventListener("keyup", this.onKeyUp), window.addEventListener("blur", this.release), document.addEventListener("visibilitychange", this.onVisibility)) : !t && this.bound && (this.bound = !1, window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("keyup", this.onKeyUp), window.removeEventListener("blur", this.release), document.removeEventListener("visibilitychange", this.onVisibility), this.state !== a && this.set(a));
|
|
73
|
+
}
|
|
74
|
+
leave(e) {
|
|
75
|
+
const t = Date.now();
|
|
76
|
+
if (e && t > this.leaveArmedUntil) {
|
|
77
|
+
this.leaveArmedUntil = t + d, l("Press L again to leave", {
|
|
78
|
+
id: "huddle-leave-confirm",
|
|
79
|
+
description: "You are sharing your screen.",
|
|
80
|
+
duration: d
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.leaveArmedUntil = 0, l.dismiss("huddle-leave-confirm"), o.leave();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const S = new y();
|
|
88
|
+
export {
|
|
89
|
+
b as focusKindOf,
|
|
90
|
+
S as huddleShortcuts
|
|
91
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var w = (l, e, t) => e in l ? v(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var r = (l, e, t) => w(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { createLevelMeter as u } from "./huddle-audio.js";
|
|
5
|
+
import { SpeakingGate as k, reconcileOrder as y, REORDER_MS as T, orderByLastSpoke as M, sameOrder as g } from "./huddle-audio-logic.js";
|
|
6
|
+
import { huddleStore as h } from "./huddle-store.js";
|
|
7
|
+
const d = {
|
|
8
|
+
speaking: {},
|
|
9
|
+
selfSpeaking: !1,
|
|
10
|
+
mutedTalking: !1,
|
|
11
|
+
order: []
|
|
12
|
+
}, R = 100;
|
|
13
|
+
class b {
|
|
14
|
+
constructor() {
|
|
15
|
+
r(this, "snap", d);
|
|
16
|
+
r(this, "listeners", /* @__PURE__ */ new Set());
|
|
17
|
+
r(this, "voices", /* @__PURE__ */ new Map());
|
|
18
|
+
r(this, "self", null);
|
|
19
|
+
r(this, "lastSpoke", {});
|
|
20
|
+
r(this, "lastReorder", 0);
|
|
21
|
+
r(this, "timer", null);
|
|
22
|
+
r(this, "started", !1);
|
|
23
|
+
r(this, "subscribe", (e) => (this.listeners.add(e), () => {
|
|
24
|
+
this.listeners.delete(e);
|
|
25
|
+
}));
|
|
26
|
+
r(this, "getSnapshot", () => this.snap);
|
|
27
|
+
}
|
|
28
|
+
emit(e) {
|
|
29
|
+
this.snap = e;
|
|
30
|
+
for (const t of this.listeners) t();
|
|
31
|
+
}
|
|
32
|
+
start() {
|
|
33
|
+
this.started || typeof window > "u" || (this.started = !0, h.subscribe(() => this.sync()), this.sync());
|
|
34
|
+
}
|
|
35
|
+
/** My own microphone level right now (0–1 RMS), muted or not; 0 when not in a huddle. */
|
|
36
|
+
selfLevel() {
|
|
37
|
+
var e;
|
|
38
|
+
return ((e = this.self) == null ? void 0 : e.meter.level()) ?? 0;
|
|
39
|
+
}
|
|
40
|
+
sync() {
|
|
41
|
+
const e = h.getSnapshot();
|
|
42
|
+
if (e.status !== "live") {
|
|
43
|
+
this.stopAll();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const [s, i] of this.voices) {
|
|
47
|
+
const n = e.peers.find((c) => c.socket === s);
|
|
48
|
+
(!n || n.audio !== i.stream) && (i.meter.stop(), this.voices.delete(s));
|
|
49
|
+
}
|
|
50
|
+
for (const s of e.peers) {
|
|
51
|
+
if (!s.audio || this.voices.has(s.socket)) continue;
|
|
52
|
+
const i = u(s.audio);
|
|
53
|
+
i && this.voices.set(s.socket, { stream: s.audio, meter: i, gate: new k() });
|
|
54
|
+
}
|
|
55
|
+
const t = h.localMic();
|
|
56
|
+
if (this.self && this.self.source !== t && this.dropSelf(), !this.self && t) {
|
|
57
|
+
const s = t.getAudioTracks()[0];
|
|
58
|
+
if (s) {
|
|
59
|
+
const i = new MediaStream([s.clone()]), n = u(i);
|
|
60
|
+
if (n) this.self = { source: t, stream: i, meter: n, gate: new k() };
|
|
61
|
+
else for (const c of i.getTracks()) c.stop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this.timer || (this.timer = setInterval(() => this.tick(), R));
|
|
65
|
+
}
|
|
66
|
+
tick() {
|
|
67
|
+
const e = h.getSnapshot();
|
|
68
|
+
if (e.status !== "live") return;
|
|
69
|
+
const t = Date.now(), s = {};
|
|
70
|
+
for (const o of e.peers) {
|
|
71
|
+
const p = this.voices.get(o.socket);
|
|
72
|
+
if (!p) continue;
|
|
73
|
+
p.gate.push(o.muted ? 0 : p.meter.level(), t) && (s[o.socket] = !0, this.lastSpoke[o.socket] = t);
|
|
74
|
+
}
|
|
75
|
+
const i = this.self ? this.self.gate.push(this.self.meter.level(), t) : !1, n = i && !e.muted, c = i && e.muted, S = e.peers.map((o) => o.socket);
|
|
76
|
+
let a = y(this.snap.order, S);
|
|
77
|
+
if (t - this.lastReorder >= T) {
|
|
78
|
+
const o = M(a, this.lastSpoke);
|
|
79
|
+
g(o, a) || (a = o, this.lastReorder = t);
|
|
80
|
+
}
|
|
81
|
+
const f = this.snap, m = Object.keys(s);
|
|
82
|
+
(f.selfSpeaking !== n || f.mutedTalking !== c || !g(f.order, a) || m.length !== Object.keys(f.speaking).length || m.some((o) => !f.speaking[o])) && this.emit({ speaking: s, selfSpeaking: n, mutedTalking: c, order: a });
|
|
83
|
+
}
|
|
84
|
+
dropSelf() {
|
|
85
|
+
if (this.self) {
|
|
86
|
+
this.self.meter.stop();
|
|
87
|
+
for (const e of this.self.stream.getTracks()) e.stop();
|
|
88
|
+
this.self = null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
stopAll() {
|
|
92
|
+
this.timer && clearInterval(this.timer), this.timer = null;
|
|
93
|
+
for (const [, e] of this.voices) e.meter.stop();
|
|
94
|
+
this.voices.clear(), this.dropSelf(), this.lastSpoke = {}, this.lastReorder = 0, this.snap !== d && this.emit(d);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const D = new b();
|
|
98
|
+
export {
|
|
99
|
+
D as huddleSpeaking
|
|
100
|
+
};
|