// CRITICAL: must be first — patches LitElement before any component is loaded. import '@lit-labs/ssr-client/lit-element-hydrate-support.js'; // Client runtime: router outlet and link custom elements. import '@beatzball/litro/runtime/LitroOutlet.js'; import '@beatzball/litro/runtime/LitroLink.js'; // Progressive enhancement for action forms in light DOM. Components that // render forms inside shadow roots attach their own enhancer instead — see // pages/index.ts (submit events do not cross shadow-root boundaries). import { enhanceForms } from '@beatzball/litro/actions/form-client'; // Routes generated by the page scanner before each vite build. // routes.generated.ts lives at the project root (not in dist/) so Vite's // emptyOutDir does not delete it between builds. import { routes } from './routes.generated.js'; // Set routes synchronously. By the time this module-script executes (all // module scripts are deferred), the HTML is fully parsed and // is already in the DOM. Setting outlet.routes here — before Lit's first // update microtask fires — ensures firstUpdated() sees the real route table // rather than the empty default, so the router starts correctly. 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.'); } enhanceForms();