pagegraph 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -148
- package/dist/audit.d.ts +2 -2
- package/dist/audit.js +4 -4
- package/dist/build-only/audit.d.ts +1 -0
- package/dist/build-only/audit.js +6 -0
- package/dist/build-only/audit.js.map +1 -0
- package/dist/build-only/claims.d.ts +1 -0
- package/dist/build-only/claims.js +6 -0
- package/dist/build-only/claims.js.map +1 -0
- package/dist/build-only/config.d.ts +1 -0
- package/dist/build-only/config.js +6 -0
- package/dist/build-only/config.js.map +1 -0
- package/dist/build-only/oxlint.d.ts +1 -0
- package/dist/build-only/oxlint.js +6 -0
- package/dist/build-only/oxlint.js.map +1 -0
- package/dist/build-only/tanstack-start.d.ts +1 -0
- package/dist/build-only/tanstack-start.js +6 -0
- package/dist/build-only/tanstack-start.js.map +1 -0
- package/dist/build-only/vite.d.ts +1 -0
- package/dist/build-only/vite.js +6 -0
- package/dist/build-only/vite.js.map +1 -0
- package/dist/{checks-nk8ZRRIA.js → checks-BS-aDXB_.js} +4 -142
- package/dist/checks-BS-aDXB_.js.map +1 -0
- package/dist/claims-Bch7Lxlo.d.ts +92 -0
- package/dist/claims-Bv7voeEV.js +431 -0
- package/dist/claims-Bv7voeEV.js.map +1 -0
- package/dist/claims.d.ts +94 -0
- package/dist/claims.js +2 -0
- package/dist/cli.js +10368 -8485
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +4 -83
- package/dist/config.js +3 -122
- package/dist/config.js.map +1 -1
- package/dist/{content-CB_kHmJ3.js → content-CHd0X4s6.js} +3 -2
- package/dist/{content-CB_kHmJ3.js.map → content-CHd0X4s6.js.map} +1 -1
- package/dist/{content-DVL2iyGU.d.ts → content-DgNr7apS.d.ts} +5 -130
- package/dist/declare-D5o7hwmv.js +9 -0
- package/dist/declare-D5o7hwmv.js.map +1 -0
- package/dist/document-CztEu3Vd.d.ts +109 -0
- package/dist/document-Dvemcv7V.js +379 -0
- package/dist/document-Dvemcv7V.js.map +1 -0
- package/dist/facts-1OKclPOk.js +115 -0
- package/dist/facts-1OKclPOk.js.map +1 -0
- package/dist/graph-D1PIndsC.d.ts +12238 -0
- package/dist/graph-DMNOLXLu.js +172 -0
- package/dist/graph-DMNOLXLu.js.map +1 -0
- package/dist/index-C5w9ripz.d.ts +204 -0
- package/dist/index.d.ts +6 -196
- package/dist/index.js +55 -134
- package/dist/index.js.map +1 -1
- package/dist/inline-BbS93GAT.js +682 -0
- package/dist/inline-BbS93GAT.js.map +1 -0
- package/dist/llms-Dhr_5u2O.js +19 -0
- package/dist/llms-Dhr_5u2O.js.map +1 -0
- package/dist/markdown-C6dRE9zD.js +168 -0
- package/dist/markdown-C6dRE9zD.js.map +1 -0
- package/dist/markdown-path-lJB9BAVZ.js +6 -0
- package/dist/markdown-path-lJB9BAVZ.js.map +1 -0
- package/dist/message-CuBjgZ74.js +12 -0
- package/dist/message-CuBjgZ74.js.map +1 -0
- package/dist/oxlint.d.ts +58 -0
- package/dist/oxlint.js +202 -0
- package/dist/oxlint.js.map +1 -0
- package/dist/page-heads-BfjWQvau.d.ts +108 -0
- package/dist/page-heads-BgbaIjj9.js +25 -0
- package/dist/page-heads-BgbaIjj9.js.map +1 -0
- package/dist/projections-Bk-qOOsR.d.ts +78 -0
- package/dist/projections-D0oOFKiY.js +142 -0
- package/dist/projections-D0oOFKiY.js.map +1 -0
- package/dist/react.d.ts +27 -12051
- package/dist/react.js +14 -4
- package/dist/react.js.map +1 -1
- package/dist/route-config-35ZEzkNC.js +308 -0
- package/dist/route-config-35ZEzkNC.js.map +1 -0
- package/dist/route-config-wneg6ktn.d.ts +29 -0
- package/dist/tanstack-start/index.d.ts +56 -0
- package/dist/tanstack-start/index.js +717 -0
- package/dist/tanstack-start/index.js.map +1 -0
- package/dist/tanstack-start/markdown.d.ts +12 -0
- package/dist/tanstack-start/markdown.js +149 -0
- package/dist/tanstack-start/markdown.js.map +1 -0
- package/dist/tanstack-start/prerender-worker.d.ts +2 -0
- package/dist/tanstack-start/prerender-worker.js +7 -0
- package/dist/tanstack-start/prerender-worker.js.map +1 -0
- package/dist/tanstack-start/react.d.ts +7 -0
- package/dist/tanstack-start/react.js +12 -0
- package/dist/tanstack-start/react.js.map +1 -0
- package/dist/tanstack-start/server.d.ts +20 -0
- package/dist/tanstack-start/server.js +77 -0
- package/dist/tanstack-start/server.js.map +1 -0
- package/dist/vite-graph-loader-CsGiYNWE.js +105 -0
- package/dist/vite-graph-loader-CsGiYNWE.js.map +1 -0
- package/dist/vite-graph-loader-DZCwejuJ.d.ts +133 -0
- package/dist/vite.d.ts +2 -28
- package/dist/vite.js +1 -307
- package/dist/wire-B4RQMc4e.js +26 -0
- package/dist/wire-B4RQMc4e.js.map +1 -0
- package/package.json +70 -7
- package/dist/checks-nk8ZRRIA.js.map +0 -1
- package/dist/vite.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checks-nk8ZRRIA.js","names":[],"sources":["../src/core/projections.ts","../src/core/freshness.ts","../src/core/checks.ts"],"sourcesContent":["/**\n * Projections of the SEO graph: sitemap.xml, robots.txt, and single-node\n * inspection. Pure functions — the origin, the host's indexability, and the\n * robots disallow list are injected by the caller, never read from the\n * environment or a generated file.\n */\n\nimport type { SeoEdge, SeoGraph, SeoNode } from \"./graph\";\n\nexport interface ProjectionConfig {\n origin: string;\n indexable: boolean;\n}\n\nexport interface RobotsConfig extends ProjectionConfig {\n /** Path prefixes to disallow on an indexable host (e.g. the app-only groups). */\n disallow: ReadonlyArray<string>;\n /**\n * Origin-wide Content-Signal preferences\n * (https://contentsignals.org/), emitted as `Content-Signal: <value>` under\n * `User-agent: *` on an indexable host. Omit for none. The plugin never\n * invents a default — pass the policy you want, e.g.\n * `\"search=yes, ai-input=yes, ai-train=yes\"`.\n */\n contentSignal?: string | undefined;\n /**\n * Extra full lines in the indexable `User-agent: *` group, after\n * Content-Signal (if any) and before Allow/Disallow. Use for directives the\n * plugin does not model, or to compose {@link contentSignal} yourself.\n */\n directives?: ReadonlyArray<string> | undefined;\n /**\n * Last-mile override: receives the rendered robots.txt and returns the file\n * to emit. Runs for indexable and preview hosts. Use when you need to wrap\n * or replace the default body rather than add group lines.\n */\n transform?: ((robots: string) => string) | undefined;\n}\n\nexport interface NodeReport {\n node: SeoNode;\n inSitemap: boolean;\n incoming: Array<SeoEdge>;\n outgoing: Array<SeoEdge>;\n}\n\nconst escapeXml = (value: string): string =>\n value\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n\n/**\n * A node belongs in the sitemap when it declares a positive sitemap policy, is not\n * a redirect, is not robots-noindexed, and is not a param template (a route whose\n * path still contains a `$` segment — those exist only so their instances inherit).\n */\nexport function isSitemapEligible(node: SeoNode): boolean {\n if (node.policy.redirectTo !== undefined) return false;\n if (node.policy.robots?.includes(\"noindex\")) return false;\n if (!node.policy.sitemap) return false; // false or absent\n if (node.path.includes(\"$\")) return false;\n return true;\n}\n\n/** Canonical absolute URL for a node under the given origin. */\nfunction urlForNode(origin: string, node: SeoNode): string {\n return node.path === \"/\" ? origin : `${origin}${node.path}`;\n}\n\n/**\n * The date a node's content last changed, as declared: an instance's\n * `modifiedAt`, else its `publishedAt`; a route's own `modifiedAt`. A node with\n * no date (a docs page without frontmatter dates, an undated route) returns\n * undefined, and the sitemap omits its `<lastmod>`.\n */\nexport function lastModified(node: SeoNode): string | undefined {\n if (node.instance) return node.instance.modifiedAt ?? node.instance.publishedAt;\n return node.policy.modifiedAt;\n}\n\n/** An ISO 8601 date, or a date-time that states its offset. */\nconst ISO_DATE = /^(\\d{4})-(\\d{2})-(\\d{2})(?:T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))?$/;\n\n/**\n * Parse a declared date to epoch milliseconds, or undefined when it is not an\n * ISO 8601 date (`2026-09-29`) or offset date-time (`2026-09-29T10:00:00Z`) on a\n * real calendar day. `Date.parse` alone would accept \"Sep 29\" in the host's\n * zone and roll \"2026-02-30\" into March; either would publish a wrong\n * `<lastmod>`. The `invalid-date` check reports the undefined case, so\n * projections that meet one fail loudly.\n */\nexport function parseDeclaredDate(value: string): number | undefined {\n const match = ISO_DATE.exec(value);\n if (match === null) return undefined;\n const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];\n const calendar = new Date(Date.UTC(year, month - 1, day));\n if (calendar.getUTCMonth() !== month - 1 || calendar.getUTCDate() !== day) return undefined;\n const time = Date.parse(value);\n return Number.isNaN(time) ? undefined : time;\n}\n\nfunction sitemapLastmod(node: SeoNode): string | undefined {\n const date = lastModified(node);\n if (date === undefined) return undefined;\n const time = parseDeclaredDate(date);\n if (time === undefined) {\n throw new Error(`\"${node.path}\" declares an invalid date \"${date}\"; run \\`pagegraph check\\`.`);\n }\n return new Date(time).toISOString();\n}\n\nfunction renderUrlEntry(url: string, lastmod: string | undefined, node: SeoNode): string {\n const sitemap = node.policy.sitemap;\n // isSitemapEligible guarantees a positive policy before this runs.\n const { changeFrequency, priority } = sitemap as { changeFrequency: string; priority: number };\n const lines = [` <url>`, ` <loc>${escapeXml(url)}</loc>`];\n if (lastmod) lines.push(` <lastmod>${lastmod}</lastmod>`);\n lines.push(\n ` <changefreq>${changeFrequency}</changefreq>`,\n ` <priority>${priority.toFixed(1)}</priority>`,\n ` </url>`,\n );\n return lines.join(\"\\n\");\n}\n\n/**\n * Render sitemap.xml from the graph. Each entry's `<lastmod>` is its\n * {@link lastModified} date: frontmatter for content instances, the declared\n * `modifiedAt` for routes. Route entries are sorted by path, then instances follow in collection order.\n * `indexable` is intentionally unused — the sitemap body is host-independent;\n * robots.txt is what gates crawling.\n */\nexport function renderSitemap(graph: SeoGraph, cfg: ProjectionConfig): string {\n const nodes = [...graph.nodes.values()];\n const staticNodes = nodes\n .filter((node) => node.source === \"route\" && isSitemapEligible(node))\n .sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));\n const instanceNodes = nodes.filter((node) => node.source !== \"route\" && isSitemapEligible(node));\n\n const seen = new Set<string>();\n const entries: Array<string> = [];\n for (const node of [...staticNodes, ...instanceNodes]) {\n const url = urlForNode(cfg.origin, node);\n const key = url.toLowerCase().replace(/\\/$/, \"\");\n if (seen.has(key)) continue;\n seen.add(key);\n entries.push(renderUrlEntry(url, sitemapLastmod(node), node));\n }\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\\n${entries.join(\n \"\\n\",\n )}\\n</urlset>\\n`;\n}\n\n/** Format a Content-Signal robots.txt directive from the preference list. */\nexport function contentSignal(value: string): string {\n return `Content-Signal: ${value}`;\n}\n\nconst groupLines = (cfg: RobotsConfig): Array<string> => {\n const lines: Array<string> = [];\n if (cfg.contentSignal !== undefined && cfg.contentSignal !== \"\") {\n lines.push(contentSignal(cfg.contentSignal));\n }\n for (const directive of cfg.directives ?? []) {\n if (directive !== \"\") lines.push(directive);\n }\n return lines;\n};\n\n/**\n * Render robots.txt. A non-indexable host (previews) gets a disallow-all\n * with no Sitemap line; an indexable host disallows exactly the prefixes the caller\n * passes. Pages that declare `robots: noindex` are intentionally NOT added as\n * Disallow entries — a Disallow would stop crawlers reaching the page to read its\n * `noindex, follow` meta, so the graph's per-node robots policy never feeds this\n * list. `graph` is unused — kept for signature parity with the other projections,\n * which callers load the graph once for and pass to each.\n *\n * Origin-wide group directives (`contentSignal`, `directives`) are indexable-host\n * only. {@link RobotsConfig.transform} always runs last so a consumer can override\n * the whole file.\n */\nexport function renderRobots(_graph: SeoGraph, cfg: RobotsConfig): string {\n const rendered = cfg.indexable\n ? [\n \"User-agent: *\",\n ...groupLines(cfg),\n \"Allow: /\",\n ...cfg.disallow.map((path) => `Disallow: ${path}`),\n \"\",\n `Sitemap: ${cfg.origin}/sitemap.xml`,\n `Host: ${cfg.origin}`,\n \"\",\n ].join(\"\\n\")\n : [\"User-agent: *\", \"Disallow: /\", \"\"].join(\"\\n\");\n return cfg.transform === undefined ? rendered : cfg.transform(rendered);\n}\n\n/** Inspect a single node: its declaration, sitemap eligibility, and edges. */\nexport function inspectNode(graph: SeoGraph, path: string): NodeReport | undefined {\n const node = graph.nodes.get(path);\n if (!node) return undefined;\n return {\n node,\n inSitemap: isSitemapEligible(node),\n incoming: graph.edges.filter((edge) => edge.to === path),\n outgoing: graph.edges.filter((edge) => edge.from === path),\n };\n}\n","/**\n * Freshness: how long ago each indexable page last changed, by the dates its\n * declaration carries ({@link lastModified}). Pure — the caller injects `now`,\n * so a test and the CLI read the same verdict from the same graph.\n *\n * Only sitemap-eligible pages are judged: a noindex or redirect page is not a\n * refresh candidate. A page with no date is reported as `undated` rather than\n * stale, because age cannot be inferred; the sitemap omits its `<lastmod>` too.\n */\n\nimport type { SeoKind } from \"./declare\";\nimport type { SeoGraph, SeoSource } from \"./graph\";\nimport { isSitemapEligible, lastModified, parseDeclaredDate } from \"./projections\";\n\n/** Project policy: pages whose last change is older than this are stale. */\nexport interface FreshnessPolicy {\n readonly maxAgeDays: number;\n}\n\nexport interface FreshnessEntry {\n readonly path: string;\n readonly kind: SeoKind;\n readonly source: SeoSource;\n /** The declared date, normalized to ISO 8601. */\n readonly lastModified: string;\n /** Whole days between `lastModified` and the report's `asOf`. */\n readonly ageDays: number;\n}\n\nexport interface FreshnessReport {\n readonly asOf: string;\n readonly maxAgeDays: number;\n /** Pages older than `maxAgeDays`, oldest first: the refresh queue. */\n readonly stale: ReadonlyArray<FreshnessEntry>;\n /** Dated pages within `maxAgeDays`, newest first. */\n readonly fresh: ReadonlyArray<FreshnessEntry>;\n /** Sitemap-eligible pages that declare no date, in graph order. */\n readonly undated: ReadonlyArray<string>;\n /** Sitemap-eligible pages whose date does not parse; `check` fails on each. */\n readonly invalid: ReadonlyArray<string>;\n}\n\nconst DAY_MS = 86_400_000;\n\n/**\n * Split the graph's sitemap-eligible pages into stale, fresh, undated, and\n * invalid. An invalid date cannot be aged, but it is listed so a report never\n * reads as complete while it skipped a page.\n */\nexport function freshnessReport(\n graph: SeoGraph,\n policy: FreshnessPolicy,\n now: Date,\n): FreshnessReport {\n const stale: Array<FreshnessEntry> = [];\n const fresh: Array<FreshnessEntry> = [];\n const undated: Array<string> = [];\n const invalid: Array<string> = [];\n\n for (const node of graph.nodes.values()) {\n if (!isSitemapEligible(node)) continue;\n const declared = lastModified(node);\n if (declared === undefined) {\n undated.push(node.path);\n continue;\n }\n const time = parseDeclaredDate(declared);\n if (time === undefined) {\n invalid.push(node.path);\n continue;\n }\n const entry: FreshnessEntry = {\n path: node.path,\n kind: node.kind,\n source: node.source,\n lastModified: new Date(time).toISOString(),\n ageDays: Math.max(0, Math.floor((now.getTime() - time) / DAY_MS)),\n };\n (entry.ageDays > policy.maxAgeDays ? stale : fresh).push(entry);\n }\n\n stale.sort((a, b) => b.ageDays - a.ageDays || (a.path < b.path ? -1 : 1));\n fresh.sort((a, b) => a.ageDays - b.ageDays || (a.path < b.path ? -1 : 1));\n return {\n asOf: now.toISOString(),\n maxAgeDays: policy.maxAgeDays,\n stale,\n fresh,\n undated,\n invalid,\n };\n}\n","/**\n * The SEO check engine: a set of rules run against the derived {@link SeoGraph}.\n * Pure — no I/O, no `clientEnv`, no React. The CLI's `pagegraph check` command and the\n * vitest suite both call {@link checkGraph}; nothing else derives correctness.\n *\n * Two severities, mapped to the CLI's exit contract:\n * - `structural` — a declaration is internally broken (a link points nowhere, a\n * card would render empty, a page contradicts its own robots/sitemap intent).\n * Any structural violation fails `pagegraph check` (exit 1); these must not ship.\n * - `editorial` — a quality smell (duplicate or mis-sized titles/descriptions).\n * Reported as warnings; `pagegraph check` still exits 0 when only these are present.\n *\n * The graph only knows what declarations and frontmatter carry, so the rules are\n * scoped to that: per-node title/description live only on collection *instances*,\n * never on structural route nodes (whose head tags are composed at render time and\n * are not in the graph). Rules are data-driven and listed once in\n * {@link CHECK_RULES}.\n */\n\nimport type { SitemapPolicy } from \"./declare\";\nimport { freshnessReport, type FreshnessPolicy } from \"./freshness\";\nimport type { SeoGraph, SeoNode } from \"./graph\";\nimport type { LinkEdge } from \"./links\";\nimport { isSitemapEligible, parseDeclaredDate } from \"./projections\";\n\nexport type Severity = \"structural\" | \"editorial\";\n\nexport interface Violation {\n severity: Severity;\n rule: string;\n path?: string | undefined;\n message: string;\n fix?: string | undefined;\n}\n\n/**\n * A contextual-link coverage rule: every sitemap-eligible page matching the\n * `path` glob must have at least `minInbound` incoming contextual links. Unlike\n * the static rules, these come from project policy (a CLI flag or\n * `seo.config.ts`), because \"which pages are money pages\" is app knowledge.\n *\n * The same rule shape is evaluated twice: `checkCoverage` counts declared\n * `related` edges, and `checkRenderedCoverage` counts the contextual anchors a\n * crawl actually served. The target universe is always the declared graph's\n * sitemap-eligible pages — the rendered pass only swaps the edge source.\n */\nexport interface CoverageRule {\n /** Path glob: `*` matches within a segment, `**` matches across segments. */\n readonly path: string;\n /** Minimum incoming contextual links the matched page needs. */\n readonly minInbound: number;\n}\n\n/** A single finding before its rule's `severity`/`rule` name are attached. */\ninterface RawViolation {\n path?: string | undefined;\n message: string;\n fix?: string | undefined;\n}\n\ninterface CheckRule {\n readonly name: string;\n readonly severity: Severity;\n readonly evaluate: (graph: SeoGraph) => ReadonlyArray<RawViolation>;\n}\n\n/** A positive sitemap policy — the author asked for this page to be indexed. */\nconst hasPositiveSitemap = (sitemap: SitemapPolicy | false | undefined): sitemap is SitemapPolicy =>\n sitemap !== undefined && sitemap !== false;\n\n/** Content and manifest instances carry page-level title/description. */\nconst isInstance = (node: SeoNode): boolean => node.source !== \"route\";\n\n/** Group instance nodes by a present, non-empty string field for duplicate detection. */\nconst groupInstancesBy = (\n graph: SeoGraph,\n field: (node: SeoNode) => string | undefined,\n): Map<string, Array<SeoNode>> => {\n const groups = new Map<string, Array<SeoNode>>();\n for (const node of graph.nodes.values()) {\n if (!isInstance(node)) continue;\n const value = field(node)?.trim();\n if (!value) continue;\n const bucket = groups.get(value);\n if (bucket) bucket.push(node);\n else groups.set(value, [node]);\n }\n return groups;\n};\n\nconst DESCRIPTION_MAX = 160;\nconst DESCRIPTION_MIN = 50;\n\n/**\n * Every check, in one place. `checkGraph` runs them in order and stamps each\n * finding with its rule name and severity, so the output is grouped by rule and\n * deterministic (nodes iterate in graph insertion order, edges in array order).\n */\nconst CHECK_RULES: ReadonlyArray<CheckRule> = [\n {\n name: \"path-owner-collision\",\n severity: \"structural\",\n evaluate: (graph) =>\n (graph.collisions ?? []).map((collision) => ({\n path: collision.path,\n message: `Canonical path \"${collision.path}\" is owned by multiple sources: ${collision.sources.join(\", \")}.`,\n fix: \"Give every concrete page one canonical path and one graph owner.\",\n })),\n },\n {\n name: \"canonical-path-collision\",\n severity: \"structural\",\n evaluate: (graph) => {\n const groups = new Map<string, Array<string>>();\n for (const path of graph.nodes.keys()) {\n const canonical = path.toLowerCase().replace(/\\/$/, \"\") || \"/\";\n const paths = groups.get(canonical);\n if (paths) paths.push(path);\n else groups.set(canonical, [path]);\n }\n return [...groups.values()]\n .filter((paths) => paths.length > 1)\n .flatMap((paths) =>\n paths.map((path) => ({\n path,\n message: `Canonical path collides with ${paths.filter((candidate) => candidate !== path).join(\", \")}.`,\n fix: \"Use one lowercase, trailing-slash-normalized canonical path.\",\n })),\n );\n },\n },\n {\n name: \"self-edge\",\n severity: \"structural\",\n evaluate: (graph) =>\n graph.edges\n .filter((edge) => edge.from === edge.to)\n .map((edge) => ({\n path: edge.from,\n message: `${edge.type} edge points back to its own source node.`,\n fix: \"Remove the self-reference from the canonical manifest or route declaration.\",\n })),\n },\n {\n name: \"duplicate-edge\",\n severity: \"structural\",\n evaluate: (graph) => {\n const seen = new Set<string>();\n const duplicates: Array<RawViolation> = [];\n for (const edge of graph.edges) {\n const key = `${edge.from}\\u0000${edge.to}\\u0000${edge.type}`;\n if (seen.has(key)) {\n duplicates.push({\n path: edge.from,\n message: `Duplicate ${edge.type} edge from \"${edge.from}\" to \"${edge.to}\".`,\n fix: \"Declare each graph relationship exactly once.\",\n });\n } else {\n seen.add(key);\n }\n }\n return duplicates;\n },\n },\n {\n // A `related` or `redirect` edge points at a path with no node — the target\n // route/page was renamed or deleted and the declaration wasn't updated.\n name: \"dead-edge\",\n severity: \"structural\",\n evaluate: (graph) =>\n graph.edges\n .filter((edge) => edge.type !== \"crumb-parent\" && !graph.nodes.has(edge.to))\n .map((edge) => ({\n path: edge.from,\n message: `${edge.type} edge from \"${edge.from}\" points at \"${edge.to}\", which is not a node in the graph.`,\n fix: `Update the ${edge.type === \"redirect\" ? \"redirectTo\" : \"related\"} target on the \"${edge.from}\" route, or restore \"${edge.to}\".`,\n })),\n },\n {\n // A content instance with no usable title can't render a legible <title> or card.\n name: \"instance-missing-title\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter((node) => isInstance(node) && !node.instance?.title.trim())\n .map((node) => ({\n path: node.path,\n message: `Content page \"${node.path}\" has no title.`,\n fix: \"Add a `title` to the page frontmatter.\",\n })),\n },\n {\n // The declaration asks for the page to be in the sitemap yet also marks it\n // noindex — contradictory intent. The projection resolves it (noindex wins,\n // excluded), but the declaration should say one thing.\n name: \"sitemap-noindex-contradiction\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) =>\n hasPositiveSitemap(node.policy.sitemap) &&\n node.policy.robots?.toLowerCase().includes(\"noindex\"),\n )\n .map((node) => ({\n path: node.path,\n message: `\"${node.path}\" declares a sitemap policy but its robots value is \"${node.policy.robots}\".`,\n fix: \"Drop the sitemap policy (or set `sitemap: false`) on a noindex page, or remove the noindex robots value.\",\n })),\n },\n {\n // Robots declarations are house-convention lowercase: the sitemap projection\n // matches `includes(\"noindex\")` literally, so a miscased value (\"Noindex\")\n // would silently stay sitemap-eligible. This gate makes that unrepresentable.\n name: \"robots-not-lowercase\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) =>\n node.policy.robots !== undefined &&\n node.policy.robots !== node.policy.robots.toLowerCase(),\n )\n .map((node) => ({\n path: node.path,\n message: `\"${node.path}\" declares robots \"${node.policy.robots}\" — robots values must be lowercase.`,\n fix: 'Lowercase the robots declaration (e.g. \"noindex, follow\").',\n })),\n },\n {\n // A `related` card for a route target renders from that route's `link`\n // metadata; without it the card has no title/description and renders empty.\n // (Content-instance targets render from their frontmatter, so they're exempt.)\n name: \"related-target-missing-link\",\n severity: \"structural\",\n evaluate: (graph) => {\n const linklessTargets = new Set<string>();\n for (const edge of graph.edges) {\n if (edge.type !== \"related\") continue;\n const target = graph.nodes.get(edge.to);\n if (target && target.source === \"route\" && target.policy.link === undefined) {\n linklessTargets.add(edge.to);\n }\n }\n return [...linklessTargets].map((path) => ({\n path,\n message: `Route \"${path}\" is a related-link target but declares no link metadata; its card would render empty.`,\n fix: `Add \\`link: { title, description }\\` to the \"${path}\" route's staticData.seo.`,\n }));\n },\n },\n {\n // A redirect/alias node should never advertise itself in the sitemap.\n name: \"redirect-in-sitemap\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()]\n .filter(\n (node) => node.policy.redirectTo !== undefined && hasPositiveSitemap(node.policy.sitemap),\n )\n .map((node) => ({\n path: node.path,\n message: `Redirect \"${node.path}\" (→ \"${node.policy.redirectTo}\") also declares a sitemap policy.`,\n fix: \"Remove the sitemap policy from the redirect route; only its target belongs in the sitemap.\",\n })),\n },\n {\n // Every declared date feeds the sitemap's `<lastmod>`, and the sitemap\n // projection refuses a date it cannot parse. Catch it here, at the\n // declaration, instead of as a failed sitemap request.\n name: \"invalid-date\",\n severity: \"structural\",\n evaluate: (graph) =>\n [...graph.nodes.values()].flatMap((node) => {\n const dates: Array<[string, string | undefined]> = node.instance\n ? [\n [\"publishedAt\", node.instance.publishedAt],\n [\"modifiedAt\", node.instance.modifiedAt],\n ]\n : [[\"modifiedAt\", node.policy.modifiedAt]];\n return dates.flatMap(([field, value]) =>\n value !== undefined && parseDeclaredDate(value) === undefined\n ? [\n {\n path: node.path,\n message: `${field} \"${value}\" is not an ISO 8601 date on a real calendar day.`,\n fix: `Write ${field} as an ISO 8601 date, e.g. \"2026-09-29\".`,\n },\n ]\n : [],\n );\n }),\n },\n {\n name: \"duplicate-title\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...groupInstancesBy(graph, (node) => node.instance?.title).entries()]\n .filter(([, nodes]) => nodes.length > 1)\n .flatMap(([title, nodes]) =>\n nodes.map((node) => ({\n path: node.path,\n message: `Title \"${title}\" is shared by ${nodes.length} pages.`,\n fix: \"Give each page a distinct title.\",\n })),\n ),\n },\n {\n name: \"duplicate-description\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...groupInstancesBy(graph, (node) => node.instance?.description).entries()]\n .filter(([, nodes]) => nodes.length > 1)\n .flatMap(([, nodes]) =>\n nodes.map((node) => ({\n path: node.path,\n message: `Description is shared by ${nodes.length} pages.`,\n fix: \"Write a distinct meta description for each page.\",\n })),\n ),\n },\n {\n // Meta descriptions outside ~50–160 chars either get truncated in SERPs or\n // read as too thin.\n name: \"description-length\",\n severity: \"editorial\",\n evaluate: (graph) =>\n [...graph.nodes.values()].flatMap((node) => {\n if (!isInstance(node)) return [];\n const description = node.instance?.description?.trim();\n if (!description) return [];\n if (description.length > DESCRIPTION_MAX) {\n return [\n {\n path: node.path,\n message: `Description is ${description.length} chars (max ${DESCRIPTION_MAX}); it will be truncated in results.`,\n fix: `Trim the description to ${DESCRIPTION_MAX} characters or fewer.`,\n },\n ];\n }\n if (description.length < DESCRIPTION_MIN) {\n return [\n {\n path: node.path,\n message: `Description is ${description.length} chars (min ${DESCRIPTION_MIN}); it reads as thin.`,\n fix: `Expand the description to at least ${DESCRIPTION_MIN} characters.`,\n },\n ];\n }\n return [];\n }),\n },\n];\n\n/**\n * Options for {@link checkGraph}. Freshness needs a clock, and the engine stays\n * pure, so a freshness policy is only accepted together with the `now` it is\n * judged against.\n */\nexport type CheckGraphOptions = {\n readonly coverage?: ReadonlyArray<CoverageRule> | undefined;\n} & (\n | { readonly freshness: FreshnessPolicy; readonly now: Date }\n | { readonly freshness?: undefined; readonly now?: undefined }\n);\n\n/**\n * Run every static rule against the graph, then any caller-supplied\n * {@link CoverageRule}s and freshness policy, and return the flat list of\n * violations. With no options the result is exactly the static rule set.\n */\nexport function checkGraph(graph: SeoGraph, options: CheckGraphOptions = {}): Array<Violation> {\n const violations: Array<Violation> = CHECK_RULES.flatMap((rule) =>\n rule.evaluate(graph).map((raw): Violation => ({\n severity: rule.severity,\n rule: rule.name,\n path: raw.path,\n message: raw.message,\n fix: raw.fix,\n })),\n );\n const coverage = options.coverage;\n if (coverage !== undefined && coverage.length > 0) {\n violations.push(...checkCoverage(graph, coverage));\n }\n if (options.freshness !== undefined) {\n violations.push(...checkFreshness(graph, options.freshness, options.now));\n }\n return violations;\n}\n\n/**\n * One editorial `stale-page` violation per sitemap-eligible page whose last\n * declared change is older than the policy allows. Undated pages are not\n * violations: see {@link freshnessReport} for the full picture.\n */\nexport function checkFreshness(\n graph: SeoGraph,\n policy: FreshnessPolicy,\n now: Date,\n): Array<Violation> {\n return freshnessReport(graph, policy, now).stale.map((entry) => ({\n severity: \"editorial\",\n rule: \"stale-page\",\n path: entry.path,\n message: `Last changed ${entry.lastModified.slice(0, 10)}, ${entry.ageDays} days ago (limit ${policy.maxAgeDays}).`,\n fix: \"Review the page; when its content changes, update its modifiedAt.\",\n }));\n}\n\n/** Escape a glob for `RegExp`, then expand `**`, `*`, and `?` to path-aware forms. */\nexport const globToRegExp = (glob: string): RegExp => {\n const escaped = glob.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const source = escaped\n .replace(/\\*\\*/g, \"\\u0000\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/\\?/g, \"[^/]\")\n .replace(/\\u0000/g, \".*\");\n return new RegExp(`^${source}$`);\n};\n\n/**\n * The minimal view a coverage rule needs: which paths exist (for the glob), which\n * of them are sitemap-eligible (the enforced set), and how many contextual links\n * each receives. Declared and rendered coverage differ only in how this surface\n * is built, so the rule engine itself stays single-sourced.\n */\ninterface CoverageSurface {\n readonly paths: ReadonlyArray<string>;\n readonly eligiblePaths: ReadonlyArray<string>;\n readonly inbound: (path: string) => number;\n}\n\n/**\n * Enforce contextual-link coverage rules over an explicit surface.\n *\n * A rule that matches no sitemap-eligible page is itself a violation: a typo or\n * a rule aimed at a noindex page would otherwise pass silently forever.\n */\nconst checkCoverageRules = (\n surface: CoverageSurface,\n rules: ReadonlyArray<CoverageRule>,\n): Array<Violation> => {\n const violations: Array<Violation> = [];\n for (const rule of rules) {\n const matcher = globToRegExp(rule.path);\n const matched = surface.paths.filter((path) => matcher.test(path));\n const eligible = surface.eligiblePaths.filter((path) => matcher.test(path));\n\n if (eligible.length === 0) {\n violations.push({\n severity: \"structural\",\n rule: \"coverage-rule-unmatched\",\n message:\n matched.length === 0\n ? `Coverage rule \"${rule.path}\" matches no page in the graph.`\n : `Coverage rule \"${rule.path}\" matches only pages that are not sitemap-eligible.`,\n fix: \"Point the rule at a sitemap-eligible path, or drop it.\",\n });\n continue;\n }\n\n for (const path of eligible) {\n const inbound = surface.inbound(path);\n if (inbound >= rule.minInbound) continue;\n violations.push({\n severity: \"structural\",\n rule: \"inbound-link-coverage\",\n path,\n message: `\"${path}\" has ${inbound} incoming contextual link(s); the coverage rule requires ${rule.minInbound}.`,\n fix: `Add ${rule.minInbound - inbound} contextual link(s) pointing at \"${path}\".`,\n });\n }\n }\n return violations;\n};\n\n/** The sitemap-eligible path set of a declared graph, in graph insertion order. */\nconst eligiblePathsOf = (graph: SeoGraph): ReadonlyArray<string> =>\n [...graph.nodes.values()].filter(isSitemapEligible).map((node) => node.path);\n\n/**\n * Enforce contextual-link coverage against the *declared* graph: only `related`\n * edges count — breadcrumb ancestry is navigation, not context.\n */\nexport function checkCoverage(\n graph: SeoGraph,\n rules: ReadonlyArray<CoverageRule>,\n): Array<Violation> {\n return checkCoverageRules(\n {\n paths: [...graph.nodes.keys()],\n eligiblePaths: eligiblePathsOf(graph),\n inbound: (path) =>\n graph.edges.filter((edge) => edge.type === \"related\" && edge.to === path).length,\n },\n rules,\n );\n}\n\n/**\n * Enforce contextual-link coverage against the *rendered* graph: only same-origin\n * body-region anchors count. Nav, header, and footer anchors are site chrome, so\n * a page linked solely from them has no contextual inbound link — the same\n * distinction the declared pass draws by counting `related` edges alone.\n *\n * The target universe is the declared graph's sitemap-eligible pages: the globs\n * in `seo.config.ts` are written against declared paths, and the crawl is what\n * supplies the served edges. Pass the crawl's `internalEdges` (each edge carries\n * its `region`).\n */\nexport function checkRenderedCoverage(\n graph: SeoGraph,\n renderedEdges: ReadonlyArray<LinkEdge>,\n rules: ReadonlyArray<CoverageRule>,\n): Array<Violation> {\n const inbound = new Map<string, number>();\n for (const edge of renderedEdges) {\n if (edge.region !== \"body\") continue;\n inbound.set(edge.to, (inbound.get(edge.to) ?? 0) + 1);\n }\n return checkCoverageRules(\n {\n paths: [...graph.nodes.keys()],\n eligiblePaths: eligiblePathsOf(graph),\n inbound: (path) => inbound.get(path) ?? 0,\n },\n rules,\n );\n}\n\n/** Structural violations fail `pagegraph check`; editorial-only stays green. */\nexport const hasStructuralViolations = (violations: ReadonlyArray<Violation>): boolean =>\n violations.some((violation) => violation.severity === \"structural\");\n"],"mappings":";AA8CA,MAAM,aAAa,UACjB,MACG,QAAQ,MAAM,OAAO,CAAC,CACtB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,QAAQ,CAAC,CACvB,QAAQ,MAAM,QAAQ;;;;;;AAO3B,SAAgB,kBAAkB,MAAwB;CACxD,IAAI,KAAK,OAAO,eAAe,KAAA,GAAW,OAAO;CACjD,IAAI,KAAK,OAAO,QAAQ,SAAS,SAAS,GAAG,OAAO;CACpD,IAAI,CAAC,KAAK,OAAO,SAAS,OAAO;CACjC,IAAI,KAAK,KAAK,SAAS,GAAG,GAAG,OAAO;CAC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UAAU;IACV,MAAM;IACN;IACA,SAAS,IAAI,KAAK,QAAQ,QAAQ,2DAA2D,KAAK,WAAW;IAC7G,KAAK,OAAO,KAAK,aAAa,QAAQ,mCAAmC,KAAK;GAChF,CAAC;EACH;CACF;CACA,OAAO;AACT;;AAGA,MAAM,mBAAmB,UACvB,CAAC,GAAG,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,OAAO,iBAAiB,CAAC,CAAC,KAAK,SAAS,KAAK,IAAI;;;;;AAM7E,SAAgB,cACd,OACA,OACkB;CAClB,OAAO,mBACL;EACE,OAAO,CAAC,GAAG,MAAM,MAAM,KAAK,CAAC;EAC7B,eAAe,gBAAgB,KAAK;EACpC,UAAU,SACR,MAAM,MAAM,QAAQ,SAAS,KAAK,SAAS,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC;CAC9E,GACA,KACF;AACF;;;;;;;;;;;;AAaA,SAAgB,sBACd,OACA,eACA,OACkB;CAClB,MAAM,0BAAU,IAAI,IAAoB;CACxC,KAAK,MAAM,QAAQ,eAAe;EAChC,IAAI,KAAK,WAAW,QAAQ;EAC5B,QAAQ,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,EAAE,KAAK,KAAK,CAAC;CACtD;CACA,OAAO,mBACL;EACE,OAAO,CAAC,GAAG,MAAM,MAAM,KAAK,CAAC;EAC7B,eAAe,gBAAgB,KAAK;EACpC,UAAU,SAAS,QAAQ,IAAI,IAAI,KAAK;CAC1C,GACA,KACF;AACF;;AAGA,MAAa,2BAA2B,eACtC,WAAW,MAAM,cAAc,UAAU,aAAa,YAAY"}
|
package/dist/vite.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":["statFile","openFile"],"sources":["../src/vite/index.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { open as openFile, stat as statFile } from \"node:fs/promises\";\nimport { basename, normalize, resolve } from \"node:path\";\n\nimport {\n Generator,\n getConfig,\n type GeneratorEvent,\n type GeneratorPlugin,\n type RouteNode,\n} from \"@tanstack/router-generator\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Derives a route-config module from the parsed TanStack route tree.\n *\n * The route tree is the single source of truth for which paths exist; this\n * plugin projects it into the small config the host consumes at runtime:\n * - `robotsExclusions` — path prefixes disallowed in robots.txt (feed them to\n * `renderRobots`).\n * - `reservedSegments` — top-level path segments the app must not hand out (an\n * org slug, a tenant name). Derived from the full public route surface — the\n * `publicGroups` route groups plus the group-less `extraPublicRoutes` — which\n * is parsed here but not emitted: \"which pages are public\" already has a\n * canonical runtime answer in the SEO graph.\n *\n * It also enforces that every page in `enforceCoverageIn` declares its SEO: a\n * page leaf missing both `staticData` and `head` fails dev startup and build.\n *\n * **Why we run our own Generator.** The parse must come from\n * `@tanstack/router-generator` itself — a second, hand-rolled scanner would\n * drift from TanStack's group/param/layout conventions. But routing our plugin\n * through TanStack Start does not work: `start-plugin-core` builds its own\n * generator-plugin array and drops `router.plugins` on the floor\n * (tanstack/router#7768 — `plugins` is not public API there), and even when\n * forced through, the router unplugin wraps `generator.run()` in\n * `catch (e) { console.error(e) }`, so a plugin can never fail a build.\n *\n * So we instantiate `Generator` ourselves — `config.plugins` is natively\n * honored on our own instance, and because we own the `.run()` call site a\n * coverage violation throws straight out of `buildStart`. Cost: route files are\n * parsed twice at startup (~40 files, milliseconds) — the host's router plugin\n * still owns the real `routeTree.gen.ts`; ours is a shadow parse whose route\n * tree is thrown away (see {@link inMemoryWriteFs}).\n *\n * `onRouteTreeChanged` fires on every generator run, but the config is written\n * only when its content changes, and the output path lives outside the routes\n * directory, so regeneration never feeds back into the watcher.\n */\n\nconst PLUGIN_NAME = \"seo-route-config\";\n\n/** Match a route's group folder (`filePath` is relative to the routes directory). */\nfunction groupOf(filePath: string, groups: ReadonlyArray<string>): string | undefined {\n return groups.find((group) => filePath.startsWith(`${group}/`));\n}\n\n/**\n * A page leaf is a `.tsx` route file that is not a `route.tsx` layout. This\n * excludes layout wrappers, `.ts` server routes (robots.txt / sitemap.xml /\n * markdown mirrors), and any other non-page file — matching the leaves that\n * contribute a crawlable URL.\n */\nfunction isPageLeaf(node: RouteNode): boolean {\n return node.filePath.endsWith(\".tsx\") && basename(node.filePath) !== \"route.tsx\";\n}\n\n/**\n * Convert a group-prefixed routePath (e.g. \"/(marketing)/blog/$slug\") into the\n * public URL form used by route-config (\"/blog/*\"): drop the group segment,\n * collapse the first dynamic/splat segment and everything after it to \"*\", and\n * trim the index trailing slash.\n */\nfunction routePathToPublicUrl(routePath: string): string {\n const stripped = routePath.replace(/^\\/\\([^)]+\\)/, \"\");\n if (stripped === \"\" || stripped === \"/\") return \"/\";\n\n const segments = stripped.split(\"/\");\n const dynamicIndex = segments.findIndex((segment) => segment.startsWith(\"$\"));\n if (dynamicIndex !== -1) {\n return `${segments.slice(0, dynamicIndex).join(\"/\")}/*`;\n }\n\n return stripped.endsWith(\"/\") ? stripped.slice(0, -1) : stripped;\n}\n\n/**\n * First path segment of each route, reserved so it can't be claimed as an org\n * slug. Strip the leading slash and a trailing \"/*\", then take the first\n * segment (\"/features/email\" -> \"features\").\n */\nfunction extractReservedSegments(routes: ReadonlyArray<string>): Array<string> {\n const segments = new Set<string>();\n for (const route of routes) {\n const first = route.replace(/^\\//, \"\").replace(/\\/\\*$/, \"\").split(\"/\")[0];\n if (first) segments.add(first);\n }\n return Array.from(segments).sort();\n}\n\n/**\n * robots.txt disallow prefixes are directory prefixes, so a splat route\n * (\"/reset-password/*\") disallows the whole subtree (\"/reset-password\").\n */\nfunction normalizeRoutePrefix(route: string): string {\n const cleaned = route.replace(/\\/\\*$/, \"\");\n return cleaned === \"\" ? \"/\" : cleaned;\n}\n\ninterface RouteConfigShape {\n robotsExclusions: Array<string>;\n reservedSegments: Array<string>;\n}\n\nfunction deriveRouteConfig(\n routeNodes: ReadonlyArray<RouteNode>,\n options: ResolvedOptions,\n): RouteConfigShape {\n const publicUrls = new Set<string>(options.extraPublicRoutes);\n const disallowedUrls = new Set<string>();\n\n for (const node of routeNodes) {\n const group = groupOf(node.filePath, options.publicGroups);\n if (group === undefined || !isPageLeaf(node) || node.routePath === undefined) continue;\n const url = routePathToPublicUrl(node.routePath);\n publicUrls.add(url);\n if (options.disallowGroups.includes(group)) disallowedUrls.add(url);\n }\n\n const reservedSegments = [\n ...extractReservedSegments([...publicUrls].sort()),\n ...options.reservedExtras,\n ].sort();\n\n const robotsExclusions = [\n ...new Set([...options.alwaysDisallow, ...[...disallowedUrls].map(normalizeRoutePrefix)]),\n ].sort();\n\n return { robotsExclusions, reservedSegments };\n}\n\n/**\n * Every page in an enforced group must declare its search presence. A leaf that\n * passes neither `staticData` (from which the SEO graph reads `staticData.seo`)\n * nor `head` has no path to correct metadata.\n */\nfunction findCoverageViolations(\n routeNodes: ReadonlyArray<RouteNode>,\n options: ResolvedOptions,\n): Array<string> {\n const violations: Array<string> = [];\n for (const node of routeNodes) {\n const group = groupOf(node.filePath, options.enforceCoverageIn);\n if (group === undefined || !isPageLeaf(node)) continue;\n\n const props = node.createFileRouteProps;\n if (props?.has(\"staticData\") || props?.has(\"head\")) continue;\n\n violations.push(`${node.filePath} (${group} page)`);\n }\n return violations;\n}\n\nfunction coverageMessage(violations: ReadonlyArray<string>): string {\n return (\n `[${PLUGIN_NAME}] ${violations.length} page(s) declare neither staticData nor ` +\n `head. Every page in an SEO-enforced route group must declare its SEO — add ` +\n `staticData: { seo: ... } or a head() to each route:\\n - ${violations.join(\"\\n - \")}`\n );\n}\n\nconst HEADER =\n `// Auto-generated by the ${PLUGIN_NAME} Vite plugin.\\n` +\n \"// DO NOT EDIT MANUALLY — regenerated from the route tree on every dev/build.\\n\";\n\nfunction renderRouteConfig(config: RouteConfigShape): string {\n return `${HEADER}\nexport const routeConfig = ${JSON.stringify(config, null, 2)} as const;\n\nexport type RouteConfig = typeof routeConfig;\n`;\n}\n\nfunction routeConfigGeneratorPlugin(options: ResolvedOptions): GeneratorPlugin {\n const { outputPath } = options;\n return {\n name: PLUGIN_NAME,\n init() {\n // The caller passes an explicit absolute output path, so a relocated routes\n // directory can never silently retarget the write. Guard the parent directory\n // here so a bad path fails at startup, not mid-watch.\n if (!existsSync(resolve(outputPath, \"..\"))) {\n throw new Error(\n `[${PLUGIN_NAME}] output directory does not exist: ${resolve(outputPath, \"..\")}`,\n );\n }\n },\n onRouteTreeChanged({ routeNodes }) {\n const violations = findCoverageViolations(routeNodes, options);\n if (violations.length > 0) throw new Error(coverageMessage(violations));\n\n const content = renderRouteConfig(deriveRouteConfig(routeNodes, options));\n const existing = existsSync(outputPath) ? readFileSync(outputPath, \"utf8\") : undefined;\n if (existing !== content) writeFileSync(outputPath, content);\n },\n };\n}\n\n/**\n * A `Generator` filesystem that reads real files but keeps every write in\n * memory, so our shadow parse cannot touch the repo.\n *\n * The Generator writes through `safeFileWrite`: `writeFile(<tmp>)`, then\n * `rename(<tmp>, <dest>)`. Two destinations exist, and neither may land:\n * - the route tree — we point it at a throwaway path and hold it in memory, so\n * the only route tree on disk stays the one the host's router plugin writes;\n * - route source files — the Generator normalizes them (`createFileRoute` ids,\n * code-split transforms). The host's generator already did that with its own\n * config; ours is not the host's, so such a write is dropped rather than\n * allowed to fight it.\n *\n * Reads and stats of real files go to disk, which keeps the Generator's mtime\n * cache honest: a route edited mid-watch is always seen.\n */\nfunction inMemoryWriteFs(routeTreePath: string) {\n const written = new Map<string, { content: string; mtimeMs: bigint }>();\n let clock = 0n;\n const tick = () => (clock += 1n);\n\n return {\n /**\n * The in-memory route tree is invisible to the watcher, so nothing else can\n * mark it stale. Bumping its mtime before each run is what makes the\n * Generator rebuild the tree — and therefore re-fire `onRouteTreeChanged`\n * — on every run, not only when the set of routes changes. Coverage and the\n * derived config depend on route *contents* (`staticData` / `head`), which\n * leave the route tree itself untouched.\n */\n touchRouteTree() {\n const file = written.get(routeTreePath);\n if (file) written.set(routeTreePath, { content: file.content, mtimeMs: tick() });\n },\n fs: {\n async stat(filePath: string) {\n const file = written.get(filePath);\n if (file) return { mtimeMs: file.mtimeMs, mode: 0o100644, uid: 0, gid: 0 };\n const real = await statFile(filePath, { bigint: true });\n return {\n mtimeMs: real.mtimeMs,\n mode: Number(real.mode),\n uid: Number(real.uid),\n gid: Number(real.gid),\n };\n },\n async readFile(filePath: string) {\n const file = written.get(filePath);\n if (file) return { stat: { mtimeMs: file.mtimeMs }, fileContent: file.content };\n if (!existsSync(filePath)) return \"file-not-existing\" as const;\n const handle = await openFile(filePath, \"r\");\n const fileStat = await handle.stat({ bigint: true });\n const fileContent = (await handle.readFile()).toString();\n await handle.close();\n return { stat: { mtimeMs: fileStat.mtimeMs }, fileContent };\n },\n async writeFile(filePath: string, content: string) {\n written.set(filePath, { content, mtimeMs: tick() });\n },\n async rename(oldPath: string, newPath: string) {\n const file = written.get(oldPath);\n written.delete(oldPath);\n // Anything but the throwaway route tree — i.e. a route source file — is\n // dropped here, which is the whole point: this generator never writes.\n if (file && newPath === routeTreePath) {\n written.set(newPath, { content: file.content, mtimeMs: tick() });\n }\n },\n async chmod() {},\n async chown() {},\n },\n };\n}\n\nexport interface SeoRouteConfigOptions {\n /** Absolute path the generated route-config module is written to. */\n outputPath: string;\n /** Route groups whose page leaves form the public surface. Include the parens. */\n publicGroups: ReadonlyArray<string>;\n /** Route groups where every page leaf must declare `staticData` or `head`. */\n enforceCoverageIn: ReadonlyArray<string>;\n /** Route groups whose page paths are disallowed in robots.txt (e.g. auth). */\n disallowGroups?: ReadonlyArray<string> | undefined;\n /** Public routes that live outside any group folder, so nothing discovers them. */\n extraPublicRoutes?: ReadonlyArray<string> | undefined;\n /** Reserved top-level segments that are not route-tree paths (e.g. an api mount). */\n reservedExtras?: ReadonlyArray<string> | undefined;\n /** Prefixes always disallowed in robots.txt, route tree or not. */\n alwaysDisallow?: ReadonlyArray<string> | undefined;\n /** Routes directory, relative to the Vite root. Defaults to `src/routes`. */\n routesDirectory?: string | undefined;\n}\n\ninterface ResolvedOptions {\n outputPath: string;\n publicGroups: ReadonlyArray<string>;\n enforceCoverageIn: ReadonlyArray<string>;\n disallowGroups: ReadonlyArray<string>;\n extraPublicRoutes: ReadonlyArray<string>;\n reservedExtras: ReadonlyArray<string>;\n alwaysDisallow: ReadonlyArray<string>;\n routesDirectory: string;\n}\n\nfunction resolveOptions(options: SeoRouteConfigOptions): ResolvedOptions {\n return {\n outputPath: options.outputPath,\n publicGroups: options.publicGroups,\n enforceCoverageIn: options.enforceCoverageIn,\n disallowGroups: options.disallowGroups ?? [],\n extraPublicRoutes: options.extraPublicRoutes ?? [],\n reservedExtras: options.reservedExtras ?? [],\n alwaysDisallow: options.alwaysDisallow ?? [],\n routesDirectory: options.routesDirectory ?? \"src/routes\",\n };\n}\n\n/**\n * Vite plugin that runs its own `@tanstack/router-generator` instance over the\n * routes directory and derives the route-config module from the result.\n */\nexport function seoRouteConfig(options: SeoRouteConfigOptions): Plugin {\n const resolved = resolveOptions(options);\n\n let generator: Generator | undefined;\n let touchRouteTree: (() => void) | undefined;\n let routesDirectory: string | undefined;\n\n /**\n * A throw here propagates: it fails `vite build` and dev startup, which is\n * the reason we own this call site instead of registering through Start.\n */\n const run = async (event?: GeneratorEvent) => {\n if (generator === undefined || touchRouteTree === undefined) {\n throw new Error(`[${PLUGIN_NAME}] generator was not initialized by configResolved`);\n }\n touchRouteTree();\n await generator.run(event);\n };\n\n return {\n name: PLUGIN_NAME,\n enforce: \"pre\",\n configResolved(config) {\n const root = config.root;\n // The route tree we generate is a byproduct we never want on disk; park it\n // (and the generator's temp files) inside node_modules so a stray write\n // could never show up as a repo change.\n const cacheDirectory = resolve(root, `node_modules/.cache/${PLUGIN_NAME}`);\n routesDirectory = resolve(root, resolved.routesDirectory);\n const generatorConfig = getConfig(\n {\n routesDirectory,\n generatedRouteTree: resolve(cacheDirectory, \"route-tree.gen.ts\"),\n tmpDir: resolve(cacheDirectory, \"tmp\"),\n plugins: [routeConfigGeneratorPlugin(resolved)],\n // The route tree is thrown away — skip its type emission and its\n // prettier pass.\n disableTypes: true,\n enableRouteTreeFormatting: false,\n // The host's generator is the one that reports on the route tree; this\n // second pass over the same files would only echo it.\n disableLogging: true,\n },\n root,\n );\n\n const memory = inMemoryWriteFs(generatorConfig.generatedRouteTree);\n touchRouteTree = memory.touchRouteTree;\n generator = new Generator({ config: generatorConfig, root, fs: memory.fs });\n },\n async buildStart() {\n await run();\n },\n // Vite watches the whole project, but only a route file can change the tree\n // or a route's declared options. Without this guard every CSS/component edit\n // would re-run the generator and its coverage pass (`touchRouteTree` forces\n // a rebuild, so the Generator's own short-circuit can't absorb them).\n async watchChange(id, { event }) {\n const file = normalize(id);\n if (routesDirectory === undefined || !file.startsWith(routesDirectory)) return;\n await run({ path: file, type: event });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,cAAc;;AAGpB,SAAS,QAAQ,UAAkB,QAAmD;CACpF,OAAO,OAAO,MAAM,UAAU,SAAS,WAAW,GAAG,MAAM,EAAE,CAAC;AAChE;;;;;;;AAQA,SAAS,WAAW,MAA0B;CAC5C,OAAO,KAAK,SAAS,SAAS,MAAM,KAAK,SAAS,KAAK,QAAQ,MAAM;AACvE;;;;;;;AAQA,SAAS,qBAAqB,WAA2B;CACvD,MAAM,WAAW,UAAU,QAAQ,gBAAgB,EAAE;CACrD,IAAI,aAAa,MAAM,aAAa,KAAK,OAAO;CAEhD,MAAM,WAAW,SAAS,MAAM,GAAG;CACnC,MAAM,eAAe,SAAS,WAAW,YAAY,QAAQ,WAAW,GAAG,CAAC;CAC5E,IAAI,iBAAiB,IACnB,OAAO,GAAG,SAAS,MAAM,GAAG,YAAY,CAAC,CAAC,KAAK,GAAG,EAAE;CAGtD,OAAO,SAAS,SAAS,GAAG,IAAI,SAAS,MAAM,GAAG,EAAE,IAAI;AAC1D;;;;;;AAOA,SAAS,wBAAwB,QAA8C;CAC7E,MAAM,2BAAW,IAAI,IAAY;CACjC,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAA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