vg-x07df 1.2.0 → 1.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/index.cjs +1055 -613
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +762 -215
- package/dist/index.d.ts +762 -215
- package/dist/index.mjs +1035 -614
- package/dist/index.mjs.map +1 -1
- package/dist/livekit/index.cjs +61 -0
- package/dist/livekit/index.cjs.map +1 -1
- package/dist/livekit/index.d.cts +6 -1
- package/dist/livekit/index.d.ts +6 -1
- package/dist/livekit/index.mjs +66 -0
- package/dist/livekit/index.mjs.map +1 -1
- package/package.json +7 -2
package/dist/livekit/index.cjs
CHANGED
|
@@ -2,8 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
var livekitClient = require('livekit-client');
|
|
4
4
|
var componentsReact = require('@livekit/components-react');
|
|
5
|
+
var zustand = require('zustand');
|
|
6
|
+
var immer = require('zustand/middleware/immer');
|
|
7
|
+
var react = require('react');
|
|
5
8
|
|
|
9
|
+
// src/livekit/index.ts
|
|
6
10
|
|
|
11
|
+
// src/state/types.ts
|
|
12
|
+
var defaultState = {
|
|
13
|
+
initiated: false,
|
|
14
|
+
session: null,
|
|
15
|
+
incomingInvite: null,
|
|
16
|
+
outgoingInvites: {},
|
|
17
|
+
errors: []
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/state/store.ts
|
|
21
|
+
var useRtcStore = zustand.create()(
|
|
22
|
+
immer.immer((set) => ({
|
|
23
|
+
...defaultState,
|
|
24
|
+
patch: (fn) => set((state) => {
|
|
25
|
+
fn(state);
|
|
26
|
+
}),
|
|
27
|
+
reset: () => set(() => defaultState),
|
|
28
|
+
addError: (error) => set((state) => {
|
|
29
|
+
state.errors.push(error);
|
|
30
|
+
}),
|
|
31
|
+
clearErrors: () => set((state) => {
|
|
32
|
+
state.errors = [];
|
|
33
|
+
})
|
|
34
|
+
}))
|
|
35
|
+
);
|
|
36
|
+
var defaultRoomOptions = {
|
|
37
|
+
adaptiveStream: true,
|
|
38
|
+
dynacast: true
|
|
39
|
+
};
|
|
40
|
+
function useRoom(options) {
|
|
41
|
+
const [room] = react.useState(() => new livekitClient.Room(defaultRoomOptions));
|
|
42
|
+
const livekitInfo = useRtcStore((state) => state.session?.livekitInfo);
|
|
43
|
+
react.useEffect(() => {
|
|
44
|
+
if (!livekitInfo) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
room.connect(livekitInfo.url, livekitInfo.token);
|
|
48
|
+
return () => {
|
|
49
|
+
room.disconnect();
|
|
50
|
+
};
|
|
51
|
+
}, [livekitInfo, room]);
|
|
52
|
+
if (!livekitInfo) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return room;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/livekit/custom.ts
|
|
59
|
+
function useParticipantCount(options) {
|
|
60
|
+
const room = useRoom();
|
|
61
|
+
if (!room) {
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
const participants = componentsReact.useParticipants(options);
|
|
65
|
+
return participants.length;
|
|
66
|
+
}
|
|
7
67
|
|
|
8
68
|
Object.defineProperty(exports, "ConnectionQuality", {
|
|
9
69
|
enumerable: true,
|
|
@@ -249,5 +309,6 @@ Object.defineProperty(exports, "useTracks", {
|
|
|
249
309
|
enumerable: true,
|
|
250
310
|
get: function () { return componentsReact.useTracks; }
|
|
251
311
|
});
|
|
312
|
+
exports.useParticipantCount = useParticipantCount;
|
|
252
313
|
//# sourceMappingURL=index.cjs.map
|
|
253
314
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/state/types.ts","../../src/state/store.ts","../../src/hooks/useRoom.ts","../../src/livekit/custom.ts"],"names":["create","immer","useState","Room","useEffect","useParticipants"],"mappings":";;;;;;;;;;;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KAAK,CAAA;AAC/C,IAAA,OAAO,MAAM;AACX,MAAA,IAAA,CAAK,UAAA,EAAW;AAAA,IAClB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,WAAA,EAAa,IAAI,CAAC,CAAA;AAEtB,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;;;AC1BO,SAAS,oBAAoB,OAAA,EAA0C;AAC5E,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,CAAA;AAAA,EACT;AAEA,EAAA,MAAM,YAAA,GAAeC,gCAAgB,OAAO,CAAA;AAC5C,EAAA,OAAO,YAAA,CAAa,MAAA;AACtB","file":"index.cjs","sourcesContent":["export interface ParticipantMetadata {\r\n userId: string;\r\n role: \"HOST\" | \"PARTICIPANT\" | \"GUEST\";\r\n firstName: string;\r\n lastName: string;\r\n username: string;\r\n email: string;\r\n profilePhoto: string;\r\n}\r\n\r\nexport interface LiveKitJoinInfo {\r\n token: string;\r\n roomName: string;\r\n url: string;\r\n}\r\n\r\nexport interface Session {\r\n id: string;\r\n status: \"pending\" | \"active\" | \"ended\";\r\n mode: \"AUDIO\" | \"VIDEO\";\r\n role: \"HOST\" | \"PARTICIPANT\" | \"GUEST\";\r\n livekitInfo?: LiveKitJoinInfo;\r\n}\r\n\r\nexport interface IncomingInvite {\r\n callId: string;\r\n caller: ParticipantMetadata;\r\n mode: \"AUDIO\" | \"VIDEO\";\r\n expiresAt: string;\r\n expiresInMs: number;\r\n}\r\n\r\nexport interface OutgoingInvite {\r\n userId: string;\r\n status: \"sent\" | \"accepted\" | \"declined\" | \"missed\";\r\n participant: ParticipantMetadata;\r\n}\r\n\r\nexport interface RtcError {\r\n code: string;\r\n message: string;\r\n timestamp: number;\r\n context?: any;\r\n}\r\n\r\nexport interface RtcState {\r\n // Did we initiate the current call?\r\n initiated: boolean;\r\n\r\n // Active session (null when no active call)\r\n session: Session | null;\r\n\r\n // Incoming invitation (null when no pending invite)\r\n incomingInvite: IncomingInvite | null;\r\n\r\n outgoingInvites: Record<string, OutgoingInvite>;\r\n\r\n // Error tracking\r\n errors: RtcError[];\r\n}\r\n\r\nexport const defaultState: RtcState = {\r\n initiated: false,\r\n session: null,\r\n incomingInvite: null,\r\n outgoingInvites: {},\r\n errors: [],\r\n};\r\n","import { create } from \"zustand\";\r\nimport { immer } from \"zustand/middleware/immer\";\r\nimport type { RtcError, RtcState } from \"./types\";\r\nimport { defaultState } from \"./types\";\r\n\r\ntype Actions = {\r\n patch: (fn: (draft: RtcState) => void) => void;\r\n reset: () => void;\r\n addError: (error: RtcError) => void;\r\n clearErrors: () => void;\r\n};\r\n\r\nexport const useRtcStore = create<RtcState & Actions>()(\r\n immer((set) => ({\r\n ...defaultState,\r\n\r\n patch: (fn) =>\r\n set((state) => {\r\n fn(state);\r\n }),\r\n\r\n reset: () => set(() => defaultState),\r\n\r\n addError: (error) =>\r\n set((state) => {\r\n state.errors.push(error);\r\n }),\r\n\r\n clearErrors: () =>\r\n set((state) => {\r\n state.errors = [];\r\n }),\r\n }))\r\n);\r\n\r\nexport const rtcStore = useRtcStore;\r\n","import { useState, useEffect } from \"react\";\r\nimport {Room, type RoomOptions} from \"livekit-client\";\r\nimport { useRtcStore } from \"../state/store\";\r\n\r\nconst defaultRoomOptions = {\r\n adaptiveStream: true,\r\n dynacast: true,\r\n};\r\n\r\nexport function useRoom(options?: RoomOptions): Room | null {\r\n const [room] = useState(() => new Room(options || defaultRoomOptions));\r\n const livekitInfo = useRtcStore((state) => state.session?.livekitInfo);\r\n\r\n useEffect(() => {\r\n if (!livekitInfo) {\r\n return;\r\n }\r\n\r\n room.connect(livekitInfo.url, livekitInfo.token);\r\n return () => {\r\n room.disconnect();\r\n };\r\n }, [livekitInfo, room]);\r\n\r\n if (!livekitInfo) {\r\n return null;\r\n }\r\n\r\n return room;\r\n}\r\n","import {useParticipants, type UseParticipantsOptions} from \"@livekit/components-react\";\r\nimport { useRoom } from \"../hooks\";\r\n\r\nexport function useParticipantCount(options?: UseParticipantsOptions): number {\r\n const room = useRoom();\r\n if (!room) {\r\n return 0;\r\n }\r\n\r\n const participants = useParticipants(options);\r\n return participants.length;\r\n}\r\n"]}
|
package/dist/livekit/index.d.cts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export { ConnectionQuality, ConnectionState, DataPacket_Kind, LocalParticipant, LocalTrack, LocalTrackPublication, Participant, ParticipantEvent, RemoteParticipant, RemoteTrack, RemoteTrackPublication, Room, RoomEvent, Track, TrackEvent, TrackPublication } from 'livekit-client';
|
|
1
|
+
export { ConnectionQuality, ConnectionState, DataPacket_Kind, LocalParticipant, LocalTrack, LocalTrackPublication, Participant, ParticipantEvent, RemoteParticipant, RemoteTrack, RemoteTrackPublication, Room, RoomEvent, RoomOptions, Track, TrackEvent, TrackPublication } from 'livekit-client';
|
|
2
|
+
import { UseParticipantsOptions } from '@livekit/components-react';
|
|
2
3
|
export { AudioTrack, LiveKitRoom, ParticipantContext, RoomAudioRenderer, RoomContext, StartAudio, StartMediaButton, VideoTrack, useAudioPlayback, useConnectionQualityIndicator, useConnectionState, useDataChannel, useDisconnectButton, useEnsureParticipant, useEnsureRoom, useEnsureTrackRef, useIsMuted, useIsRecording, useIsSpeaking, useLiveKitRoom, useLocalParticipant, useLocalParticipantPermissions, useMediaDevices, usePagination, useParticipantInfo, useParticipantTracks, useParticipants, usePersistentUserChoices, usePinnedTracks, usePreviewTracks, useRemoteParticipant, useRemoteParticipants, useRoomContext, useRoomInfo, useSortedParticipants, useSpeakingParticipants, useStartAudio, useStartVideo, useSwipe, useTextStream, useTrackByName, useTrackMutedIndicator, useTrackToggle, useTrackVolume, useTracks } from '@livekit/components-react';
|
|
4
|
+
|
|
5
|
+
declare function useParticipantCount(options?: UseParticipantsOptions): number;
|
|
6
|
+
|
|
7
|
+
export { useParticipantCount };
|
package/dist/livekit/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export { ConnectionQuality, ConnectionState, DataPacket_Kind, LocalParticipant, LocalTrack, LocalTrackPublication, Participant, ParticipantEvent, RemoteParticipant, RemoteTrack, RemoteTrackPublication, Room, RoomEvent, Track, TrackEvent, TrackPublication } from 'livekit-client';
|
|
1
|
+
export { ConnectionQuality, ConnectionState, DataPacket_Kind, LocalParticipant, LocalTrack, LocalTrackPublication, Participant, ParticipantEvent, RemoteParticipant, RemoteTrack, RemoteTrackPublication, Room, RoomEvent, RoomOptions, Track, TrackEvent, TrackPublication } from 'livekit-client';
|
|
2
|
+
import { UseParticipantsOptions } from '@livekit/components-react';
|
|
2
3
|
export { AudioTrack, LiveKitRoom, ParticipantContext, RoomAudioRenderer, RoomContext, StartAudio, StartMediaButton, VideoTrack, useAudioPlayback, useConnectionQualityIndicator, useConnectionState, useDataChannel, useDisconnectButton, useEnsureParticipant, useEnsureRoom, useEnsureTrackRef, useIsMuted, useIsRecording, useIsSpeaking, useLiveKitRoom, useLocalParticipant, useLocalParticipantPermissions, useMediaDevices, usePagination, useParticipantInfo, useParticipantTracks, useParticipants, usePersistentUserChoices, usePinnedTracks, usePreviewTracks, useRemoteParticipant, useRemoteParticipants, useRoomContext, useRoomInfo, useSortedParticipants, useSpeakingParticipants, useStartAudio, useStartVideo, useSwipe, useTextStream, useTrackByName, useTrackMutedIndicator, useTrackToggle, useTrackVolume, useTracks } from '@livekit/components-react';
|
|
4
|
+
|
|
5
|
+
declare function useParticipantCount(options?: UseParticipantsOptions): number;
|
|
6
|
+
|
|
7
|
+
export { useParticipantCount };
|
package/dist/livekit/index.mjs
CHANGED
|
@@ -1,4 +1,70 @@
|
|
|
1
|
+
import { Room } from 'livekit-client';
|
|
1
2
|
export { ConnectionQuality, ConnectionState, DataPacket_Kind, LocalParticipant, LocalTrack, LocalTrackPublication, Participant, ParticipantEvent, RemoteParticipant, RemoteTrack, RemoteTrackPublication, Room, RoomEvent, Track, TrackEvent, TrackPublication } from 'livekit-client';
|
|
3
|
+
import { useParticipants } from '@livekit/components-react';
|
|
2
4
|
export { AudioTrack, LiveKitRoom, ParticipantContext, RoomAudioRenderer, RoomContext, StartAudio, StartMediaButton, VideoTrack, useAudioPlayback, useConnectionQualityIndicator, useConnectionState, useDataChannel, useDisconnectButton, useEnsureParticipant, useEnsureRoom, useEnsureTrackRef, useIsMuted, useIsRecording, useIsSpeaking, useLiveKitRoom, useLocalParticipant, useLocalParticipantPermissions, useMediaDevices, usePagination, useParticipantInfo, useParticipantTracks, useParticipants, usePersistentUserChoices, usePinnedTracks, usePreviewTracks, useRemoteParticipant, useRemoteParticipants, useRoomContext, useRoomInfo, useSortedParticipants, useSpeakingParticipants, useStartAudio, useStartVideo, useSwipe, useTextStream, useTrackByName, useTrackMutedIndicator, useTrackToggle, useTrackVolume, useTracks } from '@livekit/components-react';
|
|
5
|
+
import { create } from 'zustand';
|
|
6
|
+
import { immer } from 'zustand/middleware/immer';
|
|
7
|
+
import { useState, useEffect } from 'react';
|
|
8
|
+
|
|
9
|
+
// src/livekit/index.ts
|
|
10
|
+
|
|
11
|
+
// src/state/types.ts
|
|
12
|
+
var defaultState = {
|
|
13
|
+
initiated: false,
|
|
14
|
+
session: null,
|
|
15
|
+
incomingInvite: null,
|
|
16
|
+
outgoingInvites: {},
|
|
17
|
+
errors: []
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/state/store.ts
|
|
21
|
+
var useRtcStore = create()(
|
|
22
|
+
immer((set) => ({
|
|
23
|
+
...defaultState,
|
|
24
|
+
patch: (fn) => set((state) => {
|
|
25
|
+
fn(state);
|
|
26
|
+
}),
|
|
27
|
+
reset: () => set(() => defaultState),
|
|
28
|
+
addError: (error) => set((state) => {
|
|
29
|
+
state.errors.push(error);
|
|
30
|
+
}),
|
|
31
|
+
clearErrors: () => set((state) => {
|
|
32
|
+
state.errors = [];
|
|
33
|
+
})
|
|
34
|
+
}))
|
|
35
|
+
);
|
|
36
|
+
var defaultRoomOptions = {
|
|
37
|
+
adaptiveStream: true,
|
|
38
|
+
dynacast: true
|
|
39
|
+
};
|
|
40
|
+
function useRoom(options) {
|
|
41
|
+
const [room] = useState(() => new Room(defaultRoomOptions));
|
|
42
|
+
const livekitInfo = useRtcStore((state) => state.session?.livekitInfo);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!livekitInfo) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
room.connect(livekitInfo.url, livekitInfo.token);
|
|
48
|
+
return () => {
|
|
49
|
+
room.disconnect();
|
|
50
|
+
};
|
|
51
|
+
}, [livekitInfo, room]);
|
|
52
|
+
if (!livekitInfo) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return room;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/livekit/custom.ts
|
|
59
|
+
function useParticipantCount(options) {
|
|
60
|
+
const room = useRoom();
|
|
61
|
+
if (!room) {
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
const participants = useParticipants(options);
|
|
65
|
+
return participants.length;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { useParticipantCount };
|
|
3
69
|
//# sourceMappingURL=index.mjs.map
|
|
4
70
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/state/types.ts","../../src/state/store.ts","../../src/hooks/useRoom.ts","../../src/livekit/custom.ts"],"names":[],"mappings":";;;;;;;;;;;AA6DO,IAAM,YAAA,GAAyB;AAAA,EACpC,SAAA,EAAW,KAAA;AAAA,EACX,OAAA,EAAS,IAAA;AAAA,EACT,cAAA,EAAgB,IAAA;AAAA,EAChB,iBAAiB,EAAC;AAAA,EAClB,QAAQ;AACV,CAAA;;;ACvDO,IAAM,cAAc,MAAA,EAA2B;AAAA,EACpD,KAAA,CAAM,CA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AAA;AACT;;;AC1BO,SAAS,oBAAoB,OAAA,EAA0C;AAC5E,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,CAAA;AAAA,EACT;AAEA,EAAA,MAAM,YAAA,GAAe,gBAAgB,OAAO,CAAA;AAC5C,EAAA,OAAO,YAAA,CAAa,MAAA;AACtB","file":"index.mjs","sourcesContent":["export interface ParticipantMetadata {\r\n userId: string;\r\n role: \"HOST\" | \"PARTICIPANT\" | \"GUEST\";\r\n firstName: string;\r\n lastName: string;\r\n username: string;\r\n email: string;\r\n profilePhoto: string;\r\n}\r\n\r\nexport interface LiveKitJoinInfo {\r\n token: string;\r\n roomName: string;\r\n url: string;\r\n}\r\n\r\nexport interface Session {\r\n id: string;\r\n status: \"pending\" | \"active\" | \"ended\";\r\n mode: \"AUDIO\" | \"VIDEO\";\r\n role: \"HOST\" | \"PARTICIPANT\" | \"GUEST\";\r\n livekitInfo?: LiveKitJoinInfo;\r\n}\r\n\r\nexport interface IncomingInvite {\r\n callId: string;\r\n caller: ParticipantMetadata;\r\n mode: \"AUDIO\" | \"VIDEO\";\r\n expiresAt: string;\r\n expiresInMs: number;\r\n}\r\n\r\nexport interface OutgoingInvite {\r\n userId: string;\r\n status: \"sent\" | \"accepted\" | \"declined\" | \"missed\";\r\n participant: ParticipantMetadata;\r\n}\r\n\r\nexport interface RtcError {\r\n code: string;\r\n message: string;\r\n timestamp: number;\r\n context?: any;\r\n}\r\n\r\nexport interface RtcState {\r\n // Did we initiate the current call?\r\n initiated: boolean;\r\n\r\n // Active session (null when no active call)\r\n session: Session | null;\r\n\r\n // Incoming invitation (null when no pending invite)\r\n incomingInvite: IncomingInvite | null;\r\n\r\n outgoingInvites: Record<string, OutgoingInvite>;\r\n\r\n // Error tracking\r\n errors: RtcError[];\r\n}\r\n\r\nexport const defaultState: RtcState = {\r\n initiated: false,\r\n session: null,\r\n incomingInvite: null,\r\n outgoingInvites: {},\r\n errors: [],\r\n};\r\n","import { create } from \"zustand\";\r\nimport { immer } from \"zustand/middleware/immer\";\r\nimport type { RtcError, RtcState } from \"./types\";\r\nimport { defaultState } from \"./types\";\r\n\r\ntype Actions = {\r\n patch: (fn: (draft: RtcState) => void) => void;\r\n reset: () => void;\r\n addError: (error: RtcError) => void;\r\n clearErrors: () => void;\r\n};\r\n\r\nexport const useRtcStore = create<RtcState & Actions>()(\r\n immer((set) => ({\r\n ...defaultState,\r\n\r\n patch: (fn) =>\r\n set((state) => {\r\n fn(state);\r\n }),\r\n\r\n reset: () => set(() => defaultState),\r\n\r\n addError: (error) =>\r\n set((state) => {\r\n state.errors.push(error);\r\n }),\r\n\r\n clearErrors: () =>\r\n set((state) => {\r\n state.errors = [];\r\n }),\r\n }))\r\n);\r\n\r\nexport const rtcStore = useRtcStore;\r\n","import { useState, useEffect } from \"react\";\r\nimport {Room, type RoomOptions} from \"livekit-client\";\r\nimport { useRtcStore } from \"../state/store\";\r\n\r\nconst defaultRoomOptions = {\r\n adaptiveStream: true,\r\n dynacast: true,\r\n};\r\n\r\nexport function useRoom(options?: RoomOptions): Room | null {\r\n const [room] = useState(() => new Room(options || defaultRoomOptions));\r\n const livekitInfo = useRtcStore((state) => state.session?.livekitInfo);\r\n\r\n useEffect(() => {\r\n if (!livekitInfo) {\r\n return;\r\n }\r\n\r\n room.connect(livekitInfo.url, livekitInfo.token);\r\n return () => {\r\n room.disconnect();\r\n };\r\n }, [livekitInfo, room]);\r\n\r\n if (!livekitInfo) {\r\n return null;\r\n }\r\n\r\n return room;\r\n}\r\n","import {useParticipants, type UseParticipantsOptions} from \"@livekit/components-react\";\r\nimport { useRoom } from \"../hooks\";\r\n\r\nexport function useParticipantCount(options?: UseParticipantsOptions): number {\r\n const room = useRoom();\r\n if (!room) {\r\n return 0;\r\n }\r\n\r\n const participants = useParticipants(options);\r\n return participants.length;\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vg-x07df",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Headless SDK for dubadav audio/video",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -51,10 +51,11 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@livekit/components-react": "^2.9.15",
|
|
53
53
|
"@livekit/components-styles": "^1.1.6",
|
|
54
|
-
"livekit-client": "^2.15.8",
|
|
55
54
|
"axios": "^1.6.0",
|
|
56
55
|
"immer": "^10.0.0",
|
|
57
56
|
"jwt-decode": "^4.0.0",
|
|
57
|
+
"livekit-client": "^2.15.8",
|
|
58
|
+
"mitt": "^3.0.1",
|
|
58
59
|
"zod": "^3.22.0",
|
|
59
60
|
"zustand": "^4.5.0"
|
|
60
61
|
},
|
|
@@ -62,10 +63,12 @@
|
|
|
62
63
|
"@hey-api/openapi-ts": "^0.37.0",
|
|
63
64
|
"@types/react": "^18.2.0",
|
|
64
65
|
"@types/react-dom": "^18.2.0",
|
|
66
|
+
"json-schema-to-zod": "^2.6.1",
|
|
65
67
|
"react": "^18.3.1",
|
|
66
68
|
"react-dom": "^18.3.1",
|
|
67
69
|
"rimraf": "^6.0.0",
|
|
68
70
|
"tsup": "^8.0.0",
|
|
71
|
+
"tsx": "^4.20.6",
|
|
69
72
|
"typescript": "^5.2.0"
|
|
70
73
|
},
|
|
71
74
|
"engines": {
|
|
@@ -73,6 +76,8 @@
|
|
|
73
76
|
},
|
|
74
77
|
"scripts": {
|
|
75
78
|
"generate:api": "openapi-ts",
|
|
79
|
+
"generate:socket": "tsx scripts/generate-socket-types.ts",
|
|
80
|
+
"generate": "pnpm generate:api && pnpm generate:socket",
|
|
76
81
|
"build": "tsup",
|
|
77
82
|
"dev": "tsup --watch",
|
|
78
83
|
"typecheck": "tsc --noEmit",
|