2026-03-21 02:04:11 +00:00
|
|
|
import Alpine from './vendor/alpinejs-3.15.8.js';
|
2026-03-21 15:08:37 +00:00
|
|
|
import bootstrap from '../static/vendor/bootstrap-5.3.8/bootstrap.bundle.min.js';
|
|
|
|
|
import { SSEManager } from './sse-manager';
|
2026-03-21 02:04:11 +00:00
|
|
|
|
2026-03-21 03:06:59 +00:00
|
|
|
// Make Alpine available on window for inline Alpine
|
|
|
|
|
window.Alpine = Alpine;
|
|
|
|
|
|
2026-03-21 05:47:39 +00:00
|
|
|
// Make bootstrap available on window for various scripts
|
|
|
|
|
window.bootstrap = bootstrap;
|
|
|
|
|
|
2026-03-21 15:08:37 +00:00
|
|
|
// Make SSEManager available to all the JavaScript
|
|
|
|
|
window.SSEManager = SSEManager;
|
|
|
|
|
|
2026-03-21 03:06:59 +00:00
|
|
|
// Wait for DOM to be ready, then initialize Alpine
|
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
|
Alpine.start();
|
2026-03-21 15:08:37 +00:00
|
|
|
SSEManager.connect("/api/events");
|
2026-03-21 03:06:59 +00:00
|
|
|
});
|
2026-03-21 02:04:11 +00:00
|
|
|
interface GreetingComponent {
|
|
|
|
|
message: string;
|
|
|
|
|
name: string;
|
|
|
|
|
updateMessage(): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Alpine.data('greeting', (): GreetingComponent => ({
|
|
|
|
|
message: 'Welcome to Alpine + TypeScript!',
|
|
|
|
|
name: 'World',
|
|
|
|
|
|
|
|
|
|
updateMessage() {
|
|
|
|
|
this.message = 'Message updated at ' + new Date().toLocaleTimeString();
|
|
|
|
|
}
|
|
|
|
|
}));
|