@tenphi/docs 0.27.0 → 0.30.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-DsyXFFAO.js","names":["parseYaml","inside","parseYaml"],"sources":["../src/html/index.ts","../src/graph/openapi.ts","../src/npm/index.ts","../src/graph/index.ts","../src/validation/index.ts","../src/content/index.ts"],"sourcesContent":["import type { Root } from \"hast\";\nimport { fromHtml } from \"hast-util-from-html\";\nimport { defaultSchema, sanitize } from \"hast-util-sanitize\";\nimport { toHtml } from \"hast-util-to-html\";\nimport { visit } from \"unist-util-visit\";\n\nconst schema = {\n ...defaultSchema,\n strip: [\"script\", \"style\", \"iframe\", \"object\", \"embed\", \"template\"],\n protocols: {\n ...defaultSchema.protocols,\n href: [...(defaultSchema.protocols?.href ?? []), \"source\"],\n },\n attributes: {\n ...defaultSchema.attributes,\n \"*\":\n defaultSchema.attributes?.[\"*\"]?.filter(\n (attribute) =>\n typeof attribute !== \"string\" ||\n ![\n \"color\",\n \"bgColor\",\n \"align\",\n \"border\",\n \"cellPadding\",\n \"cellSpacing\",\n ].includes(attribute),\n ) ?? [],\n },\n};\n\n/** Sanitize raw Markdown HTML while preserving separate inline opening/closing tags. */\nexport async function sanitizeMarkup(\n html: string,\n rewrite: (url: string, kind: \"link\" | \"image\") => Promise<string>,\n): Promise<string> {\n const closing = /^<\\/([a-z][a-z\\d-]*)\\s*>$/i.exec(html.trim());\n if (closing) {\n const tag = closing[1]?.toLowerCase() ?? \"\";\n return schema.tagNames?.includes(tag) ? `</${tag}>` : \"\";\n }\n const tree = sanitize(fromHtml(html, { fragment: true }), schema) as Root;\n const tasks: Promise<void>[] = [];\n visit(tree, \"element\", (element) => {\n for (const [property, kind] of [\n [\"href\", \"link\"],\n [\"src\", \"image\"],\n ] as const) {\n const value = element.properties[property];\n if (typeof value !== \"string\") continue;\n tasks.push(\n rewrite(value, kind).then((resolved) => {\n element.properties[property] = resolved;\n }),\n );\n }\n });\n await Promise.all(tasks);\n let result = toHtml(tree);\n // mdast represents inline <strong>text</strong> as three distinct nodes.\n const opening =\n /^<([a-z][a-z\\d-]*)(?:\\s+(?:[^<>\"']|\"[^\"]*\"|'[^']*')*)?\\s*>$/i.exec(\n html.trim(),\n );\n const first = tree.children[0];\n if (\n opening &&\n tree.children.length === 1 &&\n first?.type === \"element\" &&\n first.tagName === opening[1]?.toLowerCase() &&\n first.children.length === 0\n ) {\n result = result.replace(new RegExp(`</${first.tagName}>$`), \"\");\n }\n return result;\n}\n","import { parse as parseYaml } from \"yaml\";\n\nexport interface OpenApiPage {\n route: string;\n sourcePath: string;\n title: string;\n description?: string;\n body: string;\n}\n\ntype Data = Record<string, unknown>;\n\nconst METHODS = [\n \"get\",\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n \"head\",\n \"options\",\n \"trace\",\n];\n\n/** Turn a local OpenAPI 3 document into static, searchable Markdown pages. */\nexport function openApiPages(\n source: string,\n routeBase: string,\n text: string,\n): OpenApiPage[] {\n let document: unknown;\n try {\n document = source.endsWith(\".json\")\n ? JSON.parse(text)\n : parseYaml(text, { uniqueKeys: true });\n } catch (error) {\n throw new Error(`Invalid OpenAPI document ${source}: ${String(error)}`);\n }\n if (\n !record(document) ||\n typeof document.openapi !== \"string\" ||\n !document.openapi.startsWith(\"3.\")\n ) {\n throw new Error(`OpenAPI source ${source} must use OpenAPI 3.x.`);\n }\n if (\n !record(document.info) ||\n typeof document.info.title !== \"string\" ||\n !record(document.paths)\n ) {\n throw new Error(`OpenAPI source ${source} needs info.title and paths.`);\n }\n assertLocalReferences(document, document, source);\n\n const title = document.info.title;\n const description = string(document.info.description);\n const operations: Array<{\n method: string;\n path: string;\n operation: Data;\n route: string;\n title: string;\n }> = [];\n const routes = new Set<string>([routeBase]);\n for (const [path, rawItem] of Object.entries(document.paths)) {\n const item = resolveReference(rawItem, document);\n if (!path.startsWith(\"/\") || !record(item))\n throw new Error(`Invalid OpenAPI path ${path} in ${source}.`);\n for (const method of METHODS) {\n const operation = item[method];\n if (operation === undefined) continue;\n if (!record(operation))\n throw new Error(\n `Invalid ${method.toUpperCase()} ${path} in ${source}.`,\n );\n const name = string(operation.operationId) ?? `${method}-${path}`;\n const slug = slugify(name);\n if (!slug)\n throw new Error(\n `Cannot generate a route for ${method.toUpperCase()} ${path} in ${source}.`,\n );\n const route = `${routeBase === \"/\" ? \"\" : routeBase}/${slug}`;\n if (routes.has(route))\n throw new Error(\n `Duplicate OpenAPI operation route ${route} in ${source}. Give operations distinct operationId values.`,\n );\n routes.add(route);\n operations.push({\n method,\n path,\n operation,\n route,\n title: string(operation.summary) ?? `${method.toUpperCase()} ${path}`,\n });\n }\n }\n\n const overview: string[] = [`# ${escapeText(title)}`, \"\"];\n if (description) overview.push(description, \"\");\n if (typeof document.info.version === \"string\")\n overview.push(`**API version:** ${escapeText(document.info.version)}`, \"\");\n if (Array.isArray(document.servers) && document.servers.length) {\n overview.push(\"## Servers\", \"\");\n for (const server of document.servers) {\n if (record(server) && typeof server.url === \"string\")\n overview.push(\n `- \\`${escapeCode(server.url)}\\`${string(server.description) ? ` — ${escapeText(server.description as string)}` : \"\"}`,\n );\n }\n overview.push(\"\");\n }\n overview.push(\"## Operations\", \"\");\n for (const operation of operations)\n overview.push(\n `- [${escapeText(operation.method.toUpperCase())} ${escapeText(operation.path)} — ${escapeText(operation.title)}](${operation.route})`,\n );\n if (!operations.length) overview.push(\"No operations are defined.\");\n overview.push(\"\");\n\n const schemas =\n record(document.components) && record(document.components.schemas)\n ? document.components.schemas\n : undefined;\n if (schemas && Object.keys(schemas).length) {\n overview.push(\"## Schemas\", \"\");\n for (const [name, schema] of Object.entries(schemas)) {\n overview.push(`### ${escapeText(name)}`, \"\", jsonBlock(schema), \"\");\n }\n }\n const pages: OpenApiPage[] = [\n {\n route: routeBase,\n sourcePath: `${source}#overview.md`,\n title,\n ...(description ? { description } : {}),\n body: overview.join(\"\\n\"),\n },\n ];\n for (const {\n method,\n path,\n operation,\n route,\n title: operationTitle,\n } of operations) {\n const body: string[] = [\n `# ${escapeText(operationTitle)}`,\n \"\",\n `**${method.toUpperCase()}** \\`${escapeCode(path)}\\``,\n \"\",\n `[All operations](${routeBase})`,\n \"\",\n ];\n if (string(operation.description))\n body.push(operation.description as string, \"\");\n if (Array.isArray(operation.tags) && operation.tags.length)\n body.push(\n `**Tags:** ${operation.tags\n .filter((tag): tag is string => typeof tag === \"string\")\n .map(escapeText)\n .join(\", \")}`,\n \"\",\n );\n const pathItem = resolveReference(document.paths[path], document) as Data;\n const parameters = mergeParameters(\n pathItem.parameters,\n operation.parameters,\n document,\n );\n renderSecurity(\n body,\n operation.security !== undefined ? operation.security : document.security,\n document,\n );\n if (parameters.length) {\n body.push(\n \"## Parameters\",\n \"\",\n \"| Name | In | Required | Description |\",\n \"| --- | --- | --- | --- |\",\n );\n for (const item of parameters) {\n const schema = record(item.schema)\n ? ` (${schemaLabel(item.schema)})`\n : \"\";\n body.push(\n `| ${tableCell(string(item.name) ?? \"—\")} | ${tableCell(string(item.in) ?? \"—\")} | ${item.required === true ? \"Yes\" : \"No\"} | ${tableCell(`${string(item.description) ?? \"\"}${schema}`)} |`,\n );\n }\n body.push(\"\");\n for (const item of parameters) {\n if (\"example\" in item || \"examples\" in item || \"content\" in item) {\n body.push(\n `### ${escapeText(String(item.name))} (${escapeText(String(item.in))})`,\n \"\",\n );\n renderExamples(body, item, document);\n renderContent(body, item.content, document);\n }\n }\n }\n if (operation.requestBody !== undefined) {\n const request = resolveReference(operation.requestBody, document);\n if (record(request)) {\n body.push(\"## Request body\", \"\");\n if (string(request.description))\n body.push(request.description as string, \"\");\n body.push(\n `**Required:** ${request.required === true ? \"Yes\" : \"No\"}`,\n \"\",\n );\n renderContent(body, request.content, document);\n }\n }\n if (record(operation.responses)) {\n body.push(\"## Responses\", \"\");\n for (const [status, value] of Object.entries(operation.responses)) {\n const response = resolveReference(value, document);\n if (!record(response)) continue;\n body.push(\n `### ${escapeText(status)}${string(response.description) ? ` — ${escapeText(response.description as string)}` : \"\"}`,\n \"\",\n );\n renderContent(body, response.content, document);\n }\n }\n pages.push({\n route,\n sourcePath: `${source}#${route.split(\"/\").at(-1)}.md`,\n title: operationTitle,\n ...(string(operation.description)\n ? { description: operation.description as string }\n : {}),\n body: body.join(\"\\n\"),\n });\n }\n return pages;\n}\n\nfunction mergeParameters(\n path: unknown,\n operation: unknown,\n document: Data,\n): Data[] {\n const merged = new Map<string, Data>();\n for (const list of [path, operation]) {\n if (list === undefined) continue;\n if (!Array.isArray(list))\n throw new Error(\"OpenAPI parameters must be an array.\");\n const seen = new Set<string>();\n for (const value of list) {\n const item = resolveReference(value, document);\n if (\n !record(item) ||\n !string(item.name) ||\n ![\"query\", \"header\", \"path\", \"cookie\"].includes(String(item.in))\n )\n throw new Error(\n \"OpenAPI parameters need a name and a valid in location.\",\n );\n const identity = JSON.stringify([item.name, item.in]);\n if (seen.has(identity))\n throw new Error(\n `Duplicate OpenAPI parameter ${item.name} in ${item.in}.`,\n );\n seen.add(identity);\n merged.set(identity, item);\n }\n }\n return [...merged.values()];\n}\n\nfunction renderContent(\n lines: string[],\n content: unknown,\n document: Data,\n): void {\n if (!record(content)) return;\n for (const [mediaType, media] of Object.entries(content)) {\n lines.push(`#### ${escapeText(mediaType)}`, \"\");\n if (record(media) && media.schema !== undefined)\n lines.push(jsonBlock(media.schema), \"\");\n if (record(media)) renderExamples(lines, media, document);\n }\n}\n\nfunction renderExamples(lines: string[], owner: Data, document: Data): void {\n if (\"example\" in owner)\n lines.push(\"**Example**\", \"\", jsonBlock(owner.example), \"\");\n if (!record(owner.examples)) return;\n for (const [name, raw] of Object.entries(owner.examples)) {\n const example = resolveReference(raw, document);\n if (!record(example))\n throw new Error(`OpenAPI example ${name} must be an Example Object.`);\n lines.push(`**Example: ${escapeText(name)}**`, \"\");\n if (string(example.summary))\n lines.push(escapeText(example.summary as string), \"\");\n if (string(example.description))\n lines.push(example.description as string, \"\");\n if (\"value\" in example) lines.push(jsonBlock(example.value), \"\");\n if (string(example.externalValue)) {\n const url = example.externalValue as string;\n // External examples are linked, never downloaded during a build.\n lines.push(\n /^https?:\\/\\/[^\\s<>]+$/i.test(url)\n ? `[External example](<${url}>)`\n : `External example: ${escapeText(url)}`,\n \"\",\n );\n }\n }\n}\n\nfunction renderSecurity(\n lines: string[],\n security: unknown,\n document: Data,\n): void {\n lines.push(\"## Authentication\", \"\");\n if (security === undefined || (Array.isArray(security) && !security.length)) {\n lines.push(\"No authentication required.\", \"\");\n return;\n }\n if (!Array.isArray(security))\n throw new Error(\"OpenAPI security must be an array.\");\n const schemes =\n record(document.components) && record(document.components.securitySchemes)\n ? document.components.securitySchemes\n : {};\n if (security.length > 1) lines.push(\"Use any one of these alternatives:\", \"\");\n for (const [index, requirement] of security.entries()) {\n if (!record(requirement))\n throw new Error(\"OpenAPI security requirements must be objects.\");\n if (security.length > 1) lines.push(`### Alternative ${index + 1}`, \"\");\n const names = Object.keys(requirement);\n if (!names.length) {\n lines.push(\"No authentication required (anonymous access).\", \"\");\n continue;\n }\n if (names.length > 1)\n lines.push(\"All of the following are required together:\", \"\");\n for (const name of names) {\n const scheme = resolveReference(schemes[name], document);\n if (!record(scheme))\n throw new Error(`Unknown OpenAPI security scheme: ${name}.`);\n const scopes = requirement[name];\n if (\n !Array.isArray(scopes) ||\n scopes.some((scope) => typeof scope !== \"string\")\n )\n throw new Error(`OpenAPI security scopes for ${name} must be strings.`);\n let detail = string(scheme.type) ?? \"security scheme\";\n if (scheme.type === \"http\")\n detail = `HTTP ${string(scheme.scheme) ?? \"authentication\"}${string(scheme.bearerFormat) ? ` (${scheme.bearerFormat})` : \"\"}`;\n else if (scheme.type === \"apiKey\")\n detail = `API key ${string(scheme.name) ?? name} in ${string(scheme.in) ?? \"request\"}`;\n else if (scheme.type === \"oauth2\") detail = \"OAuth 2.0\";\n else if (scheme.type === \"openIdConnect\") detail = \"OpenID Connect\";\n else if (scheme.type === \"mutualTLS\") detail = \"Mutual TLS\";\n lines.push(\n `- **${escapeText(name)}:** ${escapeText(detail)}${scopes.length ? `. Required scopes: ${scopes.map((scope) => escapeText(String(scope))).join(\", \")}` : \"\"}`,\n );\n if (string(scheme.description))\n lines.push(\"\", scheme.description as string, \"\");\n }\n lines.push(\"\");\n }\n}\n\nfunction assertLocalReferences(\n value: unknown,\n document: Data,\n source: string,\n seen = new Set<object>(),\n): void {\n if (typeof value !== \"object\" || value === null || seen.has(value)) return;\n seen.add(value);\n if (Array.isArray(value)) {\n for (const item of value)\n assertLocalReferences(item, document, source, seen);\n } else {\n for (const [key, item] of Object.entries(value)) {\n if (\n key === \"$ref\" &&\n (typeof item !== \"string\" || !item.startsWith(\"#/\"))\n )\n throw new Error(\n `OpenAPI source ${source} has an external or invalid $ref; bundle references into the document first.`,\n );\n if (\n key === \"$ref\" &&\n typeof item === \"string\" &&\n lookupReference(item, document) === undefined\n )\n throw new Error(\n `OpenAPI source ${source} has an unresolved reference: ${item}.`,\n );\n if ([\"example\", \"default\", \"const\", \"enum\"].includes(key)) continue;\n if (key === \"examples\") {\n if (record(item))\n for (const example of Object.values(item)) {\n if (record(example)) {\n const { value: _payload, ...metadata } = example;\n assertLocalReferences(metadata, document, source, seen);\n }\n }\n continue;\n }\n if (key === \"properties\" && record(item)) {\n for (const schema of Object.values(item))\n assertLocalReferences(schema, document, source, seen);\n continue;\n }\n assertLocalReferences(item, document, source, seen);\n }\n }\n}\n\nfunction resolveReference(value: unknown, document: Data): unknown {\n const visited = new Set<string>();\n const overrides: Data = {};\n while (record(value) && typeof value.$ref === \"string\") {\n for (const key of [\"summary\", \"description\"])\n if (!(key in overrides) && typeof value[key] === \"string\")\n overrides[key] = value[key];\n const ref = value.$ref;\n if (visited.has(ref))\n throw new Error(`Circular OpenAPI reference: ${ref}.`);\n visited.add(ref);\n value = lookupReference(ref, document);\n if (value === undefined)\n throw new Error(`Unresolved OpenAPI reference: ${ref}.`);\n }\n return record(value) ? { ...value, ...overrides } : value;\n}\n\nfunction lookupReference(ref: string, document: Data): unknown {\n return decodeURIComponent(ref.slice(2))\n .split(\"/\")\n .reduce<unknown>(\n (current, part) =>\n record(current) || Array.isArray(current)\n ? (current as Record<string, unknown>)[\n part.replace(/~1/g, \"/\").replace(/~0/g, \"~\")\n ]\n : undefined,\n document,\n );\n}\n\nfunction record(value: unknown): value is Data {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction string(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length ? value : undefined;\n}\n\nfunction slugify(value: string): string {\n return value\n .normalize(\"NFKD\")\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-|-$/g, \"\");\n}\n\nfunction escapeText(value: string): string {\n return value.replace(/[\\\\`*_\\[\\]<>|]/g, \"\\\\$&\").replace(/\\r?\\n/g, \" \");\n}\n\nfunction escapeCode(value: string): string {\n return value.replace(/`/g, \"\\\\`\").replace(/\\r?\\n/g, \" \");\n}\n\nfunction tableCell(value: string): string {\n return escapeText(value);\n}\n\nfunction schemaLabel(schema: Data): string {\n return typeof schema.$ref === \"string\"\n ? (schema.$ref.split(\"/\").at(-1) ?? \"schema\")\n : (string(schema.type) ?? \"schema\");\n}\n\nfunction jsonBlock(value: unknown): string {\n const body = JSON.stringify(value, null, 2) ?? \"null\";\n let longest = 0;\n for (const [run] of body.matchAll(/`+/g))\n longest = Math.max(longest, run.length);\n const fence = \"`\".repeat(Math.max(3, longest + 1));\n return `${fence}json\\n${body}\\n${fence}`;\n}\n","import { createHash } from \"node:crypto\";\nimport { homedir } from \"node:os\";\nimport {\n lstat,\n mkdir,\n mkdtemp,\n readFile,\n readdir,\n rename,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport npa from \"npm-package-arg\";\nimport pacote from \"pacote\";\nimport { glob } from \"tinyglobby\";\nimport type {\n NormalizedDocsConfig,\n PackageDiscovery,\n PackageLockSource,\n PackageManifest,\n CookbookLock,\n DocsConfig,\n} from \"../types.js\";\n\nconst DEFAULT_REGISTRY = \"https://registry.npmjs.org/\";\nconst LOCK_FILE = \"cookbook.lock.json\";\n\nexport interface ResolvePackageOptions {\n registry?: string;\n cacheDir?: string;\n}\n\nexport async function resolvePackageLock(\n requested: string,\n options: ResolvePackageOptions = {},\n): Promise<PackageLockSource> {\n const parsed = npa(requested);\n if (![\"tag\", \"version\", \"range\"].includes(parsed.type)) {\n throw new Error(\n `Only npm registry package specifiers are supported (received ${parsed.type}).`,\n );\n }\n const registry = options.registry ?? DEFAULT_REGISTRY;\n const manifest = (await pacote.manifest(requested, {\n registry,\n ...(options.cacheDir ? { cache: options.cacheDir } : {}),\n fullMetadata: true,\n })) as PackageManifest;\n if (!manifest.name || !manifest.version || !manifest._integrity) {\n throw new Error(\n `Registry metadata for ${requested} did not include version and integrity.`,\n );\n }\n return {\n requested,\n resolved: `${manifest.name}@${manifest.version}`,\n registry,\n integrity: manifest._integrity,\n };\n}\n\nexport async function readDocsLock(\n root: string,\n): Promise<CookbookLock | undefined> {\n try {\n const value = JSON.parse(\n await readFile(join(root, LOCK_FILE), \"utf8\"),\n ) as CookbookLock;\n validateLock(value);\n return value;\n } catch (error) {\n if (isMissing(error)) return undefined;\n throw error;\n }\n}\n\nexport async function writeDocsLock(\n root: string,\n lock: CookbookLock,\n): Promise<void> {\n validateLock(lock);\n const temporary = await mkdtemp(join(root, \".cookbook-lock-\"));\n try {\n await writeFile(\n join(temporary, LOCK_FILE),\n `${JSON.stringify(lock, null, 2)}\\n`,\n \"utf8\",\n );\n await rename(join(temporary, LOCK_FILE), join(root, LOCK_FILE));\n } finally {\n await rm(temporary, { recursive: true, force: true });\n }\n}\n\n/** Reconcile declarations, including the first lock and removed sources. */\nexport async function reconcileDocsLock(\n config: DocsConfig,\n existing: CookbookLock | undefined,\n options: {\n packages?: string[];\n resolve?: typeof resolvePackageLock;\n } = {},\n): Promise<CookbookLock> {\n const configured = (config.content?.sources ?? []).filter(\n (source) => \"package\" in source,\n );\n const unique = new Map<string, (typeof configured)[number]>();\n for (const declaration of configured) {\n const previous = unique.get(declaration.package);\n if (\n previous?.registry &&\n declaration.registry &&\n previous.registry !== declaration.registry\n )\n throw new Error(\n `Package source ${declaration.package} declares conflicting registries.`,\n );\n unique.set(declaration.package, {\n ...declaration,\n ...(previous?.registry ? { registry: previous.registry } : {}),\n });\n }\n const declarations = [...unique.values()];\n const selectors = options.packages ?? [];\n for (const selector of selectors) {\n if (\n !declarations.some(\n (source) =>\n source.package === selector ||\n packageNameFromSpecifier(source.package) === selector,\n )\n ) {\n throw new Error(`No configured package source matches \"${selector}\".`);\n }\n }\n const sources: PackageLockSource[] = [];\n for (const declaration of declarations) {\n const current = existing?.sources.find(\n (source) => source.requested === declaration.package,\n );\n const selected =\n selectors.length === 0 ||\n selectors.some(\n (selector) =>\n selector === declaration.package ||\n selector === packageNameFromSpecifier(declaration.package),\n );\n if (\n !selected &&\n current &&\n (!declaration.registry || declaration.registry === current.registry)\n ) {\n sources.push(current);\n continue;\n }\n if (!selected)\n throw new Error(\n `Package source ${declaration.package} is not locked. Run \"cookbook update\" without a package selector.`,\n );\n const previous =\n current ??\n existing?.sources.find(\n (source) =>\n packageNameFromSpecifier(source.requested) ===\n packageNameFromSpecifier(declaration.package),\n );\n const registry = declaration.registry ?? previous?.registry;\n const next = await (options.resolve ?? resolvePackageLock)(\n declaration.package,\n registry ? { registry } : {},\n );\n if (previous?.vendored) {\n next.vendored =\n next.integrity === previous.integrity\n ? previous.vendored\n : `.cookbook/vendor/${createHash(\"sha256\").update(next.integrity).digest(\"hex\")}`;\n }\n sources.push(next);\n }\n return defaultLock(sources);\n}\n\nexport function validateLock(lock: CookbookLock): void {\n if (lock.schemaVersion !== 1 || !Array.isArray(lock.sources)) {\n throw new Error(\"Unsupported or invalid cookbook.lock.json.\");\n }\n for (const source of lock.sources) {\n if (\n !source.requested ||\n !source.resolved ||\n !source.registry ||\n !source.integrity\n ) {\n throw new Error(\n \"Every lock source requires requested, resolved, registry, and integrity.\",\n );\n }\n const parsed = npa(source.resolved);\n if (parsed.type !== \"version\") {\n throw new Error(\n `Locked source must use an exact version: ${source.resolved}.`,\n );\n }\n if (\n source.vendored &&\n (source.vendored.startsWith(\"/\") ||\n source.vendored.split(/[\\\\/]/).includes(\"..\"))\n ) {\n throw new Error(\n `Vendored package path must stay within the project: ${source.vendored}.`,\n );\n }\n }\n}\n\nexport async function materializePackage(\n source: PackageLockSource,\n config: NormalizedDocsConfig[\"build\"],\n projectRoot?: string,\n): Promise<string> {\n if (source.vendored) {\n if (!projectRoot) {\n throw new Error(\n `Vendored source ${source.resolved} requires a project root.`,\n );\n }\n const vendored = resolve(projectRoot, source.vendored);\n if (!inside(projectRoot, vendored)) {\n throw new Error(\n `Vendored package path escapes the project root: ${source.vendored}.`,\n );\n }\n const marker = (\n await readFile(join(vendored, \".cookbook-integrity\"), \"utf8\")\n ).trim();\n if (marker !== source.integrity) {\n throw new Error(\n `Vendored package integrity marker does not match ${source.resolved}.`,\n );\n }\n await validateExtractedTree(vendored, config);\n return vendored;\n }\n const cacheRoot = resolve(\n config.cacheDir || join(homedir(), \".cache\", \"cookbook\"),\n \"artifacts\",\n );\n const key = createHash(\"sha256\").update(source.integrity).digest(\"hex\");\n const destination = join(cacheRoot, key);\n const marker = join(destination, \".cookbook-integrity\");\n try {\n if ((await readFile(marker, \"utf8\")).trim() === source.integrity) {\n await validateExtractedTree(destination, config);\n return destination;\n }\n } catch (error) {\n if (!isMissing(error)) throw error;\n }\n\n await mkdir(cacheRoot, { recursive: true });\n const temporary = await mkdtemp(join(cacheRoot, \".extract-\"));\n try {\n const tarball = await pacote.tarball(source.resolved, {\n registry: source.registry,\n integrity: source.integrity,\n cache: join(cacheRoot, \"_cacache\"),\n });\n if (tarball.byteLength > config.maxArtifactBytes) {\n throw new Error(\n `Package artifact is ${tarball.byteLength} bytes; limit is ${config.maxArtifactBytes}.`,\n );\n }\n await pacote.extract(source.resolved, temporary, {\n registry: source.registry,\n integrity: source.integrity,\n cache: join(cacheRoot, \"_cacache\"),\n });\n await validateExtractedTree(temporary, config);\n await writeFile(\n join(temporary, \".cookbook-integrity\"),\n `${source.integrity}\\n`,\n );\n await rm(destination, { recursive: true, force: true });\n await rename(temporary, destination);\n return destination;\n } catch (error) {\n await rm(temporary, { recursive: true, force: true });\n throw error;\n }\n}\n\nasync function validateExtractedTree(\n root: string,\n config: NormalizedDocsConfig[\"build\"],\n): Promise<void> {\n let files = 0;\n let bytes = 0;\n const pending = [root];\n while (pending.length > 0) {\n const directory = pending.pop();\n if (!directory) break;\n for (const name of await readdir(directory)) {\n if (name === \".cookbook-integrity\") continue;\n const path = join(directory, name);\n const info = await lstat(path);\n const rel = relative(root, path);\n if (rel.startsWith(`..${sep}`) || rel === \"..\") {\n throw new Error(`Package path escapes artifact root: ${rel}.`);\n }\n if (rel.split(sep).length > config.maxPathDepth) {\n throw new Error(`Package path exceeds maximum depth: ${rel}.`);\n }\n if (info.isSymbolicLink()) {\n throw new Error(`Package symlinks are not allowed: ${rel}.`);\n }\n if (info.isDirectory()) {\n pending.push(path);\n } else if (info.isFile()) {\n files += 1;\n bytes += info.size;\n if (info.size > config.maxAssetBytes) {\n throw new Error(`Package file exceeds maximum size: ${rel}.`);\n }\n if (files > config.maxFiles || bytes > config.maxUnpackedBytes) {\n throw new Error(\n \"Package exceeds configured file-count or unpacked-size limit.\",\n );\n }\n } else {\n throw new Error(`Unsupported package entry type: ${rel}.`);\n }\n }\n }\n}\n\nexport async function discoverPackage(root: string): Promise<PackageDiscovery> {\n const manifest = JSON.parse(\n await readFile(join(root, \"package.json\"), \"utf8\"),\n ) as PackageManifest;\n const hints = manifest.cookbook;\n const homeCandidates = [hints?.index, \"README.md\", \"readme.md\"].filter(\n (candidate): candidate is string => Boolean(candidate),\n );\n let home: string | undefined;\n for (const candidate of homeCandidates) {\n assertSafePackagePath(candidate, \"cookbook.index\");\n try {\n const path = resolve(root, candidate);\n if (!inside(root, path)) {\n throw new Error(\n `cookbook.index escapes the package root: ${candidate}.`,\n );\n }\n if ((await stat(path)).isFile()) {\n home = candidate;\n break;\n }\n } catch (error) {\n if (!isMissing(error)) throw error;\n }\n }\n\n const patterns = hints?.include?.length\n ? hints.include\n : [\n \"docs/**/*.{md,mdx}\",\n \"docs/**/*.{png,jpg,jpeg,gif,webp,avif,svg,pdf,txt,zip}\",\n ];\n for (const pattern of patterns) {\n assertSafePackagePath(pattern, \"cookbook.include\");\n }\n for (const pattern of hints?.exclude ?? []) {\n assertSafePackagePath(pattern, \"cookbook.exclude\");\n }\n const discovered = await glob(patterns, {\n cwd: root,\n onlyFiles: true,\n dot: false,\n ignore: hints?.exclude ?? [],\n });\n for (const path of discovered) {\n assertSafePackagePath(path, \"discovered package path\");\n if (!inside(root, resolve(root, path))) {\n throw new Error(`Discovered path escapes the package root: ${path}.`);\n }\n }\n const pages = discovered.filter((path) => /\\.mdx?$/i.test(path));\n if (home && !pages.includes(home)) pages.unshift(home);\n const assets = discovered.filter((path) => !/\\.mdx?$/i.test(path));\n return { root, manifest, ...(home ? { home } : {}), pages, assets };\n}\n\nexport function packageNameFromSpecifier(specifier: string): string {\n const parsed = npa(specifier);\n if (!parsed.name)\n throw new Error(`Invalid npm package specifier: ${specifier}.`);\n return parsed.name;\n}\n\nexport function lockForSource(\n lock: CookbookLock | undefined,\n requested: string,\n): PackageLockSource {\n const exact = lock?.sources.find((source) => source.requested === requested);\n if (exact) return exact;\n throw new Error(\n `Package source ${requested} is not locked. Run \"cookbook update\" to reconcile ${LOCK_FILE} with docs.config.ts.`,\n );\n}\n\n/** Reject paths and glob patterns that could address files outside a package. */\nexport function assertSafePackagePath(path: string, field: string): void {\n const normalized = path.replaceAll(\"\\\\\", \"/\");\n if (\n path.trim() === \"\" ||\n path.includes(\"\\0\") ||\n isAbsolute(path) ||\n normalized.startsWith(\"/\") ||\n /^[a-z]:\\//i.test(normalized) ||\n normalized.includes(\"..\")\n ) {\n throw new Error(`${field} must stay within the package root: ${path}.`);\n }\n}\n\nexport function defaultLock(sources: PackageLockSource[]): CookbookLock {\n return { schemaVersion: 1, sources };\n}\n\nfunction isMissing(error: unknown): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n );\n}\n\nfunction inside(root: string, path: string): boolean {\n const rel = relative(resolve(root), resolve(path));\n return (\n rel === \"\" ||\n (!rel.startsWith(`..${sep}`) && rel !== \"..\" && !isAbsolute(rel))\n );\n}\n","import { validateTableOfContents } from \"../table-of-contents.js\";\nimport { pagePublishing, routePath, validateSeo } from \"../publishing.js\";\nimport { createHash } from \"node:crypto\";\nimport { execFile } from \"node:child_process\";\nimport { readFile, stat } from \"node:fs/promises\";\nimport {\n basename,\n dirname,\n extname,\n isAbsolute,\n relative,\n resolve,\n sep,\n} from \"node:path\";\nimport { promisify } from \"node:util\";\nimport type { Definition, Image, Link, Root } from \"mdast\";\nimport { glob } from \"tinyglobby\";\nimport { visit } from \"unist-util-visit\";\nimport { parse as parseYaml } from \"yaml\";\nimport { sanitizeMarkup } from \"../html/index.js\";\nimport { openApiPages } from \"./openapi.js\";\nimport { normalizeDocsConfig } from \"../config/index.js\";\nimport {\n cloneAst,\n parseMarkdown,\n removeRenderedTitle,\n serializeMarkdown,\n stripLeadingBadgeBlock,\n} from \"../markdown/index.js\";\nimport {\n assertSafePackagePath,\n discoverPackage,\n lockForSource,\n materializePackage,\n readDocsLock,\n} from \"../npm/index.js\";\nimport type {\n CreateDocsGraphOptions,\n DocsAsset,\n DocsDiagnostic,\n DocsEntry,\n DocsFrontmatter,\n DocsGraph,\n DocsRoute,\n DocsSource,\n NavigationItem,\n NormalizedDocsConfig,\n NavigationPlacement,\n PackageLockSource,\n} from \"../types.js\";\n\ninterface RepositoryMetadata {\n url: string;\n directory?: string;\n}\n\ninterface CollectedSource {\n sourceId: string;\n routeBase?: string;\n absolutePath: string;\n sourcePath: string;\n sourceRoot: string;\n generatedBody?: string;\n editPath?: string;\n route?: string;\n title?: string;\n description?: string;\n navigation?: false | NavigationPlacement;\n trust: \"markdown\" | \"mdx\";\n packageLock?: PackageLockSource;\n repository?: RepositoryMetadata;\n}\n\nconst MARKDOWN_EXTENSIONS = [\".md\", \".mdx\"];\nconst execFileAsync = promisify(execFile);\nexport const DOCS_FRONTMATTER_KEYS = new Set([\n \"seo\",\n \"aliases\",\n \"title\",\n \"description\",\n \"slug\",\n \"draft\",\n \"sidebar\",\n \"tableOfContents\",\n \"editUrl\",\n \"template\",\n \"hero\",\n \"lastUpdated\",\n \"prev\",\n \"next\",\n \"banner\",\n \"pagefind\",\n \"head\",\n]);\n\nexport async function createDocsGraph(\n options: CreateDocsGraphOptions = {},\n): Promise<DocsGraph> {\n const root = resolve(options.root ?? process.cwd());\n const normalized = normalizeDocsConfig(options.config);\n const config: NormalizedDocsConfig = {\n ...normalized,\n build: {\n ...normalized.build,\n ...(options.base ? { base: options.base } : {}),\n ...(options.trailingSlash !== undefined\n ? { trailingSlash: options.trailingSlash }\n : {}),\n },\n };\n const diagnostics: DocsDiagnostic[] = [];\n const lock = options.lock ?? (await readDocsLock(root));\n const collected = await collectSources(root, config, lock, diagnostics);\n const entries: DocsEntry[] = [];\n const routeMap = new Map<string, DocsEntry>();\n const absoluteMap = new Map<string, DocsEntry[]>();\n const sourceMap = new Map<string, DocsEntry[]>();\n const repositoryMap = new Map<string, RepositoryMetadata>();\n\n for (const source of collected) {\n const entry = await readEntry(source, config, diagnostics);\n if (!entry) continue;\n const existing = routeMap.get(entry.route);\n if (existing) {\n diagnostics.push({\n code: \"DOCS_DUPLICATE_ROUTE\",\n severity: \"error\",\n message: `Route ${entry.route} is owned by both ${existing.sourcePath} and ${entry.sourcePath}.`,\n file: entry.sourcePath,\n related: [{ file: existing.sourcePath, message: \"First route owner.\" }],\n });\n continue;\n }\n routeMap.set(entry.route, entry);\n if (source.generatedBody === undefined) {\n const absolute = normalizeFs(entry.absolutePath);\n absoluteMap.set(absolute, [...(absoluteMap.get(absolute) ?? []), entry]);\n }\n sourceMap.set(entry.sourcePath, [\n ...(sourceMap.get(entry.sourcePath) ?? []),\n entry,\n ]);\n sourceMap.set(entry.id, [entry]);\n if (source.repository) repositoryMap.set(entry.id, source.repository);\n entries.push(entry);\n }\n\n if (entries.length === 0) {\n diagnostics.push({\n code: \"DOCS_NO_PAGES\",\n severity: \"error\",\n message:\n \"No documentation pages were found. Add README.md, docs/**/*.md, or configure content.sources.\",\n });\n }\n\n const redirects = resolveRedirects(\n config.redirects,\n entries,\n routeMap,\n diagnostics,\n );\n for (const [alias, target] of Object.entries(redirects)) {\n const entry = routeMap.get(target);\n if (entry) routeMap.set(alias, entry);\n }\n for (const entry of entries) {\n await transformEntry(\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n );\n }\n validateNavigation(config.navigation.items ?? [], routeMap, diagnostics);\n for (const tab of config.navigation.tabs ?? []) {\n validateNavigation(\n [{ label: tab.label, link: tab.link }],\n routeMap,\n diagnostics,\n );\n validateNavigation(tab.items ?? [], routeMap, diagnostics);\n }\n for (const version of config.site.versions ?? []) {\n const homes = [\n version.routeBase,\n ...Object.keys(config.locales ?? {})\n .filter((locale) => locale !== \"root\")\n .map(\n (locale) =>\n `/${locale}${version.routeBase === \"/\" ? \"\" : version.routeBase}`,\n ),\n ];\n if (\n !homes.some(\n (route) =>\n routeMap.has(route) && !routeMap.get(route)!.frontmatter.draft,\n )\n ) {\n diagnostics.push({\n code: \"DOCS_VERSION_ROOT_MISSING\",\n severity: \"error\",\n message: `Version ${version.label} needs a non-draft page at ${version.routeBase} or a localized equivalent.`,\n });\n }\n }\n\n entries.sort((left, right) => left.route.localeCompare(right.route));\n const routes: DocsRoute[] = entries.map((entry) => ({\n route: entry.route,\n entryId: entry.id,\n sourcePath: entry.sourcePath,\n title: entry.title,\n discoverable: !entry.frontmatter.draft,\n indexable: pagePublishing(entry, config).index,\n sitemap: pagePublishing(entry, config).sitemap,\n canonical: pagePublishing(entry, config).canonical,\n ...(entry.frontmatter.sidebar !== undefined\n ? { sidebar: entry.frontmatter.sidebar }\n : {}),\n }));\n const assets = Array.from(\n new Map(\n entries\n .flatMap((entry) => entry.assets)\n .map((asset) => [\n asset.publicPath ?? `${asset.original}:${asset.line ?? \"\"}`,\n asset,\n ]),\n ).values(),\n );\n return {\n redirects,\n root,\n config,\n entries,\n routes,\n assets,\n diagnostics,\n entryByRoute(route) {\n return routeMap.get(normalizeRoute(route));\n },\n entryBySource(sourcePath, sourceId) {\n const matches = sourceMap.get(sourcePath) ?? [];\n return sourceId\n ? matches.find((entry) => entry.sourceId === sourceId)\n : matches.length === 1\n ? matches[0]\n : undefined;\n },\n };\n}\n\nfunction resolveRedirects(\n configured: Record<string, string>,\n entries: DocsEntry[],\n routes: Map<string, DocsEntry>,\n diagnostics: DocsDiagnostic[],\n): Record<string, string> {\n const requested = new Map<string, string>();\n const error = (message: string) =>\n diagnostics.push({\n code: \"DOCS_REDIRECT_INVALID\",\n severity: \"error\",\n message,\n });\n const add = (from: string, to: string) => {\n try {\n const alias = normalizeRoute(from);\n const target = normalizeRoute(to);\n if (routes.has(alias) || requested.has(alias))\n error(`Redirect ${alias} conflicts with an existing page or redirect.`);\n else requested.set(alias, target);\n } catch (cause) {\n error(errorMessage(cause));\n }\n };\n for (const [from, to] of Object.entries(configured)) add(from, to);\n for (const entry of entries) {\n for (const alias of entry.frontmatter.aliases ?? [])\n add(`${entry.routeBase}/${alias}`, entry.route);\n }\n const result: Record<string, string> = {};\n for (const [alias, target] of requested) {\n const seen = new Set([alias]);\n let current = target;\n while (requested.has(current) && !seen.has(current)) {\n seen.add(current);\n current = requested.get(current)!;\n }\n if (seen.has(current)) error(`Redirect cycle includes ${alias}.`);\n else if (!routes.has(current))\n error(`Redirect ${alias} points to missing document ${current}.`);\n else result[alias] = current;\n }\n return result;\n}\n\nasync function collectSources(\n root: string,\n config: NormalizedDocsConfig,\n lock: CreateDocsGraphOptions[\"lock\"],\n diagnostics: DocsDiagnostic[],\n): Promise<CollectedSource[]> {\n const declarations =\n config.content.sources ?? (await conventionSources(root));\n const results: CollectedSource[] = [];\n const identities = new Set<string>();\n\n const sourceIds = new Set<string>();\n for (const [index, declaration] of declarations.entries()) {\n const sourceId = declaration.id ?? `source-${index + 1}`;\n if (sourceIds.has(sourceId)) {\n diagnostics.push({\n code: \"DOCS_DUPLICATE_SOURCE\",\n severity: \"error\",\n message: `Source id ${sourceId} is declared more than once.`,\n });\n continue;\n }\n sourceIds.add(sourceId);\n try {\n const found = await collectDeclaration(\n root,\n declaration,\n config,\n lock,\n sourceId,\n );\n if (found.length === 0) {\n diagnostics.push({\n code: \"DOCS_SOURCE_NOT_FOUND\",\n severity: \"error\",\n message: `Source did not match any files: ${sourceLabel(declaration)}.`,\n });\n }\n for (const source of found) {\n const identity = `${sourceId}:${normalizeFs(source.absolutePath)}:${source.generatedBody === undefined ? \"\" : source.route}`;\n if (identities.has(identity)) continue;\n identities.add(identity);\n results.push(source);\n }\n } catch (error) {\n diagnostics.push({\n code:\n error instanceof OutsideRootError\n ? \"DOCS_SOURCE_OUTSIDE_ROOT\"\n : \"openapi\" in declaration\n ? \"DOCS_OPENAPI_INVALID\"\n : \"DOCS_SOURCE_NOT_FOUND\",\n severity: \"error\",\n message: errorMessage(error),\n });\n }\n }\n return results;\n}\n\nasync function conventionSources(root: string): Promise<DocsSource[]> {\n const sources: DocsSource[] = [];\n if (await isFile(resolve(root, \"README.md\")))\n sources.push({ file: \"README.md\", route: \"/\" });\n const docs = resolve(root, \"docs\");\n if (\n (await isDirectory(docs)) &&\n (await glob(\"docs/**/*.{md,mdx}\", { cwd: root })).length > 0\n ) {\n sources.push({ glob: \"docs/**/*.{md,mdx}\", base: \"docs\" });\n }\n return sources;\n}\n\nasync function collectDeclaration(\n root: string,\n declaration: DocsSource,\n config: NormalizedDocsConfig,\n lock: CreateDocsGraphOptions[\"lock\"],\n sourceId: string,\n): Promise<CollectedSource[]> {\n if (\"openapi\" in declaration) {\n const sourceRoot = resolve(root, declaration.root ?? \".\");\n const absolutePath = resolveSourcePath(\n sourceRoot,\n declaration.openapi,\n config.content.allowOutsideRoot,\n );\n if (!(await isFile(absolutePath))) return [];\n const info = await stat(absolutePath);\n if (info.size > config.build.maxAssetBytes)\n throw new Error(\n `OpenAPI source ${declaration.openapi} exceeds ${config.build.maxAssetBytes} bytes.`,\n );\n const routeBase = normalizeRoute(declaration.routeBase ?? \"/api\");\n const sourcePath = toPosix(relative(sourceRoot, absolutePath));\n const pages = openApiPages(\n sourcePath,\n routeBase,\n await readFile(absolutePath, \"utf8\"),\n );\n return pages.map((page) => ({\n sourceId,\n routeBase,\n absolutePath,\n sourcePath: page.sourcePath,\n sourceRoot,\n editPath: toPosix(\n relative(inside(root, absolutePath) ? root : sourceRoot, absolutePath),\n ),\n route: page.route,\n title: page.title,\n ...(page.description ? { description: page.description } : {}),\n generatedBody: page.body,\n trust: \"markdown\" as const,\n }));\n }\n if (\"package\" in declaration) {\n const packageLock = lockForSource(lock, declaration.package);\n if (declaration.registry && packageLock.registry !== declaration.registry) {\n throw new Error(\n `Registry changed for ${declaration.package}. Run \"cookbook update\".`,\n );\n }\n const sourceRoot = await materializePackage(\n packageLock,\n config.build,\n root,\n );\n const discovery = await discoverPackage(sourceRoot);\n const repository = config.content.localizeRepositoryLinks\n ? repositoryMetadata(discovery.manifest.repository)\n : undefined;\n const patterns = declaration.include?.length\n ? declaration.include\n : discovery.pages;\n for (const pattern of patterns) {\n assertSafePackagePath(pattern, \"Package source include\");\n }\n for (const pattern of declaration.exclude ?? []) {\n assertSafePackagePath(pattern, \"Package source exclude\");\n }\n if (declaration.index) {\n assertSafePackagePath(declaration.index, \"Package source index\");\n }\n const files = await glob(patterns, {\n cwd: sourceRoot,\n onlyFiles: true,\n ignore: declaration.exclude ?? [],\n });\n const index = declaration.index ?? discovery.home;\n return files\n .filter((path) =>\n MARKDOWN_EXTENSIONS.includes(extname(path).toLowerCase()),\n )\n .map((path) => {\n assertSafePackagePath(path, \"Discovered package source\");\n const absolutePath = resolve(sourceRoot, path);\n if (!inside(sourceRoot, absolutePath)) throw new OutsideRootError(path);\n return {\n sourceId,\n ...(declaration.routeBase\n ? { routeBase: declaration.routeBase }\n : {}),\n absolutePath,\n sourcePath: path,\n sourceRoot,\n route:\n path === index\n ? normalizeRoute(declaration.routeBase ?? \"/\")\n : routeForPath(path, \"docs\", declaration.routeBase),\n trust: declaration.trust ?? \"markdown\",\n packageLock,\n ...(repository ? { repository } : {}),\n };\n });\n }\n\n const sourceRoot = resolve(root, declaration.root ?? \".\");\n const repository = config.content.localizeRepositoryLinks\n ? repositoryMetadata(config.site.repository)\n : undefined;\n\n if (\"file\" in declaration) {\n const absolutePath = resolveSourcePath(\n sourceRoot,\n declaration.file,\n config.content.allowOutsideRoot,\n );\n if (!(await isFile(absolutePath))) return [];\n return [\n {\n sourceId,\n ...(declaration.routeBase ? { routeBase: declaration.routeBase } : {}),\n absolutePath,\n sourcePath: toPosix(relative(sourceRoot, absolutePath)),\n editPath: toPosix(\n relative(\n inside(root, absolutePath) ? root : sourceRoot,\n absolutePath,\n ),\n ),\n sourceRoot,\n route: declaration.route\n ? normalizeRoute(\n `${declaration.routeBase ?? \"\"}/${declaration.route}`,\n )\n : routeForPath(declaration.file, undefined, declaration.routeBase),\n ...(declaration.title ? { title: declaration.title } : {}),\n ...(declaration.description\n ? { description: declaration.description }\n : {}),\n ...(declaration.navigation !== undefined\n ? { navigation: declaration.navigation }\n : {}),\n trust: \"mdx\",\n ...(repository ? { repository } : {}),\n },\n ];\n }\n\n const patterns = Array.isArray(declaration.glob)\n ? declaration.glob\n : [declaration.glob];\n const paths = await glob(patterns, {\n cwd: sourceRoot,\n onlyFiles: true,\n dot: false,\n ignore: [\"**/_*/**\", \"**/_*\", ...(declaration.exclude ?? [])],\n });\n return paths.map((path) => {\n const absolutePath = resolveSourcePath(\n sourceRoot,\n path,\n config.content.allowOutsideRoot,\n );\n return {\n sourceId,\n ...(declaration.routeBase ? { routeBase: declaration.routeBase } : {}),\n absolutePath,\n sourcePath: toPosix(relative(sourceRoot, absolutePath)),\n editPath: toPosix(\n relative(inside(root, absolutePath) ? root : sourceRoot, absolutePath),\n ),\n sourceRoot,\n route: routeForPath(path, declaration.base, declaration.routeBase),\n ...(declaration.navigation === false ? { navigation: false } : {}),\n trust: \"mdx\",\n ...(repository ? { repository } : {}),\n };\n });\n}\n\nasync function readEntry(\n source: CollectedSource,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): Promise<DocsEntry | undefined> {\n if (\n extname(source.sourcePath).toLowerCase() === \".mdx\" &&\n source.trust !== \"mdx\"\n ) {\n diagnostics.push({\n code: \"DOCS_UNTRUSTED_MDX\",\n severity: \"error\",\n message: `Package MDX requires trust: 'mdx': ${source.sourcePath}.`,\n file: source.sourcePath,\n hint: \"Keep package sources in Markdown-safe mode or explicitly trust this locked artifact.\",\n });\n return undefined;\n }\n const original =\n source.generatedBody ?? (await readFile(source.absolutePath, \"utf8\"));\n let parsedMatter: ReturnType<typeof parseFrontmatter>;\n try {\n parsedMatter = parseFrontmatter(original);\n } catch (error) {\n diagnostics.push({\n code: \"DOCS_FRONTMATTER_INVALID\",\n severity: \"error\",\n message: `Could not parse frontmatter: ${errorMessage(error)}.`,\n file: source.sourcePath,\n });\n return undefined;\n }\n const frontmatter = parsedMatter.data;\n if (frontmatter.sidebar === undefined && source.navigation !== undefined) {\n frontmatter.sidebar = source.navigation;\n }\n const diagnosticCount = diagnostics.length;\n const metadata: Record<string, unknown> = {};\n for (const key of Object.keys(frontmatter)) {\n if (!DOCS_FRONTMATTER_KEYS.has(key)) {\n if (config.content.frontmatter !== \"reject\") {\n metadata[key] = (frontmatter as Record<string, unknown>)[key];\n delete (frontmatter as Record<string, unknown>)[key];\n continue;\n }\n diagnostics.push({\n code: \"DOCS_FRONTMATTER_INVALID\",\n severity: \"error\",\n message: `Unknown frontmatter key \"${key}\".`,\n file: source.sourcePath,\n });\n }\n }\n validateFrontmatter(frontmatter, source.sourcePath, diagnostics);\n if (diagnostics.length > diagnosticCount) return undefined;\n const mdx = extname(source.sourcePath).toLowerCase() === \".mdx\";\n const parsed = parseMarkdown(parsedMatter.content, { mdx });\n const route = normalizeRoute(\n frontmatter.slug !== undefined\n ? `${source.routeBase ?? \"\"}/${frontmatter.slug}`\n : (source.route ?? routeForPath(source.sourcePath)),\n );\n const title =\n frontmatter.title ??\n source.title ??\n parsed.firstHeading ??\n titleFromFile(source.sourcePath);\n const description =\n frontmatter.description ?? source.description ?? parsed.description;\n await resolvePageMetadata(frontmatter, source, config);\n const duplicateTitles = new Map<string, number>();\n for (const heading of parsed.headings) {\n const count = (duplicateTitles.get(heading.text) ?? 0) + 1;\n duplicateTitles.set(heading.text, count);\n if (count > 1) {\n diagnostics.push({\n code: \"DOCS_HEADING_DUPLICATE\",\n severity: \"warning\",\n message: `Repeated heading \"${heading.text}\" receives the generated ID \"${heading.slug}\".`,\n file: source.sourcePath,\n ...(heading.line ? { line: heading.line } : {}),\n });\n }\n }\n return {\n id: `${source.sourceId}:${source.sourcePath}`,\n sourceId: source.sourceId,\n routeBase: source.routeBase ?? \"/\",\n metadata,\n sourcePath: source.sourcePath,\n absolutePath: source.absolutePath,\n sourceRoot: source.sourceRoot,\n route,\n title,\n ...(description ? { description } : {}),\n frontmatter,\n headings: parsed.headings,\n body: parsedMatter.content,\n transformedBody: parsedMatter.content,\n ast: parsed.ast,\n links: [],\n assets: [],\n trust: source.trust,\n ...(source.packageLock\n ? {\n package: {\n requested: source.packageLock.requested,\n resolved: source.packageLock.resolved,\n },\n }\n : {}),\n };\n}\n\nasync function resolvePageMetadata(\n frontmatter: DocsFrontmatter,\n source: CollectedSource,\n config: NormalizedDocsConfig,\n): Promise<void> {\n // Package pages have no editPath: their files come from an npm artifact.\n if (\n frontmatter.editUrl === undefined &&\n config.editLink &&\n source.editPath !== undefined\n ) {\n const baseUrl = config.editLink.baseUrl.endsWith(\"/\")\n ? config.editLink.baseUrl\n : `${config.editLink.baseUrl}/`;\n frontmatter.editUrl = `${baseUrl}${source.editPath.replace(/^\\/+/, \"\")}`;\n }\n\n if (frontmatter.lastUpdated === false) return;\n if (frontmatter.lastUpdated === undefined && config.lastUpdated === false) {\n return;\n }\n if (frontmatter.lastUpdated instanceof Date) return;\n\n try {\n const { stdout } = await execFileAsync(\n \"git\",\n [\"log\", \"-1\", \"--format=%ct\", \"--\", source.absolutePath],\n { cwd: source.sourceRoot },\n );\n const timestamp = Number(stdout.trim());\n if (Number.isFinite(timestamp) && timestamp > 0) {\n frontmatter.lastUpdated = new Date(timestamp * 1000);\n }\n } catch {\n // Sources can come from npm caches or directories without Git history.\n }\n}\n\nasync function transformEntry(\n entry: DocsEntry,\n absoluteMap: Map<string, DocsEntry[]>,\n routeMap: Map<string, DocsEntry>,\n repositoryMap: Map<string, RepositoryMetadata>,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): Promise<void> {\n sanitizeUntrustedFrontmatter(entry, config, diagnostics);\n const ast = cloneAst(entry.ast);\n if (config.markdown.stripLeadingBadges) stripLeadingBadgeBlock(ast);\n removeRenderedTitle(ast, entry.title);\n\n const htmlTasks: Promise<void>[] = [];\n visit(ast, \"html\", (node) => {\n const policy = rawHtmlPolicy(entry, config);\n if (policy === \"allow\") return;\n if (policy === \"sanitize\") {\n htmlTasks.push(\n sanitizeMarkup(node.value, async (url, kind) => {\n const reference: Link = {\n type: \"link\",\n url,\n children: [],\n ...(node.position ? { position: node.position } : {}),\n };\n if (kind === \"link\") {\n await rewriteLink(\n reference,\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n );\n } else {\n const image: Image = {\n type: \"image\",\n url,\n alt: \"\",\n ...(node.position ? { position: node.position } : {}),\n };\n await rewriteAsset(image, entry, config, diagnostics);\n reference.url = image.url;\n }\n return reference.url;\n }).then((html) => {\n node.value = html;\n }),\n );\n return;\n }\n diagnostics.push({\n code:\n policy === \"reject\"\n ? \"DOCS_RAW_HTML_REJECTED\"\n : \"DOCS_RAW_HTML_STRIPPED\",\n severity: policy === \"reject\" ? \"error\" : \"warning\",\n message: `Raw HTML was ${policy === \"reject\" ? \"rejected\" : \"removed\"}: ${entry.sourcePath}.`,\n file: entry.sourcePath,\n ...lineData(node),\n });\n node.value = \"\";\n });\n await Promise.all(htmlTasks);\n\n const referenceKinds = new Map<string, \"link\" | \"image\" | \"mixed\">();\n visit(ast, (node) => {\n if (node.type !== \"linkReference\" && node.type !== \"imageReference\") {\n return;\n }\n const key = node.identifier.toLowerCase();\n const kind = node.type === \"imageReference\" ? \"image\" : \"link\";\n const previous = referenceKinds.get(key);\n referenceKinds.set(key, previous && previous !== kind ? \"mixed\" : kind);\n });\n\n const linkTasks: Promise<void>[] = [];\n visit(ast, (node) => {\n if (node.type === \"link\") {\n linkTasks.push(\n rewriteLink(\n node,\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n ),\n );\n } else if (node.type === \"image\") {\n linkTasks.push(rewriteAsset(node, entry, config, diagnostics));\n } else if (node.type === \"definition\") {\n const kind = referenceKinds.get(node.identifier.toLowerCase());\n if (kind === \"image\") {\n linkTasks.push(rewriteAsset(node, entry, config, diagnostics));\n } else if (kind === \"link\") {\n linkTasks.push(\n rewriteLink(\n node,\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n ),\n );\n } else if (kind === \"mixed\") {\n linkTasks.push(\n rewriteDefinition(\n node,\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n ),\n );\n }\n }\n });\n await Promise.all(linkTasks);\n await rewriteFrontmatterReferences(\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n );\n entry.ast = ast;\n entry.transformedBody = serializeMarkdown(ast, {\n mdx: extname(entry.sourcePath).toLowerCase() === \".mdx\",\n });\n}\n\nfunction sanitizeUntrustedFrontmatter(\n entry: DocsEntry,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): void {\n if (entry.trust !== \"markdown\") return;\n let removed = false;\n const plainText = (value: string): string => {\n const sanitized = value.replace(/<!--[\\s\\S]*?-->|<[^>]*>/g, \"\");\n if (sanitized !== value) removed = true;\n return sanitized;\n };\n\n entry.title = plainText(entry.title);\n if (entry.frontmatter.title !== undefined) {\n entry.frontmatter.title = plainText(entry.frontmatter.title);\n }\n const hero = entry.frontmatter.hero;\n if (hero?.title !== undefined) hero.title = plainText(hero.title);\n if (hero?.tagline !== undefined) hero.tagline = plainText(hero.tagline);\n if (hero?.image && \"html\" in hero.image) {\n delete hero.image;\n removed = true;\n }\n if (entry.frontmatter.banner) {\n entry.frontmatter.banner.content = plainText(\n entry.frontmatter.banner.content,\n );\n }\n if (entry.frontmatter.head) {\n delete entry.frontmatter.head;\n removed = true;\n }\n\n if (removed) {\n diagnostics.push({\n code:\n config.markdown.rawHtml === \"reject\"\n ? \"DOCS_RAW_HTML_REJECTED\"\n : \"DOCS_UNTRUSTED_HTML\",\n severity: config.markdown.rawHtml === \"reject\" ? \"error\" : \"warning\",\n message:\n config.markdown.rawHtml === \"reject\"\n ? `HTML-capable frontmatter is not allowed by markdown.rawHtml: ${entry.sourcePath}.`\n : \"HTML-capable frontmatter was sanitized in package Markdown. Use trust: 'mdx' only for packages you trust.\",\n file: entry.sourcePath,\n });\n }\n}\n\nfunction rawHtmlPolicy(\n entry: DocsEntry,\n config: NormalizedDocsConfig,\n): NormalizedDocsConfig[\"markdown\"][\"rawHtml\"] {\n if (config.markdown.rawHtml === \"reject\") return \"reject\";\n if (config.markdown.rawHtml === \"strip\") return \"strip\";\n return entry.trust === \"markdown\" ? \"sanitize\" : config.markdown.rawHtml;\n}\n\nasync function rewriteFrontmatterReferences(\n entry: DocsEntry,\n absoluteMap: Map<string, DocsEntry[]>,\n routeMap: Map<string, DocsEntry>,\n repositoryMap: Map<string, RepositoryMetadata>,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): Promise<void> {\n for (const action of entry.frontmatter.hero?.actions ?? []) {\n const node: Link = { type: \"link\", url: action.link, children: [] };\n await rewriteLink(\n node,\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n );\n action.link = node.url;\n }\n\n const image = entry.frontmatter.hero?.image;\n if (!image || \"html\" in image) return;\n if (\"file\" in image) {\n image.file = await rewriteFrontmatterAsset(\n image.file,\n entry,\n config,\n diagnostics,\n );\n return;\n }\n const [dark, light] = await Promise.all([\n rewriteFrontmatterAsset(image.dark, entry, config, diagnostics),\n rewriteFrontmatterAsset(image.light, entry, config, diagnostics),\n ]);\n image.dark = dark;\n image.light = light;\n}\n\nasync function rewriteFrontmatterAsset(\n url: string,\n entry: DocsEntry,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): Promise<string> {\n const asset = await materializeAsset(url, entry, config, diagnostics, {});\n entry.assets.push(asset);\n return asset.resolved ?? url;\n}\n\nasync function rewriteLink(\n node: Link | Definition,\n entry: DocsEntry,\n absoluteMap: Map<string, DocsEntry[]>,\n routeMap: Map<string, DocsEntry>,\n repositoryMap: Map<string, RepositoryMetadata>,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): Promise<void> {\n const reference: import(\"../types.js\").DocsReference = {\n original: node.url,\n ...lineData(node),\n };\n entry.links.push(reference);\n if (node.url.startsWith(\"source:\")) {\n const { pathname, query, fragment } = splitReference(node.url.slice(7));\n const slash = pathname.indexOf(\"/\");\n const sourceId = slash < 0 ? pathname : pathname.slice(0, slash);\n const sourcePath = safeDecode(pathname.slice(slash + 1));\n const target = [...absoluteMap.values()]\n .flat()\n .find(\n (candidate) =>\n candidate.sourceId === sourceId &&\n candidate.sourcePath === sourcePath,\n );\n if (!target || slash < 0)\n missingLink(diagnostics, entry, node, node.url, config);\n else {\n node.url = `${pageHref(target.route, config)}${query}${fragment ? `#${fragment}` : \"\"}`;\n reference.resolved = node.url;\n reference.targetSource = target.sourcePath;\n validateFragment(fragment, target, entry, node, diagnostics, config);\n }\n return;\n }\n if (unsafeProtocol(node.url)) {\n diagnostic(\n diagnostics,\n \"DOCS_LINK_UNSAFE\",\n `Unsafe URL protocol: ${node.url}.`,\n entry,\n node,\n );\n return;\n }\n if (isExternal(node.url)) {\n const target = config.content.localizeRepositoryLinks\n ? localizedRepositoryTarget(\n node.url,\n entry,\n absoluteMap,\n repositoryMap.get(entry.id),\n )\n : undefined;\n if (!target) return;\n const { query, fragment } = splitReference(node.url);\n node.url = `${pageHref(target.route, config)}${query}${fragment ? `#${fragment}` : \"\"}`;\n reference.resolved = node.url;\n reference.targetSource = target.sourcePath;\n if (fragment) reference.fragment = fragment;\n validateFragment(fragment, target, entry, node, diagnostics, config);\n return;\n }\n if (node.url.startsWith(\"#\")) return;\n const { pathname, query, fragment } = splitReference(node.url);\n if (pathname.startsWith(\"/\")) {\n const target = routeMap.get(normalizeRoute(pathname));\n if (!target) missingLink(diagnostics, entry, node, node.url, config);\n else {\n node.url = `${pageHref(target.route, config)}${query}${fragment ? `#${fragment}` : \"\"}`;\n reference.resolved = node.url;\n reference.targetSource = target.sourcePath;\n if (fragment) reference.fragment = fragment;\n validateFragment(fragment, target, entry, node, diagnostics, config);\n }\n return;\n }\n const decoded = safeDecode(pathname);\n const targetPath = resolve(dirname(entry.absolutePath), decoded);\n if (!inside(entry.sourceRoot, targetPath)) {\n diagnostic(\n diagnostics,\n \"DOCS_SOURCE_OUTSIDE_ROOT\",\n `Link escapes its allowed source root: ${node.url}.`,\n entry,\n node,\n );\n return;\n }\n const target = findDocument(targetPath, absoluteMap, entry.sourceId);\n if (!target) {\n if (documentMatches(targetPath, absoluteMap).length > 1) {\n diagnostic(\n diagnostics,\n \"DOCS_AMBIGUOUS_LINK\",\n `Link matches multiple source mounts: ${node.url}. Use source:<id>/<path> to choose a source.`,\n entry,\n node,\n );\n return;\n }\n if (await isFile(targetPath)) {\n const asset = await materializeAsset(\n node.url,\n entry,\n config,\n diagnostics,\n node,\n );\n if (asset.resolved) {\n node.url = asset.resolved;\n reference.resolved = asset.resolved;\n }\n entry.assets.push(asset);\n return;\n }\n missingLink(diagnostics, entry, node, node.url, config);\n return;\n }\n node.url = `${pageHref(target.route, config)}${query}${fragment ? `#${fragment}` : \"\"}`;\n reference.resolved = node.url;\n reference.targetSource = target.sourcePath;\n if (fragment) reference.fragment = fragment;\n validateFragment(fragment, target, entry, node, diagnostics, config);\n}\n\nasync function rewriteAsset(\n node: Image | Definition,\n entry: DocsEntry,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): Promise<void> {\n const asset = await materializeAsset(\n node.url,\n entry,\n config,\n diagnostics,\n node,\n );\n entry.assets.push(asset);\n if (asset.resolved) node.url = asset.resolved;\n}\n\nasync function materializeAsset(\n url: string,\n entry: DocsEntry,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n node: PositionedNode,\n): Promise<DocsAsset> {\n const asset: DocsAsset = { original: url, ...lineData(node) };\n if (unsafeProtocol(url)) {\n diagnostic(\n diagnostics,\n \"DOCS_ASSET_UNSAFE\",\n `Unsafe asset URL: ${url}.`,\n entry,\n node,\n );\n return asset;\n }\n if (isExternal(url) || url.startsWith(\"#\")) return asset;\n const { pathname, query, fragment } = splitReference(url);\n const absolute = resolve(dirname(entry.absolutePath), safeDecode(pathname));\n if (!inside(entry.sourceRoot, absolute)) {\n diagnostic(\n diagnostics,\n \"DOCS_SOURCE_OUTSIDE_ROOT\",\n `Asset escapes its allowed source root: ${url}.`,\n entry,\n node,\n );\n return asset;\n }\n try {\n const info = await stat(absolute);\n if (!info.isFile()) throw new Error(\"not a file\");\n if (info.size > config.build.maxAssetBytes) {\n throw new Error(`asset exceeds ${config.build.maxAssetBytes} bytes`);\n }\n const hash = createHash(\"sha256\")\n .update(await readFile(absolute))\n .digest(\"hex\")\n .slice(0, 12);\n const publicPath = withBase(\n `/_tasty-assets/${hash}-${basename(absolute)}`,\n config.build.base,\n );\n const resolved = `${publicPath}${query}${fragment ? `#${fragment}` : \"\"}`;\n Object.assign(asset, {\n resolved,\n sourcePath: absolute,\n publicPath,\n hash,\n bytes: info.size,\n });\n } catch (error) {\n diagnostic(\n diagnostics,\n \"DOCS_ASSET_NOT_FOUND\",\n `Asset not found or invalid: ${url} (${errorMessage(error)}).`,\n entry,\n node,\n );\n }\n return asset;\n}\n\nasync function rewriteDefinition(\n node: Definition,\n entry: DocsEntry,\n absoluteMap: Map<string, DocsEntry[]>,\n routeMap: Map<string, DocsEntry>,\n repositoryMap: Map<string, RepositoryMetadata>,\n config: NormalizedDocsConfig,\n diagnostics: DocsDiagnostic[],\n): Promise<void> {\n const { pathname } = splitReference(node.url);\n const targetPath = resolve(dirname(entry.absolutePath), safeDecode(pathname));\n if (\n documentMatches(targetPath, absoluteMap).length > 0 ||\n node.url.startsWith(\"source:\") ||\n pathname.startsWith(\"/\")\n ) {\n await rewriteLink(\n node,\n entry,\n absoluteMap,\n routeMap,\n repositoryMap,\n config,\n diagnostics,\n );\n } else {\n await rewriteAsset(node, entry, config, diagnostics);\n }\n}\n\nfunction findDocument(\n path: string,\n absoluteMap: Map<string, DocsEntry[]>,\n sourceId?: string,\n): DocsEntry | undefined {\n const matches = documentMatches(path, absoluteMap);\n return (\n matches.find((item) => item.sourceId === sourceId) ??\n (matches.length === 1 ? matches[0] : undefined)\n );\n}\n\nfunction documentMatches(\n path: string,\n absoluteMap: Map<string, DocsEntry[]>,\n): DocsEntry[] {\n const candidates = [\n path,\n ...MARKDOWN_EXTENSIONS.map((extension) => `${path}${extension}`),\n ...MARKDOWN_EXTENSIONS.map((extension) =>\n resolve(path, `README${extension}`),\n ),\n ...MARKDOWN_EXTENSIONS.map((extension) =>\n resolve(path, `index${extension}`),\n ),\n ];\n for (const candidate of candidates) {\n const matches = absoluteMap.get(normalizeFs(candidate)) ?? [];\n if (matches.length) return matches;\n }\n return [];\n}\n\nfunction validateFragment(\n fragment: string,\n target: DocsEntry,\n source: DocsEntry,\n node: Link | Definition,\n diagnostics: DocsDiagnostic[],\n config: NormalizedDocsConfig,\n): void {\n if (!fragment) return;\n const decoded = safeDecode(fragment);\n if (!target.headings.some((heading) => heading.slug === decoded)) {\n diagnostics.push({\n code: \"DOCS_FRAGMENT_NOT_FOUND\",\n severity: config.build.ci ? \"error\" : \"warning\",\n message: `Heading fragment #${fragment} does not exist on ${target.route}.`,\n file: source.sourcePath,\n ...lineData(node),\n hint: `Known headings: ${target.headings.map((heading) => `#${heading.slug}`).join(\", \") || \"(none)\"}.`,\n });\n }\n}\n\nfunction missingLink(\n diagnostics: DocsDiagnostic[],\n entry: DocsEntry,\n node: Link | Definition,\n url: string,\n config: NormalizedDocsConfig,\n): void {\n diagnostics.push({\n code: \"DOCS_LINK_NOT_FOUND\",\n severity: config.build.strict ? \"error\" : \"warning\",\n message: `Internal link target not found: ${url}.`,\n file: entry.sourcePath,\n ...lineData(node),\n });\n}\n\nfunction validateNavigation(\n items: NavigationItem[],\n routes: Map<string, DocsEntry>,\n diagnostics: DocsDiagnostic[],\n): void {\n for (const item of items) {\n if (typeof item === \"string\") {\n if (!routes.has(normalizeRoute(item))) {\n diagnostics.push({\n code: \"DOCS_NAV_TARGET_NOT_FOUND\",\n severity: \"error\",\n message: `Navigation target does not exist: ${item}.`,\n });\n }\n } else if (\n item.link?.startsWith(\"/\") &&\n !routes.has(normalizeRoute(item.link))\n ) {\n diagnostics.push({\n code: \"DOCS_NAV_TARGET_NOT_FOUND\",\n severity: \"error\",\n message: `Navigation target does not exist: ${item.link}.`,\n });\n }\n if (typeof item !== \"string\" && \"items\" in item) {\n validateNavigation(item.items, routes, diagnostics);\n }\n }\n}\n\nexport function normalizeRoute(route: string): string {\n const clean =\n route\n .split(/[?#]/, 1)[0]\n ?.replace(/\\\\/g, \"/\")\n .replace(/\\/{2,}/g, \"/\") ?? \"/\";\n const segments = clean.split(\"/\").filter(Boolean);\n if (segments.some((segment) => segment === \"..\"))\n throw new Error(`Route may not contain \"..\": ${route}.`);\n const normalized = `/${segments.join(\"/\")}`;\n return normalized === \"/\" ? \"/\" : normalized.replace(/\\/$/, \"\");\n}\n\nexport function routeForPath(\n path: string,\n base?: string,\n routeBase?: string,\n): string {\n let relativePath = toPosix(path);\n if (base) {\n const normalizedBase = toPosix(base)\n .replace(/^\\.\\//, \"\")\n .replace(/\\/$/, \"\");\n if (relativePath === normalizedBase) relativePath = \"\";\n else if (relativePath.startsWith(`${normalizedBase}/`))\n relativePath = relativePath.slice(normalizedBase.length + 1);\n }\n relativePath = relativePath.replace(/\\.(md|mdx)$/i, \"\");\n relativePath = relativePath\n .replace(/(^|\\/)README$/i, \"$1\")\n .replace(/(^|\\/)index$/i, \"$1\");\n return normalizeRoute(`${routeBase ?? \"\"}/${relativePath}`);\n}\n\nfunction resolveSourcePath(\n root: string,\n path: string,\n allowOutsideRoot: boolean,\n): string {\n const absolute = isAbsolute(path) ? resolve(path) : resolve(root, path);\n if (!allowOutsideRoot && !inside(root, absolute))\n throw new OutsideRootError(path);\n return absolute;\n}\n\nfunction inside(root: string, path: string): boolean {\n const rel = relative(resolve(root), resolve(path));\n return (\n rel === \"\" ||\n (!rel.startsWith(`..${sep}`) && rel !== \"..\" && !isAbsolute(rel))\n );\n}\n\nfunction splitReference(url: string): {\n pathname: string;\n query: string;\n fragment: string;\n} {\n const hashIndex = url.indexOf(\"#\");\n const fragment = hashIndex >= 0 ? url.slice(hashIndex + 1) : \"\";\n const withoutHash = hashIndex >= 0 ? url.slice(0, hashIndex) : url;\n const queryIndex = withoutHash.indexOf(\"?\");\n return {\n pathname: queryIndex >= 0 ? withoutHash.slice(0, queryIndex) : withoutHash,\n query: queryIndex >= 0 ? withoutHash.slice(queryIndex) : \"\",\n fragment,\n };\n}\n\nfunction isExternal(url: string): boolean {\n return /^(?:[a-z][a-z\\d+.-]*:|\\/\\/)/i.test(url);\n}\n\nfunction localizedRepositoryTarget(\n value: string,\n entry: DocsEntry,\n entries: Map<string, DocsEntry[]>,\n metadata: RepositoryMetadata | undefined,\n): DocsEntry | undefined {\n if (!metadata) return undefined;\n let link: URL;\n let repository: URL;\n try {\n link = new URL(value);\n repository = new URL(metadata.url);\n } catch {\n return undefined;\n }\n const repositoryPath = repository.pathname.replace(/\\/+$/, \"\");\n if (\n link.origin !== repository.origin ||\n !link.pathname.startsWith(`${repositoryPath}/`)\n ) {\n return undefined;\n }\n const repositoryRelative = safeDecode(\n link.pathname.slice(repositoryPath.length + 1),\n );\n if (\n !/^(?:-\\/(?:blob|tree|raw)|blob|tree|raw|src)\\//.test(repositoryRelative)\n ) {\n return undefined;\n }\n\n const directory = metadata.directory?.replace(/^\\/+|\\/+$/g, \"\");\n const matches = [...entries.values()]\n .flat()\n .filter((candidate) => candidate.sourceRoot === entry.sourceRoot)\n .flatMap((candidate) => {\n const sourcePath = candidate.sourcePath.replace(/^\\/+/, \"\");\n const paths = [sourcePath];\n if (/(?:^|\\/)(?:README|index)\\.mdx?$/i.test(sourcePath)) {\n paths.push(sourcePath.replace(/(?:^|\\/)(?:README|index)\\.mdx?$/i, \"\"));\n }\n const repositoryPaths = paths\n .flatMap((path) => [\n path,\n ...(directory ? [`${directory}/${path}`] : []),\n ])\n .map((path) => path.replace(/\\/+$/, \"\"))\n .filter(Boolean);\n const matched = repositoryPaths.find(\n (path) =>\n repositoryRelative === path ||\n repositoryRelative.endsWith(`/${path}`),\n );\n return matched ? [{ candidate, length: matched.length }] : [];\n })\n .sort(\n (left, right) =>\n Number(right.candidate.sourceId === entry.sourceId) -\n Number(left.candidate.sourceId === entry.sourceId) ||\n right.length - left.length,\n );\n return matches[0]?.candidate;\n}\n\nfunction repositoryMetadata(\n repository:\n string | { type?: string; url?: string; directory?: string } | undefined,\n): RepositoryMetadata | undefined {\n let raw = typeof repository === \"string\" ? repository : repository?.url;\n if (!raw) return undefined;\n raw = raw.replace(/^git\\+/, \"\");\n const scp = /^git@([^:]+):(.+)$/.exec(raw);\n if (scp) raw = `https://${scp[1]}/${scp[2]}`;\n try {\n let url = new URL(raw);\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n if (!url.hostname || ![\"git:\", \"ssh:\"].includes(url.protocol)) {\n return undefined;\n }\n url = new URL(`https://${url.hostname}${url.pathname}`);\n }\n url.search = \"\";\n url.hash = \"\";\n url.pathname = url.pathname.replace(/\\.git\\/?$/, \"\").replace(/\\/+$/, \"\");\n const directory =\n typeof repository === \"object\"\n ? repository.directory?.replaceAll(\"\\\\\", \"/\").replace(/^\\/+|\\/+$/g, \"\")\n : undefined;\n return {\n url: url.href.replace(/\\/$/, \"\"),\n ...(directory ? { directory } : {}),\n };\n } catch {\n return undefined;\n }\n}\n\nfunction unsafeProtocol(url: string): boolean {\n return /^(?:javascript|vbscript|data):/i.test(url.trim());\n}\n\nfunction pageHref(route: string, config: NormalizedDocsConfig): string {\n return routePath(route, config.build.base, config.build.trailingSlash);\n}\n\nfunction withBase(route: string, base: string): string {\n const normalizedBase =\n base === \"/\" ? \"\" : `/${base.replace(/^\\/+|\\/+$/g, \"\")}`;\n return `${normalizedBase}${normalizeRoute(route)}` || \"/\";\n}\n\nfunction titleFromFile(path: string): string {\n const raw = basename(path, extname(path)).replace(\n /^README$/i,\n basename(dirname(path)) || \"Documentation\",\n );\n return raw\n .replace(/[-_]+/g, \" \")\n .replace(/\\b\\w/g, (letter) => letter.toUpperCase());\n}\n\nfunction diagnostic(\n diagnostics: DocsDiagnostic[],\n code: string,\n message: string,\n entry: DocsEntry,\n node: PositionedNode,\n): void {\n diagnostics.push({\n code,\n severity: \"error\",\n message,\n file: entry.sourcePath,\n ...lineData(node),\n });\n}\n\ntype PositionedNode = { position?: { start: { line: number } } | undefined };\n\nfunction lineOf(node: PositionedNode): number | undefined {\n return node.position?.start.line;\n}\n\nfunction lineData(\n node: PositionedNode,\n): { line: number } | Record<string, never> {\n const line = lineOf(node);\n return line === undefined ? {} : { line };\n}\n\nfunction safeDecode(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\nfunction sourceLabel(source: DocsSource): string {\n if (\"file\" in source) return source.file;\n if (\"glob\" in source)\n return Array.isArray(source.glob) ? source.glob.join(\", \") : source.glob;\n if (\"openapi\" in source) return source.openapi;\n return source.package;\n}\n\nfunction normalizeFs(path: string): string {\n return resolve(path);\n}\n\nfunction toPosix(path: string): string {\n return path.split(sep).join(\"/\");\n}\n\nasync function isFile(path: string): Promise<boolean> {\n try {\n return (await stat(path)).isFile();\n } catch {\n return false;\n }\n}\n\nasync function isDirectory(path: string): Promise<boolean> {\n try {\n return (await stat(path)).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nclass OutsideRootError extends Error {\n constructor(path: string) {\n super(`Source path is outside the repository root: ${path}.`);\n this.name = \"OutsideRootError\";\n }\n}\n\nfunction parseFrontmatter(source: string): {\n data: DocsFrontmatter;\n content: string;\n} {\n const match =\n /^(?:\\uFEFF)?---[\\t ]*\\r?\\n([\\s\\S]*?)\\r?\\n(?:---|\\.\\.\\.)[\\t ]*(?:\\r?\\n|$)/.exec(\n source,\n );\n if (!match) return { data: {}, content: source };\n const value = parseYaml(match[1] ?? \"\");\n if (value !== null && !isPlainRecord(value)) {\n throw new Error(\"Markdown frontmatter must be a YAML object.\");\n }\n const data = (value ?? {}) as DocsFrontmatter;\n if (\n typeof data.lastUpdated === \"string\" &&\n !Number.isNaN(Date.parse(data.lastUpdated))\n ) {\n data.lastUpdated = new Date(data.lastUpdated);\n }\n return { data, content: source.slice(match[0].length) };\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction validateFrontmatter(\n value: DocsFrontmatter,\n file: string,\n diagnostics: DocsDiagnostic[],\n): void {\n const record = value as Record<string, unknown>;\n const error = (message: string) =>\n diagnostics.push({\n code: \"DOCS_FRONTMATTER_INVALID\",\n severity: \"error\",\n message,\n file,\n });\n if (value.seo !== undefined)\n for (const message of validateSeo(value.seo, \"page\")) error(message);\n if (\n value.aliases !== undefined &&\n (!Array.isArray(value.aliases) ||\n value.aliases.some((alias) => typeof alias !== \"string\"))\n )\n error(\"aliases must be an array of route strings.\");\n for (const key of [\"title\", \"description\", \"slug\"] as const) {\n if (record[key] !== undefined && typeof record[key] !== \"string\") {\n error(`${key} must be a string.`);\n }\n }\n for (const key of [\"draft\", \"pagefind\"] as const) {\n if (record[key] !== undefined && typeof record[key] !== \"boolean\") {\n error(`${key} must be a boolean.`);\n }\n }\n if (\n record.template !== undefined &&\n record.template !== \"doc\" &&\n record.template !== \"splash\"\n ) {\n error('template must be \"doc\" or \"splash\".');\n }\n for (const key of [\"sidebar\", \"tableOfContents\"] as const) {\n const entry = record[key];\n if (entry !== undefined && entry !== false && !isPlainRecord(entry)) {\n error(`${key} must be false or an object.`);\n }\n }\n if (isPlainRecord(record.sidebar)) {\n validateOptionalStrings(\n record.sidebar,\n [\"label\", \"group\", \"badge\"],\n \"sidebar\",\n error,\n );\n if (\n record.sidebar.order !== undefined &&\n typeof record.sidebar.order !== \"number\"\n ) {\n error(\"sidebar.order must be a number.\");\n }\n }\n if (record.tableOfContents !== undefined)\n for (const message of validateTableOfContents(record.tableOfContents))\n error(message);\n if (\n record.editUrl !== undefined &&\n record.editUrl !== false &&\n typeof record.editUrl !== \"string\"\n ) {\n error(\"editUrl must be false or a string.\");\n }\n if (\n record.lastUpdated !== undefined &&\n typeof record.lastUpdated !== \"boolean\" &&\n !(record.lastUpdated instanceof Date)\n ) {\n error(\"lastUpdated must be a date or boolean.\");\n }\n if (record.hero !== undefined) {\n if (!isPlainRecord(record.hero)) {\n error(\"hero must be an object.\");\n } else {\n validateHero(record.hero, error);\n }\n }\n if (record.banner !== undefined) {\n if (!isPlainRecord(record.banner)) {\n error(\"banner must be an object.\");\n } else if (typeof record.banner.content !== \"string\") {\n error(\"banner.content must be a string.\");\n }\n }\n for (const key of [\"prev\", \"next\"] as const) {\n const adjacent = record[key];\n if (\n adjacent !== undefined &&\n adjacent !== false &&\n typeof adjacent !== \"string\" &&\n !isPlainRecord(adjacent)\n ) {\n error(`${key} must be false, a string, or an object.`);\n } else if (isPlainRecord(adjacent)) {\n validateOptionalStrings(adjacent, [\"link\", \"label\"], key, error);\n }\n }\n if (\n record.head !== undefined &&\n (!Array.isArray(record.head) || !record.head.every(isPlainRecord))\n ) {\n error(\"head must be an array of objects.\");\n }\n}\n\nfunction validateHero(\n hero: Record<string, unknown>,\n error: (message: string) => void,\n): void {\n validateOptionalStrings(hero, [\"title\", \"tagline\"], \"hero\", error);\n if (hero.image !== undefined) {\n if (!isPlainRecord(hero.image)) {\n error(\"hero.image must be an object.\");\n } else {\n const image = hero.image;\n for (const key of [\"width\", \"height\"])\n if (\n image[key] !== undefined &&\n (!Number.isInteger(image[key]) || Number(image[key]) <= 0)\n )\n error(`hero.image.${key} must be a positive integer.`);\n if ((image.width === undefined) !== (image.height === undefined))\n error(\n \"hero.image needs both width and height when dimensions are specified.\",\n );\n const shapes = [\"html\", \"file\", \"dark\"].filter(\n (key) => image[key] !== undefined,\n );\n if (shapes.length !== 1) {\n error(\n \"hero.image must define exactly one of html, file, or dark/light.\",\n );\n }\n for (const key of [\"html\", \"file\", \"dark\", \"light\", \"alt\"] as const) {\n if (image[key] !== undefined && typeof image[key] !== \"string\") {\n error(`hero.image.${key} must be a string.`);\n }\n }\n if (image.dark !== undefined && typeof image.light !== \"string\") {\n error(\"hero.image.light must accompany hero.image.dark.\");\n }\n if (image.light !== undefined && typeof image.dark !== \"string\") {\n error(\"hero.image.dark must accompany hero.image.light.\");\n }\n }\n }\n if (hero.actions !== undefined) {\n if (!Array.isArray(hero.actions)) {\n error(\"hero.actions must be an array.\");\n } else {\n for (const [index, action] of hero.actions.entries()) {\n if (!isPlainRecord(action)) {\n error(`hero.actions[${index}] must be an object.`);\n continue;\n }\n for (const key of [\"text\", \"link\"] as const) {\n if (typeof action[key] !== \"string\") {\n error(`hero.actions[${index}].${key} must be a string.`);\n }\n }\n if (\n action.variant !== undefined &&\n ![\"primary\", \"secondary\", \"minimal\"].includes(String(action.variant))\n ) {\n error(\n `hero.actions[${index}].variant must be primary, secondary, or minimal.`,\n );\n }\n }\n }\n }\n}\n\nfunction validateOptionalStrings(\n record: Record<string, unknown>,\n keys: readonly string[],\n prefix: string,\n error: (message: string) => void,\n): void {\n for (const key of keys) {\n if (record[key] !== undefined && typeof record[key] !== \"string\") {\n error(`${prefix}.${key} must be a string.`);\n }\n }\n}\n","import type { DocsDiagnostic, DocsGraph } from \"../types.js\";\n\nexport class DocsValidationError extends Error {\n readonly diagnostics: DocsDiagnostic[];\n\n constructor(diagnostics: DocsDiagnostic[]) {\n super(formatDiagnostics(diagnostics));\n this.name = \"DocsValidationError\";\n this.diagnostics = diagnostics;\n }\n}\n\nexport function validateDocs(graph: DocsGraph): DocsDiagnostic[] {\n return [...graph.diagnostics];\n}\n\nexport function assertValidDocs(graph: DocsGraph): void {\n const errors = graph.diagnostics.filter(\n (diagnostic) => diagnostic.severity === \"error\",\n );\n if (errors.length > 0) throw new DocsValidationError(errors);\n}\n\nexport function formatDiagnostics(\n diagnostics: DocsDiagnostic[],\n json = false,\n): string {\n if (json) return JSON.stringify(diagnostics, null, 2);\n return diagnostics\n .map((diagnostic) => {\n const location = diagnostic.file\n ? `${diagnostic.file}${diagnostic.line ? `:${diagnostic.line}` : \"\"}: `\n : \"\";\n const hint = diagnostic.hint ? `\\n hint: ${diagnostic.hint}` : \"\";\n return `${diagnostic.severity.toUpperCase()} ${diagnostic.code} ${location}${diagnostic.message}${hint}`;\n })\n .join(\"\\n\");\n}\n","import { extname, join, relative, sep } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { createDocsGraph } from \"../graph/index.js\";\nimport { assertValidDocs } from \"../validation/index.js\";\nimport type {\n CreateDocsGraphOptions,\n DocsConfig,\n DocsEntry,\n} from \"../types.js\";\n\nexport interface DocsLoaderContext {\n store: {\n clear(): void;\n set(entry: {\n id: string;\n data: Record<string, unknown>;\n body: string;\n filePath?: string;\n digest?: string;\n rendered?: RenderedContent;\n assetImports?: string[];\n }): void;\n };\n logger?: { info(message: string): void };\n config?: { root: URL | string; srcDir: URL | string };\n parseData?: (input: {\n id: string;\n data: Record<string, unknown>;\n filePath?: string;\n }) => Promise<Record<string, unknown>>;\n renderMarkdown?: (\n content: string,\n options?: { fileURL?: URL },\n ) => Promise<RenderedContent>;\n generateDigest?: (data: Record<string, unknown> | string) => string;\n}\n\ninterface RenderedContent {\n html: string;\n metadata?: {\n imagePaths?: string[];\n headings?: Array<{ depth: number; slug: string; text: string }>;\n frontmatter?: Record<string, unknown>;\n [key: string]: unknown;\n };\n}\n\nexport function createDocsLoader(\n config?: DocsConfig,\n options: Omit<CreateDocsGraphOptions, \"config\"> = {},\n) {\n return {\n name: \"@tenphi/docs\",\n async load(context: DocsLoaderContext): Promise<void> {\n const graph = await createDocsGraph({\n ...options,\n ...(config ? { config } : {}),\n });\n assertValidDocs(graph);\n context.store.clear();\n for (const entry of graph.entries) {\n const loaderEntry = toLoaderEntry(entry);\n const filePath = contentFilePath(entry, context.config);\n const data = context.parseData\n ? await context.parseData({\n id: loaderEntry.id,\n data: loaderEntry.data,\n filePath,\n })\n : loaderEntry.data;\n const rendered = await context.renderMarkdown?.(entry.transformedBody, {\n fileURL: pathToFileURL(entry.absolutePath),\n });\n context.store.set({\n ...loaderEntry,\n data,\n filePath,\n ...(context.generateDigest\n ? { digest: context.generateDigest(entry.transformedBody) }\n : {}),\n ...(rendered\n ? {\n rendered,\n assetImports: rendered.metadata?.imagePaths ?? [],\n }\n : {}),\n });\n }\n context.logger?.info(`Loaded ${graph.entries.length} Cookbook pages.`);\n },\n };\n}\n\nfunction contentFilePath(\n entry: DocsEntry,\n config?: DocsLoaderContext[\"config\"],\n): string {\n const id = entry.route === \"/\" ? \"index\" : entry.route.slice(1);\n const extension =\n extname(entry.sourcePath).toLowerCase() === \".mdx\" ? \".mdx\" : \".md\";\n if (!config) return `src/content/docs/${id}${extension}`;\n\n const root = toPath(config.root);\n const srcDir = toPath(config.srcDir);\n return relative(root, join(srcDir, \"content\", \"docs\", `${id}${extension}`))\n .split(sep)\n .join(\"/\");\n}\n\nfunction toPath(value: URL | string): string {\n return typeof value === \"string\" ? value : fileURLToPath(value);\n}\n\nfunction toLoaderEntry(entry: DocsEntry): {\n id: string;\n data: Record<string, unknown>;\n body: string;\n} {\n return {\n id: entry.route === \"/\" ? \"index\" : entry.route.slice(1),\n data: {\n title: entry.title,\n draft: entry.frontmatter.draft ?? false,\n ...(entry.description ? { description: entry.description } : {}),\n ...entry.frontmatter,\n cookbook: {\n sourcePath: entry.sourcePath,\n route: entry.route,\n headings: entry.headings,\n },\n },\n body: entry.transformedBody,\n };\n}\n\nexport type { DocsEntry, DocsGraph, DocsRoute, DocsAsset } from \"../types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,MAAM,SAAS;CACb,GAAG;CACH,OAAO;EAAC;EAAU;EAAS;EAAU;EAAU;EAAS;CAAU;CAClE,WAAW;EACT,GAAG,cAAc;EACjB,MAAM,CAAC,GAAI,cAAc,WAAW,QAAQ,CAAC,GAAI,QAAQ;CAC3D;CACA,YAAY;EACV,GAAG,cAAc;EACjB,KACE,cAAc,aAAa,IAAI,EAAE,QAC9B,cACC,OAAO,cAAc,YACrB,CAAC;GACC;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,CAAC,SAAS,SAAS,CACxB,KAAK,CAAC;CACV;AACF;;AAGA,eAAsB,eACpB,MACA,SACiB;CACjB,MAAM,UAAU,6BAA6B,KAAK,KAAK,KAAK,CAAC;CAC7D,IAAI,SAAS;EACX,MAAM,MAAM,QAAQ,EAAE,EAAE,YAAY,KAAK;EACzC,OAAO,OAAO,UAAU,SAAS,GAAG,IAAI,KAAK,IAAI,KAAK;CACxD;CACA,MAAM,OAAO,SAAS,SAAS,MAAM,EAAE,UAAU,KAAK,CAAC,GAAG,MAAM;CAChE,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ANGED
@@ -1,4 +1,4 @@
1
- import { $ as ThemeConfig, A as EditLinkConfig, B as NormalizedDocsConfig, C as DocsEntry, D as DocsReference, E as DocsHeading, F as MarkdownConfig, G as SearchConfig, H as PackageLockSource, I as NavigationConfig, J as SiteLogoConfig, K as SiteConfig, L as NavigationItem, M as HeadConfig, N as HeaderLink, O as DocsRoute, P as LocaleConfig, Q as TableOfContentsConfig, R as NavigationPlacement, S as DocsDiagnostic, T as DocsGraph, U as PackageManifest, V as PackageDiscovery, W as PageSeoConfig, X as SiteVersion, Y as SiteSeoConfig, Z as SocialImage, _ as CookbookPaletteName, a as COOKBOOK_COMPONENT_NAMES, at as ThemeTokenValue, b as DocsAsset, c as ComponentStyleConfig, ct as TypographyPreset, d as ComponentsConfig, et as ThemeFont, f as ContentConfig, g as CookbookLock, h as CookbookComponentSubElementName, i as BuildConfig, it as ThemePaletteConfig, j as FontLoadingConfig, k as DocsSource, l as ComponentStyles, lt as TypographyPresets, m as CookbookComponentStyles, n as BrandDeclaration, nt as ThemeFonts, o as COOKBOOK_COMPONENT_SUB_ELEMENTS, ot as ThemeTokens, p as CookbookComponentName, q as SiteIconConfig, r as BreadcrumbItem, rt as ThemePaletteColor, s as COOKBOOK_PALETTE_NAMES, st as TrailingSlash, t as BrandConfig, tt as ThemeFontFile, u as ComponentStylesConfig, v as CreateDocsGraphOptions, w as DocsFrontmatter, x as DocsConfig, y as DiagnosticSeverity, z as NavigationTab } from "./types-yhxzgOIF.js";
1
+ import { $ as SocialImage, A as DocsRoute, B as NavigationPlacement, C as DocsConfig, D as DocsGraph, E as DocsFrontmatter, F as HeaderLink, G as PackageManifest, H as NormalizedDocsConfig, I as LocaleConfig, J as SiteConfig, K as PageSeoConfig, L as MarkdownConfig, M as EditLinkConfig, N as FontLoadingConfig, O as DocsHeading, P as HeadConfig, Q as SiteVersion, R as NavigationConfig, S as DocsAsset, T as DocsEntry, U as PackageDiscovery, V as NavigationTab, W as PackageLockSource, X as SiteLogoConfig, Y as SiteIconConfig, Z as SiteSeoConfig, _ as CookbookComponentSubElementName, a as COOKBOOK_COMPONENT_NAMES, at as ThemePaletteColor, b as CreateDocsGraphOptions, c as COOKBOOK_PALETTE_NAMES, ct as ThemeTokens, d as ComponentStylesConfig, dt as TypographyPresets, et as TableOfContentsConfig, f as ComponentsConfig, g as CookbookComponentStyles, h as CookbookComponentOverrideName, i as BuildConfig, it as ThemeFonts, j as DocsSource, k as DocsReference, l as ComponentStyleConfig, lt as TrailingSlash, m as CookbookComponentName, n as BrandDeclaration, nt as ThemeFont, o as COOKBOOK_COMPONENT_OVERRIDE_NAMES, ot as ThemePaletteConfig, p as ContentConfig, q as SearchConfig, r as BreadcrumbItem, rt as ThemeFontFile, s as COOKBOOK_COMPONENT_SUB_ELEMENTS, st as ThemeTokenValue, t as BrandConfig, tt as ThemeConfig, u as ComponentStyles, ut as TypographyPreset, v as CookbookLock, w as DocsDiagnostic, x as DiagnosticSeverity, y as CookbookPaletteName, z as NavigationItem } from "./types-ivmuV83x.js";
2
2
  import { DocsConfigError, defineDocsConfig, mergeDocsConfig, normalizeDocsConfig, validateConfig } from "./config/index.js";
