livekit-client 2.6.3 → 2.7.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/livekit-client.esm.mjs +27 -12
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/ts4.2/src/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/room/track/RemoteVideoTrack.ts +27 -12
- package/src/type-polyfills/document-pip.d.ts +12 -0
package/dist/src/index.d.ts
CHANGED
@@ -2,6 +2,7 @@ import { Mutex } from '@livekit/mutex';
|
|
2
2
|
import { DataPacket_Kind, DisconnectReason, SubscriptionError } from '@livekit/protocol';
|
3
3
|
import { LogLevel, LoggerNames, getLogger, setLogExtension, setLogLevel } from './logger';
|
4
4
|
import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
|
5
|
+
import type { ReconnectContext, ReconnectPolicy } from './room/ReconnectPolicy';
|
5
6
|
import Room, { ConnectionState } from './room/Room';
|
6
7
|
import LocalParticipant from './room/participant/LocalParticipant';
|
7
8
|
import Participant, { ConnectionQuality, ParticipantKind } from './room/participant/Participant';
|
@@ -39,5 +40,5 @@ export * from './room/track/types';
|
|
39
40
|
export type { DataPublishOptions, SimulationScenario, TranscriptionSegment, ChatMessage, } from './room/types';
|
40
41
|
export * from './version';
|
41
42
|
export { ConnectionQuality, ConnectionState, CriticalTimers, DataPacket_Kind, DefaultReconnectPolicy, DisconnectReason, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, LoggerNames, Participant, RemoteAudioTrack, RemoteParticipant, ParticipantKind, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, SubscriptionError, TrackPublication, compareVersions, createAudioAnalyser, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, isBrowserSupported, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, Mutex, };
|
42
|
-
export type { AudioAnalyserOptions, ElementInfo, LiveKitReactNativeInfo, ParticipantTrackPermission, AudioReceiverStats, AudioSenderStats, VideoReceiverStats, VideoSenderStats, };
|
43
|
+
export type { AudioAnalyserOptions, ElementInfo, LiveKitReactNativeInfo, ParticipantTrackPermission, AudioReceiverStats, AudioSenderStats, VideoReceiverStats, VideoSenderStats, ReconnectContext, ReconnectPolicy, };
|
43
44
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1F,OAAO,sBAAsB,MAAM,+BAA+B,CAAC;AACnE,OAAO,IAAI,EAAE,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AACnE,OAAO,WAAW,EAAE,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,cAAc,MAAM,eAAe,CAAC;AAC3C,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,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AACtB,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,IAAI,EACJ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,wBAAwB,EACxB,wBAAwB,EACxB,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,KAAK,GACN,CAAC;AACF,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1F,OAAO,sBAAsB,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,IAAI,EAAE,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AACnE,OAAO,WAAW,EAAE,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjG,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,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAC9F,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,QAAQ,EACR,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,IAAI,EACJ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,wBAAwB,EACxB,wBAAwB,EACxB,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,KAAK,GACN,CAAC;AACF,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,CAAC"}
|
@@ -2,6 +2,7 @@ import { Mutex } from '@livekit/mutex';
|
|
2
2
|
import { DataPacket_Kind, DisconnectReason, SubscriptionError } from '@livekit/protocol';
|
3
3
|
import { LogLevel, LoggerNames, getLogger, setLogExtension, setLogLevel } from './logger';
|
4
4
|
import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
|
5
|
+
import type { ReconnectContext, ReconnectPolicy } from './room/ReconnectPolicy';
|
5
6
|
import Room, { ConnectionState } from './room/Room';
|
6
7
|
import LocalParticipant from './room/participant/LocalParticipant';
|
7
8
|
import Participant, { ConnectionQuality, ParticipantKind } from './room/participant/Participant';
|
@@ -40,5 +41,5 @@ export * from './room/track/types';
|
|
40
41
|
export type { DataPublishOptions, SimulationScenario, TranscriptionSegment, ChatMessage, } from './room/types';
|
41
42
|
export * from './version';
|
42
43
|
export { ConnectionQuality, ConnectionState, CriticalTimers, DataPacket_Kind, DefaultReconnectPolicy, DisconnectReason, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, LoggerNames, Participant, RemoteAudioTrack, RemoteParticipant, ParticipantKind, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, SubscriptionError, TrackPublication, compareVersions, createAudioAnalyser, getBrowser, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, getLogger, isBrowserSupported, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, supportsVP9, Mutex, };
|
43
|
-
export type { AudioAnalyserOptions, ElementInfo, LiveKitReactNativeInfo, ParticipantTrackPermission, AudioReceiverStats, AudioSenderStats, VideoReceiverStats, VideoSenderStats, };
|
44
|
+
export type { AudioAnalyserOptions, ElementInfo, LiveKitReactNativeInfo, ParticipantTrackPermission, AudioReceiverStats, AudioSenderStats, VideoReceiverStats, VideoSenderStats, ReconnectContext, ReconnectPolicy, };
|
44
45
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -2,6 +2,7 @@ import { Mutex } from '@livekit/mutex';
|
|
2
2
|
import { DataPacket_Kind, DisconnectReason, SubscriptionError } from '@livekit/protocol';
|
3
3
|
import { LogLevel, LoggerNames, getLogger, setLogExtension, setLogLevel } from './logger';
|
4
4
|
import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
|
5
|
+
import type { ReconnectContext, ReconnectPolicy } from './room/ReconnectPolicy';
|
5
6
|
import Room, { ConnectionState } from './room/Room';
|
6
7
|
import LocalParticipant from './room/participant/LocalParticipant';
|
7
8
|
import Participant, { ConnectionQuality, ParticipantKind } from './room/participant/Participant';
|
@@ -108,4 +109,6 @@ export type {
|
|
108
109
|
AudioSenderStats,
|
109
110
|
VideoReceiverStats,
|
110
111
|
VideoSenderStats,
|
112
|
+
ReconnectContext,
|
113
|
+
ReconnectPolicy,
|
111
114
|
};
|
@@ -331,7 +331,7 @@ class HTMLElementInfo implements ElementInfo {
|
|
331
331
|
constructor(element: HTMLMediaElement, visible?: boolean) {
|
332
332
|
this.element = element;
|
333
333
|
this.isIntersecting = visible ?? isElementInViewport(element);
|
334
|
-
this.isPiP = isWeb() &&
|
334
|
+
this.isPiP = isWeb() && isElementInPiP(element);
|
335
335
|
this.visibilityChangedAt = 0;
|
336
336
|
}
|
337
337
|
|
@@ -346,7 +346,7 @@ class HTMLElementInfo implements ElementInfo {
|
|
346
346
|
observe() {
|
347
347
|
// make sure we update the current visible state once we start to observe
|
348
348
|
this.isIntersecting = isElementInViewport(this.element);
|
349
|
-
this.isPiP =
|
349
|
+
this.isPiP = isElementInPiP(this.element);
|
350
350
|
|
351
351
|
(this.element as ObservableMediaElement).handleResize = () => {
|
352
352
|
this.handleResize?.();
|
@@ -357,24 +357,28 @@ class HTMLElementInfo implements ElementInfo {
|
|
357
357
|
getResizeObserver().observe(this.element);
|
358
358
|
(this.element as HTMLVideoElement).addEventListener('enterpictureinpicture', this.onEnterPiP);
|
359
359
|
(this.element as HTMLVideoElement).addEventListener('leavepictureinpicture', this.onLeavePiP);
|
360
|
+
window.documentPictureInPicture?.addEventListener('enter', this.onEnterPiP);
|
361
|
+
window.documentPictureInPicture?.window?.addEventListener('pagehide', this.onLeavePiP);
|
360
362
|
}
|
361
363
|
|
362
364
|
private onVisibilityChanged = (entry: IntersectionObserverEntry) => {
|
363
365
|
const { target, isIntersecting } = entry;
|
364
366
|
if (target === this.element) {
|
365
367
|
this.isIntersecting = isIntersecting;
|
368
|
+
this.isPiP = isElementInPiP(this.element);
|
366
369
|
this.visibilityChangedAt = Date.now();
|
367
370
|
this.handleVisibilityChanged?.();
|
368
371
|
}
|
369
372
|
};
|
370
373
|
|
371
374
|
private onEnterPiP = () => {
|
372
|
-
this.
|
375
|
+
window.documentPictureInPicture?.window?.addEventListener('pagehide', this.onLeavePiP);
|
376
|
+
this.isPiP = isElementInPiP(this.element);
|
373
377
|
this.handleVisibilityChanged?.();
|
374
378
|
};
|
375
379
|
|
376
380
|
private onLeavePiP = () => {
|
377
|
-
this.isPiP =
|
381
|
+
this.isPiP = isElementInPiP(this.element);
|
378
382
|
this.handleVisibilityChanged?.();
|
379
383
|
};
|
380
384
|
|
@@ -389,17 +393,29 @@ class HTMLElementInfo implements ElementInfo {
|
|
389
393
|
'leavepictureinpicture',
|
390
394
|
this.onLeavePiP,
|
391
395
|
);
|
396
|
+
window.documentPictureInPicture?.removeEventListener('enter', this.onEnterPiP);
|
397
|
+
window.documentPictureInPicture?.window?.removeEventListener('pagehide', this.onLeavePiP);
|
392
398
|
}
|
393
399
|
}
|
394
400
|
|
395
|
-
|
396
|
-
|
401
|
+
function isElementInPiP(el: HTMLElement) {
|
402
|
+
// Simple video PiP
|
403
|
+
if (document.pictureInPictureElement === el) return true;
|
404
|
+
// Document PiP
|
405
|
+
if (window.documentPictureInPicture?.window)
|
406
|
+
return isElementInViewport(el, window.documentPictureInPicture?.window);
|
407
|
+
return false;
|
408
|
+
}
|
409
|
+
|
410
|
+
// does not account for occlusion by other elements or opacity property
|
411
|
+
function isElementInViewport(el: HTMLElement, win?: Window) {
|
412
|
+
const viewportWindow = win || window;
|
397
413
|
let top = el.offsetTop;
|
398
414
|
let left = el.offsetLeft;
|
399
415
|
const width = el.offsetWidth;
|
400
416
|
const height = el.offsetHeight;
|
401
417
|
const { hidden } = el;
|
402
|
-
const {
|
418
|
+
const { display } = getComputedStyle(el);
|
403
419
|
|
404
420
|
while (el.offsetParent) {
|
405
421
|
el = el.offsetParent as HTMLElement;
|
@@ -408,12 +424,11 @@ function isElementInViewport(el: HTMLElement) {
|
|
408
424
|
}
|
409
425
|
|
410
426
|
return (
|
411
|
-
top <
|
412
|
-
left <
|
413
|
-
top + height >
|
414
|
-
left + width >
|
427
|
+
top < viewportWindow.pageYOffset + viewportWindow.innerHeight &&
|
428
|
+
left < viewportWindow.pageXOffset + viewportWindow.innerWidth &&
|
429
|
+
top + height > viewportWindow.pageYOffset &&
|
430
|
+
left + width > viewportWindow.pageXOffset &&
|
415
431
|
!hidden &&
|
416
|
-
(opacity !== '' ? parseFloat(opacity) > 0 : true) &&
|
417
432
|
display !== 'none'
|
418
433
|
);
|
419
434
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
interface Window {
|
2
|
+
/**
|
3
|
+
* Currently only available in Chromium based browsers:
|
4
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/DocumentPictureInPicture
|
5
|
+
*/
|
6
|
+
documentPictureInPicture?: DocumentPictureInPicture;
|
7
|
+
}
|
8
|
+
|
9
|
+
interface DocumentPictureInPicture extends EventTarget {
|
10
|
+
window?: Window;
|
11
|
+
requestWindow(options?: { width: number; height: number }): Promise<Window>;
|
12
|
+
}
|