snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
48
react/features/pip/external-api.shared.ts
Normal file
48
react/features/pip/external-api.shared.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Shared utilities for PiP feature used by external_api.js.
|
||||
*
|
||||
* IMPORTANT: Keep this file minimal with no heavy dependencies.
|
||||
* It's bundled into external_api.min.js and we want to keep that bundle slim.
|
||||
* Only import lightweight modules here.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks if current environment is Electron.
|
||||
* Inline check to avoid importing BrowserDetection and its ua-parser dependency.
|
||||
*
|
||||
* @returns {boolean} - True if running in Electron.
|
||||
*/
|
||||
function isElectron(): boolean {
|
||||
return navigator.userAgent.includes('Electron');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if PiP is enabled based on config and environment.
|
||||
*
|
||||
* Honors the config it is given, but when `enableBrowserPiP` is absent it deliberately stays
|
||||
* permissive: the external API evaluates this against only the embedder-provided config, never
|
||||
* the deployment's server-side config, so applying the opt-in default here would silently
|
||||
* disable embedded auto-PiP for deployments that opt in server-side. The authoritative opt-in
|
||||
* default (an absent flag counts as disabled) is applied by `shouldShowPiP()` inside the client,
|
||||
* where the merged config is available — an over-approximating embedder only costs a no-op
|
||||
* show-PiP request that the client refuses.
|
||||
*
|
||||
* @param {Object} pipConfig - The pip config object.
|
||||
* @returns {boolean} - True if PiP is enabled.
|
||||
*/
|
||||
export function isPiPEnabled(pipConfig?: { disabled?: boolean; enableBrowserPiP?: boolean; }): boolean {
|
||||
if (pipConfig?.disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isElectron()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pipConfig?.enableBrowserPiP === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'documentPictureInPicture' in window
|
||||
|| Boolean(document.pictureInPictureEnabled);
|
||||
}
|
||||
Reference in New Issue
Block a user