Implement modular architecture with core services and Nostr integration

- Introduce a modular application structure with a new app configuration file to manage module settings and features.
- Implement a dependency injection container for service management across modules.
- Create a plugin manager to handle module registration, installation, and lifecycle management.
- Develop a global event bus for inter-module communication, enhancing loose coupling between components.
- Add core modules including base functionalities, Nostr feed, and PWA services, with support for dynamic loading and configuration.
- Establish a Nostr client hub for managing WebSocket connections and event handling.
- Enhance user experience with a responsive Nostr feed component, integrating admin announcements and community posts.
- Refactor existing components to align with the new modular architecture, improving maintainability and scalability.
This commit is contained in:
padreug 2025-09-04 23:43:33 +02:00
parent 2d8215a35e
commit 519a9003d4
16 changed files with 2520 additions and 14 deletions

View file

@ -0,0 +1,45 @@
// PWA service for base module
export class PWAService {
private deferredPrompt: any = null
async initialize(): Promise<void> {
console.log('📱 Initializing PWA service...')
// Listen for beforeinstallprompt event
window.addEventListener('beforeinstallprompt', (e) => {
console.log('PWA install prompt available')
e.preventDefault()
this.deferredPrompt = e
})
// Listen for app installed event
window.addEventListener('appinstalled', () => {
console.log('PWA was installed')
this.deferredPrompt = null
})
}
canInstall(): boolean {
return this.deferredPrompt !== null
}
async install(): Promise<boolean> {
if (!this.deferredPrompt) {
return false
}
this.deferredPrompt.prompt()
const result = await this.deferredPrompt.userChoice
if (result.outcome === 'accepted') {
console.log('User accepted PWA install')
} else {
console.log('User dismissed PWA install')
}
this.deferredPrompt = null
return result.outcome === 'accepted'
}
}
export const pwaService = new PWAService()