{ "version": 3, "sources": ["site/lib/routes.mjs"], "sourcesContent": ["/**\n * routes.mjs \u2014 shared route derivation for the docs site. The single\n * source of truth for how site/sitemap.json becomes navigable routes.\n *\n * Consumers: site/site.js (the router, browser), the build's route loader\n * and nav index, scripts/build/site-route-preload.mjs, and the Vite dev\n * server's nav index answer (vite.config.js).\n *\n * Browser-reachable module: NO `node:*` imports, pure functions only\n * (house rule \u2014 see AGENTS.md \"No top-level `import 'node:*'`\").\n */\n\n/**\n * Iterate the navigable route entries of a parsed sitemap.json object:\n * every sections[].items[] entry that is not a `divider` (dividers are\n * rail-organization markers \u2014 no path / content, not navigable routes).\n * Yields `{ item, section }` \u2014 the raw sitemap entry plus its owning\n * section \u2014 so each consumer can shape its own route object;\n * `routeFor(item, section)` builds the shared core shape.\n */\nexport function* iterRoutes(sitemap) {\n for (const section of sitemap.sections) {\n for (const item of section.items) {\n if (item.divider) continue;\n yield { item, section };\n }\n }\n}\n\n/** The route fields every consumer derives identically from a sitemap entry. */\nexport function routeFor(item, section) {\n return {\n path: item.path,\n content: item.content,\n section: section.label,\n template: item.template || null,\n setup: item.setup || null,\n text: item.text,\n // `padded` (gh#964) \u2014 opt-in variant of `template: \"standalone\"`: wrap\n // the isolated-doc iframe in
instead of\n // bare-full-bleed (ADR-0098 \u2014 site.js's templateResolver renders this\n // as , not the old\n // ). Only site/site.js's templateResolver reads it\n // today; carried through here so it survives sitemap.json \u2192 route the\n // same way every other per-route field does.\n padded: item.padded || false,\n // `sidecar` (gh#3084) \u2014 explicit `false` marks a module-tier/pattern-\n // only entry that, by design, ships no `.a2ui.json` sidecar (no\n // registered custom element, nothing for the yaml SoT \u2192 sidecar build\n // step to generate). Defaults to true (the common case: every real\n // primitive/module ships one). site.js's maybeInjectComposesManifest\n // skips the sidecar fetch entirely for `sidecar === false` routes\n // instead of fetching and eating the guaranteed 404.\n sidecar: item.sidecar !== false,\n };\n}\n\n/**\n * The paths site.js treats as the site entry, and the route they open\n * (ticket 11361: one list for site.js and the build's route loader,\n * scripts/build/site-route-preload.mjs, which keys these paths to the same\n * route's file).\n */\nexport const ENTRY_PATHS = Object.freeze(['/', '/site', '/site/', '/site/index.html',\n '/site-a2ui', '/site-a2ui/', '/site-a2ui/index.html']);\nexport const DEFAULT_ENTRY_ROUTE = '/site/examples/admin-dashboard';\n\n/**\n * Ticket 11361: what site.js holds for one sitemap entry: `route` (the router's\n * entry: the shared core of routeFor() plus the page title and meta), `item`\n * (the breadcrumb's entry) and `section` (what the nav sync reads of the\n * owning section; the items only for a `subnav` section, whose rail lists\n * them). site.js builds its tables from the sitemap with this, and the build\n * writes one per route into dist/site/route-preload/ so a first load can\n * render its route before the sitemap arrives.\n */\nexport function routeBootRecord(item, section) {\n const subnav = Boolean(section.subnav);\n return {\n route: { ...routeFor(item, section), title: `${item.text} - NonounUI`, meta: item.meta || null },\n item: { path: item.path, text: item.text, section: section.label, icon: section.icon },\n section: {\n label: section.label,\n icon: section.icon,\n subnav,\n ...(subnav ? { items: section.items.map((it) => (it.divider ? { divider: true, ...(it.text ? { text: it.text } : {}) } : { text: it.text, path: it.path })) } : {}),\n },\n };\n}\n\n/**\n * Ticket 11377: the nav index, the part of sitemap.json that site.js reads (the\n * nav, the command palette, the workspace and user selects, the version label\n * and the router's table), in the sitemap's own shape so iterRoutes() and\n * routeBootRecord() read it unchanged. The build writes it next to sitemap.json\n * (dist/site/nav-index.json, scripts/build/site-route-preload.mjs) and the Vite\n * dev server answers the same path from this function; it is never written by\n * hand. Allowlists, so a field added to the sitemap stays out until a browser\n * reader needs it. The full sitemap.json stays for every other reader.\n */\nexport const NAV_INDEX_FILE = 'nav-index.json';\nconst NAV_SECTION_KEYS = ['label', 'icon', 'category', 'subnav'];\nconst NAV_ITEM_KEYS = ['text', 'path', 'content', 'template', 'setup', 'padded', 'sidecar', 'divider', 'meta'];\nconst pick = (obj, keys) => Object.fromEntries(keys.filter((k) => obj[k] !== undefined).map((k) => [k, obj[k]]));\n\nexport function navIndexFor(sitemap) {\n return {\n brand: { version: sitemap.brand?.version },\n user: sitemap.user,\n workspaces: sitemap.workspaces,\n sections: sitemap.sections.map((section) => ({\n ...pick(section, NAV_SECTION_KEYS),\n items: section.items.map((item) => pick(item, NAV_ITEM_KEYS)),\n })),\n };\n}\n\n/**\n * Old route paths that answer with their renamed page (ticket 10112, plan\n * R7): in 0.9.0 the five genui catalog pages took their nonoun slugs,\n * /site/catalogs/nonoun-. The servers\n * redirect them with a 301 (deploy/Caddyfile and scripts/deploy/serve-dist.mjs,\n * both checked against this table by routes.test.js); site.js resolves them\n * for a first load that reaches the router under the old path (the Vite dev\n * server has no redirect). The allowlist entries for these paths name\n * 0.10.0 as the release that may drop them.\n *\n * Folded component pages answer the same way: chat-empty and chat-thread-ui\n * live as sections of the chat-thread page, chat-status of chat-header,\n * simple-content of simple-shell. Their old paths 301 to the parent page.\n *\n * Five elements that had a component page and a pattern page for the same\n * thing keep the pattern page: admin-shell, admin-sidebar, chat-shell,\n * editor-shell and layout. Their /site/components paths 301 to\n * /site/patterns/.\n */\nexport const ROUTE_ALIASES = Object.freeze({\n '/site/catalogs/adia-core': '/site/catalogs/nonoun-core',\n '/site/catalogs/adia-navigation': '/site/catalogs/nonoun-navigation',\n '/site/catalogs/adia-data': '/site/catalogs/nonoun-data',\n '/site/catalogs/adia-agent': '/site/catalogs/nonoun-agent',\n '/site/catalogs/adia-shells': '/site/catalogs/nonoun-shells',\n '/site/components/chat-empty': '/site/components/chat-thread',\n '/site/components/chat-status': '/site/components/chat-header',\n '/site/components/simple-content': '/site/components/simple-shell',\n '/site/components/chat-thread-ui': '/site/components/chat-thread',\n '/site/components/admin-shell': '/site/patterns/admin-shell',\n '/site/components/admin-sidebar': '/site/patterns/admin-sidebar',\n '/site/components/chat-shell': '/site/patterns/chat-shell',\n '/site/components/editor-shell': '/site/patterns/editor-shell',\n '/site/components/layout': '/site/patterns/layout',\n});\n\n/** The renamed path for an old route path, or null when `path` is not one. */\nexport function resolveRouteAlias(path) {\n return Object.h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