3
3
  import { createDocsLoader } from "./content/index.js";
4
4
  import "@tenphi/glaze";
@@ -12,7 +12,10 @@ interface DocsProjectOptions {
12
12
  config?: DocsConfig;
13
13
  }
14
14
  interface DocsProject {
15
+ /** Content root: the configuration's directory joined with `config.root`. */
15
16
  root: string;
17
+ /** Directory searched for configuration, normally the Astro project directory. */
18
+ directory?: string;
16
19
  config: DocsConfig;
17
20
  configFile?: string;
18
21
  }
@@ -146,5 +149,5 @@ interface BuiltDocsReport {
146
149
  /** Inspect actual output, then optionally fetch the same pages/assets from a host. */
147
150
  declare function validateBuiltDocs(options: BuiltDocsOptions): Promise<BuiltDocsReport>;
148
151
  //#endregion
149
- export { type BrandConfig, type BrandDeclaration, type BreadcrumbItem, type BuildConfig, type BuiltDocsOptions, type BuiltDocsReport, COOKBOOK_COMPONENT_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, type ComponentStyleConfig, type ComponentStyles, type ComponentStylesConfig, type ComponentsConfig, type ContentConfig, type CookbookComponentName, type CookbookComponentStyles, type CookbookComponentSubElementName, type CookbookLock, type CookbookPaletteName, type CreateDocsGraphOptions, DOCS_FRONTMATTER_KEYS, type DiagnosticSeverity, type DocsAsset, type DocsConfig, DocsConfigError, type DocsDiagnostic, type DocsEntry, type DocsFrontmatter, type DocsGraph, type DocsHeading, type DocsProject, type DocsProjectOptions, type DocsReference, type DocsRoute, type DocsSource, DocsValidationError, type EditLinkConfig, type FontLoadingConfig, type HeadConfig, type HeaderLink, type LocaleConfig, type MarkdownConfig, type NavigationConfig, type NavigationItem, type NavigationPlacement, type NavigationTab, type NormalizedDocsConfig, type PackageDiscovery, type PackageLockSource, type PackageManifest, type PageSeoConfig, type SearchConfig, type SiteConfig, type SiteIconConfig, type SiteLogoConfig, type SiteSeoConfig, type SiteVersion, type SocialImage, type TableOfContentsConfig, type ThemeConfig, type ThemeFont, type ThemeFontFile, type ThemeFonts, type ThemePaletteColor, type ThemePaletteConfig, type ThemeTokenValue, type ThemeTokens, type TrailingSlash, type TypographyPreset, type TypographyPresets, assertSafePackagePath, assertValidDocs, createDocsGraph, createDocsLoader, defaultLock, defineDocsConfig, discoverPackage, formatDiagnostics, lockForSource, materializePackage, mergeDocsConfig, normalizeDocsConfig, normalizeRoute, packageNameFromSpecifier, pagePublishing, readDocsLock, reconcileDocsLock, renderAgentMarkdown, resolveColorTheme, resolveDocsProject, resolvePackageLock, routeForPath, routePath, routeUrl, routeVersion, validateBuiltDocs, validateConfig, validateDocs, validateLock, validateProjectAssets, writeDocsLock };
152
+ export { type BrandConfig, type BrandDeclaration, type BreadcrumbItem, type BuildConfig, type BuiltDocsOptions, type BuiltDocsReport, COOKBOOK_COMPONENT_NAMES, type COOKBOOK_COMPONENT_OVERRIDE_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, type ComponentStyleConfig, type ComponentStyles, type ComponentStylesConfig, type ComponentsConfig, type ContentConfig, type CookbookComponentName, type CookbookComponentOverrideName, type CookbookComponentStyles, type CookbookComponentSubElementName, type CookbookLock, type CookbookPaletteName, type CreateDocsGraphOptions, DOCS_FRONTMATTER_KEYS, type DiagnosticSeverity, type DocsAsset, type DocsConfig, DocsConfigError, type DocsDiagnostic, type DocsEntry, type DocsFrontmatter, type DocsGraph, type DocsHeading, type DocsProject, type DocsProjectOptions, type DocsReference, type DocsRoute, type DocsSource, DocsValidationError, type EditLinkConfig, type FontLoadingConfig, type HeadConfig, type HeaderLink, type LocaleConfig, type MarkdownConfig, type NavigationConfig, type NavigationItem, type NavigationPlacement, type NavigationTab, type NormalizedDocsConfig, type PackageDiscovery, type PackageLockSource, type PackageManifest, type PageSeoConfig, type SearchConfig, type SiteConfig, type SiteIconConfig, type SiteLogoConfig, type SiteSeoConfig, type SiteVersion, type SocialImage, type TableOfContentsConfig, type ThemeConfig, type ThemeFont, type ThemeFontFile, type ThemeFonts, type ThemePaletteColor, type ThemePaletteConfig, type ThemeTokenValue, type ThemeTokens, type TrailingSlash, type TypographyPreset, type TypographyPresets, assertSafePackagePath, assertValidDocs, createDocsGraph, createDocsLoader, defaultLock, defineDocsConfig, discoverPackage, formatDiagnostics, lockForSource, materializePackage, mergeDocsConfig, normalizeDocsConfig, normalizeRoute, packageNameFromSpecifier, pagePublishing, readDocsLock, reconcileDocsLock, renderAgentMarkdown, resolveColorTheme, resolveDocsProject, resolvePackageLock, routeForPath, routePath, routeUrl, routeVersion, validateBuiltDocs, validateConfig, validateDocs, validateLock, validateProjectAssets, writeDocsLock };
150
153
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/project/index.ts","../src/graph/index.ts","../src/npm/index.ts","../src/validation/index.ts","../src/theme/contrast.ts","../src/theme/palette.ts","../src/publishing.ts","../src/agent-markdown.ts","../src/validation/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AK,+CACZ,QAAQ;;;;;;;;;;;iBC1DM,oBACd,OAAO,WACP,QAAQ;;;;iBCDY,sBACpB,SAAS,aACT,OAAO,WACP,2BACC,QAAQ;;;UCJM;EACf;EACA,QAAQ;;EAER;;UAEe;EACf;EACA;EACA;EACA;EACA;EACA,aAAa;;;iBAaO,kBACpB,SAAS,mBACR,QAAQ"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/project/index.ts","../src/graph/index.ts","../src/npm/index.ts","../src/validation/index.ts","../src/theme/contrast.ts","../src/theme/palette.ts","../src/publishing.ts","../src/agent-markdown.ts","../src/validation/assets.ts","../src/validation/build.ts"],"mappings":";;;;;UAOiB;;EAEf;;EAEA;;EAEA,SAAS;;UAGM;;EAEf;;EAEA;EACA,QAAQ;EACR;;;iBAIoB,mBACpB,UAAS,qBACR,QAAQ;;;cC+CE,uBAAqB;iBAoBZ,gBACpB,UAAS,yBACR,QAAQ;iBA+qCK,eAAe;iBAaf,aACd,cACA,eACA;;;UCnwCe;EACf;EACA;;iBAGoB,mBACpB,mBACA,UAAS,wBACR,QAAQ;iBA0BW,aACpB,eACC,QAAQ;iBAaW,cACpB,cACA,MAAM,eACL;;iBAgBmB,kBACpB,QAAQ,YACR,UAAU,0BACV;EACE;EACA,iBAAiB;IAElB,QAAQ;iBAgFK,aAAa,MAAM;iBAiCb,mBACpB,QAAQ,mBACR,QAAQ,+BACR,uBACC;iBAoHmB,gBAAgB,eAAe,QAAQ;iBAyD7C,yBAAyB;iBAOzB,cACd,MAAM,0BACN,oBACC;;iBASa,sBAAsB,cAAc;iBAcpC,YAAY,SAAS,sBAAsB;;;cCza9C,4BAA4B;WAC9B,aAAa;EAEtB,YAAY,aAAa;;iBAOX,aAAa,OAAO,YAAY;iBAIhC,gBAAgB,OAAO;iBAOvB,kBACd,aAAa,kBACb;;;cCPI;UACW;EACf;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;;;;UCHe;EACf;IACE,SAAS;IACT,aAAa;IACb,aAAa;IACb,MAAM;IACN,SAAS;IACT,aAAa;IACb,eAAe;IACf,kBAAkB;IAClB,uBAAuB;IACvB,OAAO;IACP,QAAQ;;;EAGV,aAAa,eAAe;EAC5B;IACE;IACA;IACA;IACA;;EAEF,gBAAgB;EAChB,aAAa;;iBAGC,kBAAkB,QAAO,cAAmB;;;KC1ChD,mBAAmB,KAC7B;EAGA,QAAQ;IACN;IACA,gBAAgB;;;;;;;iBAQJ,UACd,eACA,eACA,gBAAe;iBAQD,SACd,eACA,eACA,eACA,gBAAe;;iBAOD,aACd,eACA,QAAQ,KAAK,kCACZ;iBAgBa,eACd,OAAO,KAAK,+CACZ,QAAQ;;;;;;;;;;;iBC1DM,oBACd,OAAO,WACP,QAAQ;;;;iBCDY,sBACpB,SAAS,aACT,OAAO,WACP,2BACC,QAAQ;;;UCJM;EACf;EACA,QAAQ;;EAER;;UAEe;EACf;EACA;EACA;EACA;EACA;EACA,aAAa;;;iBAaO,kBACpB,SAAS,mBACR,QAAQ"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as validateConfig, c as COOKBOOK_PALETTE_NAMES, d as routePath, f as routeUrl, i as normalizeDocsConfig, l as resolveColorTheme, n as defineDocsConfig, o as COOKBOOK_COMPONENT_NAMES, p as routeVersion, r as mergeDocsConfig, s as COOKBOOK_COMPONENT_SUB_ELEMENTS, t as DocsConfigError, u as pagePublishing } from "./config-BIrsSPND.js";
2
- import { _ as reconcileDocsLock, a as validateDocs, b as writeDocsLock, c as normalizeRoute, d as defaultLock, f as discoverPackage, g as readDocsLock, h as packageNameFromSpecifier, i as formatDiagnostics, l as routeForPath, m as materializePackage, n as DocsValidationError, o as DOCS_FRONTMATTER_KEYS, p as lockForSource, r as assertValidDocs, s as createDocsGraph, t as createDocsLoader, u as assertSafePackagePath, v as resolvePackageLock, y as validateLock } from "./content-pO3pNAj5.js";
1
+ import { a as validateConfig, c as COOKBOOK_PALETTE_NAMES, d as routePath, f as routeUrl, i as normalizeDocsConfig, l as resolveColorTheme, n as defineDocsConfig, o as COOKBOOK_COMPONENT_NAMES, p as routeVersion, r as mergeDocsConfig, s as COOKBOOK_COMPONENT_SUB_ELEMENTS, t as DocsConfigError, u as pagePublishing } from "./config-gcWx-nJJ.js";
2
+ import { _ as reconcileDocsLock, a as validateDocs, b as writeDocsLock, c as normalizeRoute, d as defaultLock, f as discoverPackage, g as readDocsLock, h as packageNameFromSpecifier, i as formatDiagnostics, l as routeForPath, m as materializePackage, n as DocsValidationError, o as DOCS_FRONTMATTER_KEYS, p as lockForSource, r as assertValidDocs, s as createDocsGraph, t as createDocsLoader, u as assertSafePackagePath, v as resolvePackageLock, y as validateLock } from "./content-DsyXFFAO.js";
3
3
  import { serializeMarkdown } from "./markdown/index.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { existsSync } from "node:fs";
