@livekit/components-core
Advanced tools
Comparing version 0.6.9 to 0.6.10
@@ -1,2 +0,2 @@ | ||
import type { Room } from 'livekit-client'; | ||
import { type LocalAudioTrack, type LocalVideoTrack, type Room } from 'livekit-client'; | ||
export type SetMediaDeviceOptions = { | ||
@@ -9,3 +9,3 @@ /** | ||
}; | ||
export declare function setupDeviceSelector(kind: MediaDeviceKind, room?: Room): { | ||
export declare function setupDeviceSelector(kind: MediaDeviceKind, room?: Room, localTrack?: LocalAudioTrack | LocalVideoTrack): { | ||
className: string; | ||
@@ -12,0 +12,0 @@ activeDeviceObservable: import("rxjs").Observable<string | undefined>; |
@@ -1018,3 +1018,3 @@ "use strict"; | ||
(0, import_rxjs.map)(([kind2, deviceId]) => { | ||
console.log("activeDeviceObservable | RoomEvent.ActiveDeviceChanged", { kind: kind2, deviceId }); | ||
log.debug("activeDeviceObservable | RoomEvent.ActiveDeviceChanged", { kind: kind2, deviceId }); | ||
return deviceId; | ||
@@ -1332,8 +1332,9 @@ }), | ||
// src/components/mediaDeviceSelect.ts | ||
var import_livekit_client12 = require("livekit-client"); | ||
var import_rxjs5 = require("rxjs"); | ||
function setupDeviceSelector(kind, room) { | ||
function setupDeviceSelector(kind, room, localTrack) { | ||
const activeDeviceSubject = new import_rxjs5.BehaviorSubject(void 0); | ||
const activeDeviceObservable = room ? createActiveDeviceObservable(room, kind) : activeDeviceSubject.asObservable(); | ||
const setActiveMediaDevice = (_0, ..._1) => __async(this, [_0, ..._1], function* (id, options = {}) { | ||
var _a; | ||
var _a, _b, _c; | ||
if (room) { | ||
@@ -1344,9 +1345,24 @@ log.debug(`Switching active device of kind "${kind}" with id ${id}.`); | ||
if (actualDeviceId !== id && id !== "default") { | ||
log.warn( | ||
log.info( | ||
`We tried to select the device with id (${id}), but the browser decided to select the device with id (${actualDeviceId}) instead.` | ||
); | ||
} | ||
activeDeviceSubject.next(id === "default" ? id : actualDeviceId); | ||
} else { | ||
log.debug("Skip the device switch because the room object is not available. "); | ||
let targetTrack = void 0; | ||
if (kind === "audioinput") | ||
targetTrack = (_b = room.localParticipant.getTrack(import_livekit_client12.Track.Source.Microphone)) == null ? void 0 : _b.track; | ||
else if (kind === "videoinput") { | ||
targetTrack = (_c = room.localParticipant.getTrack(import_livekit_client12.Track.Source.Camera)) == null ? void 0 : _c.track; | ||
} | ||
const useDefault = id === "default" && !targetTrack || id === "default" && (targetTrack == null ? void 0 : targetTrack.mediaStreamTrack.label.startsWith("Default")); | ||
activeDeviceSubject.next(useDefault ? id : actualDeviceId); | ||
} else if (localTrack) { | ||
yield localTrack.setDeviceId(options.exact ? { exact: id } : id); | ||
const actualId = yield localTrack.getDeviceId(); | ||
activeDeviceSubject.next( | ||
id === "default" && localTrack.mediaStreamTrack.label.startsWith("Default") ? id : actualId | ||
); | ||
} else if (activeDeviceSubject.value !== id) { | ||
log.warn( | ||
"device switch skipped, please provide either a room or a local track to switch on. " | ||
); | ||
activeDeviceSubject.next(id); | ||
@@ -1380,10 +1396,10 @@ } | ||
// src/components/trackMutedIndicator.ts | ||
var import_livekit_client12 = require("livekit-client"); | ||
var import_livekit_client13 = require("livekit-client"); | ||
function setupTrackMutedIndicator(participant, source) { | ||
let classForSource = "track-muted-indicator-camera"; | ||
switch (source) { | ||
case import_livekit_client12.Track.Source.Camera: | ||
case import_livekit_client13.Track.Source.Camera: | ||
classForSource = "track-muted-indicator-camera"; | ||
break; | ||
case import_livekit_client12.Track.Source.Microphone: | ||
case import_livekit_client13.Track.Source.Microphone: | ||
classForSource = "track-muted-indicator-microphone"; | ||
@@ -1414,7 +1430,7 @@ break; | ||
// src/components/chat.ts | ||
var import_livekit_client14 = require("livekit-client"); | ||
var import_livekit_client15 = require("livekit-client"); | ||
var import_rxjs7 = require("rxjs"); | ||
// src/observables/dataChannel.ts | ||
var import_livekit_client13 = require("livekit-client"); | ||
var import_livekit_client14 = require("livekit-client"); | ||
var import_rxjs6 = require("rxjs"); | ||
@@ -1427,3 +1443,3 @@ var DataTopic = { | ||
const { kind, destination } = options; | ||
yield localParticipant.publishData(payload, kind != null ? kind : import_livekit_client13.DataPacket_Kind.RELIABLE, { | ||
yield localParticipant.publishData(payload, kind != null ? kind : import_livekit_client14.DataPacket_Kind.RELIABLE, { | ||
destination, | ||
@@ -1486,3 +1502,3 @@ topic | ||
yield sendMessage(room.localParticipant, encodedMsg, DataTopic.CHAT, { | ||
kind: import_livekit_client14.DataPacket_Kind.RELIABLE | ||
kind: import_livekit_client15.DataPacket_Kind.RELIABLE | ||
}); | ||
@@ -1540,3 +1556,3 @@ messageSubject.next({ | ||
// src/observables/track.ts | ||
var import_livekit_client15 = require("livekit-client"); | ||
var import_livekit_client16 = require("livekit-client"); | ||
var import_rxjs8 = require("rxjs"); | ||
@@ -1546,6 +1562,6 @@ function trackObservable(track) { | ||
track, | ||
import_livekit_client15.TrackEvent.Muted, | ||
import_livekit_client15.TrackEvent.Unmuted, | ||
import_livekit_client15.TrackEvent.Subscribed, | ||
import_livekit_client15.TrackEvent.Unsubscribed | ||
import_livekit_client16.TrackEvent.Muted, | ||
import_livekit_client16.TrackEvent.Unmuted, | ||
import_livekit_client16.TrackEvent.Subscribed, | ||
import_livekit_client16.TrackEvent.Unsubscribed | ||
); | ||
@@ -1601,9 +1617,9 @@ return trackObserver; | ||
(/* @__PURE__ */ new Set([ | ||
import_livekit_client15.RoomEvent.ParticipantConnected, | ||
import_livekit_client15.RoomEvent.ConnectionStateChanged, | ||
import_livekit_client15.RoomEvent.LocalTrackPublished, | ||
import_livekit_client15.RoomEvent.LocalTrackUnpublished, | ||
import_livekit_client15.RoomEvent.TrackPublished, | ||
import_livekit_client15.RoomEvent.TrackUnpublished, | ||
import_livekit_client15.RoomEvent.TrackSubscriptionStatusChanged, | ||
import_livekit_client16.RoomEvent.ParticipantConnected, | ||
import_livekit_client16.RoomEvent.ConnectionStateChanged, | ||
import_livekit_client16.RoomEvent.LocalTrackPublished, | ||
import_livekit_client16.RoomEvent.LocalTrackUnpublished, | ||
import_livekit_client16.RoomEvent.TrackPublished, | ||
import_livekit_client16.RoomEvent.TrackUnpublished, | ||
import_livekit_client16.RoomEvent.TrackSubscriptionStatusChanged, | ||
...additionalRoomEvents | ||
@@ -1610,0 +1626,0 @@ ])).values() |
@@ -29,3 +29,3 @@ import type { Participant, RemoteParticipant, Room, TrackPublication } from 'livekit-client'; | ||
export declare function createConnectionQualityObserver(participant: Participant): Observable<import("livekit-client").ConnectionQuality>; | ||
export declare function participantEventSelector<T extends ParticipantEvent>(participant: Participant, event: T): Observable<Parameters<ParticipantEventCallbacks[T]>>; | ||
export declare function participantEventSelector<T extends ParticipantEvent>(participant: Participant, event: T): Observable<Parameters<ParticipantEventCallbacks[Extract<T, keyof ParticipantEventCallbacks>]>>; | ||
export declare function mutedObserver(participant: Participant, source: Track.Source): Observable<boolean>; | ||
@@ -32,0 +32,0 @@ export declare function createIsSpeakingObserver(participant: Participant): Observable<boolean>; |
{ | ||
"name": "@livekit/components-core", | ||
"version": "0.6.9", | ||
"version": "0.6.10", | ||
"license": "Apache-2.0", | ||
@@ -38,3 +38,3 @@ "author": "LiveKit", | ||
"email-regex": "^5.0.0", | ||
"global-tld-list": "^0.0.1125", | ||
"global-tld-list": "^0.0.1139", | ||
"loglevel": "^1.8.1", | ||
@@ -44,6 +44,6 @@ "rxjs": "^7.8.0" | ||
"peerDependencies": { | ||
"livekit-client": "^1.11.2" | ||
"livekit-client": "^1.11.4" | ||
}, | ||
"devDependencies": { | ||
"@livekit/components-styles": "~1.0.2", | ||
"@livekit/components-styles": "~1.0.3", | ||
"@size-limit/file": "^8.2.4", | ||
@@ -53,5 +53,5 @@ "@size-limit/webpack": "^8.2.4", | ||
"size-limit": "^8.2.4", | ||
"tsup": "^6.7.0", | ||
"tsup": "^7.0.0", | ||
"typescript": "^5.0.0", | ||
"vitest": "^0.31.0" | ||
"vitest": "^0.32.0" | ||
}, | ||
@@ -58,0 +58,0 @@ "engines": { |
@@ -1,2 +0,8 @@ | ||
import type { Room } from 'livekit-client'; | ||
import { | ||
Track, | ||
type LocalAudioTrack, | ||
type LocalVideoTrack, | ||
type Room, | ||
type LocalTrack, | ||
} from 'livekit-client'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
@@ -15,3 +21,7 @@ import { log } from '../logger'; | ||
export function setupDeviceSelector(kind: MediaDeviceKind, room?: Room) { | ||
export function setupDeviceSelector( | ||
kind: MediaDeviceKind, | ||
room?: Room, | ||
localTrack?: LocalAudioTrack | LocalVideoTrack, | ||
) { | ||
const activeDeviceSubject = new BehaviorSubject<string | undefined>(undefined); | ||
@@ -29,9 +39,26 @@ | ||
if (actualDeviceId !== id && id !== 'default') { | ||
log.warn( | ||
log.info( | ||
`We tried to select the device with id (${id}), but the browser decided to select the device with id (${actualDeviceId}) instead.`, | ||
); | ||
} | ||
activeDeviceSubject.next(id === 'default' ? id : actualDeviceId); | ||
} else { | ||
log.debug('Skip the device switch because the room object is not available. '); | ||
let targetTrack: LocalTrack | undefined = undefined; | ||
if (kind === 'audioinput') | ||
targetTrack = room.localParticipant.getTrack(Track.Source.Microphone)?.track; | ||
else if (kind === 'videoinput') { | ||
targetTrack = room.localParticipant.getTrack(Track.Source.Camera)?.track; | ||
} | ||
const useDefault = | ||
(id === 'default' && !targetTrack) || | ||
(id === 'default' && targetTrack?.mediaStreamTrack.label.startsWith('Default')); | ||
activeDeviceSubject.next(useDefault ? id : actualDeviceId); | ||
} else if (localTrack) { | ||
await localTrack.setDeviceId(options.exact ? { exact: id } : id); | ||
const actualId = await localTrack.getDeviceId(); | ||
activeDeviceSubject.next( | ||
id === 'default' && localTrack.mediaStreamTrack.label.startsWith('Default') ? id : actualId, | ||
); | ||
} else if (activeDeviceSubject.value !== id) { | ||
log.warn( | ||
'device switch skipped, please provide either a room or a local track to switch on. ', | ||
); | ||
activeDeviceSubject.next(id); | ||
@@ -38,0 +65,0 @@ } |
@@ -123,4 +123,8 @@ import type { Participant, RemoteParticipant, Room, TrackPublication } from 'livekit-client'; | ||
) { | ||
const observable = new Observable<Parameters<ParticipantEventCallbacks[T]>>((subscribe) => { | ||
const update = (...params: Parameters<ParticipantEventCallbacks[T]>) => { | ||
const observable = new Observable< | ||
Parameters<ParticipantEventCallbacks[Extract<T, keyof ParticipantEventCallbacks>]> | ||
>((subscribe) => { | ||
const update = ( | ||
...params: Parameters<ParticipantEventCallbacks[Extract<T, keyof ParticipantEventCallbacks>]> | ||
) => { | ||
subscribe.next(params); | ||
@@ -127,0 +131,0 @@ }; |
@@ -6,2 +6,3 @@ import type { Subscriber, Subscription } from 'rxjs'; | ||
import type { RoomEventCallbacks } from 'livekit-client/dist/src/room/Room'; | ||
import { log } from '../logger'; | ||
export function observeRoomEvents(room: Room, ...events: RoomEvent[]): Observable<Room> { | ||
@@ -224,3 +225,3 @@ const observable = new Observable<Room>((subscribe) => { | ||
map(([kind, deviceId]) => { | ||
console.log('activeDeviceObservable | RoomEvent.ActiveDeviceChanged', { kind, deviceId }); | ||
log.debug('activeDeviceObservable | RoomEvent.ActiveDeviceChanged', { kind, deviceId }); | ||
return deviceId; | ||
@@ -227,0 +228,0 @@ }), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
486284
6688
+ Addedglobal-tld-list@0.0.1139(transitive)
- Removedglobal-tld-list@0.0.1125(transitive)
Updatedglobal-tld-list@^0.0.1139