apple-hig-mcp
Version:
High-performance MCP server providing instant access to Apple's Human Interface Guidelines via hybrid static/dynamic content delivery
101 lines • 2.9 kB
TypeScript
/**
* CrawleeHIGService
*
* Modern replacement for HIGScraper using Crawlee's PlaywrightCrawler
* for JavaScript-capable content extraction from Apple's SPA-based HIG website.
*
* Achieves 95%+ real content extraction by properly handling Apple's
* Single Page Application architecture.
*/
import type { HIGSection, ApplePlatform, HIGCategory, SearchResult, ScrapingConfig } from '../types.js';
import type { HIGCache } from '../cache.js';
export interface ContentExtractionResult {
content: string;
quality: number;
extractionMethod: 'crawlee' | 'fallback';
timestamp: Date;
}
export interface CrawleeConfig extends ScrapingConfig {
maxConcurrency: number;
browserOptions: {
headless: boolean;
viewport: {
width: number;
height: number;
};
args: string[];
};
waitOptions: {
networkIdle: number;
timeout: number;
};
}
export declare class CrawleeHIGService {
private cache;
private discoveryService;
private config;
private requestCount;
private lastRequestTime;
constructor(cache: HIGCache);
/**
* Discover all HIG sections using dynamic discovery
*/
discoverSections(): Promise<HIGSection[]>;
/**
* Fetch content for a specific HIG section using Crawlee
*/
fetchSectionContent(section: HIGSection): Promise<HIGSection>;
/**
* Extract content using direct Playwright browser instead of Crawlee
*/
private extractContentWithCrawlee;
/**
* Extract content from a loaded page
*/
private extractPageContent;
/**
* Extract content using main content strategy
*/
private extractWithMainContentStrategy;
/**
* Extract content using article strategy
*/
private extractWithArticleStrategy;
/**
* Extract content using body strategy
*/
private extractWithBodyStrategy;
/**
* Extract content using fallback strategy
*/
private extractWithFallbackStrategy;
/**
* Convert DOM element to markdown (to be injected into page context)
*/
private convertElementToMarkdown;
/**
* Clean and normalize markdown content
*/
private cleanMarkdownContent;
/**
* Calculate content quality score (0-1)
*/
private calculateContentQuality;
/**
* Respect rate limiting
*/
private respectRateLimit;
/**
* Get minimal fallback content when all extraction methods fail
*/
private getMinimalFallbackContent;
/**
* Search content using existing discovery and extraction capabilities
*/
searchContent(query: string, platform?: ApplePlatform, category?: HIGCategory, limit?: number): Promise<SearchResult[]>;
/**
* Clean up service resources
*/
teardown(): Promise<void>;
}
//# sourceMappingURL=crawlee-hig.service.d.ts.map