livekit-client
Advanced tools
Comparing version
{ | ||
"name": "livekit-client", | ||
"version": "2.9.5", | ||
"version": "2.9.6", | ||
"description": "JavaScript/TypeScript client SDK for LiveKit", | ||
@@ -40,3 +40,3 @@ "main": "./dist/livekit-client.umd.js", | ||
"@livekit/mutex": "1.1.1", | ||
"@livekit/protocol": "1.33.0", | ||
"@livekit/protocol": "1.34.0", | ||
"events": "^3.3.0", | ||
@@ -43,0 +43,0 @@ "loglevel": "^1.9.2", |
@@ -261,6 +261,6 @@ import { Mutex } from '@livekit/mutex'; | ||
this.connectOptions = opts; | ||
url = toWebsocketUrl(url); | ||
const urlObj = new URL(toWebsocketUrl(url)); | ||
// strip trailing slash | ||
url = url.replace(/\/$/, ''); | ||
url += '/rtc'; | ||
urlObj.pathname = urlObj.pathname.replace(/\/$/, ''); | ||
urlObj.pathname += '/rtc'; | ||
@@ -270,2 +270,6 @@ const clientInfo = getClientInfo(); | ||
for (const [key, value] of params) { | ||
urlObj.searchParams.set(key, value); | ||
} | ||
return new Promise<JoinResponse | ReconnectResponse | undefined>(async (resolve, reject) => { | ||
@@ -299,10 +303,15 @@ const unlock = await this.connectionLock.lock(); | ||
abortSignal?.addEventListener('abort', abortHandler); | ||
this.log.debug( | ||
`connecting to ${url + params.replace(/access_token=([^&#$]*)/, 'access_token=<redacted>')}`, | ||
this.logContext, | ||
); | ||
const redactedUrl = new URL(urlObj.toString()); | ||
if (redactedUrl.searchParams.has('access_token')) { | ||
redactedUrl.searchParams.set('access_token', '<redacted>'); | ||
} | ||
this.log.debug(`connecting to ${redactedUrl}`, { | ||
reconnect: opts.reconnect, | ||
reconnectReason: opts.reconnectReason, | ||
...this.logContext, | ||
}); | ||
if (this.ws) { | ||
await this.close(false); | ||
} | ||
this.ws = new WebSocket(url + params); | ||
this.ws = new WebSocket(urlObj); | ||
this.ws.binaryType = 'arraybuffer'; | ||
@@ -319,3 +328,6 @@ | ||
try { | ||
const resp = await fetch(`http${url.substring(2)}/validate${params}`); | ||
const validateURL = new URL(urlObj.toString()); | ||
validateURL.protocol = `http${validateURL.protocol.substring(2)}`; | ||
validateURL.pathname += '/validate'; | ||
const resp = await fetch(validateURL); | ||
if (resp.status.toFixed(0).startsWith('4')) { | ||
@@ -525,3 +537,3 @@ const msg = await resp.text(); | ||
sendIceCandidate(candidate: RTCIceCandidateInit, target: SignalTarget) { | ||
this.log.trace('sending ice candidate', { ...this.logContext, candidate }); | ||
this.log.debug('sending ice candidate', { ...this.logContext, candidate }); | ||
return this.sendRequest({ | ||
@@ -891,3 +903,7 @@ case: 'trickle', | ||
function createConnectionParams(token: string, info: ClientInfo, opts: ConnectOpts): string { | ||
function createConnectionParams( | ||
token: string, | ||
info: ClientInfo, | ||
opts: ConnectOpts, | ||
): URLSearchParams { | ||
const params = new URLSearchParams(); | ||
@@ -940,3 +956,3 @@ params.set('access_token', token); | ||
return `?${params.toString()}`; | ||
return params; | ||
} |
@@ -477,3 +477,3 @@ import { Mutex } from '@livekit/mutex'; | ||
} | ||
this.log.trace('got ICE candidate from peer', { ...this.logContext, candidate, target }); | ||
this.log.debug('got ICE candidate from peer', { ...this.logContext, candidate, target }); | ||
this.pcManager.addIceCandidate(candidate, target); | ||
@@ -480,0 +480,0 @@ }; |
@@ -317,3 +317,3 @@ import { Mutex } from '@livekit/mutex'; | ||
} | ||
const { deviceId, ...otherConstraints } = this._constraints; | ||
const { deviceId, ...otherConstraints } = constraints; | ||
this.log.debug('restarting track with constraints', { ...this.logContext, constraints }); | ||
@@ -320,0 +320,0 @@ |
@@ -136,3 +136,17 @@ import { TrackPublishedResponse, TrackSource } from '@livekit/protocol'; | ||
if (AudioContext) { | ||
return new AudioContext({ latencyHint: 'interactive' }); | ||
const audioContext = new AudioContext({ latencyHint: 'interactive' }); | ||
// If the audio context is suspended, we need to resume it when the user clicks on the page | ||
if ( | ||
audioContext.state === 'suspended' && | ||
typeof window !== 'undefined' && | ||
window.document?.body | ||
) { | ||
const handleResume = () => { | ||
audioContext.resume().then(() => { | ||
window.document.body?.removeEventListener('click', handleResume); | ||
}); | ||
}; | ||
window.document.body.addEventListener('click', handleResume); | ||
} | ||
return audioContext; | ||
} | ||
@@ -139,0 +153,0 @@ } |
@@ -436,2 +436,3 @@ import { | ||
} | ||
const streamTrack = opts.cloneTrack ? track.mediaStreamTrack.clone() : track.mediaStreamTrack; | ||
@@ -438,0 +439,0 @@ const mediaStreamSource = audioContext.createMediaStreamSource(new MediaStream([streamTrack])); |
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 too big to display
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
6316225
0.15%57220
0.1%+ Added
- Removed
Updated