2020-03-20 20:28:31 +00:00
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal' ;
2020-05-13 17:05:53 +00:00
import { deserialize } from '@electron/internal/common/type-utils' ;
2021-09-02 18:31:47 +00:00
import deprecate from '@electron/internal/common/api/deprecate' ;
2020-10-13 21:11:06 +00:00
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages' ;
2019-06-15 10:44:18 +00:00
2020-06-23 03:32:45 +00:00
const { hasSwitch } = process . _linkedBinding ( 'electron_common_command_line' ) ;
2019-10-04 17:49:09 +00:00
2020-03-20 20:28:31 +00:00
const enableStacks = hasSwitch ( 'enable-api-filtering-logging' ) ;
2019-10-04 17:49:09 +00:00
function getCurrentStack ( ) {
2020-03-20 20:28:31 +00:00
const target = { } ;
2019-10-04 17:49:09 +00:00
if ( enableStacks ) {
2020-03-20 20:28:31 +00:00
Error . captureStackTrace ( target , getCurrentStack ) ;
2019-10-04 17:49:09 +00:00
}
2020-03-20 20:28:31 +00:00
return ( target as any ) . stack ;
2019-10-04 17:49:09 +00:00
}
2021-09-02 18:31:47 +00:00
let warned = process . noDeprecation ;
2019-06-15 10:44:18 +00:00
export async function getSources ( options : Electron.SourcesOptions ) {
2021-09-02 18:31:47 +00:00
if ( ! warned ) {
deprecate . log ( 'The use of \'desktopCapturer.getSources\' in the renderer process is deprecated and will be removed. See https://www.electronjs.org/docs/breaking-changes#removed-desktopcapturergetsources-in-the-renderer for more details.' ) ;
warned = true ;
}
2020-10-13 21:11:06 +00:00
return deserialize ( await ipcRendererInternal . invoke ( IPC_MESSAGES . DESKTOP_CAPTURER_GET_SOURCES , options , getCurrentStack ( ) ) ) ;
2019-06-15 10:44:18 +00:00
}