@duffcloudservices/cms 0.9.0 → 0.11.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/serveDefineInject.ts","../../src/plugins/dcsContentPlugin.ts","../../src/plugins/dcsSeoPlugin.ts","../../src/plugins/dcsEditorPlugin.ts","../../src/plugins/dcsPreviewPlugin.ts","../../src/plugins/dcsCdnImagePlugin.ts","../../src/plugins/responsiveImagePlugin.ts"],"names":["path","fs","yaml","escapeHtml"],"mappings":";;;;;;;AAiCO,SAAS,cAAA,CAAe,aAAqB,OAAA,EAA2B;AAC7E,EAAA,OAAO;AAAA,IACLA,KAAA,CAAK,OAAA,CAAQ,WAAA,EAAa,OAAO,CAAA;AAAA,IACjCA,KAAA,CAAK,OAAA,CAAQ,WAAA,EAAa,IAAA,EAAM,OAAO,CAAA;AAAA,IACvCA,KAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,GAAA,IAAO,OAAO;AAAA,GACrC;AACF;AAGO,SAAS,cAAA,CAAe,aAAqB,OAAA,EAAqC;AACvF,EAAA,OAAO,cAAA,CAAe,WAAA,EAAa,OAAO,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,KAAMC,GAAA,CAAG,UAAA,CAAW,CAAC,CAAC,CAAA;AAC1E;AAOO,SAAS,gBAAA,CACd,WAAA,EACA,OAAA,EACA,KAAA,EACA,QAAQ,KAAA,EACO;AACf,EAAA,MAAM,KAAA,GAAQ,cAAA,CAAe,WAAA,EAAa,OAAO,CAAA;AACjD,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,IAAI,OAAO,OAAA,CAAQ,GAAA,CAAI,IAAI,KAAK,CAAA,YAAA,EAAe,OAAO,CAAA,yBAAA,CAA2B,CAAA;AACjF,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,OAAOC,MAAK,IAAA,CAAKD,GAAA,CAAG,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A,EAAG,IAAI,CAAA,cAAA,CAAA;AAAA,MAClB,CAAA,EAAG,QAAQ,CAAA,EAAG,IAAI,CAAA,cAAA;AAAA,KACpB,CAAE,KAAK,IAAI,CAAA;AAEX,IAAA,MAAM,UAAA,GAAaA,YAAW,GAAG,CAAA;AASjC,IAAA,MAAM,eAAA,GAAkBA,YAAW,GAAG,CAAA;AACtC,IAAA,MAAM,OAAA,GACJ,+BAA+B,eAAe,CAAA,4EAAA,CAAA;AAGhD,IAAA,OAAO;AAAA,MACL,WAAA;AAAA,MACA,qBAAqB,MAAM,CAAA,gEAAA,CAAA;AAAA,MAC3B,eAAe,QAAQ,CAAA,EAAG,IAAI,CAAA,eAAA,EAAkB,UAAU,8CAA8C,OAAO,CAAA,IAAA,CAAA;AAAA,MAC/G;AAAA,KACF,CAAE,KAAK,IAAI,CAAA;AAAA,EACb,CAAA;AACF","file":"index.js","sourcesContent":["/**\n * Shared serve-mode helpers for the DCS content + SEO Vite plugins.\n *\n * In a production build the plugins bake the `.dcs/*.yaml` payload into a Vite\n * `define` literal (`define: { __DCS_X__: JSON.stringify(data) }`) so the SSG /\n * SPA bundle inlines it exactly as before.\n *\n * In dev (`vite` / `vitepress dev`, i.e. the portal preview) baking a literal\n * is wrong: the value is frozen at server-start and only a `server.restart()`\n * would refresh it — and that restart is exactly what triggers VitePress's\n * MiniSearch rebuild and the duplicate-heading \"server restart failed\" crash.\n *\n * Instead, in serve mode the plugins:\n * 1. redirect the `__DCS_X__` define to a browser global\n * (`define: { __DCS_X__: 'globalThis.__DCS_X__' }`), and\n * 2. inject an inline classic `<script>` at the top of `<head>` on every HTML\n * request that assigns the FRESH on-disk YAML to that global.\n *\n * Because `transformIndexHtml` re-runs on every dev HTML request, a plain\n * iframe reload (the portal's `?_hc` hard reload) reflects the latest on-disk\n * content with NO `server.restart()` and NO module-graph surgery. The consumer\n * is untouched: it still reads the bare `__DCS_X__` identifier, which the define\n * rewrites to `globalThis.__DCS_X__`.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport yaml from 'js-yaml'\n\n/**\n * The three `.dcs` search locations the plugins have always used. VitePress\n * projects have the `docs/` folder as root, so the parent is checked too.\n */\nexport function dcsSearchPaths(projectRoot: string, relPath: string): string[] {\n return [\n path.resolve(projectRoot, relPath),\n path.resolve(projectRoot, '..', relPath),\n path.resolve(process.cwd(), relPath),\n ]\n}\n\n/** First existing `.dcs` file from the standard search, or `undefined`. */\nexport function resolveDcsFile(projectRoot: string, relPath: string): string | undefined {\n return dcsSearchPaths(projectRoot, relPath).find((p) => fs.existsSync(p))\n}\n\n/**\n * Read + parse a `.dcs` YAML file FRESH from disk on every call (no caching).\n * Returns the parsed value, or `undefined` when the file is missing or\n * unparseable. Never throws — a dev HTML request must never 500 on bad YAML.\n */\nexport function readDcsYamlFresh<T = unknown>(\n projectRoot: string,\n relPath: string,\n label: string,\n debug = false\n): T | undefined {\n const found = resolveDcsFile(projectRoot, relPath)\n if (!found) {\n if (debug) console.log(`[${label}] serve: no ${relPath} found; global left unset`)\n return undefined\n }\n try {\n return yaml.load(fs.readFileSync(found, 'utf8')) as T\n } catch (error) {\n console.warn(`[${label}] serve: failed to parse ${relPath}:`, error)\n return undefined\n }\n}\n\n/**\n * Build a safe inline `<script>` body that assigns a JSON-serialisable value to\n * a browser global. Every `<` is escaped to its `<` unicode form so an\n * embedded `</script>` (or `<!--`) inside the content data can never break out\n * of the inline script.\n */\nexport function buildGlobalAssignScript(globalName: string, value: unknown): string {\n const json = JSON.stringify(value ?? null).replace(/</g, '\\\\u003c')\n return `globalThis.${globalName} = ${json};`\n}\n","/**\n * DCS Content Plugin for Vite\n *\n * Reads `.dcs/content.yaml` at build time and injects content\n * as `__DCS_CONTENT__` global variable for use by useTextContent.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [\n * dcsContentPlugin({ debug: true })\n * ]\n * })\n * ```\n *\n * For VitePress:\n * ```typescript\n * // .vitepress/config.ts\n * import { defineConfig } from 'vitepress'\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * vite: {\n * plugins: [\n * dcsContentPlugin()\n * ]\n * }\n * })\n * ```\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport yaml from 'js-yaml'\nimport type { Plugin, ResolvedConfig, HtmlTagDescriptor } from 'vite'\nimport type { DcsContentFile } from '../types/content'\nimport { readDcsYamlFresh, buildGlobalAssignScript } from './serveDefineInject'\n\nexport interface DcsContentPluginOptions {\n /** Path to content.yaml relative to project root (default: '.dcs/content.yaml') */\n contentPath?: string\n /** Enable debug logging */\n debug?: boolean\n}\n\n/**\n * Vite plugin that injects .dcs/content.yaml at build time.\n *\n * @param options - Plugin configuration\n * @returns Vite plugin\n */\nexport function dcsContentPlugin(options: DcsContentPluginOptions = {}): Plugin {\n const { contentPath = '.dcs/content.yaml', debug = false } = options\n\n let resolvedConfig: ResolvedConfig\n // Captured during configResolved — gates the serve-only inline HTML inject.\n let isDev = false\n\n return {\n name: 'dcs-content',\n\n configResolved(config) {\n resolvedConfig = config\n isDev = config.command === 'serve'\n },\n\n config(config, env) {\n // ── Dev / preview (serve) ──────────────────────────────────────────────\n // Don't bake content into the bundle. Redirect the `__DCS_CONTENT__`\n // define to a browser global that `transformIndexHtml` (below) refreshes\n // from disk on every HTML request — so a plain iframe reload reflects the\n // latest on-disk content with NO server.restart() and NO module-graph\n // surgery. The consumer is untouched: it still reads the bare\n // `__DCS_CONTENT__` identifier, which this define rewrites to\n // `globalThis.__DCS_CONTENT__`.\n if (env.command === 'serve') {\n return {\n define: {\n __DCS_CONTENT__: 'globalThis.__DCS_CONTENT__',\n },\n }\n }\n\n // ── Production build ───────────────────────────────────────────────────\n // Unchanged: read content.yaml now and bake it into the bundle as a\n // JSON literal so the SSG / SPA output inlines content exactly as before.\n const projectRoot = config.root || process.cwd()\n\n // Try to find content.yaml in multiple locations\n // VitePress projects have the docs folder as root, so check parent too\n const possiblePaths = [\n path.resolve(projectRoot, contentPath),\n path.resolve(projectRoot, '..', contentPath),\n path.resolve(process.cwd(), contentPath),\n ]\n\n let foundPath: string | undefined\n for (const testPath of possiblePaths) {\n if (fs.existsSync(testPath)) {\n foundPath = testPath\n break\n }\n }\n\n if (!foundPath) {\n if (debug) {\n console.log('[dcs-content] No content.yaml found at:')\n possiblePaths.forEach((p) => console.log(` - ${p}`))\n console.log('[dcs-content] Using defaults only')\n }\n return {\n define: {\n __DCS_CONTENT__: 'undefined',\n },\n }\n }\n\n try {\n const fileContent = fs.readFileSync(foundPath, 'utf8')\n const content = yaml.load(fileContent) as DcsContentFile\n\n if (debug) {\n console.log(`[dcs-content] Loaded ${foundPath}`)\n console.log(`[dcs-content] Version: ${content.version}`)\n console.log(`[dcs-content] Pages: ${Object.keys(content.pages ?? {}).join(', ') || '(none)'}`)\n console.log(`[dcs-content] Global keys: ${Object.keys(content.global ?? {}).length}`)\n }\n\n return {\n define: {\n __DCS_CONTENT__: JSON.stringify(content),\n },\n }\n } catch (error) {\n console.warn('[dcs-content] Failed to parse content.yaml:', error)\n return {\n define: {\n __DCS_CONTENT__: 'undefined',\n },\n }\n }\n },\n\n /**\n * Dev-only: inject the FRESH on-disk `content.yaml` as an inline\n * `globalThis.__DCS_CONTENT__ = {…}` classic script at the top of `<head>`.\n *\n * Runs on every dev HTML request, so the portal's `?_hc` hard reload (or any\n * full page reload) re-reads the YAML with no restart. A classic `<script>`\n * in `<head>` executes during HTML parsing, before the deferred module app\n * entry, so the global is set before the consumer's `useTextContent` setup\n * reads it. Gated on `isDev` so it never runs in `vite`/`vitepress build`\n * (the build path keeps the baked `define` literal).\n */\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n if (!isDev) return html\n\n const projectRoot = resolvedConfig?.root || process.cwd()\n const content = readDcsYamlFresh<DcsContentFile>(\n projectRoot,\n contentPath,\n 'dcs-content',\n debug\n )\n // No file (or unparseable) ⇒ leave the global unset; the consumer's\n // `typeof globalThis.__DCS_CONTENT__` check falls back to defaults.\n if (content === undefined) return html\n\n if (debug) {\n console.log('[dcs-content] serve: injecting fresh __DCS_CONTENT__ into <head>')\n }\n\n const tags: HtmlTagDescriptor[] = [\n {\n tag: 'script',\n children: buildGlobalAssignScript('__DCS_CONTENT__', content),\n injectTo: 'head-prepend',\n },\n ]\n return { html, tags }\n },\n },\n\n // Watch for changes in development.\n //\n // Downgraded from `server.restart()` to a debounced client `full-reload`:\n // freshness already comes from `transformIndexHtml` re-reading the YAML on\n // every HTML request, so all we need on change is to nudge the browser to\n // reload. A `server.restart()` would rebuild VitePress's dev MiniSearch\n // index and can throw \"server restart failed\" on a duplicate heading id —\n // exactly the fragility this fix removes. A `full-reload` does neither.\n configureServer(server) {\n const projectRoot = resolvedConfig?.root || process.cwd()\n\n const watchPaths = [\n path.resolve(projectRoot, contentPath),\n path.resolve(projectRoot, '..', contentPath),\n ].map((p) => path.normalize(p))\n\n watchPaths.forEach((watchPath) => {\n if (fs.existsSync(watchPath)) {\n server.watcher.add(watchPath)\n }\n })\n\n let reloadTimer: ReturnType<typeof setTimeout> | undefined\n server.watcher.on('change', (changedPath) => {\n if (!watchPaths.includes(path.normalize(changedPath))) return\n if (reloadTimer) clearTimeout(reloadTimer)\n reloadTimer = setTimeout(() => {\n if (debug) {\n console.log('[dcs-content] content.yaml changed, sending full-reload')\n }\n server.ws.send({ type: 'full-reload' })\n }, 100)\n })\n },\n }\n}\n","/**\n * DCS SEO Plugin for Vite\n *\n * Two responsibilities, both driven by `.dcs/seo.yaml`:\n *\n * 1. **Build-time define** (always on): reads `.dcs/seo.yaml` and injects it as\n * the `__DCS_SEO__` global for the runtime `useSEO` composable.\n *\n * 2. **Static `<head>` emitter** (opt-in via `emitStaticHtml: true`, default\n * OFF): after the bundle is written, reads the SPA's built `index.html`,\n * and for every route in `.dcs/pages.yaml` writes a per-route\n * `dist/<path>/index.html` whose `<head>` carries the resolved title, meta,\n * canonical, Open Graph, Twitter, and JSON-LD tags. This gives a Vue SPA\n * per-route static SEO **without** vite-ssg.\n *\n * VitePress sites already bake SEO via their own config, so they leave this\n * option OFF and are completely unaffected.\n *\n * @example Runtime define only (default — safe for VitePress)\n * ```typescript\n * // vite.config.ts\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [dcsSeoPlugin({ debug: true })]\n * })\n * ```\n *\n * @example Vue SPA with per-route static <head> emission\n * ```typescript\n * // vite.config.ts\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [\n * dcsSeoPlugin({\n * emitStaticHtml: true, // turn the emitter ON\n * pagesPath: '.dcs/pages.yaml', // route manifest (default)\n * noindex: ['account', 'projects'], // robots: noindex,nofollow\n * exclude: ['/preview'], // skip these routes entirely\n * })\n * ]\n * })\n * ```\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport yaml from 'js-yaml'\nimport type { Plugin, ResolvedConfig, HtmlTagDescriptor } from 'vite'\nimport type { SeoConfiguration } from '../types/seo'\nimport { readDcsYamlFresh, buildGlobalAssignScript } from './serveDefineInject'\nimport { buildHeadTags } from '../seo/headTags'\nimport { spliceHeadHtml } from '../seo/spliceHeadHtml'\nimport { loadPagesManifest, type PageRouteEntry } from '../seo/pagesManifest'\nimport {\n buildSitemapXml,\n buildRobotsTxt,\n buildLlmsTxt,\n matchesExcludedGlob,\n isHandAuthoredRobotsAcceptable,\n type DcsRobotsOptions,\n} from '../seo/sitemap'\nimport {\n breadcrumbTrailFromRoute,\n findReviewItemsForPage,\n type ContentConfig,\n type ReviewSource,\n type BlogMeta,\n type FaqSource,\n} from '../seo/schemaGraph'\n\nexport interface DcsSeoPluginOptions {\n /** Path to seo.yaml relative to project root (default: '.dcs/seo.yaml') */\n seoPath?: string\n /** Enable debug logging */\n debug?: boolean\n\n /**\n * Opt-in: emit per-route static `<head>` (meta + JSON-LD) into the built\n * `dist/` at the end of the build. Default `false` — VitePress sites and any\n * site that bakes its own SEO are unaffected when this is off.\n */\n emitStaticHtml?: boolean\n\n /**\n * Path to the route manifest relative to project root, used only when\n * `emitStaticHtml` is true. Default `'.dcs/pages.yaml'`.\n */\n pagesPath?: string\n\n /**\n * Path to `content.yaml` relative to project root, used only when\n * `emitStaticHtml` is true. Threads REAL reviews into the honest\n * Review/aggregateRating on the per-route LocalBusiness node. Default\n * `'.dcs/content.yaml'`. Missing/unparseable ⇒ no reviews emitted.\n */\n contentPath?: string\n\n /**\n * Routes to skip entirely (no per-route HTML written). Matched against the\n * route `path` (e.g. `'/preview'`) OR the route `slug` (e.g. `'account'`).\n */\n exclude?: string[]\n\n /**\n * Routes that should receive `robots: noindex, nofollow`. Matched against the\n * route `path` OR `slug`. The home route (`/`) still overwrites\n * `dist/index.html`.\n */\n noindex?: string[]\n\n /**\n * Opt-in: emit the site-wide static files `dist/sitemap.xml`,\n * `dist/robots.txt`, and `dist/llms.txt` after the per-route HTML loop.\n *\n * Defaults to whatever `emitStaticHtml` is — so every site already calling\n * `dcsSeoPlugin({ emitStaticHtml: true })` gets sitemap/robots/llms for free\n * with zero per-site edits. Set explicitly to `false` to keep emitting\n * per-route HTML without the site files. The whole block is wrapped in the\n * same try/catch + existsSync guards, so it can never break a build.\n */\n emitSiteFiles?: boolean\n\n /**\n * Canonical production origin, e.g. `https://ironoakcontractors.com`. Used as\n * the sitemap/llms base and the absolute `Sitemap:` line in robots.txt. When\n * absent, falls back to `seo.yaml`'s `global.siteUrl`; if neither is known and\n * no per-page canonicals exist, the sitemap + llms.txt no-op (robots still\n * emits). Never guessed.\n */\n siteUrl?: string\n\n /** robots.txt override hooks (disallow/allow/extra/aiBots/force). */\n robots?: DcsRobotsOptions\n\n /**\n * Preview / staging gate. When `true`, robots.txt becomes `Disallow: /` (no\n * `Sitemap:` line) and neither sitemap.xml nor llms.txt is emitted (privacy).\n * Detected ONLY via this explicit option — never guessed.\n */\n preview?: boolean\n\n /** Emit `dist/llms.txt` (default `true`; always off in preview mode). */\n llms?: boolean\n}\n\n/** Resolve the SPA output directory from Vite config (absolute path). */\nfunction resolveOutDir(config: ResolvedConfig): string {\n const out = config.build?.outDir || 'dist'\n return path.isAbsolute(out) ? out : path.resolve(config.root || process.cwd(), out)\n}\n\n/**\n * Load + parse seo.yaml from the usual `.dcs` locations.\n * Returns `{ config, foundPath }` or `null` (missing/unparseable).\n */\nfunction loadSeoConfig(\n projectRoot: string,\n seoPath: string,\n debug: boolean\n): { config: SeoConfiguration; foundPath: string } | null {\n const possiblePaths = [\n path.resolve(projectRoot, seoPath),\n path.resolve(projectRoot, '..', seoPath),\n path.resolve(process.cwd(), seoPath),\n ]\n\n let foundPath: string | undefined\n for (const testPath of possiblePaths) {\n if (fs.existsSync(testPath)) {\n foundPath = testPath\n break\n }\n }\n\n if (!foundPath) {\n if (debug) {\n console.log('[dcs-seo] No seo.yaml found at:')\n possiblePaths.forEach((p) => console.log(` - ${p}`))\n console.log('[dcs-seo] Using defaults only')\n }\n return null\n }\n\n try {\n const fileContent = fs.readFileSync(foundPath, 'utf8')\n const config = yaml.load(fileContent) as SeoConfiguration\n return { config, foundPath }\n } catch (error) {\n console.warn('[dcs-seo] Failed to parse seo.yaml:', error)\n return null\n }\n}\n\n/**\n * Load + parse `.dcs/content.yaml` from the usual `.dcs` locations. Returns the\n * parsed config or `undefined` (missing/unparseable). Used to thread REAL\n * reviews into the honest Review/aggregateRating builder. Never throws.\n */\nfunction loadContentConfig(\n projectRoot: string,\n contentRelPath: string,\n debug: boolean\n): ContentConfig | undefined {\n const possiblePaths = [\n path.resolve(projectRoot, contentRelPath),\n path.resolve(projectRoot, '..', contentRelPath),\n path.resolve(process.cwd(), contentRelPath),\n ]\n const foundPath = possiblePaths.find((p) => fs.existsSync(p))\n if (!foundPath) {\n if (debug) console.log(`[dcs-seo] No content.yaml found (reviews disabled)`)\n return undefined\n }\n try {\n const parsed = yaml.load(fs.readFileSync(foundPath, 'utf8'))\n if (!parsed || typeof parsed !== 'object') return undefined\n return parsed as ContentConfig\n } catch (error) {\n console.warn('[dcs-seo] Failed to parse content.yaml (reviews disabled):', error)\n return undefined\n }\n}\n\n/**\n * Normalise a route path to the on-disk output file:\n * '/' -> '<outDir>/index.html'\n * '/services' -> '<outDir>/services/index.html'\n * '/blog/my-post' -> '<outDir>/blog/my-post/index.html'\n * '/services/' -> '<outDir>/services/index.html'\n */\nfunction routeToOutputFile(outDir: string, routePath: string): string {\n const trimmed = routePath.replace(/^\\/+/, '').replace(/\\/+$/, '')\n if (trimmed === '') return path.join(outDir, 'index.html')\n return path.join(outDir, ...trimmed.split('/'), 'index.html')\n}\n\n/** Extract the optional top-level `excluded:` glob list from pages.yaml. */\nfunction loadExcludedGlobs(projectRoot: string, pagesPath: string): string[] {\n const possiblePaths = [\n path.resolve(projectRoot, pagesPath),\n path.resolve(projectRoot, '..', pagesPath),\n path.resolve(process.cwd(), pagesPath),\n ]\n const found = possiblePaths.find((p) => fs.existsSync(p))\n if (!found) return []\n try {\n const raw = yaml.load(fs.readFileSync(found, 'utf8')) as { excluded?: unknown } | null\n const excluded = raw?.excluded\n if (!Array.isArray(excluded)) return []\n return excluded.filter((e): e is string => typeof e === 'string')\n } catch {\n return []\n }\n}\n\n/**\n * Derive a single site-wide lastmod from seo.yaml `lastUpdated` (preferred) or\n * pages.yaml `lastUpdated`. No fabricated per-page dates.\n */\nfunction deriveLastmod(\n seoConfig: SeoConfiguration | undefined,\n projectRoot: string,\n pagesPath: string\n): string | undefined {\n const fromSeo = seoConfig?.lastUpdated\n if (typeof fromSeo === 'string' && fromSeo.length > 0) return fromSeo\n\n const possiblePaths = [\n path.resolve(projectRoot, pagesPath),\n path.resolve(projectRoot, '..', pagesPath),\n path.resolve(process.cwd(), pagesPath),\n ]\n const found = possiblePaths.find((p) => fs.existsSync(p))\n if (!found) return undefined\n try {\n const raw = yaml.load(fs.readFileSync(found, 'utf8')) as { lastUpdated?: unknown } | null\n const fromPages = raw?.lastUpdated\n if (typeof fromPages === 'string' && fromPages.length > 0) return fromPages\n } catch {\n /* ignore */\n }\n return undefined\n}\n\n/**\n * Core site-file emitter, separated from Vite so it is unit-testable.\n *\n * Writes the site-wide static files into `outDir`, reusing the SAME routes +\n * seoConfig already loaded by the per-route HTML loop (no second manifest read):\n * - `sitemap.xml` (skipped in preview, or when no absolute base is derivable)\n * - `robots.txt` (always; preview = `Disallow: /`; don't-clobber unless force)\n * - `llms.txt` (skipped in preview, or when nothing indexable)\n *\n * Returns the list of relative filenames written. Pure aside from `fs` writes —\n * deterministic + idempotent. Never throws (the caller also wraps in try/catch).\n */\nexport function emitSiteFiles(params: {\n outDir: string\n projectRoot: string\n pagesPath: string\n routes: PageRouteEntry[]\n seoConfig: SeoConfiguration | undefined\n siteUrl?: string\n exclude?: string[]\n noindex?: string[]\n preview?: boolean\n robots?: DcsRobotsOptions\n llms?: boolean\n debug?: boolean\n}): string[] {\n const {\n outDir,\n projectRoot,\n pagesPath,\n routes,\n seoConfig,\n siteUrl,\n exclude = [],\n noindex = [],\n preview = false,\n robots = {},\n llms = true,\n debug = false,\n } = params\n\n const written: string[] = []\n\n const effectiveSiteUrl = siteUrl || seoConfig?.global?.siteUrl\n const excludedGlobs = loadExcludedGlobs(projectRoot, pagesPath)\n const lastmod = deriveLastmod(seoConfig, projectRoot, pagesPath)\n\n // ── sitemap.xml (not in preview) ──────────────────────────────────────────\n let wroteSitemap = false\n if (!preview) {\n const xml = buildSitemapXml({\n routes,\n siteUrl: effectiveSiteUrl,\n seoConfig,\n exclude,\n noindex,\n excludedGlobs,\n lastmod,\n })\n if (xml) {\n fs.writeFileSync(path.join(outDir, 'sitemap.xml'), xml, 'utf8')\n wroteSitemap = true\n written.push('sitemap.xml')\n if (debug) console.log('[dcs-seo] wrote sitemap.xml')\n } else if (debug) {\n console.log('[dcs-seo] no absolute <loc> derivable; sitemap.xml not written')\n }\n }\n\n // ── robots.txt (always, unless robots.enabled is false) ───────────────────\n if (robots.enabled ?? true) {\n const robotsPath = path.join(outDir, 'robots.txt')\n // Factory-as-single-source (validated override): a hand-authored\n // public/robots.txt Vite copied into dist is KEPT only when it meets the\n // factory floor (a real `User-agent: *` group + every AI-bot tier). A stub\n // (`Sitemap:`-only, like just-posh) or an SPA-shell HTML page fails the\n // floor and is overwritten so AI discovery is guaranteed on every site.\n // `force` always overwrites; an absent file is always written.\n const existing =\n fs.existsSync(robotsPath) && !robots.force ? fs.readFileSync(robotsPath, 'utf8') : null\n const keepHandAuthored = existing !== null && isHandAuthoredRobotsAcceptable(existing)\n if (keepHandAuthored) {\n if (debug)\n console.log('[dcs-seo] dist/robots.txt is hand-authored and meets the floor; leaving it')\n } else {\n const txt = buildRobotsTxt({\n siteUrl: effectiveSiteUrl,\n preview,\n robots,\n hasSitemap: wroteSitemap,\n })\n fs.writeFileSync(robotsPath, txt, 'utf8')\n written.push('robots.txt')\n if (debug) {\n console.log(\n existing !== null\n ? '[dcs-seo] dist/robots.txt failed the factory floor; overwrote with emitted robots'\n : '[dcs-seo] wrote robots.txt'\n )\n }\n }\n }\n\n // ── llms.txt (not in preview) ─────────────────────────────────────────────\n if (llms && !preview) {\n const txt = buildLlmsTxt({\n routes,\n siteUrl: effectiveSiteUrl,\n seoConfig,\n exclude,\n noindex,\n excludedGlobs,\n })\n if (txt) {\n fs.writeFileSync(path.join(outDir, 'llms.txt'), txt, 'utf8')\n written.push('llms.txt')\n if (debug) console.log('[dcs-seo] wrote llms.txt')\n } else if (debug) {\n console.log('[dcs-seo] nothing indexable; llms.txt not written')\n }\n }\n\n return written\n}\n\n/**\n * Pick a structured FAQ array (`[{ q, a }]`) for a page from content.yaml, if\n * one exists under a `faq` key (page-scoped, then global). Returns `undefined`\n * when there is no structured Q&A — a `<FaqPage />` component is NOT a source,\n * so its pages correctly yield nothing (honesty).\n */\nfunction pickPageFaq(\n content: ContentConfig | undefined,\n pageSlug: string\n): FaqSource[] | undefined {\n if (!content) return undefined\n const fromBlock = (block: Record<string, unknown> | undefined): FaqSource[] | undefined => {\n if (!block) return undefined\n const v = block['faq']\n return Array.isArray(v) ? (v as FaqSource[]) : undefined\n }\n return fromBlock(content.pages?.[pageSlug]) ?? fromBlock(content.global)\n}\n\n/**\n * Core emitter, separated from Vite so it is unit-testable.\n *\n * For each route: build the head tags from the shared resolver, splice them\n * into the shell HTML, and write `dist/<path>/index.html`. Returns the number\n * of files written. Pure aside from `fs` writes — deterministic + idempotent.\n */\nexport function emitStaticSeoHtml(params: {\n outDir: string\n shellHtml: string\n routes: PageRouteEntry[]\n seoConfig: SeoConfiguration | undefined\n /**\n * Parsed `.dcs/content.yaml` — threads REAL review items (honesty-gated) into\n * the per-route LocalBusiness node. Optional; omit ⇒ no Review/aggregateRating.\n */\n contentConfig?: ContentConfig\n exclude?: string[]\n noindex?: string[]\n /** `pages.yaml` top-level `excluded:` globs — routes matching are NOT emitted. */\n excludedGlobs?: string[]\n debug?: boolean\n}): number {\n const {\n outDir,\n shellHtml,\n routes,\n seoConfig,\n contentConfig,\n exclude = [],\n noindex = [],\n excludedGlobs = [],\n debug = false,\n } = params\n\n const excludeSet = new Set(exclude)\n const noindexSet = new Set(noindex)\n\n // Route → human title map (for breadcrumb hop labels), from the manifest.\n const siteUrl = seoConfig?.global?.siteUrl ?? ''\n const routeTitles: Record<string, string> = { '/': 'Home' }\n for (const r of routes) {\n if (r.title && r.path) routeTitles[r.path.replace(/\\/+$/, '') || '/'] = r.title\n }\n\n let written = 0\n for (const route of routes) {\n if (excludeSet.has(route.path) || (route.slug && excludeSet.has(route.slug))) {\n if (debug) console.log(`[dcs-seo] skip (excluded): ${route.path}`)\n continue\n }\n\n // Honor pages.yaml top-level `excluded:` globs (e.g. `/dev-*`, `/_*`): an\n // excluded route must NOT get a per-route index.html, or it becomes a\n // crawlable/indexable page despite being intentionally hidden — a privacy\n // and crawl-budget leak. Same glob semantics as the sitemap path.\n if (matchesExcludedGlob(route.path, excludedGlobs)) {\n if (debug) console.log(`[dcs-seo] skip (excluded glob): ${route.path}`)\n continue\n }\n\n const forceNoindex =\n noindexSet.has(route.path) || (route.slug && noindexSet.has(route.slug))\n\n // Breadcrumb trail from route depth (home ⇒ none); titles from the manifest.\n const breadcrumbTrail = siteUrl\n ? breadcrumbTrailFromRoute(route.path, siteUrl, routeTitles)\n : undefined\n\n // REAL reviews for this page from content.yaml (honesty-gated downstream).\n const reviews: ReviewSource[] | undefined = contentConfig\n ? findReviewItemsForPage(contentConfig, route.slug)\n : undefined\n\n // BlogPosting for a blog post route — only when seo.yaml has NOT already\n // hand-authored one (buildHeadTags skips ours if it has). A blog post is a\n // route nested under `/blog/` (depth ≥ 2) with a manifest title.\n const isBlogPost = /^\\/blog\\/.+/.test(route.path) && !!route.title\n const blogMeta: BlogMeta | undefined = isBlogPost\n ? { headline: route.title, url: breadcrumbTrail?.[breadcrumbTrail.length - 1]?.item }\n : undefined\n\n // FAQ from a structured `.dcs/faq.yaml`-style block on the content page, if\n // present (honesty-gated). Component-only FAQ pages carry no such data.\n const faq: FaqSource[] | undefined = pickPageFaq(contentConfig, route.slug)\n\n const tags = buildHeadTags(route.slug, route.path, seoConfig, {\n includeKeywords: true,\n fallbackTitle: route.title,\n robots: forceNoindex ? 'noindex, nofollow' : undefined,\n emitGraph: true,\n breadcrumbTrail,\n reviews,\n blogMeta,\n faq,\n })\n\n const html = spliceHeadHtml(shellHtml, tags)\n const outFile = routeToOutputFile(outDir, route.path)\n\n fs.mkdirSync(path.dirname(outFile), { recursive: true })\n fs.writeFileSync(outFile, html, 'utf8')\n written++\n\n if (debug) {\n console.log(\n `[dcs-seo] wrote ${path.relative(outDir, outFile)} (title=\"${tags.title}\"${\n forceNoindex ? ', noindex' : ''\n })`\n )\n }\n }\n\n return written\n}\n\n/**\n * Vite plugin that injects .dcs/seo.yaml at build time and, optionally, emits\n * per-route static `<head>` HTML for SPA SEO.\n *\n * @param options - Plugin configuration\n * @returns Vite plugin\n */\nexport function dcsSeoPlugin(options: DcsSeoPluginOptions = {}): Plugin {\n const {\n seoPath = '.dcs/seo.yaml',\n debug = false,\n emitStaticHtml = false,\n pagesPath = '.dcs/pages.yaml',\n contentPath = '.dcs/content.yaml',\n exclude = [],\n noindex = [],\n // Site files default ON whenever per-route HTML emission is on, so the\n // sites already using emitStaticHtml gain sitemap/robots/llms with no edit.\n emitSiteFiles: emitSiteFilesOpt = emitStaticHtml,\n siteUrl,\n robots = {},\n preview = false,\n llms = true,\n } = options\n\n let resolvedConfig: ResolvedConfig\n // Captured during configResolved — gates the serve-only inline HTML inject.\n let isDev = false\n\n return {\n name: 'dcs-seo',\n\n configResolved(config) {\n resolvedConfig = config\n isDev = config.command === 'serve'\n },\n\n config(config, env) {\n // ── Dev / preview (serve) ──────────────────────────────────────────────\n // Don't bake seo.yaml into the bundle. Redirect the `__DCS_SEO__` define\n // to a browser global that `transformIndexHtml` (below) refreshes from\n // disk on every HTML request — live preview with NO server.restart().\n // The consumer is untouched: it still reads the bare `__DCS_SEO__`\n // identifier, which this define rewrites to `globalThis.__DCS_SEO__`.\n // (VitePress treats `useSEO` as a no-op and bakes SEO via\n // transformPageData, so this only affects the runtime `useSEO` SPA path.)\n if (env.command === 'serve') {\n return {\n define: {\n __DCS_SEO__: 'globalThis.__DCS_SEO__',\n },\n }\n }\n\n // ── Production build ───────────────────────────────────────────────────\n // Unchanged: read seo.yaml now and bake it into the bundle as a literal.\n const projectRoot = config.root || process.cwd()\n\n const loaded = loadSeoConfig(projectRoot, seoPath, debug)\n if (!loaded) {\n return {\n define: {\n __DCS_SEO__: 'undefined',\n },\n }\n }\n\n if (debug) {\n console.log(`[dcs-seo] Loaded ${loaded.foundPath}`)\n console.log(`[dcs-seo] Version: ${loaded.config.version}`)\n console.log(`[dcs-seo] Site Name: ${loaded.config.global?.siteName || '(not set)'}`)\n console.log(\n `[dcs-seo] Pages: ${Object.keys(loaded.config.pages ?? {}).join(', ') || '(none)'}`\n )\n }\n\n return {\n define: {\n __DCS_SEO__: JSON.stringify(loaded.config),\n },\n }\n },\n\n /**\n * Build-time static `<head>` emitter (opt-in via `emitStaticHtml`).\n *\n * Runs after the bundle is written so the built `index.html` shell exists\n * on disk. For an SPA, Vite emits a single `index.html`; we fan it out to\n * per-route files with route-specific `<head>` content.\n *\n * Fully defensive: any missing/unparseable input logs a warning and\n * no-ops. Never throws (so it can never break a production build).\n */\n writeBundle() {\n if (!emitStaticHtml) {\n // The whole emit path is gated on emitStaticHtml. If the operator\n // explicitly asked for site files (`emitSiteFiles: true`) while\n // emitStaticHtml is off, that request is silently inert — warn so it's\n // not mistaken for \"robots/sitemap were emitted\".\n if (options.emitSiteFiles === true) {\n console.warn(\n '[dcs-seo] emitSiteFiles:true is ignored because emitStaticHtml is false; ' +\n 'set emitStaticHtml:true to emit sitemap.xml/robots.txt/llms.txt'\n )\n }\n return\n }\n\n try {\n const projectRoot = resolvedConfig?.root || process.cwd()\n const outDir = resolveOutDir(resolvedConfig)\n\n if (!fs.existsSync(outDir)) {\n console.warn(`[dcs-seo] emitStaticHtml: outDir not found (${outDir}); skipping`)\n return\n }\n\n const shellPath = path.join(outDir, 'index.html')\n if (!fs.existsSync(shellPath)) {\n console.warn(\n `[dcs-seo] emitStaticHtml: no index.html in ${outDir}; nothing to emit`\n )\n return\n }\n\n const routes = loadPagesManifest(projectRoot, pagesPath, debug)\n if (!routes) {\n console.warn(\n `[dcs-seo] emitStaticHtml: ${pagesPath} missing or empty; skipping per-route emission`\n )\n return\n }\n\n const loaded = loadSeoConfig(projectRoot, seoPath, debug)\n if (!loaded) {\n // seo.yaml is optional for emission — routes still get baked with\n // global/runtime defaults (which here means just the shell title and\n // a derived canonical-less head). Warn so the operator knows.\n console.warn(\n `[dcs-seo] emitStaticHtml: ${seoPath} missing or unparseable; emitting with defaults only`\n )\n }\n\n const shellHtml = fs.readFileSync(shellPath, 'utf8')\n\n // pages.yaml top-level `excluded:` globs gate BOTH the per-route HTML\n // emission below and the sitemap/llms set inside emitSiteFiles, so an\n // excluded route is never written as a crawlable index.html.\n const excludedGlobs = loadExcludedGlobs(projectRoot, pagesPath)\n // Optional: load content.yaml so REAL reviews can feed the honest\n // Review/aggregateRating on the per-route LocalBusiness node. Absent or\n // unparseable ⇒ undefined ⇒ no reviews emitted (no synthesis).\n const contentConfig = loadContentConfig(projectRoot, contentPath, debug)\n\n const written = emitStaticSeoHtml({\n outDir,\n shellHtml,\n routes,\n seoConfig: loaded?.config,\n contentConfig,\n exclude,\n noindex,\n excludedGlobs,\n debug,\n })\n\n if (debug) {\n console.log(`[dcs-seo] emitStaticHtml: wrote ${written} per-route HTML file(s)`)\n }\n\n // ── site-wide static files (sitemap.xml, robots.txt, llms.txt) ──────\n // Emitted AFTER the per-route HTML loop so canonicals/routes are\n // resolved and the shell exists. Reuses the already-loaded routes +\n // seoConfig (no second manifest read). Same outDir/existsSync guard +\n // the outer try/catch — so it can never break a production build.\n if (emitSiteFilesOpt) {\n const siteFiles = emitSiteFiles({\n outDir,\n projectRoot,\n pagesPath,\n routes,\n seoConfig: loaded?.config,\n siteUrl,\n exclude,\n noindex,\n preview,\n robots,\n llms,\n debug,\n })\n if (debug) {\n console.log(\n `[dcs-seo] emitSiteFiles: wrote ${siteFiles.length} site file(s): ${\n siteFiles.join(', ') || '(none)'\n }`\n )\n }\n }\n } catch (error) {\n // Never break the build on SEO emission failure.\n console.warn('[dcs-seo] emitStaticHtml failed; build output left unchanged:', error)\n }\n },\n\n /**\n * Dev-only: inject the FRESH on-disk `seo.yaml` as an inline\n * `globalThis.__DCS_SEO__ = {…}` classic script at the top of `<head>`,\n * mirroring dcsContentPlugin. Lets the runtime `useSEO` SPA path reflect\n * on-disk SEO edits on the portal's `?_hc` hard reload with no restart.\n * Gated on `isDev` so it never runs in `vite`/`vitepress build` (the build\n * path keeps the baked `define` literal + the `writeBundle` emitter).\n */\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n if (!isDev) return html\n\n const projectRoot = resolvedConfig?.root || process.cwd()\n const config = readDcsYamlFresh<SeoConfiguration>(projectRoot, seoPath, 'dcs-seo', debug)\n // No file (or unparseable) ⇒ leave the global unset; the consumer's\n // `typeof globalThis.__DCS_SEO__` check falls back to defaults.\n if (config === undefined) return html\n\n if (debug) {\n console.log('[dcs-seo] serve: injecting fresh __DCS_SEO__ into <head>')\n }\n\n const tags: HtmlTagDescriptor[] = [\n {\n tag: 'script',\n children: buildGlobalAssignScript('__DCS_SEO__', config),\n injectTo: 'head-prepend',\n },\n ]\n return { html, tags }\n },\n },\n\n // Watch for changes in development.\n //\n // Downgraded from `server.restart()` to a debounced client `full-reload`:\n // freshness already comes from `transformIndexHtml` re-reading the YAML on\n // every HTML request, so all we need on change is a browser reload. A\n // `server.restart()` would rebuild VitePress's dev MiniSearch index and can\n // throw \"server restart failed\" on a duplicate heading id — the fragility\n // this fix removes. A `full-reload` does neither.\n configureServer(server) {\n const projectRoot = resolvedConfig?.root || process.cwd()\n\n const watchPaths = [\n path.resolve(projectRoot, seoPath),\n path.resolve(projectRoot, '..', seoPath),\n ].map((p) => path.normalize(p))\n\n watchPaths.forEach((watchPath) => {\n if (fs.existsSync(watchPath)) {\n server.watcher.add(watchPath)\n }\n })\n\n let reloadTimer: ReturnType<typeof setTimeout> | undefined\n server.watcher.on('change', (changedPath) => {\n if (!watchPaths.includes(path.normalize(changedPath))) return\n if (reloadTimer) clearTimeout(reloadTimer)\n reloadTimer = setTimeout(() => {\n if (debug) {\n console.log('[dcs-seo] seo.yaml changed, sending full-reload')\n }\n server.ws.send({ type: 'full-reload' })\n }, 100)\n })\n },\n }\n}\n","/**\n * DCS Editor Plugin for Vite\n *\n * Injects the editor bridge script into customer sites when running\n * in portal preview mode (inside the visual editor iframe).\n *\n * The bridge enables:\n * - Inline text editing via contenteditable\n * - Section hover highlights and AI ✨ buttons\n * - postMessage communication with the portal\n *\n * This plugin should only be active in development/preview mode.\n * It's safe to include in production builds — it does nothing unless\n * the page detects it's inside an iframe.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { dcsEditorPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [\n * dcsEditorPlugin()\n * ]\n * })\n * ```\n */\n\nimport type { Plugin } from 'vite'\n\nexport interface DcsEditorPluginOptions {\n /** Enable debug logging */\n debug?: boolean\n}\n\n/**\n * Vite plugin that injects the editor bridge script for portal preview integration.\n *\n * The bridge auto-initializes only when the page detects it's running inside an iframe,\n * so it's safe to include in all builds — it's a no-op in standalone browsing.\n *\n * Uses a virtual module (`/__dcs-editor-bridge.js`) served through Vite's dev server\n * so that bare module specifiers (like `@duffcloudservices/cms/editor`) are properly\n * resolved through Vite's module graph rather than hitting the browser's native ESM\n * resolver, which can't handle bare specifiers.\n */\nexport function dcsEditorPlugin(options: DcsEditorPluginOptions = {}): Plugin {\n const { debug = false } = options\n const VIRTUAL_PATH = '/__dcs-editor-bridge.js'\n const RIBBON_VIRTUAL_PATH = '/__dcs-preview-ribbon.js'\n\n // Captured during configResolved — used to gate HTML injection.\n let isDev = false\n let basePath = '/'\n let isPreview = false\n\n return {\n name: 'dcs-editor-bridge',\n\n // Preview only: stop Vite running an unreachable HMR WebSocket server.\n // Freshness comes from the cms content/seo plugins (fresh transformIndexHtml\n // re-read) + the portal's ?_hc hard reload, not HMR. NOTE: this alone does\n // NOT silence the browser — Vite still injects @vite/client and calls\n // connect(); the client-side stub in transformIndexHtml is what removes the\n // console errors. A normal local `vite dev` (no DCS_PREVIEW) keeps full HMR.\n config(_config, env) {\n if (env.command === 'serve' && process.env.DCS_PREVIEW === 'true') {\n return { server: { hmr: false } }\n }\n },\n\n configResolved(config) {\n isDev = config.command === 'serve'\n basePath = config.base ?? '/'\n isPreview = process.env.DCS_PREVIEW === 'true'\n },\n\n resolveId(id) {\n if (id === VIRTUAL_PATH || id === RIBBON_VIRTUAL_PATH) {\n return id\n }\n },\n\n load(id) {\n if (id === VIRTUAL_PATH) {\n return `\nimport { initEditorBridge } from '@duffcloudservices/cms/editor'\n// The bridge only activates inside an iframe (portal preview)\nif (window.parent !== window) {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => setTimeout(initEditorBridge, 200))\n } else {\n setTimeout(initEditorBridge, 200)\n }\n}\n`\n }\n\n if (id === RIBBON_VIRTUAL_PATH) {\n return `\nimport { createApp } from 'vue'\nimport PreviewRibbon from '@duffcloudservices/cms/components'\n\nfunction mountRibbon() {\n // Create a detached mount point\n const el = document.createElement('div')\n el.id = 'dcs-preview-ribbon-root'\n document.body.appendChild(el)\n\n const app = createApp(PreviewRibbon)\n app.mount(el)\n}\n\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', mountRibbon)\n} else {\n mountRibbon()\n}\n`\n }\n },\n\n /**\n * Only inject the editor bridge and ribbon scripts when:\n * 1. Running in dev mode (Vite dev server), AND\n * 2. The app is served at the root path (base === '/')\n *\n * These are virtual modules resolved via absolute paths (e.g.\n * `/__dcs-editor-bridge.js`). When base !== '/', the app is served at a\n * sub-path (e.g. /handyman-bryan/) and the absolute virtual paths are NOT\n * routed to the Vite dev server by the reverse proxy — they hit the main\n * DCS server instead and get redirected to portal.duffcloudservices.com\n * (no CORS headers), causing browser console errors.\n *\n * In production builds, App.vue imports and mounts PreviewRibbon\n * directly, so virtual script injection is always redundant anyway.\n */\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n if (!isDev || basePath !== '/') return html\n\n if (debug) {\n console.log('[dcs-editor] Injecting editor bridge + preview ribbon script tags')\n }\n\n // Inject both the editor bridge and preview ribbon scripts\n const editorTag = `<script type=\"module\" src=\"${VIRTUAL_PATH}\"></script>`\n const ribbonTag = `<script type=\"module\" src=\"${RIBBON_VIRTUAL_PATH}\"></script>`\n const bodyHtml = html.replace('</body>', `${editorTag}\\n${ribbonTag}\\n</body>`)\n\n if (!isPreview) return bodyHtml\n\n // Preview only: neutralise Vite's HMR WebSocket. Vite always injects\n // @vite/client and unconditionally calls transport.connect(); behind the\n // preview proxy chain there is no reachable HMR WS, so it logs\n // WebSocket connection to 'wss://<portal>/?token=…' failed\n // WebSocket connection to 'wss://localhost:<port>/?token=…' failed\n // [vite] failed to connect to websocket\n // server.hmr:false does NOT stop this (the client is still injected). A\n // classic <script> in <head> runs during parse, BEFORE the deferred\n // @vite/client module, so returning an inert socket for the 'vite-hmr'\n // subprotocol silences the attempt with zero effect on app/runtime\n // WebSockets. No-op outside preview / in production builds.\n const wsStub =\n `(function(){try{var N=window.WebSocket;if(!N)return;` +\n `function hmr(p){return p==='vite-hmr'||(Array.isArray(p)&&p.indexOf('vite-hmr')!==-1)}` +\n `function Inert(){this.readyState=0}` +\n `Inert.prototype.send=function(){};Inert.prototype.close=function(){};` +\n `Inert.prototype.addEventListener=function(){};Inert.prototype.removeEventListener=function(){};` +\n `var W=function(u,p){if(hmr(p))return new Inert();return new N(u,p)};` +\n `W.prototype=N.prototype;W.CONNECTING=N.CONNECTING;W.OPEN=N.OPEN;W.CLOSING=N.CLOSING;W.CLOSED=N.CLOSED;` +\n `window.WebSocket=W}catch(e){}})()`\n\n return {\n html: bodyHtml,\n tags: [{ tag: 'script', children: wsStub, injectTo: 'head-prepend' }],\n }\n },\n },\n }\n}\n","/**\n * DCS Preview Plugin for Vue\n *\n * Registers a supplied ribbon component as a global `DcsPreviewRibbon`\n * component. The ribbon handles its own visibility — it only renders on\n * `preview.duffcloudservices.com` and hides everywhere else (localhost,\n * production domains, and inside the visual page editor iframe).\n *\n * Why does the caller pass the component in? Because this file is compiled\n * by tsup (esbuild) which has no `.vue` SFC loader. Keeping the raw `.vue`\n * import out of the compiled plugins bundle avoids the build error while\n * still letting consumer code (which *does* run through Vite) resolve the\n * SFC at dev/build time.\n *\n * @example VitePress theme/index.ts\n * ```typescript\n * import { dcsPreviewPlugin } from '@duffcloudservices/cms/plugins'\n * import PreviewRibbon from '@duffcloudservices/cms/components'\n *\n * export default {\n * Layout,\n * enhanceApp({ app }) {\n * app.use(dcsPreviewPlugin(PreviewRibbon))\n * }\n * }\n * ```\n */\n\nimport { defineComponent, h, type App, type Component, type Plugin } from 'vue'\n\nexport interface DcsPreviewPluginOptions {\n /**\n * Override the version string displayed on the ribbon.\n * If omitted, the ribbon auto-detects from VITE_SITE_VERSION or the API.\n */\n version?: string | null\n}\n\n/**\n * Creates and returns the DCS Preview plugin.\n *\n * When installed, it registers the supplied ribbon component as a global\n * `DcsPreviewRibbon` component. Add `<DcsPreviewRibbon />` to your root\n * Layout, or use the `dcsEditorPlugin` Vite plugin which injects it via\n * `transformIndexHtml`.\n *\n * @param ribbonComponent - The PreviewRibbon SFC (imported by the consumer)\n * @param options - Optional configuration\n */\nexport function dcsPreviewPlugin(\n ribbonComponent: Component,\n options: DcsPreviewPluginOptions = {},\n): Plugin {\n const Wrapper = defineComponent({\n name: 'DcsPreviewRibbon',\n setup() {\n return () => h(ribbonComponent, { version: options.version ?? null })\n },\n })\n\n return {\n install(app: App) {\n app.component('DcsPreviewRibbon', Wrapper)\n\n if (options.version !== undefined) {\n app.provide('__dcs_preview_version__', options.version)\n }\n },\n }\n}\n","/**\n * DCS CDN Image Plugin for Vite\n *\n * Rewrites local static image references (e.g. `/images/staff/photo.jpg`)\n * to CDN URLs at build time using the `.dcs/cdn-image-map.json` mapping file\n * generated by the `image-migrate adopt` CLI command.\n *\n * For raster images with WebP variants, `<img>` elements are transformed into\n * responsive `<picture>` elements with `srcset` for optimised delivery.\n * SVGs receive a simple URL swap with no variant handling.\n *\n * **In development mode this plugin is a no-op** — local `/images/` paths\n * continue to work via Vite's static asset serving so hot-reload is unaffected.\n *\n * The plugin handles two in-pipeline replacement vectors:\n *\n * 1. **Module transform** (`transform` hook) — rewrites `<img>` tags and\n * string literals in Vue SFCs, TS, JS, CSS, MD, and HTML modules.\n * 2. **Chunk rendering** (`renderChunk` hook) — rewrites image paths in\n * final rendered JS/CSS chunks AFTER Vite's `define` substitution.\n * This catches data injected by `dcsContentPlugin` via `__DCS_CONTENT__`\n * (from `.dcs/content.yaml`) which bypasses the `transform` hook.\n *\n * A third vector — **post-build file processing** — is handled by the\n * companion `dcsCdnBuildEnd` hook, which must be registered separately in\n * VitePress config. VitePress generates HTML *after* both Vite builds\n * complete, so Vite plugin hooks (`closeBundle`, `transformIndexHtml`)\n * cannot catch SSR-rendered `<head>` tags or static `public/` files like\n * `service-worker.js`.\n *\n * @example\n * ```ts\n * // .vitepress/config.ts\n * import { dcsCdnImagePlugin, dcsCdnBuildEnd } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * vite: {\n * plugins: [\n * dcsCdnImagePlugin()\n * ]\n * },\n * buildEnd: dcsCdnBuildEnd()\n * })\n * ```\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport type { Plugin } from 'vite'\n\n// ────────────────────────────────────────────────────────────────────────────\n// Types\n// ────────────────────────────────────────────────────────────────────────────\n\nexport interface CdnImageMapVariant {\n suffix: string\n blobPath: string\n cdnUrl: string\n width: number\n height: number\n size: number\n}\n\nexport interface CdnImageMapEntry {\n localPath: string\n blobPath: string\n cdnUrl: string\n fileName: string\n contentType: string\n originalSize: number\n width?: number\n height?: number\n hash: string\n variants?: CdnImageMapVariant[]\n}\n\nexport interface CdnImageMap {\n generated: string\n site: string\n cdnBase: string\n images: CdnImageMapEntry[]\n}\n\nexport interface DcsCdnImagePluginOptions {\n /** Path to cdn-image-map.json relative to project root (default: '.dcs/cdn-image-map.json') */\n mapPath?: string\n\n /**\n * Patterns to match for replacement. Each must be a **leading-slash path prefix**\n * that appears in source code (e.g. `/images/`). The `localPath` field in the\n * mapping file is compared *without* a leading slash.\n *\n * Default: `['/images/']`\n */\n pathPrefixes?: string[]\n\n /**\n * Default `sizes` attribute for responsive `<picture>` elements.\n * Override per-context via the `data-sizes` attribute on the original `<img>`.\n *\n * Default: `'(max-width: 1024px) 100vw, 1024px'`\n */\n defaultSizes?: string\n\n /** Enable debug logging */\n debug?: boolean\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Helpers\n// ────────────────────────────────────────────────────────────────────────────\n\nfunction escapeHtml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n}\n\n/**\n * Build a responsive `<picture>` element for a raster image that has\n * WebP variants.\n */\nfunction buildPictureElement(\n entry: CdnImageMapEntry,\n alt: string,\n extraAttrs: string,\n sizes: string\n): string {\n const variants = entry.variants ?? []\n\n // Collect only the display-relevant variants (not thumb, not og)\n const displayVariants = variants.filter(\n (v) => v.suffix === '-sm' || v.suffix === '-md' || v.suffix === '-lg'\n )\n\n if (displayVariants.length === 0) {\n // No display variants — fall back to original CDN URL as plain <img>\n return `<img src=\"${escapeHtml(entry.cdnUrl)}\" alt=\"${escapeHtml(alt)}\"${extraAttrs} loading=\"lazy\" decoding=\"async\" />`\n }\n\n const srcset = displayVariants\n .map((v) => `${v.cdnUrl} ${v.width}w`)\n .join(', ')\n\n // Pick the -md variant as the default src, or fall through to original\n const mdVariant = variants.find((v) => v.suffix === '-md')\n const fallbackSrc = mdVariant ? mdVariant.cdnUrl : entry.cdnUrl\n\n return [\n '<picture>',\n ` <source srcset=\"${srcset}\" type=\"image/webp\" sizes=\"${escapeHtml(sizes)}\" />`,\n ` <img src=\"${escapeHtml(fallbackSrc)}\" alt=\"${escapeHtml(alt)}\"${extraAttrs} loading=\"lazy\" decoding=\"async\" />`,\n '</picture>',\n ].join('\\n')\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Shared helpers\n// ────────────────────────────────────────────────────────────────────────────\n\n/**\n * Try to find and load the CDN image map from common locations.\n * VitePress nests docs under a subfolder, so we check parent dirs too.\n */\nfunction loadCdnImageMap(\n projectRoot: string,\n relativeMapPath: string,\n debug: boolean\n): Map<string, CdnImageMapEntry> | null {\n const possiblePaths = [\n path.resolve(projectRoot, relativeMapPath),\n path.resolve(projectRoot, '..', relativeMapPath),\n path.resolve(process.cwd(), relativeMapPath),\n ]\n\n for (const testPath of possiblePaths) {\n if (fs.existsSync(testPath)) {\n try {\n const raw = fs.readFileSync(testPath, 'utf8')\n const data: CdnImageMap = JSON.parse(raw)\n\n const map = new Map<string, CdnImageMapEntry>()\n for (const entry of data.images) {\n // Store both with and without leading slash for flexible matching\n map.set(entry.localPath, entry)\n if (!entry.localPath.startsWith('/')) {\n map.set('/' + entry.localPath, entry)\n }\n }\n\n if (debug) {\n console.log(`[dcs-cdn-image] Loaded ${data.images.length} entries from ${testPath}`)\n }\n return map\n } catch (error) {\n console.warn(`[dcs-cdn-image] Failed to parse ${testPath}:`, error)\n }\n }\n }\n\n if (debug) {\n console.log('[dcs-cdn-image] No cdn-image-map.json found at:')\n possiblePaths.forEach((p) => console.log(` - ${p}`))\n }\n return null\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Vite Plugin\n// ────────────────────────────────────────────────────────────────────────────\n\n/**\n * Vite plugin that rewrites static `/images/` paths to CDN URLs at build time.\n */\nexport function dcsCdnImagePlugin(options: DcsCdnImagePluginOptions = {}): Plugin {\n const {\n mapPath = '.dcs/cdn-image-map.json',\n pathPrefixes = ['/images/'],\n defaultSizes = '(max-width: 1024px) 100vw, 1024px',\n debug = false,\n } = options\n\n // Lookup map built from the JSON file: key = localPath (no leading slash)\n let imageMap: Map<string, CdnImageMapEntry> | null = null\n let isProduction = false\n\n /**\n * Check whether a source code string contains any of the path prefixes\n * we care about. Quick bail-out for files that don't reference images.\n */\n function hasImageReferences(code: string): boolean {\n return pathPrefixes.some((prefix) => code.includes(prefix))\n }\n\n /**\n * Replace image path references in any string value with CDN URLs.\n * Used for code transforms and renderChunk post-processing.\n */\n function replaceImagePaths(str: string): string {\n if (!imageMap || imageMap.size === 0) return str\n let result = str\n for (const prefix of pathPrefixes) {\n // Global replace: matches prefix followed by a relative path bounded\n // by quotes, parens, or whitespace. Allows spaces in filenames.\n const regex = new RegExp(\n `([\"'\\`(])${escapeRegex(prefix)}([^\"'\\`()]+)`,\n 'g'\n )\n result = result.replace(regex, (match, quote, relPath) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return match\n return `${quote}${entry.cdnUrl}`\n })\n }\n return result\n }\n\n /**\n * Replace standalone URL references in JS/TS string literals and Vue template\n * attributes. This handles patterns like:\n * src=\"/images/foo.jpg\"\n * { src: '/images/foo.jpg' }\n * url(/images/foo.svg)\n *\n * For `<img>` tags with raster images that have variants, the entire tag is\n * replaced with a `<picture>` element.\n */\n function transformCode(code: string): string {\n if (!imageMap || imageMap.size === 0) return code\n\n // ── Pass 1: Replace <img> tags that reference mapped raster images ──────\n // Matches: <img ... src=\"/images/foo.jpg\" ... /> or <img ... src=\"/images/foo.jpg\" ... >\n const imgTagRegex = /<img\\b([^>]*?)src=[\"'](\\/(images\\/[^\"']+))[\"']([^>]*?)\\/?>/gi\n code = code.replace(imgTagRegex, (_match, beforeSrc, _srcWithSlash, localPath, afterSrc) => {\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return _match\n\n // Extract alt from the existing attributes\n const altMatch = (beforeSrc + afterSrc).match(/alt=[\"']([^\"']*)[\"']/)\n const alt = altMatch ? altMatch[1] : ''\n\n // Collect other attributes (not src, alt, loading, decoding — we set those)\n const otherAttrs = (beforeSrc + afterSrc)\n .replace(/\\balt=[\"'][^\"']*[\"']/gi, '')\n .replace(/\\bloading=[\"'][^\"']*[\"']/gi, '')\n .replace(/\\bdecoding=[\"'][^\"']*[\"']/gi, '')\n .trim()\n\n const extraAttrs = otherAttrs ? ' ' + otherAttrs : ''\n\n // Extract custom sizes if specified\n const sizesMatch = (beforeSrc + afterSrc).match(/data-sizes=[\"']([^\"']*)[\"']/)\n const sizes = sizesMatch ? sizesMatch[1] : defaultSizes\n\n // SVGs and images without variants → simple URL swap <img>\n if (!entry.variants || entry.variants.length === 0) {\n return `<img src=\"${escapeHtml(entry.cdnUrl)}\" alt=\"${escapeHtml(alt)}\"${extraAttrs} loading=\"lazy\" decoding=\"async\" />`\n }\n\n // Raster with variants → <picture>\n return buildPictureElement(entry, alt, extraAttrs, sizes)\n })\n\n // ── Pass 2: Replace remaining string literal / CSS url() references ─────\n code = replaceImagePaths(code)\n\n return code\n }\n\n return {\n name: 'dcs-cdn-image',\n enforce: 'pre',\n\n configResolved(config) {\n isProduction = config.command === 'build'\n if (!isProduction) {\n if (debug) {\n console.log('[dcs-cdn-image] Dev mode — plugin disabled (local images served by Vite)')\n }\n return\n }\n imageMap = loadCdnImageMap(config.root, mapPath, debug)\n },\n\n transform(code, id) {\n // Only run in production builds\n if (!isProduction || !imageMap) return\n\n // Only process relevant file types\n if (!/\\.(vue|ts|tsx|js|jsx|css|scss|md|html)(\\?.*)?$/.test(id)) return\n\n // Quick bail — skip files with no image path references\n if (!hasImageReferences(code)) return\n\n const transformed = transformCode(code)\n if (transformed !== code) {\n return { code: transformed, map: null }\n }\n },\n\n /**\n * Replace image paths in final rendered JS/CSS chunks.\n *\n * This fires AFTER Vite's `define` substitution, catching paths that were\n * injected via `define` values (e.g. `__DCS_CONTENT__` set by\n * `dcsContentPlugin` from `.dcs/content.yaml`). Those paths bypass the\n * `transform` hook because `define` replacement happens at bundle time.\n */\n renderChunk(code, _chunk) {\n if (!isProduction || !imageMap) return null\n if (!hasImageReferences(code)) return null\n\n const replaced = replaceImagePaths(code)\n if (replaced !== code) {\n if (debug) {\n console.log(`[dcs-cdn-image] renderChunk: rewrote image paths in ${_chunk.fileName}`)\n }\n return { code: replaced, map: null }\n }\n return null\n },\n\n /**\n * Transform HTML output to catch references injected outside the module\n * pipeline — e.g. VitePress `head` config tags (favicons, OG images).\n *\n * Note: In VitePress, this hook fires for the `index.html` template but\n * NOT for SSR-rendered per-page HTML. Use `dcsCdnBuildEnd` for full\n * coverage of generated HTML files.\n */\n transformIndexHtml(html) {\n if (!isProduction || !imageMap) return html\n if (!hasImageReferences(html)) return html\n\n // Replace href/src/content attributes that reference mapped images\n for (const prefix of pathPrefixes) {\n const attrRegex = new RegExp(\n `((?:href|src|content)=[\"'])${escapeRegex(prefix)}([^\"']+)([\"'])`,\n 'gi'\n )\n html = html.replace(attrRegex, (match, pre, relPath, post) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return match\n return `${pre}${entry.cdnUrl}${post}`\n })\n }\n\n return html\n },\n }\n}\n\n/**\n * Escape a string for use in a RegExp.\n */\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// VitePress buildEnd hook\n// ────────────────────────────────────────────────────────────────────────────\n\nexport interface DcsCdnBuildEndOptions {\n /** Path to cdn-image-map.json relative to project root (default: '.dcs/cdn-image-map.json') */\n mapPath?: string\n\n /**\n * Patterns to match for replacement.\n * Default: `['/images/']`\n */\n pathPrefixes?: string[]\n\n /** Enable debug logging */\n debug?: boolean\n\n /**\n * File extensions to process in the output directory.\n * Default: `['.html', '.js']`\n */\n extensions?: string[]\n}\n\n/**\n * VitePress `buildEnd` hook factory that post-processes generated HTML and\n * static files in the output directory to replace remaining `/images/` paths\n * with CDN URLs.\n *\n * VitePress generates HTML **after** both Vite builds complete, so Vite\n * plugin hooks (`closeBundle`, `transformIndexHtml`) cannot catch\n * SSR-rendered `<head>` tags (favicons, OG images). This hook runs after all\n * HTML files are written to disk.\n *\n * Also rewrites static files (e.g. `service-worker.js`) copied from\n * `public/` that are not part of Vite's module pipeline.\n *\n * @example\n * ```ts\n * // .vitepress/config.ts\n * import { dcsCdnBuildEnd } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * buildEnd: dcsCdnBuildEnd({ debug: true })\n * })\n * ```\n */\nexport function dcsCdnBuildEnd(options: DcsCdnBuildEndOptions = {}) {\n const {\n mapPath = '.dcs/cdn-image-map.json',\n pathPrefixes = ['/images/'],\n debug = false,\n extensions = ['.html', '.js'],\n } = options\n\n return async (siteConfig: { root: string; outDir: string }) => {\n const imageMap = loadCdnImageMap(siteConfig.root, mapPath, debug)\n if (!imageMap) {\n if (debug) {\n console.log('[dcs-cdn-image] buildEnd: no image map found')\n }\n return\n }\n\n const outDir = siteConfig.outDir\n if (!fs.existsSync(outDir)) return\n\n let filesProcessed = 0\n let refsReplaced = 0\n\n function walkDir(dir: string) {\n const entries = fs.readdirSync(dir, { withFileTypes: true })\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n if (entry.isDirectory()) {\n walkDir(fullPath)\n } else if (extensions.some((ext) => entry.name.endsWith(ext))) {\n processFile(fullPath)\n }\n }\n }\n\n function processFile(filePath: string) {\n let content = fs.readFileSync(filePath, 'utf8')\n if (!pathPrefixes.some((p) => content.includes(p))) return\n\n let changed = false\n\n if (filePath.endsWith('.html')) {\n // HTML: replace href/src/content attribute values\n for (const prefix of pathPrefixes) {\n const attrRegex = new RegExp(\n `((?:href|src|content)=[\"'])${escapeRegex(prefix)}([^\"']+)([\"'])`,\n 'gi'\n )\n content = content.replace(attrRegex, (match, pre, relPath, post) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const mapEntry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!mapEntry) return match\n changed = true\n refsReplaced++\n return `${pre}${mapEntry.cdnUrl}${post}`\n })\n }\n } else {\n // JS/other: replace quoted string paths\n for (const prefix of pathPrefixes) {\n const regex = new RegExp(\n `([\"'\\`(])${escapeRegex(prefix)}([^\"'\\`()]+)`,\n 'g'\n )\n content = content.replace(regex, (match, quote, relPath) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return match\n changed = true\n refsReplaced++\n return `${quote}${entry.cdnUrl}`\n })\n }\n }\n\n if (changed) {\n fs.writeFileSync(filePath, content, 'utf8')\n filesProcessed++\n }\n }\n\n walkDir(outDir)\n\n if (debug) {\n console.log(\n `[dcs-cdn-image] buildEnd: post-processed ${filesProcessed} files, replaced ${refsReplaced} references`\n )\n }\n }\n}","/**\n * markdown-it plugin that transforms standard `![alt](url)` image syntax\n * into responsive `<picture>` elements when the URL matches the DCS CDN\n * asset pattern.\n *\n * Non-CDN images are rendered with the default image renderer (plain `<img>`).\n *\n * @example\n * ```ts\n * // .vitepress/config.ts\n * import { responsiveImagePlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * markdown: {\n * config: (md) => {\n * md.use(responsiveImagePlugin)\n * },\n * },\n * })\n * ```\n *\n * Input markdown:\n * ```md\n * ![Physical therapy session](https://files.duffcloudservices.com/kept/assets/blog/abc-123.jpg)\n * ```\n *\n * Rendered HTML:\n * ```html\n * <picture>\n * <source srcset=\"...abc-123-sm.webp 640w, ...abc-123-md.webp 1024w, ...abc-123-lg.webp 1920w\"\n * type=\"image/webp\"\n * sizes=\"(max-width: 1024px) 100vw, 1024px\" />\n * <img src=\"...abc-123-md.webp\" alt=\"Physical therapy session\" loading=\"lazy\" decoding=\"async\" />\n * </picture>\n * ```\n */\n\nimport type MarkdownIt from 'markdown-it'\n\n/**\n * Matches DCS CDN asset URLs: base path / UUID . extension.\n *\n * Aligned with `@duffcloudservices/cms-core` `responsive-image.ts`: the\n * `(?:content\\/)?` group covers the content-container shape\n * `https://files.duffcloudservices.com/content/{slug}/assets/...` in addition\n * to the branding-container shape `.../{slug}/assets/...`. The group is\n * non-capturing, so the captured base path / UUID / extension are unchanged.\n */\nconst CDN_PATTERN = /^(https?:\\/\\/files\\.[^/]+\\/(?:content\\/)?[^/]+\\/assets\\/(?:[^/]+\\/)*)([a-f0-9-]+)\\.(\\w+)$/\n\n/**\n * Escapes HTML special characters for safe attribute embedding.\n * Falls back to a simple replace chain when `md.utils.escapeHtml` is unavailable.\n */\nfunction escapeHtml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n}\n\nexport function responsiveImagePlugin(md: MarkdownIt): void {\n const defaultImageRenderer = md.renderer.rules.image\n\n md.renderer.rules.image = (tokens, idx, options, env, self) => {\n const token = tokens[idx]\n const src = token.attrGet('src') ?? ''\n const alt = token.content ?? ''\n\n const match = src.match(CDN_PATTERN)\n if (!match) {\n // Not a CDN image — render normally\n if (defaultImageRenderer) {\n return defaultImageRenderer(tokens, idx, options, env, self)\n }\n return self.renderToken(tokens, idx, options)\n }\n\n const [, basePath, uuid] = match\n\n const srcset = [\n `${basePath}${uuid}-sm.webp 640w`,\n `${basePath}${uuid}-md.webp 1024w`,\n `${basePath}${uuid}-lg.webp 1920w`,\n ].join(', ')\n\n const escapedAlt = escapeHtml(alt)\n\n // Self-heal: this plugin emits a STATIC HTML string at build time (no Vue\n // runtime), so the fallback must be an inline onerror. A fit-variant\n // (`-md`/`-lg`) may legitimately be absent (internal/imaging variants.go\n // skips variants by DIMENSION). On the first error, swap the `<img>` to the\n // ORIGINAL url AND strip the sibling `<source>` elements — a `<picture>`\n // does NOT re-resolve after a `<source>` 404s, so the variant set must be\n // removed for the original to display. (`this.onerror=null` prevents loops.)\n const escapedOriginal = escapeHtml(src)\n const onError =\n `this.onerror=null;this.src='${escapedOriginal}';` +\n `this.closest('picture')?.querySelectorAll('source').forEach(s=>s.remove())`\n\n return [\n '<picture>',\n ` <source srcset=\"${srcset}\" type=\"image/webp\" sizes=\"(max-width: 1024px) 100vw, 1024px\" />`,\n ` <img src=\"${basePath}${uuid}-md.webp\" alt=\"${escapedAlt}\" loading=\"lazy\" decoding=\"async\" onerror=\"${onError}\" />`,\n '</picture>',\n ].join('\\n')\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/plugins/serveDefineInject.ts","../../src/plugins/motionTokens.ts","../../src/plugins/agentWidget.ts","../../src/plugins/dcsContentPlugin.ts","../../src/seo/playwrightRenderer.ts","../../src/plugins/dcsSeoPlugin.ts","../../src/plugins/dcsEditorPlugin.ts","../../src/plugins/dcsPreviewPlugin.ts","../../src/plugins/dcsCdnImagePlugin.ts","../../src/plugins/responsiveImagePlugin.ts"],"names":["path","fs","yaml","escapeHtml"],"mappings":";;;;;;;;AAiCO,SAAS,cAAA,CAAe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,OAAO,IAAA,CAAK,WAAA,CAAY,MAAA,EAAQ,GAAA,EAAK,OAAO,CAAA;AAAA,IAC9C;AAEA,IAAA,MAAM,GAAG,QAAA,EAAU,IAAI,CAAA,GAAI,KAAA;AAE3B,IAAA,MAAM,MAAA,GAAS;AAAA,MACb,CAAA,EAAG,QAAQ,CAAA,EAAG,IAAI,CAAA,aAAA,CAAA;AAAA,MAClB,CAAA,EAAG,QAAQ,CAAA,EAAG,IAAI,CAAA,cAAA,CAAA;AAAA,MAClB,CAAA,EAAG,QAAQ,CAAA,EAAG,IAAI,CAAA,cAAA;AAAA,KACpB,CAAE,KAAK,IAAI,CAAA;AAEX,IAAA,MAAM,UAAA,GAAaA,YAAW,GAAG,CAAA;AASjC,IAAA,MAAM,eAAA,GAAkBA,YAAW,GAAG,CAAA;AACtC,IAAA,MAAM,OAAA,GACJ,+BAA+B,eAAe,CAAA,4EAAA,CAAA;AAGhD,IAAA,OAAO;AAAA,MACL,WAAA;AAAA,MACA,qBAAqB,MAAM,CAAA,gEAAA,CAAA;AAAA,MAC3B,eAAe,QAAQ,CAAA,EAAG,IAAI,CAAA,eAAA,EAAkB,UAAU,8CAA8C,OAAO,CAAA,IAAA,CAAA;AAAA,MAC/G;AAAA,KACF,CAAE,KAAK,IAAI,CAAA;AAAA,EACb,CAAA;AACF","file":"index.js","sourcesContent":["/**\n * Shared serve-mode helpers for the DCS content + SEO Vite plugins.\n *\n * In a production build the plugins bake the `.dcs/*.yaml` payload into a Vite\n * `define` literal (`define: { __DCS_X__: JSON.stringify(data) }`) so the SSG /\n * SPA bundle inlines it exactly as before.\n *\n * In dev (`vite` / `vitepress dev`, i.e. the portal preview) baking a literal\n * is wrong: the value is frozen at server-start and only a `server.restart()`\n * would refresh it — and that restart is exactly what triggers VitePress's\n * MiniSearch rebuild and the duplicate-heading \"server restart failed\" crash.\n *\n * Instead, in serve mode the plugins:\n * 1. redirect the `__DCS_X__` define to a browser global\n * (`define: { __DCS_X__: 'globalThis.__DCS_X__' }`), and\n * 2. inject an inline classic `<script>` at the top of `<head>` on every HTML\n * request that assigns the FRESH on-disk YAML to that global.\n *\n * Because `transformIndexHtml` re-runs on every dev HTML request, a plain\n * iframe reload (the portal's `?_hc` hard reload) reflects the latest on-disk\n * content with NO `server.restart()` and NO module-graph surgery. The consumer\n * is untouched: it still reads the bare `__DCS_X__` identifier, which the define\n * rewrites to `globalThis.__DCS_X__`.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport yaml from 'js-yaml'\n\n/**\n * The three `.dcs` search locations the plugins have always used. VitePress\n * projects have the `docs/` folder as root, so the parent is checked too.\n */\nexport function dcsSearchPaths(projectRoot: string, relPath: string): string[] {\n return [\n path.resolve(projectRoot, relPath),\n path.resolve(projectRoot, '..', relPath),\n path.resolve(process.cwd(), relPath),\n ]\n}\n\n/** First existing `.dcs` file from the standard search, or `undefined`. */\nexport function resolveDcsFile(projectRoot: string, relPath: string): string | undefined {\n return dcsSearchPaths(projectRoot, relPath).find((p) => fs.existsSync(p))\n}\n\n/**\n * Read + parse a `.dcs` YAML file FRESH from disk on every call (no caching).\n * Returns the parsed value, or `undefined` when the file is missing or\n * unparseable. Never throws — a dev HTML request must never 500 on bad YAML.\n */\nexport function readDcsYamlFresh<T = unknown>(\n projectRoot: string,\n relPath: string,\n label: string,\n debug = false\n): T | undefined {\n const found = resolveDcsFile(projectRoot, relPath)\n if (!found) {\n if (debug) console.log(`[${label}] serve: no ${relPath} found; global left unset`)\n return undefined\n }\n try {\n return yaml.load(fs.readFileSync(found, 'utf8')) as T\n } catch (error) {\n console.warn(`[${label}] serve: failed to parse ${relPath}:`, error)\n return undefined\n }\n}\n\n/**\n * Build a safe inline `<script>` body that assigns a JSON-serialisable value to\n * a browser global. Every `<` is escaped to its `<` unicode form so an\n * embedded `</script>` (or `<!--`) inside the content data can never break out\n * of the inline script.\n */\nexport function buildGlobalAssignScript(globalName: string, value: unknown): string {\n const json = JSON.stringify(value ?? null).replace(/</g, '\\\\u003c')\n return `globalThis.${globalName} = ${json};`\n}\n","import type { HtmlTagDescriptor } from 'vite'\n\n/**\n * DCS motion tokens — the customer-site copy of the shared motion vocabulary.\n *\n * Injected as a constant `<style>` into every DCS site's `<head>` by\n * `dcsContentPlugin` (see its `transformIndexHtml`). This is the fleet-wide\n * seam: every site (vue-spa and VitePress) already wires `dcsContentPlugin`,\n * so a cms version bump ships these tokens to the whole fleet with zero\n * per-site source edits.\n *\n * Source of truth is the platform copy at\n * `packages/dcs-ui/src/styles/motion.css` and the `dcs-product-motion` skill —\n * keep the values here in lockstep. Values ONLY: reduced-motion stays a\n * per-component responsibility so no blanket `!important` rule leaks into a\n * site's isolated `.<slug>-page` design subtree.\n */\nexport const DCS_MOTION_TOKENS_CSS = `:root {\n --motion-duration-stagger: 40ms;\n --motion-duration-micro: 80ms;\n --motion-duration-quick: 150ms;\n --motion-duration-fast: 250ms;\n --motion-duration-medium: 350ms;\n --motion-duration-slow: 400ms;\n --motion-duration-very-slow: 500ms;\n --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);\n --motion-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);\n --motion-ease-linear: linear;\n --motion-ease-bounce: cubic-bezier(0.34, 1.36, 0.64, 1);\n --motion-ease-bounce-strong: cubic-bezier(0.34, 3.85, 0.64, 1);\n --motion-distance-xs: 4px;\n --motion-distance-sm: 8px;\n --motion-distance-md: 12px;\n --motion-distance-lg: 24px;\n --motion-scale-lg: 0.96;\n --motion-scale-md: 0.97;\n --motion-scale-sm: 0.98;\n --motion-scale-xs: 0.99;\n --motion-blur-sm: 2px;\n --motion-blur-md: 3px;\n --motion-blur-lg: 8px;\n}`\n\n/**\n * The `<head>` tag descriptor for the motion-token block. `head-prepend` keeps\n * it above the site's own bundled CSS so a per-site `:root` override still wins.\n */\nexport function dcsMotionTokensStyleTag(): HtmlTagDescriptor {\n return {\n tag: 'style',\n attrs: { 'data-dcs-motion-tokens': '' },\n children: DCS_MOTION_TOKENS_CSS,\n injectTo: 'head-prepend',\n }\n}\n","/**\n * DCS AI-assistant widget loader — the cms head-inject seam for Phase 3 of the\n * Managed Site AI Agents plan (.docs/plans/managed-site-ai-agents/index.html).\n *\n * This rides the same always-on `dcsContentPlugin.transformIndexHtml` seam that\n * ships the motion tokens: every DCS site already wires `dcsContentPlugin`, so a\n * cms version bump delivers this loader to the whole fleet with ZERO per-site\n * source edits, and the portal per-site toggle turns the widget on/off at\n * runtime with no rebuild.\n *\n * What gets injected is a tiny (<2 KB) inline `<script>` — NOT the widget. On\n * idle it fetches the public agent config for this site; only if the agent is\n * enabled (HTTP 200) does it publish `window.__DCS_AGENT_BOOTSTRAP__` and inject\n * the real widget bundle from the CDN. The loader is **fail-silent**: a disabled\n * agent (404), a dead backend, a blocked request, or a malformed response all\n * result in no mount and no console error, so the assistant can never break a\n * customer page.\n *\n * Build-only: the loader is injected into the production build output (the fleet\n * delivery), not into `vite dev`. In local dev the config fetch would hit the\n * prod API from a non-whitelisted `localhost` origin and log an uncatchable CORS\n * error for every site developer — so, unlike the constant motion-token block,\n * this network-touching loader stays out of the dev server.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport yaml from 'js-yaml'\nimport type { HtmlTagDescriptor } from 'vite'\n\n/** DCS API origin the loader calls (matches the cms runtime composables). */\nexport const DEFAULT_AGENT_API_BASE_URL = 'https://portal.duffcloudservices.com'\n\n/**\n * Versioned CDN URL of the widget bundle. Both `cdn.` (branding CDN, CorsAllowAll)\n * and the already-live `files.` route serve the same `sgdcs` blob origin with an\n * identical `/agent-widget/v1/...` layout, so this is a plain classic-script\n * include that needs no CORS on the bundle host. Defaults to `files.` because the\n * `cdn.` Front Door route is still provisioning-gated (enableCdnDomain=false) —\n * flip the default only after that domain is live, or pass cdnScriptUrl.\n */\nexport const DEFAULT_AGENT_WIDGET_SCRIPT_URL =\n 'https://files.duffcloudservices.com/agent-widget/v1/dcs-agent-widget.js'\n\nexport interface DcsAgentWidgetLoaderOptions {\n /** Owning site slug — baked into the loader so it can build the config URL. */\n siteSlug: string\n /** DCS API base (default: the shared portal origin). */\n apiBaseUrl?: string\n /** Full URL of the CDN widget bundle. */\n cdnScriptUrl?: string\n}\n\nconst trimTrailingSlash = (value: string): string => value.replace(/\\/+$/, '')\n\n/**\n * JSON-encodes a value for safe embedding inside an inline `<script>` body.\n * `JSON.stringify` alone stops JS string-literal breakout but NOT the HTML\n * parser: a raw `</script>` (or a U+2028/U+2029 line separator, which is a valid\n * JS line terminator) inside the string would still terminate the element. So we\n * additionally escape `<`, `>`, and the two separators to their `\\uXXXX` forms —\n * defense-in-depth even though today every embedded value is build-time DCS\n * provisioning identity (DNS-label slug + platform URLs).\n */\nconst encodeForInlineScript = (value: string): string =>\n JSON.stringify(value)\n .replace(/</g, '\\\\u003c')\n .replace(/>/g, '\\\\u003e')\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029')\n\n/**\n * Builds the inline loader script body. Slug + URLs are HTML-safe-encoded (see\n * encodeForInlineScript) so no value can break out of the string literal OR the\n * `<script>` element. Kept intentionally compact to stay under the ~2 KB perf\n * budget (G4).\n */\nexport function buildAgentWidgetLoaderScript(options: DcsAgentWidgetLoaderOptions): string {\n const slug = encodeForInlineScript(options.siteSlug)\n const api = encodeForInlineScript(trimTrailingSlash(options.apiBaseUrl || DEFAULT_AGENT_API_BASE_URL))\n const cdn = encodeForInlineScript(options.cdnScriptUrl || DEFAULT_AGENT_WIDGET_SCRIPT_URL)\n\n return (\n '(function(){try{' +\n 'if(window.__DCS_AGENT_LOADER__)return;window.__DCS_AGENT_LOADER__=1;' +\n // Suppression parity with PreviewRibbon: skip the editor iframe (self!==top,\n // cross-origin access throws → treated as framed) and the ?dcs-hide-widget\n // screenshot/perf suppressor.\n 'try{if(window.self!==window.top)return;}catch(e){return;}' +\n 'if(/[?&]dcs-hide-widget(?:[=&]|$)/.test(location.search))return;' +\n 'var S=' + slug + ',A=' + api + ',C=' + cdn + ';' +\n 'var go=function(){try{' +\n 'fetch(A+\"/api/v1/sites/\"+encodeURIComponent(S)+\"/agent/config\",{headers:{Accept:\"application/json\"}})' +\n '.then(function(r){return r&&r.ok?r.json():null;})' +\n '.then(function(c){if(!c||!c.enabled)return;' +\n 'window.__DCS_AGENT_BOOTSTRAP__={siteSlug:S,apiBaseUrl:A,config:c};' +\n 'var s=document.createElement(\"script\");s.src=C;s.async=true;s.setAttribute(\"data-dcs-agent-slug\",S);' +\n '(document.head||document.documentElement).appendChild(s);})' +\n '.catch(function(){});' +\n '}catch(e){}};' +\n 'if(\"requestIdleCallback\"in window){requestIdleCallback(go,{timeout:4000});}else{setTimeout(go,1200);}' +\n '}catch(e){}})();'\n )\n}\n\nconst SITE_YAML_CANDIDATES = ['.dcs/site.yaml', '../.dcs/site.yaml']\n\n/**\n * Reads `site_slug` from the site's `.dcs/site.yaml` (the same identity file the\n * announcements/provisioning path uses). Returns null when no site.yaml exists\n * or it carries no slug — the caller then injects nothing (silence for non-DCS\n * builds).\n */\nexport function readSiteSlug(projectRoot: string): string | null {\n const candidates = [\n ...SITE_YAML_CANDIDATES.map((rel) => path.resolve(projectRoot, rel)),\n path.resolve(process.cwd(), '.dcs/site.yaml'),\n ]\n for (const candidate of candidates) {\n try {\n if (!fs.existsSync(candidate)) continue\n const parsed = yaml.load(fs.readFileSync(candidate, 'utf8')) as { site_slug?: unknown } | null\n const slug = parsed && typeof parsed.site_slug === 'string' ? parsed.site_slug.trim() : ''\n if (slug) return slug\n } catch {\n // Unreadable/unparseable — try the next candidate, else return null.\n }\n }\n return null\n}\n\nexport interface DcsAgentWidgetTagOptions {\n /** Vite project root used to resolve the site slug. */\n projectRoot: string\n /** Override the DCS API base (default: process.env.VITE_API_BASE_URL, else the shared origin). */\n apiBaseUrl?: string\n /** Override the CDN bundle URL. */\n cdnScriptUrl?: string\n}\n\n/**\n * The `<head>` tag descriptor for the loader, or `null` when this build is not a\n * DCS-managed site (no resolvable slug) — in which case nothing is injected.\n */\nexport function dcsAgentWidgetLoaderTag(options: DcsAgentWidgetTagOptions): HtmlTagDescriptor | null {\n const siteSlug = readSiteSlug(options.projectRoot)\n if (!siteSlug) return null\n\n return {\n tag: 'script',\n attrs: { 'data-dcs-agent-loader': '' },\n children: buildAgentWidgetLoaderScript({\n siteSlug,\n apiBaseUrl: options.apiBaseUrl,\n cdnScriptUrl: options.cdnScriptUrl,\n }),\n injectTo: 'head',\n }\n}\n","/**\n * DCS Content Plugin for Vite\n *\n * Reads `.dcs/content.yaml` at build time and injects content\n * as `__DCS_CONTENT__` global variable for use by useTextContent.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [\n * dcsContentPlugin({ debug: true })\n * ]\n * })\n * ```\n *\n * For VitePress:\n * ```typescript\n * // .vitepress/config.ts\n * import { defineConfig } from 'vitepress'\n * import { dcsContentPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * vite: {\n * plugins: [\n * dcsContentPlugin()\n * ]\n * }\n * })\n * ```\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport yaml from 'js-yaml'\nimport type { Plugin, ResolvedConfig, HtmlTagDescriptor } from 'vite'\nimport type { DcsContentFile } from '../types/content'\nimport { readDcsYamlFresh, buildGlobalAssignScript } from './serveDefineInject'\nimport { dcsMotionTokensStyleTag } from './motionTokens'\nimport { dcsAgentWidgetLoaderTag } from './agentWidget'\n\nexport interface DcsContentPluginOptions {\n /** Path to content.yaml relative to project root (default: '.dcs/content.yaml') */\n contentPath?: string\n /** Enable debug logging */\n debug?: boolean\n}\n\n/**\n * Packages that MUST be bundled into the SSR build (noExternal) rather than\n * externalized to `node_modules`.\n *\n * WHY: this plugin injects the site's content as the `__DCS_CONTENT__` Vite\n * `define`. A `define` is a compile-time text substitution that Vite applies\n * ONLY to source that passes through its transform pipeline. When a package is\n * SSR-externalized (loaded by Node's native resolver at server-render time), the\n * substitution never happens — `__DCS_CONTENT__` stays an undefined global on\n * the server. The content composables (`useReviewContent`, `useTextContent`)\n * then fall back to their empty/placeholder branch during SSR while the client\n * (where the define DID apply) renders the real content — producing the\n * \"Hydration completed but contains mismatches\" bug and, worse, baking\n * fabricated fallback content into the crawler-visible SSR HTML.\n *\n * Forcing the cms package `noExternal` bundles it into the SSR graph so the\n * define reaches the composables server-side, keeping SSR and client in lockstep\n * and putting the REAL content in the pre-rendered HTML. This is applied by the\n * plugin itself (merged into the user's Vite config) so every VitePress / vite\n * consumer inherits the fix on a cms bump — no per-site config knob to forget.\n */\nconst DCS_SSR_NO_EXTERNAL = ['@duffcloudservices/cms']\n\n/**\n * Vite plugin that injects .dcs/content.yaml at build time.\n *\n * @param options - Plugin configuration\n * @returns Vite plugin\n */\nexport function dcsContentPlugin(options: DcsContentPluginOptions = {}): Plugin {\n const { contentPath = '.dcs/content.yaml', debug = false } = options\n\n let resolvedConfig: ResolvedConfig\n // Captured during configResolved — gates the serve-only inline HTML inject.\n let isDev = false\n\n return {\n name: 'dcs-content',\n\n configResolved(config) {\n resolvedConfig = config\n isDev = config.command === 'serve'\n },\n\n config(config, env) {\n // ── Dev / preview (serve) ──────────────────────────────────────────────\n // Don't bake content into the bundle. Redirect the `__DCS_CONTENT__`\n // define to a browser global that `transformIndexHtml` (below) refreshes\n // from disk on every HTML request — so a plain iframe reload reflects the\n // latest on-disk content with NO server.restart() and NO module-graph\n // surgery. The consumer is untouched: it still reads the bare\n // `__DCS_CONTENT__` identifier, which this define rewrites to\n // `globalThis.__DCS_CONTENT__`.\n if (env.command === 'serve') {\n return {\n define: {\n __DCS_CONTENT__: 'globalThis.__DCS_CONTENT__',\n },\n ssr: { noExternal: DCS_SSR_NO_EXTERNAL },\n }\n }\n\n // ── Production build ───────────────────────────────────────────────────\n // Unchanged: read content.yaml now and bake it into the bundle as a\n // JSON literal so the SSG / SPA output inlines content exactly as before.\n const projectRoot = config.root || process.cwd()\n\n // Try to find content.yaml in multiple locations\n // VitePress projects have the docs folder as root, so check parent too\n const possiblePaths = [\n path.resolve(projectRoot, contentPath),\n path.resolve(projectRoot, '..', contentPath),\n path.resolve(process.cwd(), contentPath),\n ]\n\n let foundPath: string | undefined\n for (const testPath of possiblePaths) {\n if (fs.existsSync(testPath)) {\n foundPath = testPath\n break\n }\n }\n\n if (!foundPath) {\n if (debug) {\n console.log('[dcs-content] No content.yaml found at:')\n possiblePaths.forEach((p) => console.log(` - ${p}`))\n console.log('[dcs-content] Using defaults only')\n }\n return {\n define: {\n __DCS_CONTENT__: 'undefined',\n },\n ssr: { noExternal: DCS_SSR_NO_EXTERNAL },\n }\n }\n\n try {\n const fileContent = fs.readFileSync(foundPath, 'utf8')\n const content = yaml.load(fileContent) as DcsContentFile\n\n if (debug) {\n console.log(`[dcs-content] Loaded ${foundPath}`)\n console.log(`[dcs-content] Version: ${content.version}`)\n console.log(`[dcs-content] Pages: ${Object.keys(content.pages ?? {}).join(', ') || '(none)'}`)\n console.log(`[dcs-content] Global keys: ${Object.keys(content.global ?? {}).length}`)\n }\n\n return {\n define: {\n __DCS_CONTENT__: JSON.stringify(content),\n },\n ssr: { noExternal: DCS_SSR_NO_EXTERNAL },\n }\n } catch (error) {\n console.warn('[dcs-content] Failed to parse content.yaml:', error)\n return {\n define: {\n __DCS_CONTENT__: 'undefined',\n },\n ssr: { noExternal: DCS_SSR_NO_EXTERNAL },\n }\n }\n },\n\n /**\n * Inject into `<head>` on every HTML request. Two concerns:\n *\n * 1. The constant DCS motion-token `:root` block (`DCS_MOTION_TOKENS_CSS`)\n * — the fleet-wide seam that gives every DCS site the shared `--motion-*`\n * vocabulary. It carries no per-site data, so (unlike the content inject)\n * it is NOT gated on `isDev`: it runs in both `serve` and `build`.\n * `head-prepend` keeps it ABOVE the bundled site CSS, so a site's own\n * `:root` (theme `tailwind.css` / `style.css`) can still override a token.\n *\n * 2. Dev-only: the FRESH on-disk `content.yaml` as an inline\n * `globalThis.__DCS_CONTENT__ = {…}` classic script. Runs on every dev\n * HTML request, so the portal's `?_hc` hard reload re-reads the YAML with\n * no restart. A classic `<script>` in `<head>` executes before the\n * deferred module app entry, so the global is set before the consumer's\n * `useTextContent` setup reads it. Gated on `isDev` so it never runs in\n * `vite`/`vitepress build` (the build path keeps the baked `define`).\n */\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n // (1) Always-on, per the note above: the constant motion-token block.\n const tags: HtmlTagDescriptor[] = [dcsMotionTokensStyleTag()]\n\n // (1b) Build-only: the AI-assistant widget loader. Rides this same\n // fleet-wide seam (a cms bump ships it everywhere with no per-site\n // edits) but is NOT injected into `vite dev` — its idle config\n // fetch would hit the prod API from a non-whitelisted localhost\n // origin and log an uncatchable CORS error for every site dev. The\n // loader is fail-silent and returns null for non-DCS builds (no\n // resolvable site slug), so nothing is injected there.\n if (!isDev) {\n const projectRoot = resolvedConfig?.root || process.cwd()\n const agentTag = dcsAgentWidgetLoaderTag({\n projectRoot,\n apiBaseUrl: process.env.VITE_API_BASE_URL,\n })\n if (agentTag) tags.push(agentTag)\n }\n\n // (2) Dev-only fresh content inject.\n if (isDev) {\n const projectRoot = resolvedConfig?.root || process.cwd()\n const content = readDcsYamlFresh<DcsContentFile>(\n projectRoot,\n contentPath,\n 'dcs-content',\n debug\n )\n // No file (or unparseable) ⇒ leave the global unset; the consumer's\n // `typeof globalThis.__DCS_CONTENT__` check falls back to defaults.\n if (content !== undefined) {\n if (debug) {\n console.log('[dcs-content] serve: injecting fresh __DCS_CONTENT__ into <head>')\n }\n tags.push({\n tag: 'script',\n children: buildGlobalAssignScript('__DCS_CONTENT__', content),\n injectTo: 'head-prepend',\n })\n }\n }\n\n return { html, tags }\n },\n },\n\n // Watch for changes in development.\n //\n // Downgraded from `server.restart()` to a debounced client `full-reload`:\n // freshness already comes from `transformIndexHtml` re-reading the YAML on\n // every HTML request, so all we need on change is to nudge the browser to\n // reload. A `server.restart()` would rebuild VitePress's dev MiniSearch\n // index and can throw \"server restart failed\" on a duplicate heading id —\n // exactly the fragility this fix removes. A `full-reload` does neither.\n configureServer(server) {\n const projectRoot = resolvedConfig?.root || process.cwd()\n\n const watchPaths = [\n path.resolve(projectRoot, contentPath),\n path.resolve(projectRoot, '..', contentPath),\n ].map((p) => path.normalize(p))\n\n watchPaths.forEach((watchPath) => {\n if (fs.existsSync(watchPath)) {\n server.watcher.add(watchPath)\n }\n })\n\n let reloadTimer: ReturnType<typeof setTimeout> | undefined\n server.watcher.on('change', (changedPath) => {\n if (!watchPaths.includes(path.normalize(changedPath))) return\n if (reloadTimer) clearTimeout(reloadTimer)\n reloadTimer = setTimeout(() => {\n if (debug) {\n console.log('[dcs-content] content.yaml changed, sending full-reload')\n }\n server.ws.send({ type: 'full-reload' })\n }, 100)\n })\n },\n }\n}\n","/**\n * The production {@link RouteRenderer}: a headless-Playwright renderer that\n * drives the JUST-BUILT SPA from `dist/` and returns each route's rendered\n * `#app` body.\n *\n * Design choices (see `bodyPrerender.ts` for the why):\n * - **Renders the PRODUCTION bundle**, so `import.meta.env.DEV` is already\n * `false` and the dev-only fabrication gates render their honest empty state\n * (A-34 safety by construction — no separate SSR bundle to leak defaults).\n * - **Playwright is dynamically imported and OPTIONAL.** If it (or a browser)\n * is unavailable, the factory returns `null` and the caller no-ops (the head\n * + JSON-LD emit is untouched, so the build never breaks on missing infra).\n * Playwright is already a universal devDependency of the DCS site fleet\n * (snapshot capture), so this activates on a cms bump with no per-site edit.\n * - **Offline + deterministic.** A tiny built-in static server serves `dist/`;\n * every EXTERNAL request (CDN images, App Insights, the site-auth probe) is\n * aborted. The DOM still carries those `<img>`/`<link>` tags (crawler-visible)\n * while the render stays fast and free of expected offline network noise.\n * - **Crash-only fail-loud.** Only an uncaught page exception or a failed mount\n * is reported as a fatal error; benign offline console errors are not. The\n * caller turns a fatal error into a red build.\n */\n\nimport http from 'node:http'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport type { AddressInfo } from 'node:net'\nimport type { RenderedRoute, RouteRenderer } from './bodyPrerender'\n\n/** A started static server plus its `http://127.0.0.1:<port>` origin. */\ninterface StaticServer {\n origin: string\n close: () => Promise<void>\n}\n\nconst CONTENT_TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.mjs': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.webp': 'image/webp',\n '.gif': 'image/gif',\n '.ico': 'image/x-icon',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n '.ttf': 'font/ttf',\n '.txt': 'text/plain; charset=utf-8',\n '.xml': 'application/xml; charset=utf-8',\n '.map': 'application/json; charset=utf-8',\n}\n\n/**\n * Serve `dist/` over loopback with directory-index resolution\n * (`/services` → `/services/index.html`) and an SPA fallback to the root\n * `index.html` for any path with no matching file/dir. Bound to `127.0.0.1:0`\n * so the OS assigns a free port; nothing is exposed off-box.\n */\nasync function startStaticServer(outDir: string): Promise<StaticServer> {\n const server = http.createServer((req, res) => {\n let pathname = '/'\n try {\n pathname = decodeURIComponent(new URL(req.url ?? '/', 'http://127.0.0.1').pathname)\n } catch {\n pathname = '/'\n }\n\n // Resolve within outDir; reject path traversal.\n const resolved = path.resolve(outDir, '.' + pathname)\n if (resolved !== outDir && !resolved.startsWith(outDir + path.sep)) {\n res.writeHead(403)\n res.end()\n return\n }\n\n let filePath = resolved\n try {\n const stat = fs.statSync(filePath)\n if (stat.isDirectory()) filePath = path.join(filePath, 'index.html')\n } catch {\n // Missing path: a request for an asset (has an extension) is a genuine 404;\n // a route-shaped request falls back to the SPA shell.\n if (path.extname(pathname)) {\n res.writeHead(404)\n res.end()\n return\n }\n filePath = path.join(outDir, 'index.html')\n }\n\n fs.readFile(filePath, (err, buf) => {\n if (err) {\n res.writeHead(404)\n res.end()\n return\n }\n res.writeHead(200, {\n 'Content-Type': CONTENT_TYPES[path.extname(filePath).toLowerCase()] ?? 'application/octet-stream',\n })\n res.end(buf)\n })\n })\n\n await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))\n const addr = server.address() as AddressInfo\n const origin = `http://127.0.0.1:${addr.port}`\n\n return {\n origin,\n close: () =>\n new Promise<void>((resolve) => {\n server.close(() => resolve())\n }),\n }\n}\n\n/** Options for {@link createPlaywrightRenderer}. */\nexport interface PlaywrightRendererOptions {\n /** Absolute path to the built SPA output directory (`dist`). */\n outDir: string\n /** Per-route navigation + settle budget (ms). Default 30000 nav, 15000 mount. */\n navTimeoutMs?: number\n mountTimeoutMs?: number\n /** Extra quiet settle after mount for post-render microtasks (ms). Default 250. */\n settleMs?: number\n debug?: boolean\n}\n\n/** A ready renderer plus a `close()` that tears down the browser + server. */\nexport interface PlaywrightRendererHandle {\n renderer: RouteRenderer\n close: () => Promise<void>\n}\n\n// Minimal structural types for the OPTIONAL, dynamically-imported `playwright`\n// surface — avoids a hard type/dependency on the package (it is not a cms\n// devDependency; it resolves from the consuming site at build time).\ninterface PwConsoleMessage {\n type(): string\n text(): string\n}\ninterface PwPage {\n on(event: 'pageerror', cb: (err: Error) => void): void\n on(event: 'console', cb: (msg: PwConsoleMessage) => void): void\n route(url: string, handler: (route: PwRoute) => unknown): Promise<void>\n goto(url: string, opts: { waitUntil: string; timeout: number }): Promise<unknown>\n waitForFunction(fn: () => unknown, arg?: unknown, opts?: { timeout: number }): Promise<unknown>\n waitForTimeout(ms: number): Promise<void>\n $eval(sel: string, fn: (el: Element) => string): Promise<string>\n close(): Promise<void>\n}\ninterface PwRoute {\n request(): { url(): string }\n abort(): Promise<void>\n continue(): Promise<void>\n}\ninterface PwContext {\n newPage(): Promise<PwPage>\n close(): Promise<void>\n}\ninterface PwBrowser {\n newContext(opts?: unknown): Promise<PwContext>\n close(): Promise<void>\n}\n\n/**\n * Build the headless-Playwright renderer, or return `null` when Playwright / a\n * browser is unavailable (the caller then no-ops — head + JSON-LD are already\n * emitted, so the build is unaffected). Never throws on missing infra.\n */\nexport async function createPlaywrightRenderer(\n options: PlaywrightRendererOptions\n): Promise<PlaywrightRendererHandle | null> {\n const {\n outDir,\n navTimeoutMs = 30000,\n mountTimeoutMs = 15000,\n settleMs = 250,\n debug = false,\n } = options\n\n // Optional dependency: resolve `playwright` from the consuming site. The\n // computed specifier keeps the bundler from trying to resolve it at build time.\n let chromium: { launch(opts?: unknown): Promise<PwBrowser> } | undefined\n try {\n const specifier = 'playwright'\n const pw = (await import(/* @vite-ignore */ specifier)) as {\n chromium?: { launch(opts?: unknown): Promise<PwBrowser> }\n }\n chromium = pw.chromium\n } catch {\n console.warn(\n '[dcs-seo] body-prerender: `playwright` is not installed; skipping body ' +\n 'prerender (head + JSON-LD still emitted). `pnpm add -D playwright` to enable.'\n )\n return null\n }\n if (!chromium) {\n console.warn('[dcs-seo] body-prerender: playwright has no chromium export; skipping.')\n return null\n }\n\n let browser: PwBrowser\n try {\n browser = await chromium.launch({ headless: true })\n } catch (err) {\n console.warn(\n '[dcs-seo] body-prerender: failed to launch Chromium (run ' +\n '`npx playwright install chromium`); skipping body prerender:',\n err instanceof Error ? err.message : err\n )\n return null\n }\n\n const staticServer = await startStaticServer(outDir)\n const context = await browser.newContext({ reducedMotion: 'reduce' })\n\n const renderer: RouteRenderer = {\n async renderRoute(routePath: string): Promise<RenderedRoute> {\n const page = await context.newPage()\n const errors: string[] = []\n page.on('pageerror', (err) => errors.push(`pageerror: ${err.message}`))\n if (debug) {\n page.on('console', (msg) => {\n if (msg.type() === 'error') console.log(`[dcs-seo] (console) ${msg.text()}`)\n })\n }\n\n // Keep the render offline + fast: serve our own origin, abort everything\n // else. The DOM keeps external <img>/<link> tags regardless. Compare the\n // parsed origin, not a string prefix — `http://127.0.0.1:<port>@evil.com/…`\n // starts with our origin but resolves to evil.com. (Perf/noise gate, not a\n // security boundary — the trust boundary is that we run the site's own\n // production bundle.)\n await page.route('**/*', (route) => {\n let sameOrigin = false\n try {\n sameOrigin = new URL(route.request().url()).origin === staticServer.origin\n } catch {\n sameOrigin = false\n }\n // Swallow the continue/abort rejection that races page.close (\"Route is\n // already handled\" / target closed) — an unhandled rejection would crash\n // the vite process under Node's throw-on-unhandled default.\n if (sameOrigin) {\n route.continue().catch(() => {})\n } else {\n route.abort().catch(() => {})\n }\n })\n\n try {\n await page.goto(staticServer.origin + routePath, {\n waitUntil: 'load',\n timeout: navTimeoutMs,\n })\n // The app mounts into #app; wait until it has real children (a failed\n // mount / crash never satisfies this → timeout → fatal error below).\n await page.waitForFunction(\n () => {\n const el = document.querySelector('#app')\n return !!el && el.children.length > 0\n },\n undefined,\n { timeout: mountTimeoutMs }\n )\n if (settleMs > 0) await page.waitForTimeout(settleMs)\n const bodyHtml = await page.$eval('#app', (el) => el.innerHTML)\n return { bodyHtml: bodyHtml ?? '', errors }\n } catch (err) {\n // A nav/mount timeout is itself a fatal render failure — report it so the\n // caller fails the build loud rather than shipping an empty body.\n errors.push(err instanceof Error ? err.message : String(err))\n return { bodyHtml: '', errors }\n } finally {\n await page.close()\n }\n },\n }\n\n return {\n renderer,\n async close() {\n try {\n await context.close()\n } catch {\n /* ignore */\n }\n try {\n await browser.close()\n } catch {\n /* ignore */\n }\n await staticServer.close()\n },\n }\n}\n","/**\n * DCS SEO Plugin for Vite\n *\n * Two responsibilities, both driven by `.dcs/seo.yaml`:\n *\n * 1. **Build-time define** (always on): reads `.dcs/seo.yaml` and injects it as\n * the `__DCS_SEO__` global for the runtime `useSEO` composable.\n *\n * 2. **Static `<head>` emitter** (opt-in via `emitStaticHtml: true`, default\n * OFF): after the bundle is written, reads the SPA's built `index.html`,\n * and for every route in `.dcs/pages.yaml` writes a per-route\n * `dist/<path>/index.html` whose `<head>` carries the resolved title, meta,\n * canonical, Open Graph, Twitter, and JSON-LD tags. This gives a Vue SPA\n * per-route static SEO **without** vite-ssg.\n *\n * VitePress sites already bake SEO via their own config, so they leave this\n * option OFF and are completely unaffected.\n *\n * @example Runtime define only (default — safe for VitePress)\n * ```typescript\n * // vite.config.ts\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [dcsSeoPlugin({ debug: true })]\n * })\n * ```\n *\n * @example Vue SPA with per-route static <head> emission\n * ```typescript\n * // vite.config.ts\n * import { dcsSeoPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [\n * dcsSeoPlugin({\n * emitStaticHtml: true, // turn the emitter ON\n * pagesPath: '.dcs/pages.yaml', // route manifest (default)\n * noindex: ['account', 'projects'], // robots: noindex,nofollow\n * exclude: ['/preview'], // skip these routes entirely\n * })\n * ]\n * })\n * ```\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport yaml from 'js-yaml'\nimport type { Plugin, ResolvedConfig, HtmlTagDescriptor } from 'vite'\nimport type { SeoConfiguration } from '../types/seo'\nimport { readDcsYamlFresh, buildGlobalAssignScript } from './serveDefineInject'\nimport { buildHeadTags } from '../seo/headTags'\nimport { spliceHeadHtml } from '../seo/spliceHeadHtml'\nimport { loadPagesManifest, type PageRouteEntry } from '../seo/pagesManifest'\nimport {\n prerenderBodies,\n isBodyPrerenderEnabled,\n routeToOutputFile,\n} from '../seo/bodyPrerender'\nimport { createPlaywrightRenderer } from '../seo/playwrightRenderer'\nimport {\n buildSitemapXml,\n buildRobotsTxt,\n buildLlmsTxt,\n matchesExcludedGlob,\n isHandAuthoredRobotsAcceptable,\n type DcsRobotsOptions,\n} from '../seo/sitemap'\nimport {\n breadcrumbTrailFromRoute,\n findReviewItemsForPage,\n findBusinessLicense,\n type ContentConfig,\n type ReviewSource,\n type BlogMeta,\n type FaqSource,\n} from '../seo/schemaGraph'\n\nexport interface DcsSeoPluginOptions {\n /** Path to seo.yaml relative to project root (default: '.dcs/seo.yaml') */\n seoPath?: string\n /** Enable debug logging */\n debug?: boolean\n\n /**\n * Opt-in: emit per-route static `<head>` (meta + JSON-LD) into the built\n * `dist/` at the end of the build. Default `false` — VitePress sites and any\n * site that bakes its own SEO are unaffected when this is off.\n */\n emitStaticHtml?: boolean\n\n /**\n * Build-time BODY prerender: after the per-route `<head>` is emitted, render\n * each indexable route's real DOM from the just-built SPA (headless Chromium\n * via the site's `playwright`) and splice it into the mount container so non-JS\n * AI crawlers see the page's body prose — not just `<div id=\"app\"></div>`.\n *\n * Defaults to whatever `emitStaticHtml` is, so every SPA already emitting\n * per-route HTML gains crawler-visible bodies on a cms bump with no per-site\n * edit. Set `false` here to keep head-only emission. It is ALSO overridable\n * per-site (no code change / no cms republish) via `.dcs/seo.yaml`\n * `prerenderBody: false`. noindex/auth-gated routes are never body-prerendered;\n * a route that crashes at render time fails the build loud rather than shipping\n * a broken body. Requires `playwright` in the site (already the fleet default);\n * absent ⇒ graceful no-op (head + JSON-LD still emitted).\n */\n prerenderBody?: boolean\n\n /**\n * Path to the route manifest relative to project root, used only when\n * `emitStaticHtml` is true. Default `'.dcs/pages.yaml'`.\n */\n pagesPath?: string\n\n /**\n * Path to `content.yaml` relative to project root, used only when\n * `emitStaticHtml` is true. Threads REAL reviews into the honest\n * Review/aggregateRating on the per-route LocalBusiness node. Default\n * `'.dcs/content.yaml'`. Missing/unparseable ⇒ no reviews emitted.\n */\n contentPath?: string\n\n /**\n * Routes to skip entirely (no per-route HTML written). Matched against the\n * route `path` (e.g. `'/preview'`) OR the route `slug` (e.g. `'account'`).\n */\n exclude?: string[]\n\n /**\n * Routes that should receive `robots: noindex, nofollow`. Matched against the\n * route `path` OR `slug`. The home route (`/`) still overwrites\n * `dist/index.html`.\n */\n noindex?: string[]\n\n /**\n * Opt-in: emit the site-wide static files `dist/sitemap.xml`,\n * `dist/robots.txt`, and `dist/llms.txt` after the per-route HTML loop.\n *\n * Defaults to whatever `emitStaticHtml` is — so every site already calling\n * `dcsSeoPlugin({ emitStaticHtml: true })` gets sitemap/robots/llms for free\n * with zero per-site edits. Set explicitly to `false` to keep emitting\n * per-route HTML without the site files. The whole block is wrapped in the\n * same try/catch + existsSync guards, so it can never break a build.\n */\n emitSiteFiles?: boolean\n\n /**\n * Canonical production origin, e.g. `https://ironoakcontractors.com`. Used as\n * the sitemap/llms base and the absolute `Sitemap:` line in robots.txt. When\n * absent, falls back to `seo.yaml`'s `global.siteUrl`; if neither is known and\n * no per-page canonicals exist, the sitemap + llms.txt no-op (robots still\n * emits). Never guessed.\n */\n siteUrl?: string\n\n /** robots.txt override hooks (disallow/allow/extra/aiBots/force). */\n robots?: DcsRobotsOptions\n\n /**\n * Preview / staging gate. When `true`, robots.txt becomes `Disallow: /` (no\n * `Sitemap:` line) and neither sitemap.xml nor llms.txt is emitted (privacy).\n * Detected ONLY via this explicit option — never guessed.\n */\n preview?: boolean\n\n /** Emit `dist/llms.txt` (default `true`; always off in preview mode). */\n llms?: boolean\n}\n\n/** Resolve the SPA output directory from Vite config (absolute path). */\nfunction resolveOutDir(config: ResolvedConfig): string {\n const out = config.build?.outDir || 'dist'\n return path.isAbsolute(out) ? out : path.resolve(config.root || process.cwd(), out)\n}\n\n/**\n * Load + parse seo.yaml from the usual `.dcs` locations.\n * Returns `{ config, foundPath }` or `null` (missing/unparseable).\n */\nfunction loadSeoConfig(\n projectRoot: string,\n seoPath: string,\n debug: boolean\n): { config: SeoConfiguration; foundPath: string } | null {\n const possiblePaths = [\n path.resolve(projectRoot, seoPath),\n path.resolve(projectRoot, '..', seoPath),\n path.resolve(process.cwd(), seoPath),\n ]\n\n let foundPath: string | undefined\n for (const testPath of possiblePaths) {\n if (fs.existsSync(testPath)) {\n foundPath = testPath\n break\n }\n }\n\n if (!foundPath) {\n if (debug) {\n console.log('[dcs-seo] No seo.yaml found at:')\n possiblePaths.forEach((p) => console.log(` - ${p}`))\n console.log('[dcs-seo] Using defaults only')\n }\n return null\n }\n\n try {\n const fileContent = fs.readFileSync(foundPath, 'utf8')\n const config = yaml.load(fileContent) as SeoConfiguration\n return { config, foundPath }\n } catch (error) {\n console.warn('[dcs-seo] Failed to parse seo.yaml:', error)\n return null\n }\n}\n\n/**\n * Load + parse `.dcs/content.yaml` from the usual `.dcs` locations. Returns the\n * parsed config or `undefined` (missing/unparseable). Used to thread REAL\n * reviews into the honest Review/aggregateRating builder. Never throws.\n */\nfunction loadContentConfig(\n projectRoot: string,\n contentRelPath: string,\n debug: boolean\n): ContentConfig | undefined {\n const possiblePaths = [\n path.resolve(projectRoot, contentRelPath),\n path.resolve(projectRoot, '..', contentRelPath),\n path.resolve(process.cwd(), contentRelPath),\n ]\n const foundPath = possiblePaths.find((p) => fs.existsSync(p))\n if (!foundPath) {\n if (debug) console.log(`[dcs-seo] No content.yaml found (reviews disabled)`)\n return undefined\n }\n try {\n const parsed = yaml.load(fs.readFileSync(foundPath, 'utf8'))\n if (!parsed || typeof parsed !== 'object') return undefined\n return parsed as ContentConfig\n } catch (error) {\n console.warn('[dcs-seo] Failed to parse content.yaml (reviews disabled):', error)\n return undefined\n }\n}\n\n/** Extract the optional top-level `excluded:` glob list from pages.yaml. */\nfunction loadExcludedGlobs(projectRoot: string, pagesPath: string): string[] {\n const possiblePaths = [\n path.resolve(projectRoot, pagesPath),\n path.resolve(projectRoot, '..', pagesPath),\n path.resolve(process.cwd(), pagesPath),\n ]\n const found = possiblePaths.find((p) => fs.existsSync(p))\n if (!found) return []\n try {\n const raw = yaml.load(fs.readFileSync(found, 'utf8')) as { excluded?: unknown } | null\n const excluded = raw?.excluded\n if (!Array.isArray(excluded)) return []\n return excluded.filter((e): e is string => typeof e === 'string')\n } catch {\n return []\n }\n}\n\n/**\n * Derive a single site-wide lastmod from seo.yaml `lastUpdated` (preferred) or\n * pages.yaml `lastUpdated`. No fabricated per-page dates.\n */\nfunction deriveLastmod(\n seoConfig: SeoConfiguration | undefined,\n projectRoot: string,\n pagesPath: string\n): string | undefined {\n const fromSeo = seoConfig?.lastUpdated\n if (typeof fromSeo === 'string' && fromSeo.length > 0) return fromSeo\n\n const possiblePaths = [\n path.resolve(projectRoot, pagesPath),\n path.resolve(projectRoot, '..', pagesPath),\n path.resolve(process.cwd(), pagesPath),\n ]\n const found = possiblePaths.find((p) => fs.existsSync(p))\n if (!found) return undefined\n try {\n const raw = yaml.load(fs.readFileSync(found, 'utf8')) as { lastUpdated?: unknown } | null\n const fromPages = raw?.lastUpdated\n if (typeof fromPages === 'string' && fromPages.length > 0) return fromPages\n } catch {\n /* ignore */\n }\n return undefined\n}\n\n/**\n * Core site-file emitter, separated from Vite so it is unit-testable.\n *\n * Writes the site-wide static files into `outDir`, reusing the SAME routes +\n * seoConfig already loaded by the per-route HTML loop (no second manifest read):\n * - `sitemap.xml` (skipped in preview, or when no absolute base is derivable)\n * - `robots.txt` (always; preview = `Disallow: /`; don't-clobber unless force)\n * - `llms.txt` (skipped in preview, or when nothing indexable)\n *\n * Returns the list of relative filenames written. Pure aside from `fs` writes —\n * deterministic + idempotent. Never throws (the caller also wraps in try/catch).\n */\nexport function emitSiteFiles(params: {\n outDir: string\n projectRoot: string\n pagesPath: string\n routes: PageRouteEntry[]\n seoConfig: SeoConfiguration | undefined\n siteUrl?: string\n exclude?: string[]\n noindex?: string[]\n preview?: boolean\n robots?: DcsRobotsOptions\n llms?: boolean\n debug?: boolean\n}): string[] {\n const {\n outDir,\n projectRoot,\n pagesPath,\n routes,\n seoConfig,\n siteUrl,\n exclude = [],\n noindex = [],\n preview = false,\n robots = {},\n llms = true,\n debug = false,\n } = params\n\n const written: string[] = []\n\n const effectiveSiteUrl = siteUrl || seoConfig?.global?.siteUrl\n const excludedGlobs = loadExcludedGlobs(projectRoot, pagesPath)\n const lastmod = deriveLastmod(seoConfig, projectRoot, pagesPath)\n\n // ── sitemap.xml (not in preview) ──────────────────────────────────────────\n let wroteSitemap = false\n if (!preview) {\n const xml = buildSitemapXml({\n routes,\n siteUrl: effectiveSiteUrl,\n seoConfig,\n exclude,\n noindex,\n excludedGlobs,\n lastmod,\n })\n if (xml) {\n fs.writeFileSync(path.join(outDir, 'sitemap.xml'), xml, 'utf8')\n wroteSitemap = true\n written.push('sitemap.xml')\n if (debug) console.log('[dcs-seo] wrote sitemap.xml')\n } else if (debug) {\n console.log('[dcs-seo] no absolute <loc> derivable; sitemap.xml not written')\n }\n }\n\n // ── robots.txt (always, unless robots.enabled is false) ───────────────────\n if (robots.enabled ?? true) {\n const robotsPath = path.join(outDir, 'robots.txt')\n // Factory-as-single-source (validated override): a hand-authored\n // public/robots.txt Vite copied into dist is KEPT only when it meets the\n // factory floor (a real `User-agent: *` group + every AI-bot tier). A stub\n // (`Sitemap:`-only, like just-posh) or an SPA-shell HTML page fails the\n // floor and is overwritten so AI discovery is guaranteed on every site.\n // `force` always overwrites; an absent file is always written.\n const existing =\n fs.existsSync(robotsPath) && !robots.force ? fs.readFileSync(robotsPath, 'utf8') : null\n const keepHandAuthored = existing !== null && isHandAuthoredRobotsAcceptable(existing)\n if (keepHandAuthored) {\n if (debug)\n console.log('[dcs-seo] dist/robots.txt is hand-authored and meets the floor; leaving it')\n } else {\n const txt = buildRobotsTxt({\n siteUrl: effectiveSiteUrl,\n preview,\n robots,\n hasSitemap: wroteSitemap,\n })\n fs.writeFileSync(robotsPath, txt, 'utf8')\n written.push('robots.txt')\n if (debug) {\n console.log(\n existing !== null\n ? '[dcs-seo] dist/robots.txt failed the factory floor; overwrote with emitted robots'\n : '[dcs-seo] wrote robots.txt'\n )\n }\n }\n }\n\n // ── llms.txt (not in preview) ─────────────────────────────────────────────\n if (llms && !preview) {\n const txt = buildLlmsTxt({\n routes,\n siteUrl: effectiveSiteUrl,\n seoConfig,\n exclude,\n noindex,\n excludedGlobs,\n })\n if (txt) {\n fs.writeFileSync(path.join(outDir, 'llms.txt'), txt, 'utf8')\n written.push('llms.txt')\n if (debug) console.log('[dcs-seo] wrote llms.txt')\n } else if (debug) {\n console.log('[dcs-seo] nothing indexable; llms.txt not written')\n }\n }\n\n return written\n}\n\n/**\n * Pick a structured FAQ array (`[{ q, a }]`) for a page from content.yaml, if\n * one exists under a `faq` key (page-scoped, then global). Returns `undefined`\n * when there is no structured Q&A — a `<FaqPage />` component is NOT a source,\n * so its pages correctly yield nothing (honesty).\n */\nfunction pickPageFaq(\n content: ContentConfig | undefined,\n pageSlug: string\n): FaqSource[] | undefined {\n if (!content) return undefined\n const fromBlock = (block: Record<string, unknown> | undefined): FaqSource[] | undefined => {\n if (!block) return undefined\n const v = block['faq']\n return Array.isArray(v) ? (v as FaqSource[]) : undefined\n }\n return fromBlock(content.pages?.[pageSlug]) ?? fromBlock(content.global)\n}\n\n/**\n * Core emitter, separated from Vite so it is unit-testable.\n *\n * For each route: build the head tags from the shared resolver, splice them\n * into the shell HTML, and write `dist/<path>/index.html`. Returns the number\n * of files written. Pure aside from `fs` writes — deterministic + idempotent.\n */\nexport function emitStaticSeoHtml(params: {\n outDir: string\n shellHtml: string\n routes: PageRouteEntry[]\n seoConfig: SeoConfiguration | undefined\n /**\n * Parsed `.dcs/content.yaml` — threads REAL review items (honesty-gated) into\n * the per-route LocalBusiness node. Optional; omit ⇒ no Review/aggregateRating.\n */\n contentConfig?: ContentConfig\n exclude?: string[]\n noindex?: string[]\n /** `pages.yaml` top-level `excluded:` globs — routes matching are NOT emitted. */\n excludedGlobs?: string[]\n debug?: boolean\n}): number {\n const {\n outDir,\n shellHtml,\n routes,\n seoConfig,\n contentConfig,\n exclude = [],\n noindex = [],\n excludedGlobs = [],\n debug = false,\n } = params\n\n const excludeSet = new Set(exclude)\n const noindexSet = new Set(noindex)\n\n // Route → human title map (for breadcrumb hop labels), from the manifest.\n const siteUrl = seoConfig?.global?.siteUrl ?? ''\n const routeTitles: Record<string, string> = { '/': 'Home' }\n for (const r of routes) {\n if (r.title && r.path) routeTitles[r.path.replace(/\\/+$/, '') || '/'] = r.title\n }\n\n let written = 0\n for (const route of routes) {\n if (excludeSet.has(route.path) || (route.slug && excludeSet.has(route.slug))) {\n if (debug) console.log(`[dcs-seo] skip (excluded): ${route.path}`)\n continue\n }\n\n // Honor pages.yaml top-level `excluded:` globs (e.g. `/dev-*`, `/_*`): an\n // excluded route must NOT get a per-route index.html, or it becomes a\n // crawlable/indexable page despite being intentionally hidden — a privacy\n // and crawl-budget leak. Same glob semantics as the sitemap path.\n if (matchesExcludedGlob(route.path, excludedGlobs)) {\n if (debug) console.log(`[dcs-seo] skip (excluded glob): ${route.path}`)\n continue\n }\n\n const forceNoindex =\n noindexSet.has(route.path) || (route.slug && noindexSet.has(route.slug))\n\n // Breadcrumb trail from route depth (home ⇒ none); titles from the manifest.\n const breadcrumbTrail = siteUrl\n ? breadcrumbTrailFromRoute(route.path, siteUrl, routeTitles)\n : undefined\n\n // REAL reviews for this page from content.yaml (honesty-gated downstream).\n const reviews: ReviewSource[] | undefined = contentConfig\n ? findReviewItemsForPage(contentConfig, route.slug)\n : undefined\n\n // Trade/occupational license from content.yaml `business.license` (dark when\n // the key is empty/absent — no hasCredential is emitted). Honesty-gated in\n // buildHasCredential downstream.\n const license: string | undefined = contentConfig\n ? findBusinessLicense(contentConfig, route.slug)\n : undefined\n\n // BlogPosting for a blog post route — only when seo.yaml has NOT already\n // hand-authored one (buildHeadTags skips ours if it has). A blog post is a\n // route nested under `/blog/` (depth ≥ 2) with a manifest title.\n const isBlogPost = /^\\/blog\\/.+/.test(route.path) && !!route.title\n const blogMeta: BlogMeta | undefined = isBlogPost\n ? { headline: route.title, url: breadcrumbTrail?.[breadcrumbTrail.length - 1]?.item }\n : undefined\n\n // FAQ from a structured `.dcs/faq.yaml`-style block on the content page, if\n // present (honesty-gated). Component-only FAQ pages carry no such data.\n const faq: FaqSource[] | undefined = pickPageFaq(contentConfig, route.slug)\n\n const tags = buildHeadTags(route.slug, route.path, seoConfig, {\n includeKeywords: true,\n fallbackTitle: route.title,\n robots: forceNoindex ? 'noindex, nofollow' : undefined,\n emitGraph: true,\n breadcrumbTrail,\n reviews,\n license,\n blogMeta,\n faq,\n })\n\n const html = spliceHeadHtml(shellHtml, tags)\n const outFile = routeToOutputFile(outDir, route.path)\n\n fs.mkdirSync(path.dirname(outFile), { recursive: true })\n fs.writeFileSync(outFile, html, 'utf8')\n written++\n\n if (debug) {\n console.log(\n `[dcs-seo] wrote ${path.relative(outDir, outFile)} (title=\"${tags.title}\"${\n forceNoindex ? ', noindex' : ''\n })`\n )\n }\n }\n\n return written\n}\n\n/**\n * Run the body-prerender pass: bring up the headless renderer, fill each\n * indexable route's `<div id=\"app\">` with its real rendered DOM, then tear the\n * renderer down. Missing infra (no playwright / no browser) is a graceful no-op;\n * a render crash/fabrication propagates a `BodyPrerenderError` to fail the build.\n */\nasync function runBodyPrerender(\n ctx: { outDir: string; routes: PageRouteEntry[]; excludedGlobs: string[] },\n opts: { exclude: string[]; noindex: string[]; debug: boolean }\n): Promise<void> {\n const handle = await createPlaywrightRenderer({ outDir: ctx.outDir, debug: opts.debug })\n if (!handle) return // graceful: playwright/browser unavailable\n\n console.log('[dcs-seo] body-prerender: rendering routes via headless Chromium…')\n try {\n const result = await prerenderBodies({\n outDir: ctx.outDir,\n routes: ctx.routes,\n renderer: handle.renderer,\n exclude: opts.exclude,\n noindex: opts.noindex,\n excludedGlobs: ctx.excludedGlobs,\n debug: opts.debug,\n })\n console.log(\n `[dcs-seo] body-prerender: ${result.prerendered} route(s) now have ` +\n `crawler-visible body content (${result.skipped} skipped)`\n )\n } finally {\n await handle.close()\n }\n}\n\n/**\n * Vite plugin that injects .dcs/seo.yaml at build time and, optionally, emits\n * per-route static `<head>` HTML for SPA SEO.\n *\n * @param options - Plugin configuration\n * @returns Vite plugin\n */\nexport function dcsSeoPlugin(options: DcsSeoPluginOptions = {}): Plugin {\n const {\n seoPath = '.dcs/seo.yaml',\n debug = false,\n emitStaticHtml = false,\n prerenderBody,\n pagesPath = '.dcs/pages.yaml',\n contentPath = '.dcs/content.yaml',\n exclude = [],\n noindex = [],\n // Site files default ON whenever per-route HTML emission is on, so the\n // sites already using emitStaticHtml gain sitemap/robots/llms with no edit.\n emitSiteFiles: emitSiteFilesOpt = emitStaticHtml,\n siteUrl,\n robots = {},\n // Self-detect preview builds from DCS_PREVIEW (mirrors dcsEditorPlugin) so a\n // release/** SWA preview build never body-prerenders; an explicit option wins.\n preview = process.env.DCS_PREVIEW === 'true',\n llms = true,\n } = options\n\n let resolvedConfig: ResolvedConfig\n // Captured during configResolved — gates the serve-only inline HTML inject.\n let isDev = false\n\n return {\n name: 'dcs-seo',\n\n configResolved(config) {\n resolvedConfig = config\n isDev = config.command === 'serve'\n },\n\n config(config, env) {\n // ── Dev / preview (serve) ──────────────────────────────────────────────\n // Don't bake seo.yaml into the bundle. Redirect the `__DCS_SEO__` define\n // to a browser global that `transformIndexHtml` (below) refreshes from\n // disk on every HTML request — live preview with NO server.restart().\n // The consumer is untouched: it still reads the bare `__DCS_SEO__`\n // identifier, which this define rewrites to `globalThis.__DCS_SEO__`.\n // (VitePress treats `useSEO` as a no-op and bakes SEO via\n // transformPageData, so this only affects the runtime `useSEO` SPA path.)\n if (env.command === 'serve') {\n return {\n define: {\n __DCS_SEO__: 'globalThis.__DCS_SEO__',\n },\n }\n }\n\n // ── Production build ───────────────────────────────────────────────────\n // Unchanged: read seo.yaml now and bake it into the bundle as a literal.\n const projectRoot = config.root || process.cwd()\n\n const loaded = loadSeoConfig(projectRoot, seoPath, debug)\n if (!loaded) {\n return {\n define: {\n __DCS_SEO__: 'undefined',\n },\n }\n }\n\n if (debug) {\n console.log(`[dcs-seo] Loaded ${loaded.foundPath}`)\n console.log(`[dcs-seo] Version: ${loaded.config.version}`)\n console.log(`[dcs-seo] Site Name: ${loaded.config.global?.siteName || '(not set)'}`)\n console.log(\n `[dcs-seo] Pages: ${Object.keys(loaded.config.pages ?? {}).join(', ') || '(none)'}`\n )\n }\n\n return {\n define: {\n __DCS_SEO__: JSON.stringify(loaded.config),\n },\n }\n },\n\n /**\n * Build-time static `<head>` emitter (opt-in via `emitStaticHtml`).\n *\n * Runs after the bundle is written so the built `index.html` shell exists\n * on disk. For an SPA, Vite emits a single `index.html`; we fan it out to\n * per-route files with route-specific `<head>` content.\n *\n * Fully defensive: any missing/unparseable input logs a warning and\n * no-ops. Never throws (so it can never break a production build).\n */\n async writeBundle() {\n if (!emitStaticHtml) {\n // The whole emit path is gated on emitStaticHtml. If the operator\n // explicitly asked for site files (`emitSiteFiles: true`) while\n // emitStaticHtml is off, that request is silently inert — warn so it's\n // not mistaken for \"robots/sitemap were emitted\".\n if (options.emitSiteFiles === true) {\n console.warn(\n '[dcs-seo] emitSiteFiles:true is ignored because emitStaticHtml is false; ' +\n 'set emitStaticHtml:true to emit sitemap.xml/robots.txt/llms.txt'\n )\n }\n return\n }\n\n // Captured inside the never-break emit below, consumed by the separately\n // guarded body-prerender step after it (so a fabrication/crash there can\n // fail the build loud instead of being swallowed by the emit try/catch).\n let bodyPrerenderCtx:\n | { outDir: string; routes: PageRouteEntry[]; excludedGlobs: string[] }\n | null = null\n\n try {\n const projectRoot = resolvedConfig?.root || process.cwd()\n const outDir = resolveOutDir(resolvedConfig)\n\n if (!fs.existsSync(outDir)) {\n console.warn(`[dcs-seo] emitStaticHtml: outDir not found (${outDir}); skipping`)\n return\n }\n\n const shellPath = path.join(outDir, 'index.html')\n if (!fs.existsSync(shellPath)) {\n console.warn(\n `[dcs-seo] emitStaticHtml: no index.html in ${outDir}; nothing to emit`\n )\n return\n }\n\n const routes = loadPagesManifest(projectRoot, pagesPath, debug)\n if (!routes) {\n console.warn(\n `[dcs-seo] emitStaticHtml: ${pagesPath} missing or empty; skipping per-route emission`\n )\n return\n }\n\n const loaded = loadSeoConfig(projectRoot, seoPath, debug)\n if (!loaded) {\n // seo.yaml is optional for emission — routes still get baked with\n // global/runtime defaults (which here means just the shell title and\n // a derived canonical-less head). Warn so the operator knows.\n console.warn(\n `[dcs-seo] emitStaticHtml: ${seoPath} missing or unparseable; emitting with defaults only`\n )\n }\n\n const shellHtml = fs.readFileSync(shellPath, 'utf8')\n\n // pages.yaml top-level `excluded:` globs gate BOTH the per-route HTML\n // emission below and the sitemap/llms set inside emitSiteFiles, so an\n // excluded route is never written as a crawlable index.html.\n const excludedGlobs = loadExcludedGlobs(projectRoot, pagesPath)\n // Optional: load content.yaml so REAL reviews can feed the honest\n // Review/aggregateRating on the per-route LocalBusiness node. Absent or\n // unparseable ⇒ undefined ⇒ no reviews emitted (no synthesis).\n const contentConfig = loadContentConfig(projectRoot, contentPath, debug)\n\n const written = emitStaticSeoHtml({\n outDir,\n shellHtml,\n routes,\n seoConfig: loaded?.config,\n contentConfig,\n exclude,\n noindex,\n excludedGlobs,\n debug,\n })\n\n if (debug) {\n console.log(`[dcs-seo] emitStaticHtml: wrote ${written} per-route HTML file(s)`)\n }\n\n // ── site-wide static files (sitemap.xml, robots.txt, llms.txt) ──────\n // Emitted AFTER the per-route HTML loop so canonicals/routes are\n // resolved and the shell exists. Reuses the already-loaded routes +\n // seoConfig (no second manifest read). Same outDir/existsSync guard +\n // the outer try/catch — so it can never break a production build.\n if (emitSiteFilesOpt) {\n const siteFiles = emitSiteFiles({\n outDir,\n projectRoot,\n pagesPath,\n routes,\n seoConfig: loaded?.config,\n siteUrl,\n exclude,\n noindex,\n preview,\n robots,\n llms,\n debug,\n })\n if (debug) {\n console.log(\n `[dcs-seo] emitSiteFiles: wrote ${siteFiles.length} site file(s): ${\n siteFiles.join(', ') || '(none)'\n }`\n )\n }\n }\n\n // Body prerender runs only when enabled for this build (default ON when\n // emitting; off via the `prerenderBody` option, the seo.yaml escape\n // hatch, or preview mode). Stash what it needs so it executes under its\n // own fail-loud guard below, NOT this swallow-catch.\n // Extra guard: the prerender server serves the built assets from root,\n // so a non-root `base` (subpath preview deploys like /kept/) would 404\n // every asset → the app never mounts → a spurious build failure. Skip\n // (loudly) rather than fail — head + JSON-LD are already emitted.\n const buildBase = resolvedConfig?.base ?? '/'\n const baseIsRoot = buildBase === '/' || buildBase === './' || buildBase === ''\n if (\n isBodyPrerenderEnabled({\n emitStaticHtml,\n prerenderBodyOption: prerenderBody,\n preview,\n seoPrerenderBody: loaded?.config?.prerenderBody,\n })\n ) {\n if (baseIsRoot) {\n bodyPrerenderCtx = { outDir, routes, excludedGlobs }\n } else {\n console.warn(\n `[dcs-seo] body prerender skipped: non-root base \"${buildBase}\" ` +\n '(assets would not resolve through the prerender server; head + JSON-LD still emitted)',\n )\n }\n }\n } catch (error) {\n // Never break the build on SEO emission failure.\n console.warn('[dcs-seo] emitStaticHtml failed; build output left unchanged:', error)\n }\n\n // ── Body prerender (SEPARATE guard — fail loud on fabrication/crash) ──────\n // Deliberately OUTSIDE the swallow-catch above: missing infra (no\n // playwright / no browser) degrades gracefully to a no-op, but a route that\n // crashes or would ship broken content throws BodyPrerenderError and FAILS\n // the build. Head + JSON-LD are already on disk regardless.\n if (bodyPrerenderCtx) {\n await runBodyPrerender(bodyPrerenderCtx, { exclude, noindex, debug })\n }\n },\n\n /**\n * Dev-only: inject the FRESH on-disk `seo.yaml` as an inline\n * `globalThis.__DCS_SEO__ = {…}` classic script at the top of `<head>`,\n * mirroring dcsContentPlugin. Lets the runtime `useSEO` SPA path reflect\n * on-disk SEO edits on the portal's `?_hc` hard reload with no restart.\n * Gated on `isDev` so it never runs in `vite`/`vitepress build` (the build\n * path keeps the baked `define` literal + the `writeBundle` emitter).\n */\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n if (!isDev) return html\n\n const projectRoot = resolvedConfig?.root || process.cwd()\n const config = readDcsYamlFresh<SeoConfiguration>(projectRoot, seoPath, 'dcs-seo', debug)\n // No file (or unparseable) ⇒ leave the global unset; the consumer's\n // `typeof globalThis.__DCS_SEO__` check falls back to defaults.\n if (config === undefined) return html\n\n if (debug) {\n console.log('[dcs-seo] serve: injecting fresh __DCS_SEO__ into <head>')\n }\n\n const tags: HtmlTagDescriptor[] = [\n {\n tag: 'script',\n children: buildGlobalAssignScript('__DCS_SEO__', config),\n injectTo: 'head-prepend',\n },\n ]\n return { html, tags }\n },\n },\n\n // Watch for changes in development.\n //\n // Downgraded from `server.restart()` to a debounced client `full-reload`:\n // freshness already comes from `transformIndexHtml` re-reading the YAML on\n // every HTML request, so all we need on change is a browser reload. A\n // `server.restart()` would rebuild VitePress's dev MiniSearch index and can\n // throw \"server restart failed\" on a duplicate heading id — the fragility\n // this fix removes. A `full-reload` does neither.\n configureServer(server) {\n const projectRoot = resolvedConfig?.root || process.cwd()\n\n const watchPaths = [\n path.resolve(projectRoot, seoPath),\n path.resolve(projectRoot, '..', seoPath),\n ].map((p) => path.normalize(p))\n\n watchPaths.forEach((watchPath) => {\n if (fs.existsSync(watchPath)) {\n server.watcher.add(watchPath)\n }\n })\n\n let reloadTimer: ReturnType<typeof setTimeout> | undefined\n server.watcher.on('change', (changedPath) => {\n if (!watchPaths.includes(path.normalize(changedPath))) return\n if (reloadTimer) clearTimeout(reloadTimer)\n reloadTimer = setTimeout(() => {\n if (debug) {\n console.log('[dcs-seo] seo.yaml changed, sending full-reload')\n }\n server.ws.send({ type: 'full-reload' })\n }, 100)\n })\n },\n }\n}\n","/**\n * DCS Editor Plugin for Vite\n *\n * Injects the editor bridge script into customer sites when running\n * in portal preview mode (inside the visual editor iframe).\n *\n * The bridge enables:\n * - Inline text editing via contenteditable\n * - Section hover highlights and AI ✨ buttons\n * - postMessage communication with the portal\n *\n * This plugin should only be active in development/preview mode.\n * It's safe to include in production builds — it does nothing unless\n * the page detects it's inside an iframe.\n *\n * @example\n * ```typescript\n * // vite.config.ts\n * import { dcsEditorPlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * plugins: [\n * dcsEditorPlugin()\n * ]\n * })\n * ```\n */\n\nimport type { Plugin } from 'vite'\n\nexport interface DcsEditorPluginOptions {\n /** Enable debug logging */\n debug?: boolean\n}\n\n/**\n * Vite plugin that injects the editor bridge script for portal preview integration.\n *\n * The bridge auto-initializes only when the page detects it's running inside an iframe,\n * so it's safe to include in all builds — it's a no-op in standalone browsing.\n *\n * Uses a virtual module (`/__dcs-editor-bridge.js`) served through Vite's dev server\n * so that bare module specifiers (like `@duffcloudservices/cms/editor`) are properly\n * resolved through Vite's module graph rather than hitting the browser's native ESM\n * resolver, which can't handle bare specifiers.\n */\nexport function dcsEditorPlugin(options: DcsEditorPluginOptions = {}): Plugin {\n const { debug = false } = options\n const VIRTUAL_PATH = '/__dcs-editor-bridge.js'\n const RIBBON_VIRTUAL_PATH = '/__dcs-preview-ribbon.js'\n\n // Captured during configResolved — used to gate HTML injection.\n let isDev = false\n let basePath = '/'\n let isPreview = false\n\n return {\n name: 'dcs-editor-bridge',\n\n // Preview only: stop Vite running an unreachable HMR WebSocket server.\n // Freshness comes from the cms content/seo plugins (fresh transformIndexHtml\n // re-read) + the portal's ?_hc hard reload, not HMR. NOTE: this alone does\n // NOT silence the browser — Vite still injects @vite/client and calls\n // connect(); the client-side stub in transformIndexHtml is what removes the\n // console errors. A normal local `vite dev` (no DCS_PREVIEW) keeps full HMR.\n config(_config, env) {\n if (env.command === 'serve' && process.env.DCS_PREVIEW === 'true') {\n return { server: { hmr: false } }\n }\n },\n\n configResolved(config) {\n isDev = config.command === 'serve'\n basePath = config.base ?? '/'\n isPreview = process.env.DCS_PREVIEW === 'true'\n },\n\n resolveId(id) {\n if (id === VIRTUAL_PATH || id === RIBBON_VIRTUAL_PATH) {\n return id\n }\n },\n\n load(id) {\n if (id === VIRTUAL_PATH) {\n return `\nimport { initEditorBridge } from '@duffcloudservices/cms/editor'\n// The bridge only activates inside an iframe (portal preview)\nif (window.parent !== window) {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => setTimeout(initEditorBridge, 200))\n } else {\n setTimeout(initEditorBridge, 200)\n }\n}\n`\n }\n\n if (id === RIBBON_VIRTUAL_PATH) {\n return `\nimport { createApp } from 'vue'\nimport PreviewRibbon from '@duffcloudservices/cms/components'\n\nfunction mountRibbon() {\n // Create a detached mount point\n const el = document.createElement('div')\n el.id = 'dcs-preview-ribbon-root'\n document.body.appendChild(el)\n\n const app = createApp(PreviewRibbon)\n app.mount(el)\n}\n\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', mountRibbon)\n} else {\n mountRibbon()\n}\n`\n }\n },\n\n /**\n * Only inject the editor bridge and ribbon scripts when:\n * 1. Running in dev mode (Vite dev server), AND\n * 2. The app is served at the root path (base === '/')\n *\n * These are virtual modules resolved via absolute paths (e.g.\n * `/__dcs-editor-bridge.js`). When base !== '/', the app is served at a\n * sub-path (e.g. /handyman-bryan/) and the absolute virtual paths are NOT\n * routed to the Vite dev server by the reverse proxy — they hit the main\n * DCS server instead and get redirected to portal.duffcloudservices.com\n * (no CORS headers), causing browser console errors.\n *\n * In production builds, App.vue imports and mounts PreviewRibbon\n * directly, so virtual script injection is always redundant anyway.\n */\n transformIndexHtml: {\n order: 'pre',\n handler(html) {\n if (!isDev || basePath !== '/') return html\n\n if (debug) {\n console.log('[dcs-editor] Injecting editor bridge + preview ribbon script tags')\n }\n\n // Inject both the editor bridge and preview ribbon scripts\n const editorTag = `<script type=\"module\" src=\"${VIRTUAL_PATH}\"></script>`\n const ribbonTag = `<script type=\"module\" src=\"${RIBBON_VIRTUAL_PATH}\"></script>`\n const bodyHtml = html.replace('</body>', `${editorTag}\\n${ribbonTag}\\n</body>`)\n\n if (!isPreview) return bodyHtml\n\n // Preview only: neutralise Vite's HMR WebSocket. Vite always injects\n // @vite/client and unconditionally calls transport.connect(); behind the\n // preview proxy chain there is no reachable HMR WS, so it logs\n // WebSocket connection to 'wss://<portal>/?token=…' failed\n // WebSocket connection to 'wss://localhost:<port>/?token=…' failed\n // [vite] failed to connect to websocket\n // server.hmr:false does NOT stop this (the client is still injected). A\n // classic <script> in <head> runs during parse, BEFORE the deferred\n // @vite/client module, so returning an inert socket for the 'vite-hmr'\n // subprotocol silences the attempt with zero effect on app/runtime\n // WebSockets. No-op outside preview / in production builds.\n const wsStub =\n `(function(){try{var N=window.WebSocket;if(!N)return;` +\n `function hmr(p){return p==='vite-hmr'||(Array.isArray(p)&&p.indexOf('vite-hmr')!==-1)}` +\n `function Inert(){this.readyState=0}` +\n `Inert.prototype.send=function(){};Inert.prototype.close=function(){};` +\n `Inert.prototype.addEventListener=function(){};Inert.prototype.removeEventListener=function(){};` +\n `var W=function(u,p){if(hmr(p))return new Inert();return new N(u,p)};` +\n `W.prototype=N.prototype;W.CONNECTING=N.CONNECTING;W.OPEN=N.OPEN;W.CLOSING=N.CLOSING;W.CLOSED=N.CLOSED;` +\n `window.WebSocket=W}catch(e){}})()`\n\n return {\n html: bodyHtml,\n tags: [{ tag: 'script', children: wsStub, injectTo: 'head-prepend' }],\n }\n },\n },\n }\n}\n","/**\n * DCS Preview Plugin for Vue\n *\n * Registers a supplied ribbon component as a global `DcsPreviewRibbon`\n * component. The ribbon handles its own visibility — it only renders on\n * `preview.duffcloudservices.com` and hides everywhere else (localhost,\n * production domains, and inside the visual page editor iframe).\n *\n * Why does the caller pass the component in? Because this file is compiled\n * by tsup (esbuild) which has no `.vue` SFC loader. Keeping the raw `.vue`\n * import out of the compiled plugins bundle avoids the build error while\n * still letting consumer code (which *does* run through Vite) resolve the\n * SFC at dev/build time.\n *\n * @example VitePress theme/index.ts\n * ```typescript\n * import { dcsPreviewPlugin } from '@duffcloudservices/cms/plugins'\n * import PreviewRibbon from '@duffcloudservices/cms/components'\n *\n * export default {\n * Layout,\n * enhanceApp({ app }) {\n * app.use(dcsPreviewPlugin(PreviewRibbon))\n * }\n * }\n * ```\n */\n\nimport { defineComponent, h, type App, type Component, type Plugin } from 'vue'\n\nexport interface DcsPreviewPluginOptions {\n /**\n * Override the version string displayed on the ribbon.\n * If omitted, the ribbon auto-detects from VITE_SITE_VERSION or the API.\n */\n version?: string | null\n}\n\n/**\n * Creates and returns the DCS Preview plugin.\n *\n * When installed, it registers the supplied ribbon component as a global\n * `DcsPreviewRibbon` component. Add `<DcsPreviewRibbon />` to your root\n * Layout, or use the `dcsEditorPlugin` Vite plugin which injects it via\n * `transformIndexHtml`.\n *\n * @param ribbonComponent - The PreviewRibbon SFC (imported by the consumer)\n * @param options - Optional configuration\n */\nexport function dcsPreviewPlugin(\n ribbonComponent: Component,\n options: DcsPreviewPluginOptions = {},\n): Plugin {\n const Wrapper = defineComponent({\n name: 'DcsPreviewRibbon',\n setup() {\n return () => h(ribbonComponent, { version: options.version ?? null })\n },\n })\n\n return {\n install(app: App) {\n app.component('DcsPreviewRibbon', Wrapper)\n\n if (options.version !== undefined) {\n app.provide('__dcs_preview_version__', options.version)\n }\n },\n }\n}\n","/**\n * DCS CDN Image Plugin for Vite\n *\n * Rewrites local static image references (e.g. `/images/staff/photo.jpg`)\n * to CDN URLs at build time using the `.dcs/cdn-image-map.json` mapping file\n * generated by the `image-migrate adopt` CLI command.\n *\n * For raster images with WebP variants, `<img>` elements are transformed into\n * responsive `<picture>` elements with `srcset` for optimised delivery.\n * SVGs receive a simple URL swap with no variant handling.\n *\n * **In development mode this plugin is a no-op** — local `/images/` paths\n * continue to work via Vite's static asset serving so hot-reload is unaffected.\n *\n * The plugin handles two in-pipeline replacement vectors:\n *\n * 1. **Module transform** (`transform` hook) — rewrites `<img>` tags and\n * string literals in Vue SFCs, TS, JS, CSS, MD, and HTML modules.\n * 2. **Chunk rendering** (`renderChunk` hook) — rewrites image paths in\n * final rendered JS/CSS chunks AFTER Vite's `define` substitution.\n * This catches data injected by `dcsContentPlugin` via `__DCS_CONTENT__`\n * (from `.dcs/content.yaml`) which bypasses the `transform` hook.\n *\n * A third vector — **post-build file processing** — is handled by the\n * companion `dcsCdnBuildEnd` hook, which must be registered separately in\n * VitePress config. VitePress generates HTML *after* both Vite builds\n * complete, so Vite plugin hooks (`closeBundle`, `transformIndexHtml`)\n * cannot catch SSR-rendered `<head>` tags or static `public/` files like\n * `service-worker.js`.\n *\n * @example\n * ```ts\n * // .vitepress/config.ts\n * import { dcsCdnImagePlugin, dcsCdnBuildEnd } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * vite: {\n * plugins: [\n * dcsCdnImagePlugin()\n * ]\n * },\n * buildEnd: dcsCdnBuildEnd()\n * })\n * ```\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport type { Plugin } from 'vite'\n\n// ────────────────────────────────────────────────────────────────────────────\n// Types\n// ────────────────────────────────────────────────────────────────────────────\n\nexport interface CdnImageMapVariant {\n suffix: string\n blobPath: string\n cdnUrl: string\n width: number\n height: number\n size: number\n}\n\nexport interface CdnImageMapEntry {\n localPath: string\n blobPath: string\n cdnUrl: string\n fileName: string\n contentType: string\n originalSize: number\n width?: number\n height?: number\n hash: string\n variants?: CdnImageMapVariant[]\n}\n\nexport interface CdnImageMap {\n generated: string\n site: string\n cdnBase: string\n images: CdnImageMapEntry[]\n}\n\nexport interface DcsCdnImagePluginOptions {\n /** Path to cdn-image-map.json relative to project root (default: '.dcs/cdn-image-map.json') */\n mapPath?: string\n\n /**\n * Patterns to match for replacement. Each must be a **leading-slash path prefix**\n * that appears in source code (e.g. `/images/`). The `localPath` field in the\n * mapping file is compared *without* a leading slash.\n *\n * Default: `['/images/']`\n */\n pathPrefixes?: string[]\n\n /**\n * Default `sizes` attribute for responsive `<picture>` elements.\n * Override per-context via the `data-sizes` attribute on the original `<img>`.\n *\n * Default: `'(max-width: 1024px) 100vw, 1024px'`\n */\n defaultSizes?: string\n\n /** Enable debug logging */\n debug?: boolean\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Helpers\n// ────────────────────────────────────────────────────────────────────────────\n\nfunction escapeHtml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n}\n\n/**\n * Build a responsive `<picture>` element for a raster image that has\n * WebP variants.\n */\nfunction buildPictureElement(\n entry: CdnImageMapEntry,\n alt: string,\n extraAttrs: string,\n sizes: string\n): string {\n const variants = entry.variants ?? []\n\n // Collect only the display-relevant variants (not thumb, not og)\n const displayVariants = variants.filter(\n (v) => v.suffix === '-sm' || v.suffix === '-md' || v.suffix === '-lg'\n )\n\n if (displayVariants.length === 0) {\n // No display variants — fall back to original CDN URL as plain <img>\n return `<img src=\"${escapeHtml(entry.cdnUrl)}\" alt=\"${escapeHtml(alt)}\"${extraAttrs} loading=\"lazy\" decoding=\"async\" />`\n }\n\n const srcset = displayVariants\n .map((v) => `${v.cdnUrl} ${v.width}w`)\n .join(', ')\n\n // Pick the -md variant as the default src, or fall through to original\n const mdVariant = variants.find((v) => v.suffix === '-md')\n const fallbackSrc = mdVariant ? mdVariant.cdnUrl : entry.cdnUrl\n\n return [\n '<picture>',\n ` <source srcset=\"${srcset}\" type=\"image/webp\" sizes=\"${escapeHtml(sizes)}\" />`,\n ` <img src=\"${escapeHtml(fallbackSrc)}\" alt=\"${escapeHtml(alt)}\"${extraAttrs} loading=\"lazy\" decoding=\"async\" />`,\n '</picture>',\n ].join('\\n')\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Shared helpers\n// ────────────────────────────────────────────────────────────────────────────\n\n/**\n * Try to find and load the CDN image map from common locations.\n * VitePress nests docs under a subfolder, so we check parent dirs too.\n */\nfunction loadCdnImageMap(\n projectRoot: string,\n relativeMapPath: string,\n debug: boolean\n): Map<string, CdnImageMapEntry> | null {\n const possiblePaths = [\n path.resolve(projectRoot, relativeMapPath),\n path.resolve(projectRoot, '..', relativeMapPath),\n path.resolve(process.cwd(), relativeMapPath),\n ]\n\n for (const testPath of possiblePaths) {\n if (fs.existsSync(testPath)) {\n try {\n const raw = fs.readFileSync(testPath, 'utf8')\n const data: CdnImageMap = JSON.parse(raw)\n\n const map = new Map<string, CdnImageMapEntry>()\n for (const entry of data.images) {\n // Store both with and without leading slash for flexible matching\n map.set(entry.localPath, entry)\n if (!entry.localPath.startsWith('/')) {\n map.set('/' + entry.localPath, entry)\n }\n }\n\n if (debug) {\n console.log(`[dcs-cdn-image] Loaded ${data.images.length} entries from ${testPath}`)\n }\n return map\n } catch (error) {\n console.warn(`[dcs-cdn-image] Failed to parse ${testPath}:`, error)\n }\n }\n }\n\n if (debug) {\n console.log('[dcs-cdn-image] No cdn-image-map.json found at:')\n possiblePaths.forEach((p) => console.log(` - ${p}`))\n }\n return null\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// Vite Plugin\n// ────────────────────────────────────────────────────────────────────────────\n\n/**\n * Vite plugin that rewrites static `/images/` paths to CDN URLs at build time.\n */\nexport function dcsCdnImagePlugin(options: DcsCdnImagePluginOptions = {}): Plugin {\n const {\n mapPath = '.dcs/cdn-image-map.json',\n pathPrefixes = ['/images/'],\n defaultSizes = '(max-width: 1024px) 100vw, 1024px',\n debug = false,\n } = options\n\n // Lookup map built from the JSON file: key = localPath (no leading slash)\n let imageMap: Map<string, CdnImageMapEntry> | null = null\n let isProduction = false\n\n /**\n * Check whether a source code string contains any of the path prefixes\n * we care about. Quick bail-out for files that don't reference images.\n */\n function hasImageReferences(code: string): boolean {\n return pathPrefixes.some((prefix) => code.includes(prefix))\n }\n\n /**\n * Replace image path references in any string value with CDN URLs.\n * Used for code transforms and renderChunk post-processing.\n */\n function replaceImagePaths(str: string): string {\n if (!imageMap || imageMap.size === 0) return str\n let result = str\n for (const prefix of pathPrefixes) {\n // Global replace: matches prefix followed by a relative path bounded\n // by quotes, parens, or whitespace. Allows spaces in filenames.\n const regex = new RegExp(\n `([\"'\\`(])${escapeRegex(prefix)}([^\"'\\`()]+)`,\n 'g'\n )\n result = result.replace(regex, (match, quote, relPath) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return match\n return `${quote}${entry.cdnUrl}`\n })\n }\n return result\n }\n\n /**\n * Replace standalone URL references in JS/TS string literals and Vue template\n * attributes. This handles patterns like:\n * src=\"/images/foo.jpg\"\n * { src: '/images/foo.jpg' }\n * url(/images/foo.svg)\n *\n * For `<img>` tags with raster images that have variants, the entire tag is\n * replaced with a `<picture>` element.\n */\n function transformCode(code: string): string {\n if (!imageMap || imageMap.size === 0) return code\n\n // ── Pass 1: Replace <img> tags that reference mapped raster images ──────\n // Matches: <img ... src=\"/images/foo.jpg\" ... /> or <img ... src=\"/images/foo.jpg\" ... >\n const imgTagRegex = /<img\\b([^>]*?)src=[\"'](\\/(images\\/[^\"']+))[\"']([^>]*?)\\/?>/gi\n code = code.replace(imgTagRegex, (_match, beforeSrc, _srcWithSlash, localPath, afterSrc) => {\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return _match\n\n // Extract alt from the existing attributes\n const altMatch = (beforeSrc + afterSrc).match(/alt=[\"']([^\"']*)[\"']/)\n const alt = altMatch ? altMatch[1] : ''\n\n // Collect other attributes (not src, alt, loading, decoding — we set those)\n const otherAttrs = (beforeSrc + afterSrc)\n .replace(/\\balt=[\"'][^\"']*[\"']/gi, '')\n .replace(/\\bloading=[\"'][^\"']*[\"']/gi, '')\n .replace(/\\bdecoding=[\"'][^\"']*[\"']/gi, '')\n .trim()\n\n const extraAttrs = otherAttrs ? ' ' + otherAttrs : ''\n\n // Extract custom sizes if specified\n const sizesMatch = (beforeSrc + afterSrc).match(/data-sizes=[\"']([^\"']*)[\"']/)\n const sizes = sizesMatch ? sizesMatch[1] : defaultSizes\n\n // SVGs and images without variants → simple URL swap <img>\n if (!entry.variants || entry.variants.length === 0) {\n return `<img src=\"${escapeHtml(entry.cdnUrl)}\" alt=\"${escapeHtml(alt)}\"${extraAttrs} loading=\"lazy\" decoding=\"async\" />`\n }\n\n // Raster with variants → <picture>\n return buildPictureElement(entry, alt, extraAttrs, sizes)\n })\n\n // ── Pass 2: Replace remaining string literal / CSS url() references ─────\n code = replaceImagePaths(code)\n\n return code\n }\n\n return {\n name: 'dcs-cdn-image',\n enforce: 'pre',\n\n configResolved(config) {\n isProduction = config.command === 'build'\n if (!isProduction) {\n if (debug) {\n console.log('[dcs-cdn-image] Dev mode — plugin disabled (local images served by Vite)')\n }\n return\n }\n imageMap = loadCdnImageMap(config.root, mapPath, debug)\n },\n\n transform(code, id) {\n // Only run in production builds\n if (!isProduction || !imageMap) return\n\n // Only process relevant file types\n if (!/\\.(vue|ts|tsx|js|jsx|css|scss|md|html)(\\?.*)?$/.test(id)) return\n\n // Quick bail — skip files with no image path references\n if (!hasImageReferences(code)) return\n\n const transformed = transformCode(code)\n if (transformed !== code) {\n return { code: transformed, map: null }\n }\n },\n\n /**\n * Replace image paths in final rendered JS/CSS chunks.\n *\n * This fires AFTER Vite's `define` substitution, catching paths that were\n * injected via `define` values (e.g. `__DCS_CONTENT__` set by\n * `dcsContentPlugin` from `.dcs/content.yaml`). Those paths bypass the\n * `transform` hook because `define` replacement happens at bundle time.\n */\n renderChunk(code, _chunk) {\n if (!isProduction || !imageMap) return null\n if (!hasImageReferences(code)) return null\n\n const replaced = replaceImagePaths(code)\n if (replaced !== code) {\n if (debug) {\n console.log(`[dcs-cdn-image] renderChunk: rewrote image paths in ${_chunk.fileName}`)\n }\n return { code: replaced, map: null }\n }\n return null\n },\n\n /**\n * Transform HTML output to catch references injected outside the module\n * pipeline — e.g. VitePress `head` config tags (favicons, OG images).\n *\n * Note: In VitePress, this hook fires for the `index.html` template but\n * NOT for SSR-rendered per-page HTML. Use `dcsCdnBuildEnd` for full\n * coverage of generated HTML files.\n */\n transformIndexHtml(html) {\n if (!isProduction || !imageMap) return html\n if (!hasImageReferences(html)) return html\n\n // Replace href/src/content attributes that reference mapped images\n for (const prefix of pathPrefixes) {\n const attrRegex = new RegExp(\n `((?:href|src|content)=[\"'])${escapeRegex(prefix)}([^\"']+)([\"'])`,\n 'gi'\n )\n html = html.replace(attrRegex, (match, pre, relPath, post) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return match\n return `${pre}${entry.cdnUrl}${post}`\n })\n }\n\n return html\n },\n }\n}\n\n/**\n * Escape a string for use in a RegExp.\n */\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n// ────────────────────────────────────────────────────────────────────────────\n// VitePress buildEnd hook\n// ────────────────────────────────────────────────────────────────────────────\n\nexport interface DcsCdnBuildEndOptions {\n /** Path to cdn-image-map.json relative to project root (default: '.dcs/cdn-image-map.json') */\n mapPath?: string\n\n /**\n * Patterns to match for replacement.\n * Default: `['/images/']`\n */\n pathPrefixes?: string[]\n\n /** Enable debug logging */\n debug?: boolean\n\n /**\n * File extensions to process in the output directory.\n * Default: `['.html', '.js']`\n */\n extensions?: string[]\n}\n\n/**\n * VitePress `buildEnd` hook factory that post-processes generated HTML and\n * static files in the output directory to replace remaining `/images/` paths\n * with CDN URLs.\n *\n * VitePress generates HTML **after** both Vite builds complete, so Vite\n * plugin hooks (`closeBundle`, `transformIndexHtml`) cannot catch\n * SSR-rendered `<head>` tags (favicons, OG images). This hook runs after all\n * HTML files are written to disk.\n *\n * Also rewrites static files (e.g. `service-worker.js`) copied from\n * `public/` that are not part of Vite's module pipeline.\n *\n * @example\n * ```ts\n * // .vitepress/config.ts\n * import { dcsCdnBuildEnd } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * buildEnd: dcsCdnBuildEnd({ debug: true })\n * })\n * ```\n */\nexport function dcsCdnBuildEnd(options: DcsCdnBuildEndOptions = {}) {\n const {\n mapPath = '.dcs/cdn-image-map.json',\n pathPrefixes = ['/images/'],\n debug = false,\n extensions = ['.html', '.js'],\n } = options\n\n return async (siteConfig: { root: string; outDir: string }) => {\n const imageMap = loadCdnImageMap(siteConfig.root, mapPath, debug)\n if (!imageMap) {\n if (debug) {\n console.log('[dcs-cdn-image] buildEnd: no image map found')\n }\n return\n }\n\n const outDir = siteConfig.outDir\n if (!fs.existsSync(outDir)) return\n\n let filesProcessed = 0\n let refsReplaced = 0\n\n function walkDir(dir: string) {\n const entries = fs.readdirSync(dir, { withFileTypes: true })\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n if (entry.isDirectory()) {\n walkDir(fullPath)\n } else if (extensions.some((ext) => entry.name.endsWith(ext))) {\n processFile(fullPath)\n }\n }\n }\n\n function processFile(filePath: string) {\n let content = fs.readFileSync(filePath, 'utf8')\n if (!pathPrefixes.some((p) => content.includes(p))) return\n\n let changed = false\n\n if (filePath.endsWith('.html')) {\n // HTML: replace href/src/content attribute values\n for (const prefix of pathPrefixes) {\n const attrRegex = new RegExp(\n `((?:href|src|content)=[\"'])${escapeRegex(prefix)}([^\"']+)([\"'])`,\n 'gi'\n )\n content = content.replace(attrRegex, (match, pre, relPath, post) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const mapEntry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!mapEntry) return match\n changed = true\n refsReplaced++\n return `${pre}${mapEntry.cdnUrl}${post}`\n })\n }\n } else {\n // JS/other: replace quoted string paths\n for (const prefix of pathPrefixes) {\n const regex = new RegExp(\n `([\"'\\`(])${escapeRegex(prefix)}([^\"'\\`()]+)`,\n 'g'\n )\n content = content.replace(regex, (match, quote, relPath) => {\n const localPath = prefix.replace(/^\\//, '') + relPath\n const entry = imageMap!.get(localPath) || imageMap!.get('/' + localPath)\n if (!entry) return match\n changed = true\n refsReplaced++\n return `${quote}${entry.cdnUrl}`\n })\n }\n }\n\n if (changed) {\n fs.writeFileSync(filePath, content, 'utf8')\n filesProcessed++\n }\n }\n\n walkDir(outDir)\n\n if (debug) {\n console.log(\n `[dcs-cdn-image] buildEnd: post-processed ${filesProcessed} files, replaced ${refsReplaced} references`\n )\n }\n }\n}","/**\n * markdown-it plugin that transforms standard `![alt](url)` image syntax\n * into responsive `<picture>` elements when the URL matches the DCS CDN\n * asset pattern.\n *\n * Non-CDN images are rendered with the default image renderer (plain `<img>`).\n *\n * @example\n * ```ts\n * // .vitepress/config.ts\n * import { responsiveImagePlugin } from '@duffcloudservices/cms/plugins'\n *\n * export default defineConfig({\n * markdown: {\n * config: (md) => {\n * md.use(responsiveImagePlugin)\n * },\n * },\n * })\n * ```\n *\n * Input markdown:\n * ```md\n * ![Physical therapy session](https://files.duffcloudservices.com/kept/assets/blog/abc-123.jpg)\n * ```\n *\n * Rendered HTML:\n * ```html\n * <picture>\n * <source srcset=\"...abc-123-sm.webp 640w, ...abc-123-md.webp 1024w, ...abc-123-lg.webp 1920w\"\n * type=\"image/webp\"\n * sizes=\"(max-width: 1024px) 100vw, 1024px\" />\n * <img src=\"...abc-123-md.webp\" alt=\"Physical therapy session\" loading=\"lazy\" decoding=\"async\" />\n * </picture>\n * ```\n */\n\nimport type MarkdownIt from 'markdown-it'\n\n/**\n * Matches DCS CDN asset URLs: base path / UUID . extension.\n *\n * Aligned with `@duffcloudservices/cms-core` `responsive-image.ts`: the\n * `(?:content\\/)?` group covers the content-container shape\n * `https://files.duffcloudservices.com/content/{slug}/assets/...` in addition\n * to the branding-container shape `.../{slug}/assets/...`. The group is\n * non-capturing, so the captured base path / UUID / extension are unchanged.\n */\nconst CDN_PATTERN = /^(https?:\\/\\/files\\.[^/]+\\/(?:content\\/)?[^/]+\\/assets\\/(?:[^/]+\\/)*)([a-f0-9-]+)\\.(\\w+)$/\n\n/**\n * Escapes HTML special characters for safe attribute embedding.\n * Falls back to a simple replace chain when `md.utils.escapeHtml` is unavailable.\n */\nfunction escapeHtml(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n}\n\nexport function responsiveImagePlugin(md: MarkdownIt): void {\n const defaultImageRenderer = md.renderer.rules.image\n\n md.renderer.rules.image = (tokens, idx, options, env, self) => {\n const token = tokens[idx]\n const src = token.attrGet('src') ?? ''\n const alt = token.content ?? ''\n\n const match = src.match(CDN_PATTERN)\n if (!match) {\n // Not a CDN image — render normally\n if (defaultImageRenderer) {\n return defaultImageRenderer(tokens, idx, options, env, self)\n }\n return self.renderToken(tokens, idx, options)\n }\n\n const [, basePath, uuid] = match\n\n const srcset = [\n `${basePath}${uuid}-sm.webp 640w`,\n `${basePath}${uuid}-md.webp 1024w`,\n `${basePath}${uuid}-lg.webp 1920w`,\n ].join(', ')\n\n const escapedAlt = escapeHtml(alt)\n\n // Self-heal: this plugin emits a STATIC HTML string at build time (no Vue\n // runtime), so the fallback must be an inline onerror. A fit-variant\n // (`-md`/`-lg`) may legitimately be absent (internal/imaging variants.go\n // skips variants by DIMENSION). On the first error, swap the `<img>` to the\n // ORIGINAL url AND strip the sibling `<source>` elements — a `<picture>`\n // does NOT re-resolve after a `<source>` 404s, so the variant set must be\n // removed for the original to display. (`this.onerror=null` prevents loops.)\n const escapedOriginal = escapeHtml(src)\n const onError =\n `this.onerror=null;this.src='${escapedOriginal}';` +\n `this.closest('picture')?.querySelectorAll('source').forEach(s=>s.remove())`\n\n return [\n '<picture>',\n ` <source srcset=\"${srcset}\" type=\"image/webp\" sizes=\"(max-width: 1024px) 100vw, 1024px\" />`,\n ` <img src=\"${basePath}${uuid}-md.webp\" alt=\"${escapedAlt}\" loading=\"lazy\" decoding=\"async\" onerror=\"${onError}\" />`,\n '</picture>',\n ].join('\\n')\n }\n}\n"]}