import type { App } from 'vue' import type { ModulePlugin } from '@/core/types' import { container, SERVICE_TOKENS } from '@/core/di-container' import { relayHub } from './nostr/relay-hub' // Import auth services import { auth } from './auth/auth-service' // Import PWA services import { pwaService } from './pwa/pwa-service' // Import core services import { paymentService } from '@/core/services/PaymentService' import { visibilityService } from '@/core/services/VisibilityService' import { storageService } from '@/core/services/StorageService' import { toastService } from '@/core/services/ToastService' /** * Base Module Plugin * Provides core infrastructure: Nostr, Auth, PWA, and UI components */ export const baseModule: ModulePlugin = { name: 'base', version: '1.0.0', async install(_app: App, options?: any) { console.log('🔧 Installing base module...') // Register core Nostr services container.provide(SERVICE_TOKENS.RELAY_HUB, relayHub) // Register auth service container.provide(SERVICE_TOKENS.AUTH_SERVICE, auth) // Register payment service container.provide(SERVICE_TOKENS.PAYMENT_SERVICE, paymentService) // Register visibility service container.provide(SERVICE_TOKENS.VISIBILITY_SERVICE, visibilityService) // Register storage service container.provide(SERVICE_TOKENS.STORAGE_SERVICE, storageService) // Register toast service container.provide(SERVICE_TOKENS.TOAST_SERVICE, toastService) // Register PWA service container.provide('pwaService', pwaService) // Initialize core services relayHub.setRelayUrls(options?.config?.nostr?.relays || []) await relayHub.initialize() await auth.initialize({ waitForDependencies: false, // Auth has no dependencies maxRetries: 1 }) await paymentService.initialize({ waitForDependencies: true, // PaymentService depends on AuthService maxRetries: 3 }) await visibilityService.initialize({ waitForDependencies: false, // VisibilityService has no dependencies maxRetries: 1 }) await storageService.initialize({ waitForDependencies: true, // StorageService depends on AuthService maxRetries: 3 }) await toastService.initialize({ waitForDependencies: false, // ToastService has no dependencies maxRetries: 1 }) console.log('✅ Base module installed successfully') }, async uninstall() { console.log('🗑️ Uninstalling base module...') // Cleanup services await relayHub.dispose() await auth.dispose() await paymentService.dispose() await visibilityService.dispose() await storageService.dispose() await toastService.dispose() console.log('✅ Base module uninstalled') }, services: { relayHub, auth, paymentService, visibilityService, storageService, toastService, pwaService }, // No routes - base module is pure infrastructure routes: [], // No UI components at module level - they'll be imported as needed components: {} } export default baseModule