/** * The real client entry. * * app.ts loads this file with a dynamic import so that Lit's hydration support * is installed before any Lit code is evaluated. New imports belong here, never * in app.ts — see the header of app.ts and BUILD-009. */ // Client runtime: router outlet and link custom elements. import '@beatzball/litro/runtime/LitroOutlet.js'; import '@beatzball/litro/runtime/LitroLink.js'; // Shoelace components (tree-shaken — only what the template uses) import '@shoelace-style/shoelace/dist/components/button/button.js'; import '@shoelace-style/shoelace/dist/components/icon/icon.js'; import '@shoelace-style/shoelace/dist/components/badge/badge.js'; import '@shoelace-style/shoelace/dist/components/copy-button/copy-button.js'; import '@shoelace-style/shoelace/dist/components/details/details.js'; import '@shoelace-style/shoelace/dist/components/tab-group/tab-group.js'; import '@shoelace-style/shoelace/dist/components/tab/tab.js'; import '@shoelace-style/shoelace/dist/components/tab-panel/tab-panel.js'; import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path.js'; // Point Shoelace's icon loader at the served assets directory setBasePath('/shoelace/'); // Routes generated by the page scanner before each vite build. import { routes } from './routes.generated.js'; // Hand the route table to the outlet as soon as the document has one. // // app.ts loads this module with a DYNAMIC import, which can resolve after // DOMContentLoaded has already fired — and a listener added after its event // never runs, so the router would never start. Check readyState first. const startRouter = () => { const outlet = document.querySelector('litro-outlet') as (Element & { routes: unknown }) | null; if (outlet) { outlet.routes = routes; } else { console.warn('[litro] not found — router will not start.'); } }; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', startRouter, { once: true }); } else { startRouter(); }