@casoon/auditmysite
Version:
A comprehensive command-line tool for automated accessibility, security, performance, and SEO testing using Playwright and pa11y, based on sitemap URLs
69 lines โข 2.38 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BrowserManager = void 0;
const playwright_1 = require("playwright");
class BrowserManager {
constructor(config = {}) {
this.config = config;
this.browser = null;
this.context = null;
this.wsEndpoint = null;
this.port = config.port || 9222;
}
async initialize() {
console.log('๐ Initialisiere geteilten Browser...');
// Browser mit Remote Debugging starten
this.browser = await playwright_1.chromium.launch({
headless: this.config.headless !== false,
slowMo: this.config.slowMo || 0,
devtools: this.config.devtools || false,
args: [
'--disable-web-security',
'--disable-features=VizDisplayCompositor',
'--no-sandbox',
'--disable-setuid-sandbox',
'--remote-debugging-port=' + this.port,
'--remote-debugging-address=127.0.0.1',
...(this.config.args || [])
]
});
// Browser Context erstellen
this.context = await this.browser.newContext({
viewport: { width: 1920, height: 1080 },
userAgent: 'auditmysite/1.0 (+https://github.com/casoon/AuditMySite)'
});
// WebSocket Endpoint fรผr pa11y/Lighthouse
this.wsEndpoint = `ws://127.0.0.1:${this.port}`;
console.log(`โ
Geteilter Browser bereit auf Port ${this.port}`);
console.log(`๐ WebSocket: ${this.wsEndpoint}`);
}
async getPage() {
if (!this.context) {
throw new Error('Browser not initialized');
}
return await this.context.newPage();
}
getWsEndpoint() {
if (!this.wsEndpoint) {
throw new Error('Browser not initialized');
}
return this.wsEndpoint;
}
getPort() {
return this.port;
}
async cleanup() {
if (this.context) {
await this.context.close();
}
if (this.browser) {
await this.browser.close();
}
console.log('๐งน Shared browser cleaned up');
}
isInitialized() {
return this.browser !== null && this.context !== null;
}
}
exports.BrowserManager = BrowserManager;
//# sourceMappingURL=browser-manager.js.map