@camera.ui/browser 0.0.186 → 0.0.189
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.js +34 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3018,6 +3018,11 @@ async function processWebRTCMessage(handler, msg) {
|
|
|
3018
3018
|
//#endregion
|
|
3019
3019
|
//#region src/streaming/streamConnection.ts
|
|
3020
3020
|
var log = new Logger("StreamConnection");
|
|
3021
|
+
function isVideoInPictureInPicture(video) {
|
|
3022
|
+
if (!video) return false;
|
|
3023
|
+
if (typeof document !== "undefined" && "pictureInPictureElement" in document && document.pictureInPictureElement === video) return true;
|
|
3024
|
+
return video.webkitPresentationMode === "picture-in-picture";
|
|
3025
|
+
}
|
|
3021
3026
|
var StreamConnection = class {
|
|
3022
3027
|
status;
|
|
3023
3028
|
activeMode;
|
|
@@ -3050,6 +3055,7 @@ var StreamConnection = class {
|
|
|
3050
3055
|
abortController = new AbortController();
|
|
3051
3056
|
probedSourceId;
|
|
3052
3057
|
wasPausedByVisibility = false;
|
|
3058
|
+
disarmPipWatch = null;
|
|
3053
3059
|
wsHandle;
|
|
3054
3060
|
webrtcHandler;
|
|
3055
3061
|
mseHandler;
|
|
@@ -3148,12 +3154,18 @@ var StreamConnection = class {
|
|
|
3148
3154
|
log.debug(`onTabPaused — already in ${this.status.value}, skipping stop()`);
|
|
3149
3155
|
return;
|
|
3150
3156
|
}
|
|
3157
|
+
if (isVideoInPictureInPicture(this.videoElement.value)) {
|
|
3158
|
+
log.debug("onTabPaused — video is in picture-in-picture, keeping the stream");
|
|
3159
|
+
this.watchPipLeave();
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3151
3162
|
this.wasPausedByVisibility = true;
|
|
3152
3163
|
this.stop();
|
|
3153
3164
|
log.debug("onTabPaused — stop() done, wasPausedByVisibility=true");
|
|
3154
3165
|
});
|
|
3155
3166
|
this.offTabVisible = onTabVisible(() => {
|
|
3156
3167
|
log.debug(`onTabVisible fired — wasPausedByVisibility=${this.wasPausedByVisibility}, status=${this.status.value}, isReady=${this.isReady.value}, target=${!!this.target.value}`);
|
|
3168
|
+
this.disarmPipWatch?.();
|
|
3157
3169
|
if (!this.wasPausedByVisibility) {
|
|
3158
3170
|
log.debug("onTabVisible — not paused by visibility, no-op");
|
|
3159
3171
|
return;
|
|
@@ -3166,6 +3178,27 @@ var StreamConnection = class {
|
|
|
3166
3178
|
}, { immediate: true });
|
|
3167
3179
|
});
|
|
3168
3180
|
}
|
|
3181
|
+
watchPipLeave() {
|
|
3182
|
+
if (this.disarmPipWatch) return;
|
|
3183
|
+
const video = this.videoElement.value;
|
|
3184
|
+
if (!video) return;
|
|
3185
|
+
const onLeave = () => {
|
|
3186
|
+
if (isVideoInPictureInPicture(video)) return;
|
|
3187
|
+
this.disarmPipWatch?.();
|
|
3188
|
+
if (typeof document !== "undefined" && document.visibilityState === "visible") return;
|
|
3189
|
+
if (this.status.value === "idle" || this.status.value === "closed") return;
|
|
3190
|
+
log.debug("picture-in-picture closed while tab hidden — stopping the stream");
|
|
3191
|
+
this.wasPausedByVisibility = true;
|
|
3192
|
+
this.stop();
|
|
3193
|
+
};
|
|
3194
|
+
video.addEventListener("leavepictureinpicture", onLeave);
|
|
3195
|
+
video.addEventListener("webkitpresentationmodechanged", onLeave);
|
|
3196
|
+
this.disarmPipWatch = () => {
|
|
3197
|
+
video.removeEventListener("leavepictureinpicture", onLeave);
|
|
3198
|
+
video.removeEventListener("webkitpresentationmodechanged", onLeave);
|
|
3199
|
+
this.disarmPipWatch = null;
|
|
3200
|
+
};
|
|
3201
|
+
}
|
|
3169
3202
|
async start() {
|
|
3170
3203
|
log.debug(`start() called — status=${this.status.value}, isReady=${this.isReady.value}`);
|
|
3171
3204
|
if (this.status.value !== "idle" && this.status.value !== "closed") {
|
|
@@ -3308,6 +3341,7 @@ var StreamConnection = class {
|
|
|
3308
3341
|
this.offTabVisible = void 0;
|
|
3309
3342
|
this.offTabPaused?.();
|
|
3310
3343
|
this.offTabPaused = void 0;
|
|
3344
|
+
this.disarmPipWatch?.();
|
|
3311
3345
|
const video = this.videoElement.value;
|
|
3312
3346
|
if (video) {
|
|
3313
3347
|
if (this.onVideoPauseBound) video.removeEventListener("pause", this.onVideoPauseBound);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camera.ui/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.189",
|
|
4
4
|
"description": "camera.ui browser client",
|
|
5
5
|
"author": "seydx (https://github.com/cameraui/clients)",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@camera.ui/logger": "file:../../packages/logger",
|
|
41
41
|
"@camera.ui/rpc": "^1.0.12",
|
|
42
|
-
"@camera.ui/sdk": "~1.2.
|
|
42
|
+
"@camera.ui/sdk": "~1.2.37",
|
|
43
43
|
"@camera.ui/transport": "file:../../packages/transport",
|
|
44
44
|
"@eneris/push-receiver": "^4.3.1",
|
|
45
45
|
"@microsoft/api-extractor": "^7.59.1",
|