/** * Core module - initializes htmx, extensions, and Alpine.js * * This module bundles all core libraries that are needed on every page: * - htmx for hypermedia-driven interactions * - htmx extensions (loading-states, sse) * - Alpine.js for declarative reactivity * * Heavy libraries (maps, cropper) are NOT loaded here - they are lazy-loaded * only when needed via the features modules. */ // Import Alpine.js import Alpine from 'alpinejs' // Import htmx import htmx from 'htmx.org' // Import auth utilities import { authFetch, authPostJson, refreshAuth, refreshSession } from './auth' // Import htmx extensions import { initAuthRefreshExtension } from './htmx-extensions/auth-refresh' import { initLoadingStatesExtension } from './htmx-extensions/loading-states' import { initSSEExtension } from './htmx-extensions/sse' // Import types import type { HtmxApi } from './types' // Expose htmx globally (required for some inline attributes) declare global { interface Window { htmx: HtmxApi Alpine: typeof Alpine } } // Cast and expose htmx globally const htmxApi = htmx as unknown as HtmxApi window.htmx = htmxApi // Initialize htmx extensions initAuthRefreshExtension(htmxApi) initLoadingStatesExtension(htmxApi) initSSEExtension(htmxApi) // Expose Alpine globally window.Alpine = Alpine // Start Alpine when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { Alpine.start() }) } else { Alpine.start() } export { htmxApi as htmx, Alpine, refreshSession, refreshAuth, authFetch, authPostJson }