Expose native API call to get desktop screen sources (#1881)
* Expose native API call to get screen sources * Move eslint line to the bottom
This commit is contained in:
parent
5056ec7ace
commit
875a0f8bfd
|
@ -6,7 +6,7 @@
|
|||
|
||||
/* eslint-disable no-magic-numbers */
|
||||
|
||||
import {contextBridge, ipcRenderer, webFrame} from 'electron';
|
||||
import {contextBridge, ipcRenderer, webFrame, desktopCapturer} from 'electron';
|
||||
|
||||
// I've filed an issue in electron-log https://github.com/megahertz/electron-log/issues/267
|
||||
// we'll be able to use it again if there is a workaround for the 'os' import
|
||||
|
@ -262,4 +262,18 @@ window.addEventListener('storage', (e) => {
|
|||
}
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('desktopCapturer', {
|
||||
getSources: async (options) => {
|
||||
const sources = await desktopCapturer.getSources(options);
|
||||
return sources.map((source) => {
|
||||
return {
|
||||
id: source.id,
|
||||
name: source.name,
|
||||
thumbnailURL: source.thumbnail.toDataURL(),
|
||||
};
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
/* eslint-enable no-magic-numbers */
|
||||
|
||||
|
|
Loading…
Reference in a new issue