2024-06-01 08:56:16 +05:30
|
|
|
import { RemoteBrowser } from "./RemoteBrowser";
|
|
|
|
|
import logger from "../../logger";
|
|
|
|
|
|
2024-06-01 08:56:52 +05:30
|
|
|
/**
|
|
|
|
|
* @category Types
|
|
|
|
|
*/
|
2024-06-01 08:56:16 +05:30
|
|
|
interface BrowserPoolInfo {
|
2024-06-01 08:56:52 +05:30
|
|
|
/**
|
|
|
|
|
* The instance of remote browser.
|
|
|
|
|
*/
|
2024-06-01 08:56:16 +05:30
|
|
|
browser: RemoteBrowser,
|
2024-06-01 08:56:52 +05:30
|
|
|
/**
|
|
|
|
|
* States if the browser's instance is being actively used.
|
|
|
|
|
* Helps to persist the progress on the frontend when the application has been reloaded.
|
|
|
|
|
* @default false
|
|
|
|
|
*/
|
2024-06-01 08:56:16 +05:30
|
|
|
active: boolean,
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-01 08:57:10 +05:30
|
|
|
/**
|
|
|
|
|
* Dictionary of all the active remote browser's instances indexed by their id.
|
|
|
|
|
* The value in this dictionary is of type BrowserPoolInfo,
|
|
|
|
|
* which provides additional information about the browser's usage.
|
|
|
|
|
* @category Types
|
|
|
|
|
*/
|
2024-06-01 08:56:16 +05:30
|
|
|
interface PoolDictionary {
|
|
|
|
|
[key: string]: BrowserPoolInfo,
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-01 10:24:20 +05:30
|
|
|
/**
|
|
|
|
|
* A browser pool is a collection of remote browsers that are initialized and ready to be used.
|
|
|
|
|
* Adds the possibility to add, remove and retrieve remote browsers from the pool.
|
|
|
|
|
* It is possible to manage multiple browsers for creating or running a recording.
|
|
|
|
|
* @category BrowserManagement
|
|
|
|
|
*/
|
|
|
|
|
export class BrowserPool {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Holds all the instances of remote browsers.
|
|
|
|
|
*/
|
|
|
|
|
private pool : PoolDictionary = {};
|
|
|
|
|
}
|