28 lines
1002 B
TypeScript
28 lines
1002 B
TypeScript
|
import { BrowserWindowConstructorOptions, LoadURLOptions } from 'electron';
|
||
|
import { SimpleMutex } from '../mutex/simple-mutex';
|
||
|
import { ISessionHelper } from '../session/i-session-helper';
|
||
|
import { ISiteAppWindow } from './i-site-app-window';
|
||
|
import { UrlAppWindow } from './url-app-window';
|
||
|
|
||
|
/**
|
||
|
* This class represents an app window of a site which need to be crawled via the built-in chromium of Electron.
|
||
|
* It offers a lock so that multiple calls do executed simultaneously on the same chromium window.
|
||
|
*/
|
||
|
export abstract class SiteAppWindow extends UrlAppWindow implements ISiteAppWindow {
|
||
|
private windowLock: IMutex;
|
||
|
|
||
|
protected constructor(
|
||
|
sessionHelper: ISessionHelper,
|
||
|
uri: string,
|
||
|
options: BrowserWindowConstructorOptions = {},
|
||
|
loadOptions: LoadURLOptions = {}
|
||
|
) {
|
||
|
super(sessionHelper, uri, options, loadOptions);
|
||
|
this.windowLock = new SimpleMutex();
|
||
|
}
|
||
|
|
||
|
public acquireLock(): Promise<Mutex.ReleaseFunction> {
|
||
|
return this.windowLock.acquire();
|
||
|
}
|
||
|
}
|