@pierrad/web-carbon-analyzer
Version:
A tool to measure the carbon footprint of websites using CO2.js
39 lines (38 loc) • 1.27 kB
TypeScript
/**
* Lighthouse Controller
* Manages Lighthouse audits via playwright-lighthouse
*/
import { Page } from 'playwright';
import { LighthouseConfig } from '../types';
export default class LighthouseController {
private config;
/**
* Creates a new LighthouseController instance
* @param config Lighthouse configuration
*/
constructor(config: LighthouseConfig);
/**
* Run lighthouse audit on the current page
* @param page The Playwright page to audit
* @param url The URL being audited (for reporting purposes)
* @returns Lighthouse audit results
*/
runAudit(page: Page, url: string): Promise<{
scores: {
performance: number;
accessibility: number;
bestPractices: number;
seo: number;
pwa: number;
};
metrics: {
firstContentfulPaint: number | undefined;
largestContentfulPaint: number | undefined;
totalBlockingTime: number | undefined;
speedIndex: number | undefined;
timeToInteractive: number | undefined;
cumulativeLayoutShift: number | undefined;
};
stackPacks: import("lighthouse").Result.StackPack[] | undefined;
} | null>;
}