refactored db's and browser
This commit is contained in:
parent
a0a3b26177
commit
89cbfb7848
12 changed files with 111 additions and 39 deletions
|
|
@ -1,20 +1,21 @@
|
|||
import { BrowserContext, chromium, Page, Browser as PlaywrightBrowser } from 'playwright';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { BrowserOptions, NetworkEvent, NetworkEventHandler } from './types';
|
||||
|
||||
class BrowserSingleton {
|
||||
export class Browser {
|
||||
private browser?: PlaywrightBrowser;
|
||||
private contexts: Map<string, BrowserContext> = new Map();
|
||||
private logger = getLogger('browser');
|
||||
private logger: any;
|
||||
private options: BrowserOptions;
|
||||
private initialized = false;
|
||||
|
||||
constructor() {
|
||||
constructor(logger?: any, defaultOptions?: BrowserOptions) {
|
||||
this.logger = logger || console;
|
||||
this.options = {
|
||||
headless: true,
|
||||
timeout: 30000,
|
||||
blockResources: false,
|
||||
enableNetworkLogging: false,
|
||||
...defaultOptions,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -359,8 +360,5 @@ class BrowserSingleton {
|
|||
}
|
||||
}
|
||||
|
||||
// Export singleton instance
|
||||
export const Browser = new BrowserSingleton();
|
||||
|
||||
// Also export the class for typing if needed
|
||||
export { BrowserSingleton as BrowserClass };
|
||||
// Export default for backward compatibility
|
||||
export default Browser;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
export { Browser } from './browser';
|
||||
export { BrowserTabManager } from './tab-manager';
|
||||
// TODO: Update BrowserTabManager to work with non-singleton Browser
|
||||
// export { BrowserTabManager } from './tab-manager';
|
||||
export type { BrowserOptions, ScrapingResult } from './types';
|
||||
|
||||
// Default export for the class
|
||||
export { default as BrowserClass } from './browser';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue