@ozdao/martyrs 0.2.431 → 0.2.433
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chats.server.js +19 -0
- package/dist/chats.server.mjs +19 -0
- package/dist/martyrs/src/components/Button/{Button.vue2.cjs → Button.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Button/{Button.vue2.js.map → Button.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/Button/{Button.vue2.js → Button.vue.js} +2 -2
- package/dist/martyrs/src/components/Button/Button.vue.js.map +1 -0
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs → Dropdown.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.js → Dropdown.vue2.js} +2 -2
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs.map → Dropdown.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/Feed/Feed.vue.cjs +1 -1
- package/dist/martyrs/src/components/Feed/Feed.vue.js +1 -1
- package/dist/martyrs/src/components/Menu/{Menu.vue.cjs → Menu.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Menu/{Menu.vue.js → Menu.vue2.js} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +1 -0
- package/dist/martyrs/src/components/SelectMulti/{SelectMulti.vue.cjs → SelectMulti.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/SelectMulti/SelectMulti.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/SelectMulti/{SelectMulti.vue.js → SelectMulti.vue2.js} +2 -2
- package/dist/martyrs/src/components/SelectMulti/{SelectMulti.vue.cjs.map → SelectMulti.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/Tab/{Tab.vue2.cjs → Tab.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Tab/{Tab.vue2.js.map → Tab.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/Tab/{Tab.vue2.js → Tab.vue.js} +2 -2
- package/dist/martyrs/src/components/Tab/Tab.vue.js.map +1 -0
- package/dist/martyrs/src/modules/auth/views/components/layouts/Auth.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/layouts/Auth.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +3 -3
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +3 -3
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileBlogposts.vue.cjs +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileBlogposts.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/components/sections/ProfileEditCredentials.vue.cjs +1 -1
- package/dist/martyrs/src/modules/auth/views/components/sections/ProfileEditCredentials.vue.js +1 -1
- package/dist/martyrs/src/modules/backoffice/components/partials/Sidebar.vue.cjs +1 -1
- package/dist/martyrs/src/modules/backoffice/components/partials/Sidebar.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
- package/dist/martyrs/src/modules/community/components/sections/HotPosts.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/sections/HotPosts.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonCheck.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonCheck.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonJoin.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/elements/ButtonJoin.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/EventsHot.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/EventsHot.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +2 -2
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +2 -2
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +2 -2
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +2 -2
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/NavigationBar.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/NavigationBar.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/sections/SectionPageTitle.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/sections/SectionPageTitle.vue.js +1 -1
- package/dist/martyrs/src/modules/landing/landing.client.cjs +0 -6
- package/dist/martyrs/src/modules/landing/landing.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/landing/landing.client.js +0 -6
- package/dist/martyrs/src/modules/landing/landing.client.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.cjs +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.js +1 -1
- package/dist/martyrs/src/modules/notifications/components/layouts/NotificationsLayout.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs +248 -135
- package/dist/martyrs/src/modules/notifications/notifications.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/notifications.client.js +248 -135
- package/dist/martyrs/src/modules/notifications/notifications.client.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +3 -3
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +3 -3
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormAddCustomer.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormAddCustomer.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/elements/ButtonToggleMembership.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/elements/ButtonToggleMembership.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/pages/Organizations.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +2 -2
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/partials/SidebarPages.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/partials/SidebarPages.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/CardPosition.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/CardPosition.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Leftovers.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Leftovers.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditProductInfo.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.js +2 -2
- package/dist/martyrs/src/modules/rents/views/components/pages/GanttChart.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/GanttChart.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Rents.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Rents.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
- package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/Map.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/Map.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.js +2 -2
- package/dist/style.css +4 -92
- package/package.json +1 -1
- package/src/modules/chats/routes/chats.routes.js +19 -19
- package/src/modules/landing/landing.client.js +6 -6
- package/src/modules/notifications/components/layouts/NotificationsLayout.vue +2 -0
- package/src/modules/notifications/notifications.client.js +351 -167
- package/src/modules/notifications/notifications2.client.js +256 -0
- package/dist/martyrs/src/components/Button/Button.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue.js.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue.cjs.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue.js.map +0 -1
- package/dist/martyrs/src/components/SelectMulti/SelectMulti.vue.js.map +0 -1
- package/dist/martyrs/src/components/Tab/Tab.vue2.cjs.map +0 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.cjs +0 -101
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.cjs.map +0 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.js +0 -101
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeaturesImages.vue.js.map +0 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.cjs +0 -85
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.cjs.map +0 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.js +0 -85
- package/dist/martyrs/src/modules/landing/components/sections/SectionHeroToken.vue.js.map +0 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.cjs +0 -97
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.cjs.map +0 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.js +0 -97
- package/dist/martyrs/src/modules/landing/components/sections/SectionRoadmap.vue.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.client.cjs","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { watch, toRefs } from \"vue\";\nimport routerNotifications from './router/notifications.router.js';\nimport * as storeNotifications from './store/notifications.store.js';\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport Notifications from './components/pages/Notifications.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\nimport NotificationItem from './components/blocks/NotificationItem.vue';\n\n// WebSocket notification handlers\nconst wsNotificationHandlers = {\n connect: (store, userId, options = {}) => {\n if (typeof window === 'undefined' || !userId) return Promise.resolve(false);\n \n return globalWebSocket.connect(userId).then(() => {\n const moduleName = 'notifications';\n const listeners = [];\n\n const addListener = (event, handler) => {\n listeners.push(globalWebSocket.addEventListener(event, handler, { module: moduleName }));\n };\n\n addListener('notification', (data) => {\n if (!data || !data.data) return;\n const notification = data.data;\n \n store.notifications.actions.addLocalNotification({\n _id: notification._id,\n title: notification.title,\n body: notification.body,\n type: notification.type || 'info',\n metadata: notification.metadata || {},\n status: 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString()\n });\n });\n\n addListener('notification_read', (data) => {\n store.notifications.actions.syncNotificationStatus(data.notificationId, 'read');\n });\n\n return { listeners, moduleName };\n });\n },\n\n disconnect: (moduleName, listeners) => {\n if (listeners) {\n globalWebSocket.removeModuleListeners(moduleName);\n }\n }\n};\n\n// Capacitor Push Notification handlers\nconst pushNotificationHandlers = {\n initialize: async () => {\n if (typeof window === 'undefined') return false;\n\n try {\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n if (!Capacitor.isNativePlatform()) return false;\n\n return { pushNotifications: PushNotifications, device: Device };\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n },\n\n requestPermissions: async (store) => {\n if (typeof window === 'undefined') return false;\n\n const plugins = await pushNotificationHandlers.initialize();\n if (!plugins) return false;\n\n const { pushNotifications, device } = plugins;\n\n const permissionResult = await pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n const setupListeners = () => {\n pushNotifications.addListener('registration', async (token) => {\n try {\n const deviceInfo = await device.getInfo();\n const deviceId = await device.getId();\n\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value\n };\n\n await store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n });\n\n pushNotifications.addListener('pushNotificationReceived', (notification) => {\n store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {}\n });\n });\n\n pushNotifications.addListener('pushNotificationActionPerformed', (actionData) => {\n if (actionData.notification && actionData.notification.data) {\n store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n });\n };\n\n setupListeners();\n await pushNotifications.register();\n return true;\n },\n\n removeListeners: (pushNotifications) => {\n if (typeof window === 'undefined' || !pushNotifications) return;\n pushNotifications.removeAllListeners();\n }\n};\n\n// Notification utilities\nconst notificationUtils = {\n initialize: async (store, options = {}) => {\n if (typeof window === 'undefined') return;\n\n const userId = store.auth.state.user?._id;\n if (!userId) {\n console.warn('Cannot initialize notifications: No user ID found in auth store');\n return;\n }\n\n let wsListeners = null;\n if (options.enablePush !== false) {\n await pushNotificationHandlers.requestPermissions(store);\n }\n\n wsListeners = await wsNotificationHandlers.connect(store, userId, options);\n\n await store.notifications.actions.getNotifications(userId);\n\n return {\n disconnect: () => {\n wsNotificationHandlers.disconnect(wsListeners?.moduleName, wsListeners?.listeners);\n pushNotificationHandlers.removeListeners(globalThis.pushNotifications);\n }\n };\n },\n\n prefetchForSSR: async (store, context) => {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n }\n};\n\n// Main initialization function\nconst initializeNotifications = (app, store, router, options = {}) => {\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: options.wsUrl });\n }\n\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n let notificationManager = null;\n\n if (autoInit) {\n const initNotifications = async () => {\n if (store.auth.state.isAuthenticated && store.auth.state.user?._id) {\n notificationManager = await notificationUtils.initialize(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000\n });\n }\n };\n\n watch(() => store.auth.state.isAuthenticated, (isAuthenticated) => {\n if (isAuthenticated) {\n initNotifications();\n } else if (notificationManager) {\n notificationManager.disconnect();\n store.notifications.mutations.resetNotifications();\n notificationManager = null;\n }\n });\n\n if (store.auth.state.isAuthenticated) {\n initNotifications();\n }\n }\n\n app.provide('useNotifications', () => ({\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: () => notificationUtils.initialize(store, options),\n disconnect: () => notificationManager?.disconnect(),\n isServer\n }));\n\n return {\n SSR: { prefetchNotifications: notificationUtils.prefetchForSSR }\n };\n};\n\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n views: {\n store: { storeNotifications },\n router: { routerNotifications },\n components: {\n NotificationBadge,\n NotificationItem,\n NotificationsList,\n NotificationPreferences,\n Notifications,\n NotificationsLayout\n }\n }\n};\n\nexport {\n NotificationBadge,\n NotificationItem,\n NotificationsList,\n NotificationPreferences,\n Notifications,\n NotificationsLayout,\n notificationUtils as SSRUtils\n};\n\nexport default ModuleNotifications;"],"names":["globalWebSocket","routerNotifications","storeNotifications","watch","toRefs","NotificationBadge","NotificationItem","NotificationsList","NotificationPreferences","Notifications","NotificationsLayout"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,yBAAyB;AAAA,EAC7B,SAAS,CAAC,OAAO,QAAQ,UAAU,CAAA,MAAO;AACxC,QAAI,OAAO,WAAW,eAAe,CAAC,OAAQ,QAAO,Q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,eAAc;AAAA,EAC/D;AACH;AAEK,MAAC,sBAAsB;AAAA,EAC1B,YAAY;AAAA,EACZ,OAAO;AAAA,IACL,OAAO,EAAEF,oBAAAA,oBAAoB;AAAA,IAC7B,QAAQ,EAAED,qBAAAA,qBAAAA,QAAqB;AAAA,IAC/B,YAAY;AAAA,MAChB,mBAAMI,kBAAiB;AAAA,MACvB,kBAAMC,iBAAgB;AAAA,MACtB,mBAAMC,kBAAiB;AAAA,MACvB,yBAAMC,wBAAuB;AAAA,MAC7B,eAAMC,cAAa;AAAA,MACbC,qBAAAA,oBAAAA;AAAAA,IACN;AAAA,EACA;AACA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"notifications.client.cjs","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { watch, toRefs } from \"vue\";\n// Router import \nimport routerNotifications from './router/notifications.router.js'; \n// Store \nimport * as storeNotifications from './store/notifications.store.js'; \n// Auth store import\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Layouts \nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue'; \n// Sections \nimport NotificationsList from './components/sections/NotificationsList.vue'; \nimport NotificationPreferences from './components/sections/NotificationPreferences.vue'; \n// Pages \nimport Notifications from './components/pages/Notifications.vue'; \n// Components \nimport NotificationBadge from './components/elements/NotificationBadge.vue'; \nimport NotificationItem from './components/blocks/NotificationItem.vue'; \n\n/**\n * WebSocket notification handler that uses the global WebSocket connection\n */\nclass WebSocketNotificationHandler {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.moduleName = 'notifications';\n this.listeners = [];\n }\n\n /**\n * Connect to notifications channel\n */\n connect(userId) {\n // Skip if running in SSR\n if (typeof window === 'undefined' || !userId) {\n return Promise.resolve(false);\n }\n\n // First ensure the global WebSocket is connected\n return globalWebSocket.connect(userId).then(() => {\n // Register event listeners\n this._registerListeners();\n return true;\n });\n }\n\n /**\n * Disconnect notification listeners\n */\n disconnect() {\n globalWebSocket.removeModuleListeners(this.moduleName);\n }\n\n /**\n * Register notification event listeners\n */\n _registerListeners() {\n // Listen for notification events\n this.listeners.push(\n globalWebSocket.addEventListener('notification', this._processNotification.bind(this), {\n module: this.moduleName\n })\n );\n \n // Listen for notification read status changes\n this.listeners.push(\n globalWebSocket.addEventListener('notification_read', (data) => {\n this.store.notifications.actions.syncNotificationStatus(data.notificationId, 'read');\n }, { module: this.moduleName })\n );\n }\n\n /**\n * Process incoming notification\n */\n _processNotification(data) {\n if (!data || !data.data) return;\n \n const notification = data.data;\n \n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n _id: notification._id,\n title: notification.title,\n body: notification.body,\n type: notification.type || 'info',\n metadata: notification.metadata || {},\n status: 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString()\n });\n }\n}\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n \n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n \n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n \n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n \n // Set up event listeners\n this._setupListeners();\n \n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', \n this._handleRegistration.bind(this)\n );\n \n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived',\n this._handleNotificationReceived.bind(this)\n );\n \n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed',\n this._handleNotificationAction.bind(this)\n );\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n \n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value\n };\n \n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {}\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(\n actionData.notification.data\n );\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n \n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.wsHandler = new WebSocketNotificationHandler(store, options);\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n /**\n * Initialize notifications\n */\n async initialize() {\n if (this.initialized || this.isServer) return;\n \n // Get current user ID from auth store instead of localStorage\n const userId = this.store.auth.state.user?._id;\n if (!userId) {\n console.warn('Cannot initialize notifications: No user ID found in auth store');\n return;\n }\n \n // Initialize WebSocket for realtime notifications\n await this.wsHandler.connect(userId);\n \n // Initialize push notifications for mobile if enabled\n if (this.options.enablePush !== false) {\n await this.pushHandler.requestPermissions();\n }\n \n this.initialized = true;\n \n // Fetch existing notifications\n await this.store.notifications.actions.getNotifications(userId);\n }\n\n /**\n * Disconnect and clean up\n */\n disconnect() {\n if (this.isServer) return;\n \n this.wsHandler.disconnect();\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n }\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n \n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: options.wsUrl });\n }\n \n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000\n });\n \n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n \n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n \n if (autoInit) {\n // Initialize after auth is confirmed\n const isAuthenticated = store.auth.state.isAuthenticated;\n const userId = store.auth.state.user?._id;\n \n if (isAuthenticated && userId) {\n notificationManager.initialize();\n }\n \n // Watch for user login/logout using auth store\n watch(() => store.auth.state.isAuthenticated, (isAuthenticated) => {\n if (isAuthenticated) {\n notificationManager.initialize();\n } else {\n notificationManager.disconnect();\n store.notifications.mutations.resetNotifications();\n }\n });\n }\n \n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer\n };\n });\n \n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout\n }\n }\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // SSR Utilities\n SSRUtils\n};\n\nexport default ModuleNotifications;\n"],"names":["globalWebSocket","routerNotifications","storeNotifications","watch","isAuthenticated","toRefs","NotificationBadge","NotificationItem","NotificationsList","NotificationPreferences","Notifications","NotificationsLayout"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,6BAA6B;AAAA,EACjC,YAAY,OAAO,UAAU,IAAI;AAC/B,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,YAAY,CAAE;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EA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ACD,QAAQ;AAAA,MACND,qBAAAA,qBAAAA;AAAAA,IACD;AAAA,IACD,YAAY;AAAA;AAAA,MAEhB,mBAAMK,kBAAiB;AAAA;AAAA,MAEvB,kBAAMC,iBAAgB;AAAA;AAAA,MAEtB,mBAAMC,kBAAiB;AAAA,MACvB,yBAAMC,wBAAuB;AAAA;AAAA,MAE7B,eAAMC,cAAa;AAAA;AAAA,MAEbC,qBAAAA,oBAAAA;AAAAA,IACN;AAAA,EACA;AACA;;;;;;;;;"}
|
|
@@ -9,125 +9,230 @@ import NotificationPreferences from "./components/sections/NotificationPreferenc
|
|
|
9
9
|
import Notifications from "./components/pages/Notifications.vue.js";
|
|
10
10
|
import NotificationBadge from "./components/elements/NotificationBadge.vue.js";
|
|
11
11
|
import NotificationItem from "./components/blocks/NotificationItem.vue.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
class WebSocketNotificationHandler {
|
|
13
|
+
constructor(store, options = {}) {
|
|
14
|
+
this.store = store;
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.moduleName = "notifications";
|
|
17
|
+
this.listeners = [];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Connect to notifications channel
|
|
21
|
+
*/
|
|
22
|
+
connect(userId) {
|
|
23
|
+
if (typeof window === "undefined" || !userId) {
|
|
24
|
+
return Promise.resolve(false);
|
|
25
|
+
}
|
|
15
26
|
return globalWebSocket.connect(userId).then(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const addListener = (event, handler) => {
|
|
19
|
-
listeners.push(globalWebSocket.addEventListener(event, handler, { module: moduleName }));
|
|
20
|
-
};
|
|
21
|
-
addListener("notification", (data) => {
|
|
22
|
-
if (!data || !data.data) return;
|
|
23
|
-
const notification = data.data;
|
|
24
|
-
store.notifications.actions.addLocalNotification({
|
|
25
|
-
_id: notification._id,
|
|
26
|
-
title: notification.title,
|
|
27
|
-
body: notification.body,
|
|
28
|
-
type: notification.type || "info",
|
|
29
|
-
metadata: notification.metadata || {},
|
|
30
|
-
status: "unread",
|
|
31
|
-
createdAt: notification.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
32
|
-
updatedAt: notification.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
addListener("notification_read", (data) => {
|
|
36
|
-
store.notifications.actions.syncNotificationStatus(data.notificationId, "read");
|
|
37
|
-
});
|
|
38
|
-
return { listeners, moduleName };
|
|
27
|
+
this._registerListeners();
|
|
28
|
+
return true;
|
|
39
29
|
});
|
|
40
|
-
},
|
|
41
|
-
disconnect: (moduleName, listeners) => {
|
|
42
|
-
if (listeners) {
|
|
43
|
-
globalWebSocket.removeModuleListeners(moduleName);
|
|
44
|
-
}
|
|
45
30
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Disconnect notification listeners
|
|
33
|
+
*/
|
|
34
|
+
disconnect() {
|
|
35
|
+
globalWebSocket.removeModuleListeners(this.moduleName);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Register notification event listeners
|
|
39
|
+
*/
|
|
40
|
+
_registerListeners() {
|
|
41
|
+
this.listeners.push(
|
|
42
|
+
globalWebSocket.addEventListener("notification", this._processNotification.bind(this), {
|
|
43
|
+
module: this.moduleName
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
this.listeners.push(
|
|
47
|
+
globalWebSocket.addEventListener("notification_read", (data) => {
|
|
48
|
+
this.store.notifications.actions.syncNotificationStatus(data.notificationId, "read");
|
|
49
|
+
}, { module: this.moduleName })
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Process incoming notification
|
|
54
|
+
*/
|
|
55
|
+
_processNotification(data) {
|
|
56
|
+
if (!data || !data.data) return;
|
|
57
|
+
const notification = data.data;
|
|
58
|
+
this.store.notifications.actions.addLocalNotification({
|
|
59
|
+
_id: notification._id,
|
|
60
|
+
title: notification.title,
|
|
61
|
+
body: notification.body,
|
|
62
|
+
type: notification.type || "info",
|
|
63
|
+
metadata: notification.metadata || {},
|
|
64
|
+
status: "unread",
|
|
65
|
+
createdAt: notification.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
66
|
+
updatedAt: notification.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class CapacitorPushHandler {
|
|
71
|
+
constructor(store) {
|
|
72
|
+
this.store = store;
|
|
73
|
+
this.pushNotifications = null;
|
|
74
|
+
this.device = null;
|
|
75
|
+
this.isInitialized = false;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Initialize Capacitor plugins
|
|
79
|
+
*/
|
|
80
|
+
async initialize() {
|
|
81
|
+
if (typeof window === "undefined") {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
50
84
|
try {
|
|
51
85
|
const { Capacitor } = await import("../../../node_modules/@capacitor/core/dist/index.js");
|
|
52
86
|
const { PushNotifications } = await import("../../../../node_modules/@capacitor/push-notifications/dist/esm/index.js");
|
|
53
87
|
const { Device } = await import("../../../../node_modules/@capacitor/device/dist/esm/index.js");
|
|
54
|
-
|
|
55
|
-
|
|
88
|
+
this.capacitor = Capacitor;
|
|
89
|
+
this.pushNotifications = PushNotifications;
|
|
90
|
+
this.device = Device;
|
|
91
|
+
if (!this.capacitor.isNativePlatform()) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
this.isInitialized = true;
|
|
95
|
+
return true;
|
|
56
96
|
} catch (error) {
|
|
57
97
|
console.error("Error importing Capacitor plugins:", error);
|
|
58
98
|
return false;
|
|
59
99
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Request permission and register for push notifications
|
|
103
|
+
*/
|
|
104
|
+
async requestPermissions() {
|
|
105
|
+
if (typeof window === "undefined") {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (!this.isInitialized) {
|
|
109
|
+
const initialized = await this.initialize();
|
|
110
|
+
if (!initialized) return false;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const permissionResult = await this.pushNotifications.requestPermissions();
|
|
114
|
+
if (permissionResult.receive !== "granted") {
|
|
115
|
+
console.log("Push notification permission denied");
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
this._setupListeners();
|
|
119
|
+
await this.pushNotifications.register();
|
|
120
|
+
return true;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error("Error requesting push notification permissions:", error);
|
|
69
123
|
return false;
|
|
70
124
|
}
|
|
71
|
-
const setupListeners = () => {
|
|
72
|
-
pushNotifications.addListener("registration", async (token) => {
|
|
73
|
-
try {
|
|
74
|
-
const deviceInfo = await device.getInfo();
|
|
75
|
-
const deviceId = await device.getId();
|
|
76
|
-
const deviceData = {
|
|
77
|
-
deviceId: deviceId.uuid,
|
|
78
|
-
deviceType: deviceInfo.platform.toLowerCase(),
|
|
79
|
-
deviceToken: token.value
|
|
80
|
-
};
|
|
81
|
-
await store.notifications.actions.registerDevice(deviceData);
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error("Error handling push registration:", error);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
pushNotifications.addListener("pushNotificationReceived", (notification) => {
|
|
87
|
-
store.notifications.actions.addLocalNotification({
|
|
88
|
-
title: notification.title,
|
|
89
|
-
body: notification.body,
|
|
90
|
-
data: notification.data || {}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
pushNotifications.addListener("pushNotificationActionPerformed", (actionData) => {
|
|
94
|
-
if (actionData.notification && actionData.notification.data) {
|
|
95
|
-
store.notifications.actions.handleNotificationAction(actionData.notification.data);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
setupListeners();
|
|
100
|
-
await pushNotifications.register();
|
|
101
|
-
return true;
|
|
102
|
-
},
|
|
103
|
-
removeListeners: (pushNotifications) => {
|
|
104
|
-
if (typeof window === "undefined" || !pushNotifications) return;
|
|
105
|
-
pushNotifications.removeAllListeners();
|
|
106
125
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Setup push notification event listeners
|
|
128
|
+
*/
|
|
129
|
+
_setupListeners() {
|
|
130
|
+
this.pushNotifications.addListener(
|
|
131
|
+
"registration",
|
|
132
|
+
this._handleRegistration.bind(this)
|
|
133
|
+
);
|
|
134
|
+
this.pushNotifications.addListener(
|
|
135
|
+
"pushNotificationReceived",
|
|
136
|
+
this._handleNotificationReceived.bind(this)
|
|
137
|
+
);
|
|
138
|
+
this.pushNotifications.addListener(
|
|
139
|
+
"pushNotificationActionPerformed",
|
|
140
|
+
this._handleNotificationAction.bind(this)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Handle registration token received
|
|
145
|
+
*/
|
|
146
|
+
async _handleRegistration(token) {
|
|
147
|
+
try {
|
|
148
|
+
const deviceInfo = await this.device.getInfo();
|
|
149
|
+
const deviceId = await this.device.getId();
|
|
150
|
+
const deviceData = {
|
|
151
|
+
deviceId: deviceId.uuid,
|
|
152
|
+
deviceType: deviceInfo.platform.toLowerCase(),
|
|
153
|
+
deviceToken: token.value
|
|
154
|
+
};
|
|
155
|
+
await this.store.notifications.actions.registerDevice(deviceData);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error("Error handling push registration:", error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Handle received notification
|
|
162
|
+
*/
|
|
163
|
+
_handleNotificationReceived(notification) {
|
|
164
|
+
this.store.notifications.actions.addLocalNotification({
|
|
165
|
+
title: notification.title,
|
|
166
|
+
body: notification.body,
|
|
167
|
+
data: notification.data || {}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Handle notification action (when user taps on notification)
|
|
172
|
+
*/
|
|
173
|
+
_handleNotificationAction(actionData) {
|
|
174
|
+
if (actionData.notification && actionData.notification.data) {
|
|
175
|
+
this.store.notifications.actions.handleNotificationAction(
|
|
176
|
+
actionData.notification.data
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Remove push notification listeners
|
|
182
|
+
*/
|
|
183
|
+
removeListeners() {
|
|
184
|
+
if (typeof window === "undefined") {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (this.pushNotifications) {
|
|
188
|
+
this.pushNotifications.removeAllListeners();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
class NotificationManager {
|
|
193
|
+
constructor(store, options = {}) {
|
|
194
|
+
this.store = store;
|
|
195
|
+
this.options = options;
|
|
196
|
+
this.wsHandler = new WebSocketNotificationHandler(store, options);
|
|
197
|
+
this.pushHandler = new CapacitorPushHandler(store);
|
|
198
|
+
this.initialized = false;
|
|
199
|
+
this.isServer = typeof window === "undefined";
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Initialize notifications
|
|
203
|
+
*/
|
|
204
|
+
async initialize() {
|
|
110
205
|
var _a;
|
|
111
|
-
if (
|
|
112
|
-
const userId = (_a = store.auth.state.user) == null ? void 0 : _a._id;
|
|
206
|
+
if (this.initialized || this.isServer) return;
|
|
207
|
+
const userId = (_a = this.store.auth.state.user) == null ? void 0 : _a._id;
|
|
113
208
|
if (!userId) {
|
|
114
209
|
console.warn("Cannot initialize notifications: No user ID found in auth store");
|
|
115
210
|
return;
|
|
116
211
|
}
|
|
117
|
-
|
|
118
|
-
if (options.enablePush !== false) {
|
|
119
|
-
await
|
|
212
|
+
await this.wsHandler.connect(userId);
|
|
213
|
+
if (this.options.enablePush !== false) {
|
|
214
|
+
await this.pushHandler.requestPermissions();
|
|
120
215
|
}
|
|
121
|
-
|
|
122
|
-
await store.notifications.actions.getNotifications(userId);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
216
|
+
this.initialized = true;
|
|
217
|
+
await this.store.notifications.actions.getNotifications(userId);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Disconnect and clean up
|
|
221
|
+
*/
|
|
222
|
+
disconnect() {
|
|
223
|
+
if (this.isServer) return;
|
|
224
|
+
this.wsHandler.disconnect();
|
|
225
|
+
this.pushHandler.removeListeners();
|
|
226
|
+
this.initialized = false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const SSRUtils = {
|
|
230
|
+
/**
|
|
231
|
+
* Pre-fetch notifications for SSR
|
|
232
|
+
* @param {Object} store - Store instance
|
|
233
|
+
* @param {Object} context - SSR context
|
|
234
|
+
*/
|
|
235
|
+
async prefetchNotifications(store, context) {
|
|
131
236
|
var _a;
|
|
132
237
|
try {
|
|
133
238
|
const userId = (_a = store.auth.state.user) == null ? void 0 : _a._id;
|
|
@@ -139,64 +244,72 @@ const notificationUtils = {
|
|
|
139
244
|
}
|
|
140
245
|
}
|
|
141
246
|
};
|
|
142
|
-
|
|
247
|
+
function initializeNotifications(app, store, router, options = {}) {
|
|
248
|
+
var _a;
|
|
143
249
|
const route = options.route || "User Profile Root";
|
|
144
250
|
router.addRoute(route, nofitications);
|
|
145
251
|
store.addStore("notifications", notifications_store);
|
|
146
252
|
if (options.wsUrl) {
|
|
147
253
|
globalWebSocket.initialize({ wsUrl: options.wsUrl });
|
|
148
254
|
}
|
|
255
|
+
const notificationManager = new NotificationManager(store, {
|
|
256
|
+
enablePush: options.enablePush !== false,
|
|
257
|
+
maxReconnectAttempts: options.maxReconnectAttempts || 5,
|
|
258
|
+
reconnectDelay: options.reconnectDelay || 3e3,
|
|
259
|
+
pingInterval: options.pingInterval || 3e4
|
|
260
|
+
});
|
|
261
|
+
store.notificationManager = notificationManager;
|
|
149
262
|
const isServer = typeof window === "undefined";
|
|
150
263
|
const autoInit = !isServer && options.autoInit !== false;
|
|
151
|
-
let notificationManager = null;
|
|
152
264
|
if (autoInit) {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
watch(() => store.auth.state.isAuthenticated, (isAuthenticated) => {
|
|
165
|
-
if (isAuthenticated) {
|
|
166
|
-
initNotifications();
|
|
167
|
-
} else if (notificationManager) {
|
|
265
|
+
const isAuthenticated = store.auth.state.isAuthenticated;
|
|
266
|
+
const userId = (_a = store.auth.state.user) == null ? void 0 : _a._id;
|
|
267
|
+
if (isAuthenticated && userId) {
|
|
268
|
+
notificationManager.initialize();
|
|
269
|
+
}
|
|
270
|
+
watch(() => store.auth.state.isAuthenticated, (isAuthenticated2) => {
|
|
271
|
+
if (isAuthenticated2) {
|
|
272
|
+
notificationManager.initialize();
|
|
273
|
+
} else {
|
|
168
274
|
notificationManager.disconnect();
|
|
169
275
|
store.notifications.mutations.resetNotifications();
|
|
170
|
-
notificationManager = null;
|
|
171
276
|
}
|
|
172
277
|
});
|
|
173
|
-
if (store.auth.state.isAuthenticated) {
|
|
174
|
-
initNotifications();
|
|
175
|
-
}
|
|
176
278
|
}
|
|
177
|
-
app.provide("useNotifications", () =>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
279
|
+
app.provide("useNotifications", () => {
|
|
280
|
+
return {
|
|
281
|
+
...toRefs(store.notifications.state),
|
|
282
|
+
...store.notifications.actions,
|
|
283
|
+
...store.notifications.mutations,
|
|
284
|
+
init: notificationManager.initialize.bind(notificationManager),
|
|
285
|
+
disconnect: notificationManager.disconnect.bind(notificationManager),
|
|
286
|
+
isServer
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
return notificationManager;
|
|
290
|
+
}
|
|
189
291
|
const ModuleNotifications = {
|
|
190
292
|
initialize: initializeNotifications,
|
|
293
|
+
SSR: SSRUtils,
|
|
294
|
+
// Export SSR utilities
|
|
191
295
|
views: {
|
|
192
|
-
store: {
|
|
193
|
-
|
|
296
|
+
store: {
|
|
297
|
+
storeNotifications: notifications_store
|
|
298
|
+
},
|
|
299
|
+
router: {
|
|
300
|
+
routerNotifications: nofitications
|
|
301
|
+
},
|
|
194
302
|
components: {
|
|
303
|
+
// Elements
|
|
195
304
|
NotificationBadge,
|
|
305
|
+
// Blocks
|
|
196
306
|
NotificationItem,
|
|
307
|
+
// Sections
|
|
197
308
|
NotificationsList,
|
|
198
309
|
NotificationPreferences,
|
|
310
|
+
// Pages
|
|
199
311
|
Notifications,
|
|
312
|
+
// Layouts
|
|
200
313
|
NotificationsLayout
|
|
201
314
|
}
|
|
202
315
|
}
|
|
@@ -208,7 +321,7 @@ export {
|
|
|
208
321
|
Notifications,
|
|
209
322
|
NotificationsLayout,
|
|
210
323
|
NotificationsList,
|
|
211
|
-
|
|
324
|
+
SSRUtils,
|
|
212
325
|
ModuleNotifications as default
|
|
213
326
|
};
|
|
214
327
|
//# sourceMappingURL=notifications.client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.client.js","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { watch, toRefs } from \"vue\";\nimport routerNotifications from './router/notifications.router.js';\nimport * as storeNotifications from './store/notifications.store.js';\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue';\nimport NotificationsList from './components/sections/NotificationsList.vue';\nimport NotificationPreferences from './components/sections/NotificationPreferences.vue';\nimport Notifications from './components/pages/Notifications.vue';\nimport NotificationBadge from './components/elements/NotificationBadge.vue';\nimport NotificationItem from './components/blocks/NotificationItem.vue';\n\n// WebSocket notification handlers\nconst wsNotificationHandlers = {\n connect: (store, userId, options = {}) => {\n if (typeof window === 'undefined' || !userId) return Promise.resolve(false);\n \n return globalWebSocket.connect(userId).then(() => {\n const moduleName = 'notifications';\n const listeners = [];\n\n const addListener = (event, handler) => {\n listeners.push(globalWebSocket.addEventListener(event, handler, { module: moduleName }));\n };\n\n addListener('notification', (data) => {\n if (!data || !data.data) return;\n const notification = data.data;\n \n store.notifications.actions.addLocalNotification({\n _id: notification._id,\n title: notification.title,\n body: notification.body,\n type: notification.type || 'info',\n metadata: notification.metadata || {},\n status: 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString()\n });\n });\n\n addListener('notification_read', (data) => {\n store.notifications.actions.syncNotificationStatus(data.notificationId, 'read');\n });\n\n return { listeners, moduleName };\n });\n },\n\n disconnect: (moduleName, listeners) => {\n if (listeners) {\n globalWebSocket.removeModuleListeners(moduleName);\n }\n }\n};\n\n// Capacitor Push Notification handlers\nconst pushNotificationHandlers = {\n initialize: async () => {\n if (typeof window === 'undefined') return false;\n\n try {\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n\n if (!Capacitor.isNativePlatform()) return false;\n\n return { pushNotifications: PushNotifications, device: Device };\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n },\n\n requestPermissions: async (store) => {\n if (typeof window === 'undefined') return false;\n\n const plugins = await pushNotificationHandlers.initialize();\n if (!plugins) return false;\n\n const { pushNotifications, device } = plugins;\n\n const permissionResult = await pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n\n const setupListeners = () => {\n pushNotifications.addListener('registration', async (token) => {\n try {\n const deviceInfo = await device.getInfo();\n const deviceId = await device.getId();\n\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value\n };\n\n await store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n });\n\n pushNotifications.addListener('pushNotificationReceived', (notification) => {\n store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {}\n });\n });\n\n pushNotifications.addListener('pushNotificationActionPerformed', (actionData) => {\n if (actionData.notification && actionData.notification.data) {\n store.notifications.actions.handleNotificationAction(actionData.notification.data);\n }\n });\n };\n\n setupListeners();\n await pushNotifications.register();\n return true;\n },\n\n removeListeners: (pushNotifications) => {\n if (typeof window === 'undefined' || !pushNotifications) return;\n pushNotifications.removeAllListeners();\n }\n};\n\n// Notification utilities\nconst notificationUtils = {\n initialize: async (store, options = {}) => {\n if (typeof window === 'undefined') return;\n\n const userId = store.auth.state.user?._id;\n if (!userId) {\n console.warn('Cannot initialize notifications: No user ID found in auth store');\n return;\n }\n\n let wsListeners = null;\n if (options.enablePush !== false) {\n await pushNotificationHandlers.requestPermissions(store);\n }\n\n wsListeners = await wsNotificationHandlers.connect(store, userId, options);\n\n await store.notifications.actions.getNotifications(userId);\n\n return {\n disconnect: () => {\n wsNotificationHandlers.disconnect(wsListeners?.moduleName, wsListeners?.listeners);\n pushNotificationHandlers.removeListeners(globalThis.pushNotifications);\n }\n };\n },\n\n prefetchForSSR: async (store, context) => {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n }\n};\n\n// Main initialization function\nconst initializeNotifications = (app, store, router, options = {}) => {\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: options.wsUrl });\n }\n\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n\n let notificationManager = null;\n\n if (autoInit) {\n const initNotifications = async () => {\n if (store.auth.state.isAuthenticated && store.auth.state.user?._id) {\n notificationManager = await notificationUtils.initialize(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000\n });\n }\n };\n\n watch(() => store.auth.state.isAuthenticated, (isAuthenticated) => {\n if (isAuthenticated) {\n initNotifications();\n } else if (notificationManager) {\n notificationManager.disconnect();\n store.notifications.mutations.resetNotifications();\n notificationManager = null;\n }\n });\n\n if (store.auth.state.isAuthenticated) {\n initNotifications();\n }\n }\n\n app.provide('useNotifications', () => ({\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: () => notificationUtils.initialize(store, options),\n disconnect: () => notificationManager?.disconnect(),\n isServer\n }));\n\n return {\n SSR: { prefetchNotifications: notificationUtils.prefetchForSSR }\n };\n};\n\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n views: {\n store: { storeNotifications },\n router: { routerNotifications },\n components: {\n NotificationBadge,\n NotificationItem,\n NotificationsList,\n NotificationPreferences,\n Notifications,\n NotificationsLayout\n }\n }\n};\n\nexport {\n NotificationBadge,\n NotificationItem,\n NotificationsList,\n NotificationPreferences,\n Notifications,\n NotificationsLayout,\n notificationUtils as SSRUtils\n};\n\nexport default ModuleNotifications;"],"names":["routerNotifications","storeNotifications"],"mappings":";;;;;;;;;;;AAaA,MAAM,yBAAyB;AAAA,EAC7B,SAAS,CAAC,OAAO,QAAQ,UAAU,CAAA,MAAO;AACxC,QAAI,OAAO,WAAW,eAAe,CAAC,OAAQ,QAAO,QAAQ,QAAQ,KAAK;AAE1E,WAAO,gBAAgB,QAAQ,MAAM,EAAE,KAAK,MAAM;AAChD,YAAM,aAAa;AACnB,YAAM,YAAY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AA,IACN;AAAA,EACA;AACA;"}
|
|
1
|
+
{"version":3,"file":"notifications.client.js","sources":["../../../../../src/modules/notifications/notifications.client.js"],"sourcesContent":["import { watch, toRefs } from \"vue\";\n// Router import \nimport routerNotifications from './router/notifications.router.js'; \n// Store \nimport * as storeNotifications from './store/notifications.store.js'; \n// Auth store import\nimport * as auth from '@martyrs/src/modules/auth/views/store/auth';\n// Global WebSocket import\nimport globalWebSocket from '@martyrs/src/modules/globals/views/classes/globals.websocket.js';\n// Layouts \nimport NotificationsLayout from './components/layouts/NotificationsLayout.vue'; \n// Sections \nimport NotificationsList from './components/sections/NotificationsList.vue'; \nimport NotificationPreferences from './components/sections/NotificationPreferences.vue'; \n// Pages \nimport Notifications from './components/pages/Notifications.vue'; \n// Components \nimport NotificationBadge from './components/elements/NotificationBadge.vue'; \nimport NotificationItem from './components/blocks/NotificationItem.vue'; \n\n/**\n * WebSocket notification handler that uses the global WebSocket connection\n */\nclass WebSocketNotificationHandler {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.moduleName = 'notifications';\n this.listeners = [];\n }\n\n /**\n * Connect to notifications channel\n */\n connect(userId) {\n // Skip if running in SSR\n if (typeof window === 'undefined' || !userId) {\n return Promise.resolve(false);\n }\n\n // First ensure the global WebSocket is connected\n return globalWebSocket.connect(userId).then(() => {\n // Register event listeners\n this._registerListeners();\n return true;\n });\n }\n\n /**\n * Disconnect notification listeners\n */\n disconnect() {\n globalWebSocket.removeModuleListeners(this.moduleName);\n }\n\n /**\n * Register notification event listeners\n */\n _registerListeners() {\n // Listen for notification events\n this.listeners.push(\n globalWebSocket.addEventListener('notification', this._processNotification.bind(this), {\n module: this.moduleName\n })\n );\n \n // Listen for notification read status changes\n this.listeners.push(\n globalWebSocket.addEventListener('notification_read', (data) => {\n this.store.notifications.actions.syncNotificationStatus(data.notificationId, 'read');\n }, { module: this.moduleName })\n );\n }\n\n /**\n * Process incoming notification\n */\n _processNotification(data) {\n if (!data || !data.data) return;\n \n const notification = data.data;\n \n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n _id: notification._id,\n title: notification.title,\n body: notification.body,\n type: notification.type || 'info',\n metadata: notification.metadata || {},\n status: 'unread',\n createdAt: notification.createdAt || new Date().toISOString(),\n updatedAt: notification.updatedAt || new Date().toISOString()\n });\n }\n}\n\n/**\n * Capacitor Push Notification handler\n */\nclass CapacitorPushHandler {\n constructor(store) {\n this.store = store;\n this.pushNotifications = null;\n this.device = null;\n this.isInitialized = false;\n }\n\n /**\n * Initialize Capacitor plugins\n */\n async initialize() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n try {\n // Dynamic imports to prevent errors in web environment\n const { Capacitor } = await import('@capacitor/core');\n const { PushNotifications } = await import('@capacitor/push-notifications');\n const { Device } = await import('@capacitor/device');\n \n this.capacitor = Capacitor;\n this.pushNotifications = PushNotifications;\n this.device = Device;\n \n // Only proceed if running on a native platform\n if (!this.capacitor.isNativePlatform()) {\n return false;\n }\n \n this.isInitialized = true;\n return true;\n } catch (error) {\n console.error('Error importing Capacitor plugins:', error);\n return false;\n }\n }\n\n /**\n * Request permission and register for push notifications\n */\n async requestPermissions() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return false;\n }\n\n if (!this.isInitialized) {\n const initialized = await this.initialize();\n if (!initialized) return false;\n }\n\n try {\n // Request permission\n const permissionResult = await this.pushNotifications.requestPermissions();\n if (permissionResult.receive !== 'granted') {\n console.log('Push notification permission denied');\n return false;\n }\n \n // Set up event listeners\n this._setupListeners();\n \n // Register with Apple/Google\n await this.pushNotifications.register();\n return true;\n } catch (error) {\n console.error('Error requesting push notification permissions:', error);\n return false;\n }\n }\n\n /**\n * Setup push notification event listeners\n */\n _setupListeners() {\n // Registration event\n this.pushNotifications.addListener('registration', \n this._handleRegistration.bind(this)\n );\n \n // Notification received event\n this.pushNotifications.addListener('pushNotificationReceived',\n this._handleNotificationReceived.bind(this)\n );\n \n // Notification action performed event\n this.pushNotifications.addListener('pushNotificationActionPerformed',\n this._handleNotificationAction.bind(this)\n );\n }\n\n /**\n * Handle registration token received\n */\n async _handleRegistration(token) {\n try {\n // Get device info\n const deviceInfo = await this.device.getInfo();\n const deviceId = await this.device.getId();\n \n // Prepare device data\n const deviceData = {\n deviceId: deviceId.uuid,\n deviceType: deviceInfo.platform.toLowerCase(),\n deviceToken: token.value\n };\n \n // Register device with backend\n await this.store.notifications.actions.registerDevice(deviceData);\n } catch (error) {\n console.error('Error handling push registration:', error);\n }\n }\n\n /**\n * Handle received notification\n */\n _handleNotificationReceived(notification) {\n // Add notification to store\n this.store.notifications.actions.addLocalNotification({\n title: notification.title,\n body: notification.body,\n data: notification.data || {}\n });\n }\n\n /**\n * Handle notification action (when user taps on notification)\n */\n _handleNotificationAction(actionData) {\n if (actionData.notification && actionData.notification.data) {\n this.store.notifications.actions.handleNotificationAction(\n actionData.notification.data\n );\n }\n }\n\n /**\n * Remove push notification listeners\n */\n removeListeners() {\n if (typeof window === 'undefined') {\n return;\n }\n \n if (this.pushNotifications) {\n this.pushNotifications.removeAllListeners();\n }\n }\n}\n\n/**\n * Notification Manager for coordinating WebSocket and Push notifications\n */\nclass NotificationManager {\n constructor(store, options = {}) {\n this.store = store;\n this.options = options;\n this.wsHandler = new WebSocketNotificationHandler(store, options);\n this.pushHandler = new CapacitorPushHandler(store);\n this.initialized = false;\n this.isServer = typeof window === 'undefined';\n }\n\n /**\n * Initialize notifications\n */\n async initialize() {\n if (this.initialized || this.isServer) return;\n \n // Get current user ID from auth store instead of localStorage\n const userId = this.store.auth.state.user?._id;\n if (!userId) {\n console.warn('Cannot initialize notifications: No user ID found in auth store');\n return;\n }\n \n // Initialize WebSocket for realtime notifications\n await this.wsHandler.connect(userId);\n \n // Initialize push notifications for mobile if enabled\n if (this.options.enablePush !== false) {\n await this.pushHandler.requestPermissions();\n }\n \n this.initialized = true;\n \n // Fetch existing notifications\n await this.store.notifications.actions.getNotifications(userId);\n }\n\n /**\n * Disconnect and clean up\n */\n disconnect() {\n if (this.isServer) return;\n \n this.wsHandler.disconnect();\n this.pushHandler.removeListeners();\n this.initialized = false;\n }\n}\n\n/**\n * Server-side utility for pre-fetching notification data\n */\nconst SSRUtils = {\n /**\n * Pre-fetch notifications for SSR\n * @param {Object} store - Store instance\n * @param {Object} context - SSR context\n */\n async prefetchNotifications(store, context) {\n try {\n const userId = store.auth.state.user?._id;\n if (userId) {\n // Fetch notifications without WebSocket or push setup\n await store.notifications.actions.getNotifications(userId);\n }\n } catch (error) {\n console.error('Error pre-fetching notifications for SSR:', error);\n }\n }\n};\n\n/**\n * Function to initialize the notifications module\n * @param {Object} app - Vue app instance\n * @param {Object} store - Vuex/Pinia store\n * @param {Object} router - Vue Router instance\n * @param {Object} options - Configuration options\n */\nfunction initializeNotifications(app, store, router, options = {}) {\n // Add routes and store\n const route = options.route || 'User Profile Root';\n router.addRoute(route, routerNotifications);\n store.addStore('notifications', storeNotifications);\n \n // Initialize global WebSocket if needed\n if (options.wsUrl) {\n globalWebSocket.initialize({ wsUrl: options.wsUrl });\n }\n \n // Create notification manager\n const notificationManager = new NotificationManager(store, {\n enablePush: options.enablePush !== false,\n maxReconnectAttempts: options.maxReconnectAttempts || 5,\n reconnectDelay: options.reconnectDelay || 3000,\n pingInterval: options.pingInterval || 30000\n });\n \n // Attach notification manager to store for access in components\n store.notificationManager = notificationManager;\n \n // Don't auto-initialize on server\n const isServer = typeof window === 'undefined';\n const autoInit = !isServer && options.autoInit !== false;\n \n if (autoInit) {\n // Initialize after auth is confirmed\n const isAuthenticated = store.auth.state.isAuthenticated;\n const userId = store.auth.state.user?._id;\n \n if (isAuthenticated && userId) {\n notificationManager.initialize();\n }\n \n // Watch for user login/logout using auth store\n watch(() => store.auth.state.isAuthenticated, (isAuthenticated) => {\n if (isAuthenticated) {\n notificationManager.initialize();\n } else {\n notificationManager.disconnect();\n store.notifications.mutations.resetNotifications();\n }\n });\n }\n \n // Provide composable for components to access notification functionality\n app.provide('useNotifications', () => {\n return {\n ...toRefs(store.notifications.state),\n ...store.notifications.actions,\n ...store.notifications.mutations,\n init: notificationManager.initialize.bind(notificationManager),\n disconnect: notificationManager.disconnect.bind(notificationManager),\n isServer\n };\n });\n \n return notificationManager;\n}\n\n// Module export\nconst ModuleNotifications = {\n initialize: initializeNotifications,\n SSR: SSRUtils, // Export SSR utilities\n views: {\n store: {\n storeNotifications,\n },\n router: {\n routerNotifications\n },\n components: {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout\n }\n }\n};\n\n// Component exports\nexport {\n // Elements\n NotificationBadge,\n // Blocks\n NotificationItem,\n // Sections\n NotificationsList,\n NotificationPreferences,\n // Pages\n Notifications,\n // Layouts\n NotificationsLayout,\n // SSR Utilities\n SSRUtils\n};\n\nexport default ModuleNotifications;\n"],"names":["routerNotifications","storeNotifications","isAuthenticated"],"mappings":";;;;;;;;;;;AAuBA,MAAM,6BAA6B;AAAA,EACjC,YAAY,OAAO,UAAU,IAAI;AAC/B,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,YAAY,CAAE;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKE,QAAQ,QAAQ;AAEd,QAAI,OAAO,WAAW,eAAe,CAAC,QAAQ;AAC5C,aAAO,QAAQ,QAAQ,KAAK;AAAA,IAClC;AAGI,WAAO,gBAAgB,QAAQ,MAAM,EAAE,KAAK,MAAM;AAEhD,WAAK,mBAAoB;AACzB,aAAO;AAAA,IACb,CAAK;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKE,aAAa;AACX,oBAAgB,sBAAsB,KAAK,UAAU;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA,EAKE,qBAAqB;AAEnB,SAAK,UAAU;AAAA,MACb,gBAAgB,iBAAiB,gBAAgB,KAAK,qBAAqB,KAAK,IAAI,GAAG;AAAA,QACrF,QAAQ,KAAK;AA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,MAAM,KAAK,MAAM,iBAAiB,CAACC,qBAAoB;AACjE,UAAIA,kBAAiB;AACnB,4BAAoB,WAAY;AAAA,MACxC,OAAa;AACL,4BAAoB,WAAY;AAChC,cAAM,cAAc,UAAU,mBAAoB;AAAA,MAC1D;AAAA,IACA,CAAK;AAAA,EACL;AAGE,MAAI,QAAQ,oBAAoB,MAAM;AACpC,WAAO;AAAA,MACL,GAAG,OAAO,MAAM,cAAc,KAAK;AAAA,MACnC,GAAG,MAAM,cAAc;AAAA,MACvB,GAAG,MAAM,cAAc;AAAA,MACvB,MAAM,oBAAoB,WAAW,KAAK,mBAAmB;AAAA,MAC7D,YAAY,oBAAoB,WAAW,KAAK,mBAAmB;AAAA,MACnE;AAAA,IACD;AAAA,EACL,CAAG;AAED,SAAO;AACT;AAGK,MAAC,sBAAsB;AAAA,EAC1B,YAAY;AAAA,EACZ,KAAK;AAAA;AAAA,EACL,OAAO;AAAA,IACL,OAAO;AAAA,MACX,oBAAMD;AAAAA,IACD;AAAA,IACD,QAAQ;AAAA,MACND,qBAAAA;AAAAA,IACD;AAAA,IACD,YAAY;AAAA;AAAA,MAEV;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA;AAAA,MAEA;AAAA,IACN;AAAA,EACA;AACA;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const vue = require("vue");
|
|
4
4
|
const vueRouter = require("vue-router");
|
|
5
|
-
const Button = require("../../../../components/Button/Button.
|
|
5
|
+
const Button = require("../../../../components/Button/Button.vue.cjs");
|
|
6
6
|
const Select = require("../../../../components/Select/Select.vue.cjs");
|
|
7
7
|
const Popup = require("../../../../components/Popup/Popup.vue.cjs");
|
|
8
8
|
const IconTime = require("../../../icons/entities/IconTime.vue.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, onMounted, computed, createElementBlock, createCommentVNode, openBlock, createVNode, createElementVNode, createTextVNode, toDisplayString, Fragment, renderList, normalizeClass, withCtx, createBlock, unref } from "vue";
|
|
2
2
|
import { useRouter, useRoute } from "vue-router";
|
|
3
|
-
import _sfc_main$2 from "../../../../components/Button/Button.
|
|
3
|
+
import _sfc_main$2 from "../../../../components/Button/Button.vue.js";
|
|
4
4
|
import Select from "../../../../components/Select/Select.vue.js";
|
|
5
5
|
import _sfc_main$1 from "../../../../components/Popup/Popup.vue.js";
|
|
6
6
|
import IconTime from "../../../icons/entities/IconTime.vue.js";
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const vue = require("vue");
|
|
4
4
|
const vueRouter = require("vue-router");
|
|
5
|
-
const Button = require("../../../../components/Button/Button.
|
|
6
|
-
const Tab = require("../../../../components/Tab/Tab.
|
|
5
|
+
const Button = require("../../../../components/Button/Button.vue.cjs");
|
|
6
|
+
const Tab = require("../../../../components/Tab/Tab.vue.cjs");
|
|
7
7
|
const Popup = require("../../../../components/Popup/Popup.vue.cjs");
|
|
8
8
|
const Block = require("../../../../components/Block/Block.vue.cjs");
|
|
9
9
|
const Feed = require("../../../../components/Feed/Feed.vue.cjs");
|
|
10
10
|
const CardOrderItem = require("../blocks/CardOrderItem.vue.cjs");
|
|
11
|
-
;/* empty css
|
|
11
|
+
;/* empty css */
|
|
12
12
|
;/* empty css */
|
|
13
13
|
const CardUser = require("../../../auth/views/components/blocks/CardUser.vue.cjs");
|
|
14
14
|
const FormAddCustomer = require("../sections/FormAddCustomer.vue.cjs");
|