UNPKG

apple-hig-mcp

Version:

High-performance MCP server providing instant access to Apple's Human Interface Guidelines via hybrid static/dynamic content delivery

73 lines 2.67 kB
/** * Cross Reference Generator Service * Single Responsibility: Generate cross-references between sections */ export class CrossReferenceGeneratorService { sections = []; crossReferences = {}; addSection(section) { this.sections.push(section); } generateReferences() { this.crossReferences = {}; for (const section of this.sections) { const related = this.findRelatedSections(section); const backlinks = this.findBacklinks(section); const tags = this.generateTags(section); this.crossReferences[section.id] = { relatedSections: related, backlinks, tags }; } // Generate backlinks in a second pass this.generateBacklinks(); return { ...this.crossReferences }; } clear() { this.sections = []; this.crossReferences = {}; } findRelatedSections(section) { return this.sections .filter(s => s.id !== section.id) .filter(s => s.platform === section.platform || s.category === section.category) .map(s => s.id) .slice(0, 5); // Limit to top 5 } findBacklinks(section) { return this.sections .filter(s => s.id !== section.id) .filter(s => (s.content || '').toLowerCase().includes(section.title.toLowerCase())) .map(s => s.id); } generateTags(section) { const tags = [section.platform, section.category]; const title = section.title.toLowerCase(); if (title.includes('button')) tags.push('controls', 'interaction'); if (title.includes('navigation')) tags.push('navigation-ui', 'hierarchy'); if (title.includes('color')) tags.push('visual-design', 'theming'); if (title.includes('typography')) tags.push('text', 'fonts'); if (title.includes('icon')) tags.push('visual-elements'); if (title.includes('accessibility')) tags.push('a11y'); return [...new Set(tags)]; } generateBacklinks() { for (const [sectionId, refs] of Object.entries(this.crossReferences)) { refs.relatedSections.forEach((relatedId) => { if (this.crossReferences[relatedId]) { if (!this.crossReferences[relatedId].backlinks.includes(sectionId)) { this.crossReferences[relatedId].backlinks.push(sectionId); } } }); } } } //# sourceMappingURL=cross-reference-generator.service.js.map