зеркало из https://github.com/electron/electron.git
don't make functions `async`
This commit is contained in:
Родитель
1d480ad23d
Коммит
a17823663c
|
@ -18,7 +18,7 @@ export async function getSources (args: Electron.SourcesOptions) {
|
||||||
if (!isValid(args)) throw new Error('Invalid options');
|
if (!isValid(args)) throw new Error('Invalid options');
|
||||||
|
|
||||||
const resizableValues = new Map();
|
const resizableValues = new Map();
|
||||||
let winsOwnedByElectronProcess: ElectronInternal.GetSourcesResult[];
|
let winsOwnedByElectronProcess: Promise<ElectronInternal.GetSourcesResult[]>;
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
// Fix for bug in ScreenCaptureKit that modifies a window's styleMask the first time
|
// Fix for bug in ScreenCaptureKit that modifies a window's styleMask the first time
|
||||||
// it captures a non-resizable window. We record each non-resizable window's styleMask,
|
// it captures a non-resizable window. We record each non-resizable window's styleMask,
|
||||||
|
@ -52,7 +52,7 @@ export async function getSources (args: Electron.SourcesOptions) {
|
||||||
const getSources = new Promise<ElectronInternal.GetSourcesResult[]>((resolve, reject) => {
|
const getSources = new Promise<ElectronInternal.GetSourcesResult[]>((resolve, reject) => {
|
||||||
let capturer: ElectronInternal.DesktopCapturer | null = createDesktopCapturer();
|
let capturer: ElectronInternal.DesktopCapturer | null = createDesktopCapturer();
|
||||||
|
|
||||||
const stopRunning = async () => {
|
const stopRunning = () => {
|
||||||
if (capturer) {
|
if (capturer) {
|
||||||
delete capturer._onerror;
|
delete capturer._onerror;
|
||||||
delete capturer._onfinished;
|
delete capturer._onfinished;
|
||||||
|
@ -84,25 +84,23 @@ export async function getSources (args: Electron.SourcesOptions) {
|
||||||
appIcon: null
|
appIcon: null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
winsOwnedByElectronProcess = await Promise.all(fetches);
|
winsOwnedByElectronProcess = Promise.all(fetches);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Remove from currentlyRunning once we resolve or reject
|
// Remove from currentlyRunning once we resolve or reject
|
||||||
currentlyRunning = currentlyRunning.filter(running => running.options !== options);
|
currentlyRunning = currentlyRunning.filter(running => running.options !== options);
|
||||||
};
|
};
|
||||||
|
|
||||||
capturer._onerror = async (error: string) => {
|
capturer._onerror = (error: string) => {
|
||||||
await stopRunning();
|
stopRunning();
|
||||||
reject(error);
|
reject(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
capturer._onfinished = async (sources: Electron.DesktopCapturerSource[]) => {
|
capturer._onfinished = (sources: Electron.DesktopCapturerSource[]) => {
|
||||||
await stopRunning();
|
stopRunning();
|
||||||
if (Array.isArray(winsOwnedByElectronProcess)) {
|
winsOwnedByElectronProcess.then((wins) => {
|
||||||
resolve([...sources, ...winsOwnedByElectronProcess]);
|
resolve([...sources, ...wins]);
|
||||||
} else {
|
});
|
||||||
resolve(sources);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
capturer.startHandling(captureWindow, captureScreen, thumbnailSize, fetchWindowIcons);
|
capturer.startHandling(captureWindow, captureScreen, thumbnailSize, fetchWindowIcons);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче