forked from ulixee/unblocked
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IBrowserContext.ts
34 lines (30 loc) · 1.03 KB
/
IBrowserContext.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { URL } from 'url';
import type ITypedEventEmitter from '@ulixee/commons/interfaces/ITypedEventEmitter';
import { IPage } from './IPage';
import { IWorker } from './IWorker';
import IBrowser from './IBrowser';
import { IBrowserContextHooks } from '../hooks/IBrowserHooks';
import { ICookie } from '../net/ICookie';
import IInteractHooks from '../hooks/IInteractHooks';
export default interface IBrowserContext extends ITypedEventEmitter<IBrowserContextEvents> {
id: string;
browserId: string;
browser: IBrowser;
isIncognito: boolean;
pagesById: Map<string, IPage>;
workersById: Map<string, IWorker>;
hooks: IBrowserContextHooks & IInteractHooks;
newPage(): Promise<IPage>;
close(): Promise<void>;
getCookies(url?: URL): Promise<ICookie[]>;
addCookies(
cookies: (Omit<ICookie, 'expires'> & { expires?: string | Date | number })[],
origins?: string[],
): Promise<void>;
}
export interface IBrowserContextEvents {
page: { page: IPage };
worker: { worker: IWorker };
close: void;
'all-pages-closed': void;
}