vg-x07df 1.9.2 → 1.9.3
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/index.cjs +309 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +309 -42
- package/dist/index.mjs.map +1 -1
- package/dist/livekit/index.cjs +5 -0
- package/dist/livekit/index.cjs.map +1 -1
- package/dist/livekit/index.d.cts +1 -0
- package/dist/livekit/index.d.ts +1 -0
- package/dist/livekit/index.mjs +1 -0
- package/dist/livekit/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var immer$1 = require('immer');
|
|
|
9
9
|
var mitt = require('mitt');
|
|
10
10
|
var livekitClient = require('livekit-client');
|
|
11
11
|
var componentsReact = require('@livekit/components-react');
|
|
12
|
+
require('@livekit/track-processors');
|
|
12
13
|
|
|
13
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
|
|
@@ -1406,6 +1407,301 @@ var callRecordingStoppedSchema = zod.z.object({
|
|
|
1406
1407
|
egressId: zod.z.string(),
|
|
1407
1408
|
state: zod.z.string()
|
|
1408
1409
|
}).strict();
|
|
1410
|
+
var defaultChatState = {
|
|
1411
|
+
byId: {},
|
|
1412
|
+
order: [],
|
|
1413
|
+
pendingOps: {},
|
|
1414
|
+
participantCache: {},
|
|
1415
|
+
maxEntries: 1e3
|
|
1416
|
+
};
|
|
1417
|
+
function applyReactionToEntry(entry, emoji, participantId, op) {
|
|
1418
|
+
const emojiSet = entry.reactions[emoji];
|
|
1419
|
+
if (!emojiSet) {
|
|
1420
|
+
entry.reactions[emoji] = /* @__PURE__ */ new Set();
|
|
1421
|
+
}
|
|
1422
|
+
if (op === "add") {
|
|
1423
|
+
entry.reactions[emoji]?.add(participantId);
|
|
1424
|
+
} else {
|
|
1425
|
+
entry.reactions[emoji]?.delete(participantId);
|
|
1426
|
+
if (entry.reactions[emoji]?.size === 0) {
|
|
1427
|
+
delete entry.reactions[emoji];
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
function trimEntriesIfNeeded(state) {
|
|
1432
|
+
if (Object.keys(state.byId).length > state.maxEntries) {
|
|
1433
|
+
const entriesToRemove = Object.keys(state.byId).length - state.maxEntries;
|
|
1434
|
+
for (let i = 0; i < entriesToRemove; i++) {
|
|
1435
|
+
const oldestId = state.order[i];
|
|
1436
|
+
if (oldestId) {
|
|
1437
|
+
delete state.byId[oldestId];
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
state.order = state.order.slice(entriesToRemove);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
var useChatStore = zustand.create()(
|
|
1444
|
+
immer.immer((set) => ({
|
|
1445
|
+
...defaultChatState,
|
|
1446
|
+
patch: (fn) => set((state) => {
|
|
1447
|
+
fn(state);
|
|
1448
|
+
}),
|
|
1449
|
+
applyIncoming: (envelope) => set((state) => {
|
|
1450
|
+
if (envelope.kind === "entry") {
|
|
1451
|
+
if (state.byId[envelope.entryId]) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
if (envelope.sender.info) {
|
|
1455
|
+
state.participantCache[envelope.sender.id] = envelope.sender.info;
|
|
1456
|
+
}
|
|
1457
|
+
const entry = {
|
|
1458
|
+
id: envelope.entryId,
|
|
1459
|
+
content: envelope.payload.content,
|
|
1460
|
+
sender: {
|
|
1461
|
+
id: envelope.sender.id
|
|
1462
|
+
},
|
|
1463
|
+
createdAt: envelope.ts,
|
|
1464
|
+
version: 1,
|
|
1465
|
+
reactions: {},
|
|
1466
|
+
status: "sent",
|
|
1467
|
+
filename: envelope.payload?.meta?.filename
|
|
1468
|
+
};
|
|
1469
|
+
state.byId[envelope.entryId] = entry;
|
|
1470
|
+
state.order.push(envelope.entryId);
|
|
1471
|
+
trimEntriesIfNeeded(state);
|
|
1472
|
+
const pendingOps = state.pendingOps[envelope.entryId];
|
|
1473
|
+
if (pendingOps) {
|
|
1474
|
+
delete state.pendingOps[envelope.entryId];
|
|
1475
|
+
for (const op of pendingOps) {
|
|
1476
|
+
if (op.kind === "edit") {
|
|
1477
|
+
const entry2 = state.byId[op.entryId];
|
|
1478
|
+
if (entry2 && op.payload.version > entry2.version) {
|
|
1479
|
+
entry2.content = op.payload.newContent;
|
|
1480
|
+
entry2.version = op.payload.version;
|
|
1481
|
+
entry2.editedAt = op.ts;
|
|
1482
|
+
}
|
|
1483
|
+
} else if (op.kind === "remove") {
|
|
1484
|
+
const entry2 = state.byId[op.entryId];
|
|
1485
|
+
if (entry2 && !entry2.removedAt) {
|
|
1486
|
+
entry2.removedAt = op.ts;
|
|
1487
|
+
}
|
|
1488
|
+
} else if (op.kind === "reaction") {
|
|
1489
|
+
if (op.sender.info) {
|
|
1490
|
+
state.participantCache[op.sender.id] = op.sender.info;
|
|
1491
|
+
}
|
|
1492
|
+
const entry2 = state.byId[op.entryId];
|
|
1493
|
+
if (entry2) {
|
|
1494
|
+
applyReactionToEntry(
|
|
1495
|
+
entry2,
|
|
1496
|
+
op.payload.emoji,
|
|
1497
|
+
op.sender.id,
|
|
1498
|
+
op.payload.op
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
} else if (envelope.kind === "edit") {
|
|
1505
|
+
const entry = state.byId[envelope.entryId];
|
|
1506
|
+
if (entry) {
|
|
1507
|
+
if (envelope.payload.version > entry.version) {
|
|
1508
|
+
entry.content = envelope.payload.newContent;
|
|
1509
|
+
entry.version = envelope.payload.version;
|
|
1510
|
+
entry.editedAt = envelope.ts;
|
|
1511
|
+
}
|
|
1512
|
+
} else {
|
|
1513
|
+
if (!state.pendingOps[envelope.entryId]) {
|
|
1514
|
+
state.pendingOps[envelope.entryId] = [];
|
|
1515
|
+
}
|
|
1516
|
+
state.pendingOps[envelope.entryId]?.push(envelope);
|
|
1517
|
+
}
|
|
1518
|
+
} else if (envelope.kind === "remove") {
|
|
1519
|
+
const entry = state.byId[envelope.entryId];
|
|
1520
|
+
if (entry) {
|
|
1521
|
+
if (!entry.removedAt) {
|
|
1522
|
+
entry.removedAt = envelope.ts;
|
|
1523
|
+
}
|
|
1524
|
+
} else {
|
|
1525
|
+
if (!state.pendingOps[envelope.entryId]) {
|
|
1526
|
+
state.pendingOps[envelope.entryId] = [];
|
|
1527
|
+
}
|
|
1528
|
+
state.pendingOps[envelope.entryId]?.push(envelope);
|
|
1529
|
+
}
|
|
1530
|
+
} else if (envelope.kind === "reaction") {
|
|
1531
|
+
if (envelope.sender.info) {
|
|
1532
|
+
state.participantCache[envelope.sender.id] = envelope.sender.info;
|
|
1533
|
+
}
|
|
1534
|
+
const entry = state.byId[envelope.entryId];
|
|
1535
|
+
if (entry) {
|
|
1536
|
+
applyReactionToEntry(
|
|
1537
|
+
entry,
|
|
1538
|
+
envelope.payload.emoji,
|
|
1539
|
+
envelope.sender.id,
|
|
1540
|
+
envelope.payload.op
|
|
1541
|
+
);
|
|
1542
|
+
} else {
|
|
1543
|
+
if (!state.pendingOps[envelope.entryId]) {
|
|
1544
|
+
state.pendingOps[envelope.entryId] = [];
|
|
1545
|
+
}
|
|
1546
|
+
state.pendingOps[envelope.entryId]?.push(envelope);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
}),
|
|
1550
|
+
addFile: (file, filename) => set((state) => {
|
|
1551
|
+
const values = Object.values(state.byId);
|
|
1552
|
+
const entryArr = values.filter((val) => val.filename === filename);
|
|
1553
|
+
const entry = entryArr[0];
|
|
1554
|
+
entry.file = file;
|
|
1555
|
+
state.byId[entry.id] = entry;
|
|
1556
|
+
}),
|
|
1557
|
+
addEntryOptimistic: (entry) => set((state) => {
|
|
1558
|
+
state.byId[entry.id] = entry;
|
|
1559
|
+
state.order.push(entry.id);
|
|
1560
|
+
trimEntriesIfNeeded(state);
|
|
1561
|
+
}),
|
|
1562
|
+
markEntrySent: (entryId) => set((state) => {
|
|
1563
|
+
const entry = state.byId[entryId];
|
|
1564
|
+
if (entry) {
|
|
1565
|
+
entry.status = "sent";
|
|
1566
|
+
}
|
|
1567
|
+
}),
|
|
1568
|
+
markEntryFailed: (entryId) => set((state) => {
|
|
1569
|
+
const entry = state.byId[entryId];
|
|
1570
|
+
if (entry) {
|
|
1571
|
+
entry.status = "failed";
|
|
1572
|
+
}
|
|
1573
|
+
}),
|
|
1574
|
+
applyEdit: (entryId, newContent, version) => set((state) => {
|
|
1575
|
+
const entry = state.byId[entryId];
|
|
1576
|
+
if (entry && version > entry.version) {
|
|
1577
|
+
entry.content = newContent;
|
|
1578
|
+
entry.version = version;
|
|
1579
|
+
entry.editedAt = Date.now();
|
|
1580
|
+
}
|
|
1581
|
+
}),
|
|
1582
|
+
applyRemove: (entryId) => set((state) => {
|
|
1583
|
+
const entry = state.byId[entryId];
|
|
1584
|
+
if (entry && !entry.removedAt) {
|
|
1585
|
+
entry.removedAt = Date.now();
|
|
1586
|
+
}
|
|
1587
|
+
}),
|
|
1588
|
+
applyReaction: (entryId, emoji, participantId, op) => set((state) => {
|
|
1589
|
+
const entry = state.byId[entryId];
|
|
1590
|
+
if (entry) {
|
|
1591
|
+
applyReactionToEntry(entry, emoji, participantId, op);
|
|
1592
|
+
}
|
|
1593
|
+
}),
|
|
1594
|
+
queuePendingOp: (entryId, envelope) => set((state) => {
|
|
1595
|
+
if (!state.pendingOps[entryId]) {
|
|
1596
|
+
state.pendingOps[entryId] = [];
|
|
1597
|
+
}
|
|
1598
|
+
state.pendingOps[entryId].push(envelope);
|
|
1599
|
+
}),
|
|
1600
|
+
processPendingOps: (entryId) => set((state) => {
|
|
1601
|
+
const pendingOps = state.pendingOps[entryId];
|
|
1602
|
+
if (!pendingOps) {
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
delete state.pendingOps[entryId];
|
|
1606
|
+
for (const envelope of pendingOps) {
|
|
1607
|
+
if (envelope.kind === "edit") {
|
|
1608
|
+
const entry = state.byId[envelope.entryId];
|
|
1609
|
+
if (entry && envelope.payload.version > entry.version) {
|
|
1610
|
+
entry.content = envelope.payload.newContent;
|
|
1611
|
+
entry.version = envelope.payload.version;
|
|
1612
|
+
entry.editedAt = envelope.ts;
|
|
1613
|
+
}
|
|
1614
|
+
} else if (envelope.kind === "remove") {
|
|
1615
|
+
const entry = state.byId[envelope.entryId];
|
|
1616
|
+
if (entry && !entry.removedAt) {
|
|
1617
|
+
entry.removedAt = envelope.ts;
|
|
1618
|
+
}
|
|
1619
|
+
} else if (envelope.kind === "reaction") {
|
|
1620
|
+
if (envelope.sender.info) {
|
|
1621
|
+
state.participantCache[envelope.sender.id] = envelope.sender.info;
|
|
1622
|
+
}
|
|
1623
|
+
const entry = state.byId[envelope.entryId];
|
|
1624
|
+
if (entry) {
|
|
1625
|
+
applyReactionToEntry(
|
|
1626
|
+
entry,
|
|
1627
|
+
envelope.payload.emoji,
|
|
1628
|
+
envelope.sender.id,
|
|
1629
|
+
envelope.payload.op
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}),
|
|
1635
|
+
trimOldEntries: () => set((state) => {
|
|
1636
|
+
trimEntriesIfNeeded(state);
|
|
1637
|
+
}),
|
|
1638
|
+
clearChat: () => set(() => defaultChatState)
|
|
1639
|
+
}))
|
|
1640
|
+
);
|
|
1641
|
+
var defaultState2 = {
|
|
1642
|
+
raisedHands: /* @__PURE__ */ new Map(),
|
|
1643
|
+
nextOrder: 1
|
|
1644
|
+
};
|
|
1645
|
+
var useRaiseHandStore = zustand.create()(
|
|
1646
|
+
immer.immer((set, get) => ({
|
|
1647
|
+
...defaultState2,
|
|
1648
|
+
raiseHand: (participantId) => set((state) => {
|
|
1649
|
+
if (!state.raisedHands.has(participantId)) {
|
|
1650
|
+
state.raisedHands.set(participantId, {
|
|
1651
|
+
ts: Date.now(),
|
|
1652
|
+
order: state.nextOrder++
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
}),
|
|
1656
|
+
lowerHand: (participantId) => set((state) => {
|
|
1657
|
+
state.raisedHands.delete(participantId);
|
|
1658
|
+
if (state.raisedHands.size === 0) {
|
|
1659
|
+
state.nextOrder = 1;
|
|
1660
|
+
}
|
|
1661
|
+
}),
|
|
1662
|
+
lowerAllHands: () => set((state) => {
|
|
1663
|
+
state.raisedHands.clear();
|
|
1664
|
+
state.nextOrder = 1;
|
|
1665
|
+
}),
|
|
1666
|
+
isHandRaised: (participantId) => get().raisedHands.has(participantId),
|
|
1667
|
+
getRaisedHandOrder: (participantId) => {
|
|
1668
|
+
const hand = get().raisedHands.get(participantId);
|
|
1669
|
+
return hand?.order ?? null;
|
|
1670
|
+
},
|
|
1671
|
+
upsertParticipantInfo: (id, info) => {
|
|
1672
|
+
},
|
|
1673
|
+
clear: () => set(() => ({
|
|
1674
|
+
raisedHands: /* @__PURE__ */ new Map(),
|
|
1675
|
+
nextOrder: 1
|
|
1676
|
+
}))
|
|
1677
|
+
}))
|
|
1678
|
+
);
|
|
1679
|
+
var defaultState3 = {
|
|
1680
|
+
spotlightedUser: null,
|
|
1681
|
+
isSpotlighted: false
|
|
1682
|
+
};
|
|
1683
|
+
var useSpotlightStore = zustand.create()(
|
|
1684
|
+
immer.immer((set, get) => ({
|
|
1685
|
+
...defaultState3,
|
|
1686
|
+
spotlight: (participantId, info) => set((state) => {
|
|
1687
|
+
state.spotlightedUser = {
|
|
1688
|
+
participantId,
|
|
1689
|
+
ts: Date.now(),
|
|
1690
|
+
...info && { info }
|
|
1691
|
+
};
|
|
1692
|
+
state.isSpotlighted = true;
|
|
1693
|
+
}),
|
|
1694
|
+
unspotlight: () => set((state) => {
|
|
1695
|
+
state.spotlightedUser = null;
|
|
1696
|
+
state.isSpotlighted = false;
|
|
1697
|
+
}),
|
|
1698
|
+
getSpotlightedUser: () => get().spotlightedUser,
|
|
1699
|
+
clear: () => set(() => ({
|
|
1700
|
+
spotlightedUser: null,
|
|
1701
|
+
isSpotlighted: false
|
|
1702
|
+
}))
|
|
1703
|
+
}))
|
|
1704
|
+
);
|
|
1409
1705
|
|
|
1410
1706
|
// src/state/errors.ts
|
|
1411
1707
|
function pushError(code, message, context, logger7) {
|
|
@@ -1591,13 +1887,13 @@ var useProfileCache = zustand.create()(
|
|
|
1591
1887
|
}))
|
|
1592
1888
|
);
|
|
1593
1889
|
var profileCache = useProfileCache;
|
|
1594
|
-
var
|
|
1890
|
+
var defaultState4 = {
|
|
1595
1891
|
recording: null,
|
|
1596
1892
|
isRecording: false
|
|
1597
1893
|
};
|
|
1598
1894
|
var useRecordingStore = zustand.create()(
|
|
1599
1895
|
immer.immer((set) => ({
|
|
1600
|
-
...
|
|
1896
|
+
...defaultState4,
|
|
1601
1897
|
setRecording: (recording) => set((state) => {
|
|
1602
1898
|
state.recording = recording;
|
|
1603
1899
|
state.isRecording = recording !== null;
|
|
@@ -1690,6 +1986,9 @@ var SessionEndedHandler = class extends BaseSocketHandler {
|
|
|
1690
1986
|
rtcStore.getState().reset();
|
|
1691
1987
|
profileCache.getState().clear();
|
|
1692
1988
|
recordingStore.getState().clear();
|
|
1989
|
+
useChatStore.getState().clearChat();
|
|
1990
|
+
useSpotlightStore.getState().clear();
|
|
1991
|
+
useRaiseHandStore.getState().clear();
|
|
1693
1992
|
if (this.livekit) {
|
|
1694
1993
|
this.livekit.disconnect().catch((error) => {
|
|
1695
1994
|
this.logger.error("Error disconnecting from LiveKit", { error });
|
|
@@ -2621,6 +2920,9 @@ function createCallsService(config, deps) {
|
|
|
2621
2920
|
rtcStore.getState().reset();
|
|
2622
2921
|
profileCache.getState().clear();
|
|
2623
2922
|
recordingStore.getState().clear();
|
|
2923
|
+
useChatStore.getState().clearChat();
|
|
2924
|
+
useSpotlightStore.getState().clear();
|
|
2925
|
+
useRaiseHandStore.getState().clear();
|
|
2624
2926
|
}
|
|
2625
2927
|
} catch (error) {
|
|
2626
2928
|
rtcStore.getState().addError({
|
|
@@ -2702,6 +3004,9 @@ function createCallsService(config, deps) {
|
|
|
2702
3004
|
rtcStore.getState().reset();
|
|
2703
3005
|
profileCache.getState().clear();
|
|
2704
3006
|
recordingStore.getState().clear();
|
|
3007
|
+
useChatStore.getState().clearChat();
|
|
3008
|
+
useSpotlightStore.getState().clear();
|
|
3009
|
+
useRaiseHandStore.getState().clear();
|
|
2705
3010
|
return response;
|
|
2706
3011
|
} catch (error) {
|
|
2707
3012
|
rtcStore.getState().addError({
|
|
@@ -3476,50 +3781,12 @@ function useTerminate() {
|
|
|
3476
3781
|
isInitiator
|
|
3477
3782
|
};
|
|
3478
3783
|
}
|
|
3479
|
-
var
|
|
3480
|
-
raisedHands: /* @__PURE__ */ new Map(),
|
|
3481
|
-
nextOrder: 1
|
|
3482
|
-
};
|
|
3483
|
-
var useRaiseHandStore = zustand.create()(
|
|
3484
|
-
immer.immer((set, get) => ({
|
|
3485
|
-
...defaultState3,
|
|
3486
|
-
raiseHand: (participantId) => set((state) => {
|
|
3487
|
-
if (!state.raisedHands.has(participantId)) {
|
|
3488
|
-
state.raisedHands.set(participantId, {
|
|
3489
|
-
ts: Date.now(),
|
|
3490
|
-
order: state.nextOrder++
|
|
3491
|
-
});
|
|
3492
|
-
}
|
|
3493
|
-
}),
|
|
3494
|
-
lowerHand: (participantId) => set((state) => {
|
|
3495
|
-
state.raisedHands.delete(participantId);
|
|
3496
|
-
if (state.raisedHands.size === 0) {
|
|
3497
|
-
state.nextOrder = 1;
|
|
3498
|
-
}
|
|
3499
|
-
}),
|
|
3500
|
-
lowerAllHands: () => set((state) => {
|
|
3501
|
-
state.raisedHands.clear();
|
|
3502
|
-
state.nextOrder = 1;
|
|
3503
|
-
}),
|
|
3504
|
-
isHandRaised: (participantId) => get().raisedHands.has(participantId),
|
|
3505
|
-
getRaisedHandOrder: (participantId) => {
|
|
3506
|
-
const hand = get().raisedHands.get(participantId);
|
|
3507
|
-
return hand?.order ?? null;
|
|
3508
|
-
},
|
|
3509
|
-
upsertParticipantInfo: (id, info) => {
|
|
3510
|
-
},
|
|
3511
|
-
clear: () => set(() => ({
|
|
3512
|
-
raisedHands: /* @__PURE__ */ new Map(),
|
|
3513
|
-
nextOrder: 1
|
|
3514
|
-
}))
|
|
3515
|
-
}))
|
|
3516
|
-
);
|
|
3517
|
-
var defaultState4 = {
|
|
3784
|
+
var defaultState5 = {
|
|
3518
3785
|
pinnedParticipantIds: /* @__PURE__ */ new Set()
|
|
3519
3786
|
};
|
|
3520
3787
|
var useParticipantListStore = zustand.create()(
|
|
3521
3788
|
immer.immer((set, get) => ({
|
|
3522
|
-
...
|
|
3789
|
+
...defaultState5,
|
|
3523
3790
|
togglePin: (participantId) => set((state) => {
|
|
3524
3791
|
if (state.pinnedParticipantIds.has(participantId)) {
|
|
3525
3792
|
state.pinnedParticipantIds.delete(participantId);
|