@@ -37,6 +37,7 @@ async function resolveDocsProject(options = {}) {
37
37
  normalizeDocsConfig(config);
38
38
  return {
39
39
  root: resolve(configFile ? dirname(configFile) : directory, config.root ?? "."),
40
+ directory,
40
41
  config,
41
42
  ...configFile ? { configFile } : {}
42
43
  };
@@ -122,10 +123,11 @@ async function validateProjectAssets(project, graph, publicDirectory = resolve(p
122
123
  for (const src of "file" in hero ? [hero.file] : [hero.light, hero.dark]) if (!entry.assets.some((asset) => asset.resolved === src || asset.publicPath === src)) await publicFile(src, `${entry.sourcePath}: hero.image`);
123
124
  }
124
125
  }
125
- const require = createRequire(resolve(project.root, "package.json"));
126
+ const directory = project.directory ?? project.root;
127
+ const require = createRequire(resolve(directory, "package.json"));
126
128
  for (const [name, component] of Object.entries(project.config.components?.overrides ?? {})) {
127
129
  if (typeof component !== "string") continue;
128
- if (isAbsolute(component) || component.startsWith(".") || component.startsWith("src/")) await check(resolve(project.root, component), `components.overrides.${name}`);
130
+ if (isAbsolute(component) || component.startsWith(".")) await check(resolve(directory, component), `components.overrides.${name}`);
129
131
  else try {
130
132
  require.resolve(component);
131
133
  } catch {
@@ -133,7 +135,7 @@ async function validateProjectAssets(project, graph, publicDirectory = resolve(p
133
135
  code: "DOCS_COMPONENT_UNRESOLVED",
134
136
  severity: "error",
135
137
  message: `components.overrides.${name} cannot resolve ${component}.`,
136
- hint: "Install the component package or use a path relative to the project root."
138
+ hint: "Install the component package, or start a local path with ./ to resolve it from the Astro project directory."
137
139
  });
138
140
  }
139
141
  }