@casoon/auditmysite
Version:
Professional website analysis suite with robust accessibility testing, Core Web Vitals performance monitoring, SEO analysis, and content optimization insights. Features isolated browser contexts, retry mechanisms, and comprehensive API endpoints for profe
101 lines • 3.46 kB
TypeScript
/**
* 📊 Content Weight Analyzer
*
* Analyzes the weight and composition of webpage content including:
* - Resource sizes (HTML, CSS, JS, images, fonts)
* - Content quality metrics
* - Text-to-code ratios
* - Performance impact analysis
*/
import { Page, Response } from 'playwright';
import { ContentWeight, ContentAnalysis, ResourceTiming } from '../types/enhanced-metrics';
import { BaseAnalyzer, BaseAnalysisResult, BaseAnalysisOptions, BaseRecommendation, Grade, CertificateLevel } from '../types/base-types';
interface ContentWeightAnalysisResult extends BaseAnalysisResult {
contentWeight: ContentWeight;
contentAnalysis: ContentAnalysis;
resourceTimings: ResourceTiming[];
recommendations: BaseRecommendation[];
}
interface ContentWeightAnalysisOptions extends BaseAnalysisOptions {
includeResourceAnalysis?: boolean;
analysisTimeout?: number;
verbose?: boolean;
}
export declare class ContentWeightAnalyzer implements BaseAnalyzer<ContentWeightAnalysisResult, ContentWeightAnalysisOptions> {
private resourceTimings;
private responses;
constructor();
getName(): string;
getVersion(): string;
getScore(result: ContentWeightAnalysisResult): number;
getGrade(score: number): Grade;
getCertificateLevel(score: number): CertificateLevel;
getRecommendations(result: ContentWeightAnalysisResult): BaseRecommendation[];
/**
* Main analyze method implementing BaseAnalyzer interface
*/
analyze(page: Page, url: string | {
loc: string;
}, options?: ContentWeightAnalysisOptions): Promise<ContentWeightAnalysisResult>;
/**
* Enhanced analyze method that accepts pre-captured network responses
* This fixes the issue where network monitoring starts after page load
*/
analyzeWithResponses(page: Page, url: string | {
loc: string;
}, options?: ContentWeightAnalysisOptions, networkResponses?: Response[]): Promise<ContentWeightAnalysisResult>;
/**
* Set up response tracking to capture all network requests
*/
private setupResponseTracking;
/**
* Calculate the weight of different content types
*/
private calculateContentWeight;
/**
* Analyze content composition and quality metrics
*/
private analyzeContentComposition;
/**
* Extract detailed resource timing information
*/
private extractResourceTimings;
/**
* Get the size of a response
*/
private getResponseSize;
/**
* Get transfer size from headers
*/
private getTransferSize;
/**
* Categorize resource by URL and content type
*/
private categorizeResource;
/**
* Get resource type for timing analysis
*/
private getResourceType;
/**
* Calculate content quality score based on various factors
*/
private calculateContentQualityScore;
/**
* Format bytes to human readable string
*/
private formatBytes;
/**
* Calculate overall score from content weight and analysis data
*/
private calculateOverallScore;
/**
* Generate optimization recommendations
*/
private generateRecommendations;
/**
* Get performance recommendations based on content weight analysis
*/
static generateContentRecommendations(contentWeight: ContentWeight, contentAnalysis: ContentAnalysis): string[];
}
export {};
//# sourceMappingURL=content-weight-analyzer.d.ts.map