@selfcommunity/react-core 0.1.7-alpha.0 → 0.1.8-alpha.0
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/lib/{types → cjs}/components/provider/SCAlertMessagesProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCAlertMessagesProvider/index.d.ts.map +0 -0
- package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js +37 -35
- package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/provider/SCContextProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCContextProvider/index.d.ts.map +0 -0
- package/lib/cjs/components/provider/SCContextProvider/index.js +74 -81
- package/lib/cjs/components/provider/SCContextProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/provider/SCLocaleProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCLocaleProvider/index.d.ts.map +0 -0
- package/lib/cjs/components/provider/SCLocaleProvider/index.js +86 -121
- package/lib/cjs/components/provider/SCLocaleProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/provider/SCNotificationProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCNotificationProvider/index.d.ts.map +0 -0
- package/lib/cjs/components/provider/SCNotificationProvider/index.js +41 -41
- package/lib/cjs/components/provider/SCNotificationProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/provider/SCPreferencesProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCPreferencesProvider/index.d.ts.map +0 -0
- package/lib/cjs/components/provider/SCPreferencesProvider/index.js +61 -62
- package/lib/cjs/components/provider/SCPreferencesProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/provider/SCRoutingProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCRoutingProvider/index.d.ts.map +1 -1
- package/lib/cjs/components/provider/SCRoutingProvider/index.js +104 -111
- package/lib/cjs/components/provider/SCRoutingProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/provider/SCThemeProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCThemeProvider/index.d.ts.map +0 -0
- package/lib/cjs/components/provider/SCThemeProvider/index.js +66 -79
- package/lib/cjs/components/provider/SCThemeProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/provider/SCUserProvider/index.d.ts +0 -0
- package/lib/{types → cjs}/components/provider/SCUserProvider/index.d.ts.map +0 -0
- package/lib/cjs/components/provider/SCUserProvider/index.js +215 -270
- package/lib/cjs/components/provider/SCUserProvider/index.js.map +1 -0
- package/lib/{types → cjs}/components/router/index.d.ts +0 -0
- package/lib/{types → cjs}/components/router/index.d.ts.map +0 -0
- package/lib/cjs/components/router/index.js +48 -49
- package/lib/cjs/components/router/index.js.map +1 -0
- package/lib/{types → cjs}/constants/Actions.d.ts +0 -0
- package/lib/{types → cjs}/constants/Actions.d.ts.map +0 -0
- package/lib/cjs/constants/Actions.js +3 -4
- package/lib/cjs/constants/Actions.js.map +1 -0
- package/lib/{types → cjs}/constants/ContextProviders.d.ts +0 -0
- package/lib/{types → cjs}/constants/ContextProviders.d.ts.map +0 -0
- package/lib/cjs/constants/ContextProviders.js +22 -24
- package/lib/cjs/constants/ContextProviders.js.map +1 -0
- package/lib/{types → cjs}/constants/Device.d.ts +0 -0
- package/lib/{types → cjs}/constants/Device.d.ts.map +0 -0
- package/lib/cjs/constants/Device.js +3 -5
- package/lib/cjs/constants/Device.js.map +1 -0
- package/lib/{types → cjs}/constants/Errors.d.ts +0 -0
- package/lib/{types → cjs}/constants/Errors.d.ts.map +0 -0
- package/lib/cjs/constants/Errors.js +3 -5
- package/lib/cjs/constants/Errors.js.map +1 -0
- package/lib/{types → cjs}/constants/Features.d.ts +0 -0
- package/lib/{types → cjs}/constants/Features.d.ts.map +0 -0
- package/lib/cjs/constants/Features.js +43 -83
- package/lib/cjs/constants/Features.js.map +1 -0
- package/lib/{types → cjs}/constants/Locale.d.ts +0 -0
- package/lib/{types → cjs}/constants/Locale.d.ts.map +0 -0
- package/lib/cjs/constants/Locale.js +10 -17
- package/lib/cjs/constants/Locale.js.map +1 -0
- package/lib/{types → cjs}/constants/Notification.d.ts +0 -0
- package/lib/{types → cjs}/constants/Notification.d.ts.map +0 -0
- package/lib/cjs/constants/Notification.js +44 -53
- package/lib/cjs/constants/Notification.js.map +1 -0
- package/lib/{types → cjs}/constants/Notifications.d.ts +0 -0
- package/lib/{types → cjs}/constants/Notifications.d.ts.map +0 -0
- package/lib/cjs/constants/Notifications.js +11 -25
- package/lib/cjs/constants/Notifications.js.map +1 -0
- package/lib/cjs/constants/Preferences.d.ts +201 -0
- package/lib/cjs/constants/Preferences.d.ts.map +1 -0
- package/lib/cjs/constants/Preferences.js +184 -292
- package/lib/cjs/constants/Preferences.js.map +1 -0
- package/lib/{types → cjs}/constants/Routes.d.ts +0 -0
- package/lib/{types → cjs}/constants/Routes.d.ts.map +0 -0
- package/lib/cjs/constants/Routes.js +38 -59
- package/lib/cjs/constants/Routes.js.map +1 -0
- package/lib/{types → cjs}/constants/Session.d.ts +0 -0
- package/lib/{types → cjs}/constants/Session.d.ts.map +0 -0
- package/lib/cjs/constants/Session.js +12 -21
- package/lib/cjs/constants/Session.js.map +1 -0
- package/lib/{types → cjs}/constants/Theme.d.ts +0 -0
- package/lib/{types → cjs}/constants/Theme.d.ts.map +0 -0
- package/lib/cjs/constants/Theme.js +3 -4
- package/lib/cjs/constants/Theme.js.map +1 -0
- package/lib/cjs/constants/WebSocket.d.ts +4 -0
- package/lib/cjs/constants/WebSocket.d.ts.map +1 -0
- package/lib/cjs/constants/WebSocket.js +6 -9
- package/lib/cjs/constants/WebSocket.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCAuth.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCAuth.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCAuth.js +212 -282
- package/lib/cjs/hooks/useSCAuth.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCCachingManager.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCCachingManager.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCCachingManager.js +37 -51
- package/lib/cjs/hooks/useSCCachingManager.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCConnectionsManager.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCConnectionsManager.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCConnectionsManager.js +190 -254
- package/lib/cjs/hooks/useSCConnectionsManager.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchAddressingTagList.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchAddressingTagList.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchAddressingTagList.js +64 -55
- package/lib/cjs/hooks/useSCFetchAddressingTagList.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchCategories.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchCategories.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchCategories.js +46 -56
- package/lib/cjs/hooks/useSCFetchCategories.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchCategory.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchCategory.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchCategory.js +44 -59
- package/lib/cjs/hooks/useSCFetchCategory.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchCommentObject.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchCommentObject.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchCommentObject.js +44 -59
- package/lib/cjs/hooks/useSCFetchCommentObject.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchCommentObjects.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchCommentObjects.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchCommentObjects.js +157 -254
- package/lib/cjs/hooks/useSCFetchCommentObjects.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchCustomAdv.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchCustomAdv.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchCustomAdv.js +57 -75
- package/lib/cjs/hooks/useSCFetchCustomAdv.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchFeedObject.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchFeedObject.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchFeedObject.js +49 -69
- package/lib/cjs/hooks/useSCFetchFeedObject.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchIncubator.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchIncubator.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchIncubator.js +44 -59
- package/lib/cjs/hooks/useSCFetchIncubator.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchTag.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchTag.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFetchTag.js +44 -59
- package/lib/cjs/hooks/useSCFetchTag.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFetchUser.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFetchUser.d.ts.map +1 -1
- package/lib/cjs/hooks/useSCFetchUser.js +47 -59
- package/lib/cjs/hooks/useSCFetchUser.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFollowedCategoriesManager.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFollowedCategoriesManager.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.js +105 -147
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCFollowersManager.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCFollowersManager.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCFollowersManager.js +154 -204
- package/lib/cjs/hooks/useSCFollowersManager.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCMediaClick.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCMediaClick.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCMediaClick.js +18 -25
- package/lib/cjs/hooks/useSCMediaClick.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCSubscribedIncubatorsManager.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCSubscribedIncubatorsManager.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js +118 -148
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCWebPushMessaging.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCWebPushMessaging.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCWebPushMessaging.js +268 -268
- package/lib/cjs/hooks/useSCWebPushMessaging.js.map +1 -0
- package/lib/{types → cjs}/hooks/useSCWebSocket.d.ts +0 -0
- package/lib/{types → cjs}/hooks/useSCWebSocket.d.ts.map +0 -0
- package/lib/cjs/hooks/useSCWebSocket.js +103 -125
- package/lib/cjs/hooks/useSCWebSocket.js.map +1 -0
- package/lib/{types → cjs}/index.d.ts +0 -0
- package/lib/{types → cjs}/index.d.ts.map +0 -0
- package/lib/cjs/index.js +131 -144
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/themes/theme.d.ts +9 -0
- package/lib/cjs/themes/theme.d.ts.map +1 -0
- package/lib/cjs/themes/theme.js +132 -143
- package/lib/cjs/themes/theme.js.map +1 -0
- package/lib/{types → cjs}/types/context.d.ts +0 -0
- package/lib/{types → cjs}/types/context.d.ts.map +0 -0
- package/lib/cjs/types/context.js +2 -2
- package/lib/cjs/types/context.js.map +1 -0
- package/lib/{types → cjs}/types/index.d.ts +0 -0
- package/lib/{types → cjs}/types/index.d.ts.map +0 -0
- package/lib/cjs/types/index.js +2 -21
- package/lib/cjs/types/index.js.map +1 -0
- package/lib/{types → cjs}/utils/errors.d.ts +0 -0
- package/lib/{types → cjs}/utils/errors.d.ts.map +0 -0
- package/lib/cjs/utils/errors.js +138 -149
- package/lib/cjs/utils/errors.js.map +1 -0
- package/lib/{types → cjs}/utils/locale.d.ts +0 -0
- package/lib/{types → cjs}/utils/locale.d.ts.map +0 -0
- package/lib/cjs/utils/locale.js +32 -48
- package/lib/cjs/utils/locale.js.map +1 -0
- package/lib/{types → cjs}/utils/user.d.ts +0 -0
- package/lib/{types → cjs}/utils/user.d.ts.map +0 -0
- package/lib/cjs/utils/user.js +25 -40
- package/lib/cjs/utils/user.js.map +1 -0
- package/lib/{types → cjs}/utils/validator.d.ts +0 -0
- package/lib/{types → cjs}/utils/validator.d.ts.map +0 -0
- package/lib/cjs/utils/validator.js +386 -576
- package/lib/cjs/utils/validator.js.map +1 -0
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.d.ts +37 -0
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.js +11 -37
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.js.map +1 -0
- package/lib/esm/components/provider/SCContextProvider/index.d.ts +35 -0
- package/lib/esm/components/provider/SCContextProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCContextProvider/index.js +48 -83
- package/lib/esm/components/provider/SCContextProvider/index.js.map +1 -0
- package/lib/esm/components/provider/SCLocaleProvider/index.d.ts +42 -0
- package/lib/esm/components/provider/SCLocaleProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCLocaleProvider/index.js +59 -123
- package/lib/esm/components/provider/SCLocaleProvider/index.js.map +1 -0
- package/lib/esm/components/provider/SCNotificationProvider/index.d.ts +37 -0
- package/lib/esm/components/provider/SCNotificationProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCNotificationProvider/index.js +12 -43
- package/lib/esm/components/provider/SCNotificationProvider/index.js.map +1 -0
- package/lib/esm/components/provider/SCPreferencesProvider/index.d.ts +38 -0
- package/lib/esm/components/provider/SCPreferencesProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCPreferencesProvider/index.js +35 -64
- package/lib/esm/components/provider/SCPreferencesProvider/index.js.map +1 -0
- package/lib/esm/components/provider/SCRoutingProvider/index.d.ts +39 -0
- package/lib/esm/components/provider/SCRoutingProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCRoutingProvider/index.js +78 -113
- package/lib/esm/components/provider/SCRoutingProvider/index.js.map +1 -0
- package/lib/esm/components/provider/SCThemeProvider/index.d.ts +49 -0
- package/lib/esm/components/provider/SCThemeProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCThemeProvider/index.js +36 -81
- package/lib/esm/components/provider/SCThemeProvider/index.js.map +1 -0
- package/lib/esm/components/provider/SCUserProvider/index.d.ts +38 -0
- package/lib/esm/components/provider/SCUserProvider/index.d.ts.map +1 -0
- package/lib/esm/components/provider/SCUserProvider/index.js +186 -272
- package/lib/esm/components/provider/SCUserProvider/index.js.map +1 -0
- package/lib/esm/components/router/index.d.ts +34 -0
- package/lib/esm/components/router/index.d.ts.map +1 -0
- package/lib/esm/components/router/index.js +24 -50
- package/lib/esm/components/router/index.js.map +1 -0
- package/lib/esm/constants/Actions.d.ts +2 -0
- package/lib/esm/constants/Actions.d.ts.map +1 -0
- package/lib/esm/constants/Actions.js +2 -6
- package/lib/esm/constants/Actions.js.map +1 -0
- package/lib/esm/constants/ContextProviders.d.ts +6 -0
- package/lib/esm/constants/ContextProviders.d.ts.map +1 -0
- package/lib/esm/constants/ContextProviders.js +18 -26
- package/lib/esm/constants/ContextProviders.js.map +1 -0
- package/lib/esm/constants/Device.d.ts +6 -0
- package/lib/esm/constants/Device.d.ts.map +1 -0
- package/lib/esm/constants/Device.js +2 -7
- package/lib/esm/constants/Device.js.map +1 -0
- package/lib/esm/constants/Errors.d.ts +5 -0
- package/lib/esm/constants/Errors.d.ts.map +1 -0
- package/lib/esm/constants/Errors.js +2 -7
- package/lib/esm/constants/Errors.js.map +1 -0
- package/lib/esm/constants/Features.d.ts +41 -0
- package/lib/esm/constants/Features.d.ts.map +1 -0
- package/lib/esm/constants/Features.js +41 -84
- package/lib/esm/constants/Features.js.map +1 -0
- package/lib/esm/constants/Locale.d.ts +8 -0
- package/lib/esm/constants/Locale.d.ts.map +1 -0
- package/lib/esm/constants/Locale.js +8 -18
- package/lib/esm/constants/Locale.js.map +1 -0
- package/lib/esm/constants/Notification.d.ts +55 -0
- package/lib/esm/constants/Notification.d.ts.map +1 -0
- package/lib/esm/constants/Notification.js +42 -54
- package/lib/esm/constants/Notification.js.map +1 -0
- package/lib/esm/constants/Notifications.d.ts +11 -0
- package/lib/esm/constants/Notifications.d.ts.map +1 -0
- package/lib/esm/constants/Notifications.js +9 -26
- package/lib/esm/constants/Notifications.js.map +1 -0
- package/lib/esm/constants/Preferences.d.ts +201 -0
- package/lib/esm/constants/Preferences.d.ts.map +1 -0
- package/lib/esm/constants/Preferences.js +181 -296
- package/lib/esm/constants/Preferences.js.map +1 -0
- package/lib/esm/constants/Routes.d.ts +29 -0
- package/lib/esm/constants/Routes.d.ts.map +1 -0
- package/lib/esm/constants/Routes.js +36 -60
- package/lib/esm/constants/Routes.js.map +1 -0
- package/lib/esm/constants/Session.d.ts +10 -0
- package/lib/esm/constants/Session.d.ts.map +1 -0
- package/lib/esm/constants/Session.js +10 -22
- package/lib/esm/constants/Session.js.map +1 -0
- package/lib/esm/constants/Theme.d.ts +2 -0
- package/lib/esm/constants/Theme.d.ts.map +1 -0
- package/lib/esm/constants/Theme.js +2 -6
- package/lib/esm/constants/Theme.js.map +1 -0
- package/lib/esm/constants/WebSocket.d.ts +4 -0
- package/lib/esm/constants/WebSocket.d.ts.map +1 -0
- package/lib/esm/constants/WebSocket.js +4 -10
- package/lib/esm/constants/WebSocket.js.map +1 -0
- package/lib/esm/hooks/useSCAuth.d.ts +56 -0
- package/lib/esm/hooks/useSCAuth.d.ts.map +1 -0
- package/lib/esm/hooks/useSCAuth.js +185 -285
- package/lib/esm/hooks/useSCAuth.js.map +1 -0
- package/lib/esm/hooks/useSCCachingManager.d.ts +19 -0
- package/lib/esm/hooks/useSCCachingManager.d.ts.map +1 -0
- package/lib/esm/hooks/useSCCachingManager.js +36 -53
- package/lib/esm/hooks/useSCCachingManager.js.map +1 -0
- package/lib/esm/hooks/useSCConnectionsManager.d.ts +40 -0
- package/lib/esm/hooks/useSCConnectionsManager.d.ts.map +1 -0
- package/lib/esm/hooks/useSCConnectionsManager.js +186 -256
- package/lib/esm/hooks/useSCConnectionsManager.js.map +1 -0
- package/lib/esm/hooks/useSCFetchAddressingTagList.d.ts +14 -0
- package/lib/esm/hooks/useSCFetchAddressingTagList.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchAddressingTagList.js +39 -56
- package/lib/esm/hooks/useSCFetchAddressingTagList.js.map +1 -0
- package/lib/esm/hooks/useSCFetchCategories.d.ts +17 -0
- package/lib/esm/hooks/useSCFetchCategories.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchCategories.js +45 -57
- package/lib/esm/hooks/useSCFetchCategories.js.map +1 -0
- package/lib/esm/hooks/useSCFetchCategory.d.ts +19 -0
- package/lib/esm/hooks/useSCFetchCategory.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchCategory.js +42 -60
- package/lib/esm/hooks/useSCFetchCategory.js.map +1 -0
- package/lib/esm/hooks/useSCFetchCommentObject.d.ts +19 -0
- package/lib/esm/hooks/useSCFetchCommentObject.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchCommentObject.js +42 -60
- package/lib/esm/hooks/useSCFetchCommentObject.js.map +1 -0
- package/lib/esm/hooks/useSCFetchCommentObjects.d.ts +53 -0
- package/lib/esm/hooks/useSCFetchCommentObjects.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchCommentObjects.js +153 -257
- package/lib/esm/hooks/useSCFetchCommentObjects.js.map +1 -0
- package/lib/esm/hooks/useSCFetchCustomAdv.d.ts +19 -0
- package/lib/esm/hooks/useSCFetchCustomAdv.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchCustomAdv.js +55 -76
- package/lib/esm/hooks/useSCFetchCustomAdv.js.map +1 -0
- package/lib/esm/hooks/useSCFetchFeedObject.d.ts +21 -0
- package/lib/esm/hooks/useSCFetchFeedObject.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchFeedObject.js +47 -70
- package/lib/esm/hooks/useSCFetchFeedObject.js.map +1 -0
- package/lib/esm/hooks/useSCFetchIncubator.d.ts +19 -0
- package/lib/esm/hooks/useSCFetchIncubator.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchIncubator.js +42 -60
- package/lib/esm/hooks/useSCFetchIncubator.js.map +1 -0
- package/lib/esm/hooks/useSCFetchTag.d.ts +19 -0
- package/lib/esm/hooks/useSCFetchTag.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchTag.js +42 -60
- package/lib/esm/hooks/useSCFetchTag.js.map +1 -0
- package/lib/esm/hooks/useSCFetchUser.d.ts +19 -0
- package/lib/esm/hooks/useSCFetchUser.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFetchUser.js +45 -60
- package/lib/esm/hooks/useSCFetchUser.js.map +1 -0
- package/lib/esm/hooks/useSCFollowedCategoriesManager.d.ts +37 -0
- package/lib/esm/hooks/useSCFollowedCategoriesManager.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFollowedCategoriesManager.js +101 -149
- package/lib/esm/hooks/useSCFollowedCategoriesManager.js.map +1 -0
- package/lib/esm/hooks/useSCFollowersManager.d.ts +37 -0
- package/lib/esm/hooks/useSCFollowersManager.d.ts.map +1 -0
- package/lib/esm/hooks/useSCFollowersManager.js +150 -206
- package/lib/esm/hooks/useSCFollowersManager.js.map +1 -0
- package/lib/esm/hooks/useSCMediaClick.d.ts +4 -0
- package/lib/esm/hooks/useSCMediaClick.d.ts.map +1 -0
- package/lib/esm/hooks/useSCMediaClick.js +17 -27
- package/lib/esm/hooks/useSCMediaClick.js.map +1 -0
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.d.ts +27 -0
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.d.ts.map +1 -0
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js +114 -150
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js.map +1 -0
- package/lib/esm/hooks/useSCWebPushMessaging.d.ts +9 -0
- package/lib/esm/hooks/useSCWebPushMessaging.d.ts.map +1 -0
- package/lib/esm/hooks/useSCWebPushMessaging.js +244 -270
- package/lib/esm/hooks/useSCWebPushMessaging.js.map +1 -0
- package/lib/esm/hooks/useSCWebSocket.d.ts +12 -0
- package/lib/esm/hooks/useSCWebSocket.d.ts.map +1 -0
- package/lib/esm/hooks/useSCWebSocket.js +99 -127
- package/lib/esm/hooks/useSCWebSocket.js.map +1 -0
- package/lib/esm/index.d.ts +73 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +69 -151
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/themes/theme.d.ts +9 -0
- package/lib/esm/themes/theme.d.ts.map +1 -0
- package/lib/esm/themes/theme.js +128 -144
- package/lib/esm/themes/theme.js.map +1 -0
- package/lib/esm/types/context.d.ts +428 -0
- package/lib/esm/types/context.d.ts.map +1 -0
- package/lib/esm/types/context.js +2 -3
- package/lib/esm/types/context.js.map +1 -0
- package/lib/esm/types/index.d.ts +3 -0
- package/lib/esm/types/index.d.ts.map +1 -0
- package/lib/esm/types/index.js +2 -22
- package/lib/esm/types/index.js.map +1 -0
- package/lib/esm/utils/errors.d.ts +98 -0
- package/lib/esm/utils/errors.d.ts.map +1 -0
- package/lib/esm/utils/errors.js +114 -155
- package/lib/esm/utils/errors.js.map +1 -0
- package/lib/esm/utils/locale.d.ts +10 -0
- package/lib/esm/utils/locale.d.ts.map +1 -0
- package/lib/esm/utils/locale.js +27 -50
- package/lib/esm/utils/locale.js.map +1 -0
- package/lib/esm/utils/user.d.ts +41 -0
- package/lib/esm/utils/user.d.ts.map +1 -0
- package/lib/esm/utils/user.js +23 -46
- package/lib/esm/utils/user.js.map +1 -0
- package/lib/esm/utils/validator.d.ts +239 -0
- package/lib/esm/utils/validator.d.ts.map +1 -0
- package/lib/esm/utils/validator.js +352 -588
- package/lib/esm/utils/validator.js.map +1 -0
- package/lib/umd/react-core.js +1 -1
- package/package.json +9 -11
- package/lib/types/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,284 +1,258 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _utils = require("@selfcommunity/utils");
|
|
13
|
-
|
|
14
|
-
var _Errors = require("../constants/Errors");
|
|
15
|
-
|
|
16
|
-
var _apiServices = require("@selfcommunity/api-services");
|
|
17
|
-
|
|
18
|
-
var _Device = require("../constants/Device");
|
|
19
|
-
|
|
20
|
-
var _SCPreferencesProvider = require("../components/provider/SCPreferencesProvider");
|
|
21
|
-
|
|
22
|
-
var SCPreferences = _interopRequireWildcard(require("../constants/Preferences"));
|
|
23
|
-
|
|
24
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
-
|
|
26
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
1
|
+
import { useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useSCContext } from '../components/provider/SCContextProvider';
|
|
3
|
+
import { useSCUser } from '../components/provider/SCUserProvider';
|
|
4
|
+
import { Logger } from '@selfcommunity/utils';
|
|
5
|
+
import { loadVersionBrowser, urlB64ToUint8Array } from '@selfcommunity/utils';
|
|
6
|
+
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
7
|
+
import { http, Endpoints } from '@selfcommunity/api-services';
|
|
8
|
+
import { WEB_PUSH_NOTIFICATION_DEVICE_TYPE } from '../constants/Device';
|
|
9
|
+
import { SCPreferencesContext } from '../components/provider/SCPreferencesProvider';
|
|
10
|
+
import * as SCPreferences from '../constants/Preferences';
|
|
28
11
|
/**
|
|
29
12
|
:::info
|
|
30
13
|
This custom hook is used to to init web push messaging.
|
|
31
14
|
:::
|
|
32
15
|
*/
|
|
33
|
-
function useSCWebPushMessaging() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* updateSubscriptionOnServer to sync current subscription
|
|
74
|
-
* @param sub
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const updateSubscriptionOnServer = (sub, remove) => {
|
|
79
|
-
const browser = (0, _utils.loadVersionBrowser)();
|
|
80
|
-
const endpointParts = sub.endpoint.split('/');
|
|
81
|
-
const registration_id = endpointParts[endpointParts.length - 1];
|
|
82
|
-
const data = {
|
|
83
|
-
browser: browser.name.toUpperCase(),
|
|
84
|
-
p256dh: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('p256dh')))),
|
|
85
|
-
auth: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('auth')))),
|
|
86
|
-
user: scUserContext.user ? scUserContext.user.username : '',
|
|
87
|
-
registration_id: registration_id
|
|
16
|
+
export default function useSCWebPushMessaging() {
|
|
17
|
+
// CONTEXT
|
|
18
|
+
const scContext = useSCContext();
|
|
19
|
+
const scUserContext = useSCUser();
|
|
20
|
+
const scPreferencesContext = useContext(SCPreferencesContext);
|
|
21
|
+
// STATE
|
|
22
|
+
const [wpSubscription, setWpSubscription] = useState(null);
|
|
23
|
+
// REFS
|
|
24
|
+
const subAttempts = useRef(0);
|
|
25
|
+
// CONST
|
|
26
|
+
const applicationServerKey = scContext.settings.notifications.webPushMessaging.applicationServerKey !== undefined
|
|
27
|
+
? scContext.settings.notifications.webPushMessaging.applicationServerKey
|
|
28
|
+
: SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY in scPreferencesContext.preferences
|
|
29
|
+
? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY].value
|
|
30
|
+
: null;
|
|
31
|
+
const webPushEnabled = SCPreferences.PROVIDERS_WEB_PUSH_ENABLED in scPreferencesContext.preferences &&
|
|
32
|
+
scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value
|
|
33
|
+
? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value
|
|
34
|
+
: false;
|
|
35
|
+
/**
|
|
36
|
+
* perform update the Subscription
|
|
37
|
+
* @param data
|
|
38
|
+
* @param remove
|
|
39
|
+
*/
|
|
40
|
+
const performUpdateSubscription = (data, remove) => {
|
|
41
|
+
const url = remove
|
|
42
|
+
? Endpoints.DeleteDevice.url({ type: WEB_PUSH_NOTIFICATION_DEVICE_TYPE, id: data.registration_id })
|
|
43
|
+
: Endpoints.NewDevice.url({ type: WEB_PUSH_NOTIFICATION_DEVICE_TYPE });
|
|
44
|
+
const method = remove ? Endpoints.DeleteDevice.method : Endpoints.NewDevice.method;
|
|
45
|
+
return http
|
|
46
|
+
.request(Object.assign({ url,
|
|
47
|
+
method }, (remove ? {} : { data: data })))
|
|
48
|
+
.then((res) => {
|
|
49
|
+
if (res.status >= 300) {
|
|
50
|
+
return Promise.reject(res);
|
|
51
|
+
}
|
|
52
|
+
return Promise.resolve(res.data);
|
|
53
|
+
});
|
|
88
54
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} // We have a subscription, so call unsubscribe on it
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
pushSubscription.unsubscribe().then(() => {
|
|
119
|
-
_utils.Logger.info(_Errors.SCOPE_SC_CORE, 'Unsubscription successfully'); // Request to server to remove
|
|
120
|
-
// the users data from your data store so you
|
|
121
|
-
// don't attempt to send them push messages anymore
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
updateSubscriptionOnServer(pushSubscription, true).then(() => {
|
|
125
|
-
callback && callback();
|
|
126
|
-
});
|
|
127
|
-
}).catch(function (e) {
|
|
128
|
-
// We failed to unsubscribe, this can lead to
|
|
129
|
-
// an unusual state, so may be best to remove
|
|
130
|
-
// the subscription id from your data store and
|
|
131
|
-
// inform the user that you disabled push
|
|
132
|
-
_utils.Logger.info(_Errors.SCOPE_SC_CORE, `Unsubscription error.`);
|
|
133
|
-
|
|
134
|
-
console.log(e);
|
|
55
|
+
/**
|
|
56
|
+
* updateSubscriptionOnServer to sync current subscription
|
|
57
|
+
* @param sub
|
|
58
|
+
*/
|
|
59
|
+
const updateSubscriptionOnServer = (sub, remove) => {
|
|
60
|
+
const browser = loadVersionBrowser();
|
|
61
|
+
const endpointParts = sub.endpoint.split('/');
|
|
62
|
+
const registration_id = endpointParts[endpointParts.length - 1];
|
|
63
|
+
const data = {
|
|
64
|
+
browser: browser.name.toUpperCase(),
|
|
65
|
+
p256dh: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('p256dh')))),
|
|
66
|
+
auth: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('auth')))),
|
|
67
|
+
user: scUserContext.user ? scUserContext.user.username : '',
|
|
68
|
+
registration_id: registration_id,
|
|
69
|
+
};
|
|
70
|
+
return performUpdateSubscription(data, remove)
|
|
71
|
+
.then((res) => {
|
|
72
|
+
if (remove) {
|
|
73
|
+
setWpSubscription(null);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
setWpSubscription(res);
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
.catch((e) => {
|
|
80
|
+
Logger.error(SCOPE_SC_CORE, e);
|
|
135
81
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Request web push notification permission
|
|
181
|
-
* @type {(function(): void)|*}
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const requestNotificationPermission = () => {
|
|
186
|
-
if (Notification.permission !== 'granted') {
|
|
187
|
-
Notification.requestPermission().then(function (permission) {
|
|
188
|
-
if (permission === 'granted') {
|
|
189
|
-
navigator.serviceWorker.ready.then(serviceWorkerRegistration => {
|
|
190
|
-
// Do we already have a push message subscription?
|
|
191
|
-
serviceWorkerRegistration.pushManager.getSubscription().then(function (subscription) {
|
|
192
|
-
// Enable any UI which subscribes / unsubscribes from
|
|
193
|
-
// push messages.
|
|
194
|
-
if (!subscription) {
|
|
195
|
-
subscribe();
|
|
196
|
-
return;
|
|
197
|
-
} // Keep your server in sync with the latest subscription
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
updateSubscriptionOnServer(subscription, false);
|
|
201
|
-
}).catch(err => {
|
|
202
|
-
_utils.Logger.info(_Errors.SCOPE_SC_CORE, 'Error during getSubscription()');
|
|
203
|
-
|
|
204
|
-
console.log(err);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Unsubscribe
|
|
85
|
+
* @param callback
|
|
86
|
+
*/
|
|
87
|
+
const unsubscribe = (callback = null) => {
|
|
88
|
+
navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
|
|
89
|
+
// To unsubscribe from push messaging, you need get the
|
|
90
|
+
// subcription object, which you can call unsubscribe() on.
|
|
91
|
+
serviceWorkerRegistration.pushManager
|
|
92
|
+
.getSubscription()
|
|
93
|
+
.then((pushSubscription) => {
|
|
94
|
+
// Check we have a subscription to unsubscribe
|
|
95
|
+
if (!pushSubscription) {
|
|
96
|
+
// No subscription object, so set the state
|
|
97
|
+
// to allow the user to subscribe to push
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// We have a subscription, so call unsubscribe on it
|
|
101
|
+
pushSubscription
|
|
102
|
+
.unsubscribe()
|
|
103
|
+
.then(() => {
|
|
104
|
+
Logger.info(SCOPE_SC_CORE, 'Unsubscription successfully');
|
|
105
|
+
// Request to server to remove
|
|
106
|
+
// the users data from your data store so you
|
|
107
|
+
// don't attempt to send them push messages anymore
|
|
108
|
+
updateSubscriptionOnServer(pushSubscription, true).then(() => {
|
|
109
|
+
callback && callback();
|
|
110
|
+
});
|
|
111
|
+
})
|
|
112
|
+
.catch(function (e) {
|
|
113
|
+
// We failed to unsubscribe, this can lead to
|
|
114
|
+
// an unusual state, so may be best to remove
|
|
115
|
+
// the subscription id from your data store and
|
|
116
|
+
// inform the user that you disabled push
|
|
117
|
+
Logger.info(SCOPE_SC_CORE, `Unsubscription error.`);
|
|
118
|
+
console.log(e);
|
|
119
|
+
});
|
|
120
|
+
})
|
|
121
|
+
.catch(function (e) {
|
|
122
|
+
Logger.info(SCOPE_SC_CORE, `Error thrown while unsubscribing from push messaging. ${e}`);
|
|
205
123
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Get subscription
|
|
128
|
+
*/
|
|
129
|
+
const subscribe = () => {
|
|
130
|
+
navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
|
|
131
|
+
serviceWorkerRegistration.pushManager
|
|
132
|
+
.subscribe({ userVisibleOnly: true, applicationServerKey: urlB64ToUint8Array(applicationServerKey) })
|
|
133
|
+
.then(function (subscription) {
|
|
134
|
+
if (!subscription) {
|
|
135
|
+
Logger.info(SCOPE_SC_CORE, 'We aren’t subscribed to push.');
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
updateSubscriptionOnServer(subscription, false);
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
.catch(function (e) {
|
|
142
|
+
if (Notification.permission === 'denied') {
|
|
143
|
+
// The user denied the notification permission which
|
|
144
|
+
// means we failed to subscribe and the user will need
|
|
145
|
+
// to manually change the notification permission to
|
|
146
|
+
// subscribe to push messages
|
|
147
|
+
Logger.info(SCOPE_SC_CORE, 'Permission for Notifications was denied');
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// A problem occurred with the subscription
|
|
151
|
+
subAttempts.current += 1;
|
|
152
|
+
Logger.info(SCOPE_SC_CORE, `Unable to subscribe(${subAttempts.current}) to push. ${e}`);
|
|
153
|
+
if (subAttempts.current < 3) {
|
|
154
|
+
unsubscribe(() => subscribe());
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
Logger.info(SCOPE_SC_CORE, `Unable to subscribe to push. ${e}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
};
|
|
219
163
|
/**
|
|
220
|
-
*
|
|
164
|
+
* Request web push notification permission
|
|
165
|
+
* @type {(function(): void)|*}
|
|
221
166
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
167
|
+
const requestNotificationPermission = () => {
|
|
168
|
+
if (Notification.permission !== 'granted') {
|
|
169
|
+
Notification.requestPermission().then(function (permission) {
|
|
170
|
+
if (permission === 'granted') {
|
|
171
|
+
navigator.serviceWorker.ready.then((serviceWorkerRegistration) => {
|
|
172
|
+
// Do we already have a push message subscription?
|
|
173
|
+
serviceWorkerRegistration.pushManager
|
|
174
|
+
.getSubscription()
|
|
175
|
+
.then(function (subscription) {
|
|
176
|
+
// Enable any UI which subscribes / unsubscribes from
|
|
177
|
+
// push messages.
|
|
178
|
+
if (!subscription) {
|
|
179
|
+
subscribe();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// Keep your server in sync with the latest subscription
|
|
183
|
+
updateSubscriptionOnServer(subscription, false);
|
|
184
|
+
})
|
|
185
|
+
.catch((err) => {
|
|
186
|
+
Logger.info(SCOPE_SC_CORE, 'Error during getSubscription()');
|
|
187
|
+
console.log(err);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
Logger.info(SCOPE_SC_CORE, 'Permission for Notifications was denied');
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
227
197
|
/**
|
|
228
|
-
*
|
|
229
|
-
* so your development environment must serve content over HTTPS to match a production environment.
|
|
230
|
-
* Check if push messaging is supported.
|
|
198
|
+
* Initialize state
|
|
231
199
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
200
|
+
const initialiseState = () => {
|
|
201
|
+
/**
|
|
202
|
+
* Check if Notifications supported in the service worker
|
|
203
|
+
*/
|
|
204
|
+
if (!('showNotification' in ServiceWorkerRegistration.prototype)) {
|
|
205
|
+
Logger.info(SCOPE_SC_CORE, "Notifications aren't supported.");
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Features, such as service workers and push notifications, require HTTPS secure domains,
|
|
210
|
+
* so your development environment must serve content over HTTPS to match a production environment.
|
|
211
|
+
* Check if push messaging is supported.
|
|
212
|
+
*/
|
|
213
|
+
if (!('PushManager' in window && 'serviceWorker' in navigator)) {
|
|
214
|
+
Logger.info(SCOPE_SC_CORE, "Service Worker or Push messaging aren't supported.");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Check the current Notification permission.
|
|
219
|
+
* If its denied, it's a permanent block until the user changes the permission
|
|
220
|
+
*/
|
|
221
|
+
if (Notification.permission === 'denied') {
|
|
222
|
+
Logger.info(SCOPE_SC_CORE, 'The user has blocked notifications.');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
if (Notification.permission === 'default') {
|
|
227
|
+
Logger.info(SCOPE_SC_CORE, 'Request permission.');
|
|
228
|
+
requestNotificationPermission();
|
|
229
|
+
}
|
|
230
|
+
else if (Notification.permission === 'granted') {
|
|
231
|
+
subscribe();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
239
235
|
/**
|
|
240
|
-
*
|
|
241
|
-
* If
|
|
236
|
+
* Init state web push subscription
|
|
237
|
+
* If web push enabled, applicationServerKey and user is logged, check subscription
|
|
242
238
|
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
(0, _react.useEffect)(() => {
|
|
266
|
-
if (!wpSubscription && !scContext.settings.notifications.webPushMessaging.disableToastMessage && scUserContext.user) {
|
|
267
|
-
if (!webPushEnabled) {
|
|
268
|
-
_utils.Logger.warn(_Errors.SCOPE_SC_CORE, 'This instance is not configured to support notifications. Enable this feature.');
|
|
269
|
-
} else if (!applicationServerKey) {
|
|
270
|
-
_utils.Logger.warn(_Errors.SCOPE_SC_CORE, 'Invalid or missing applicationServerKey. Check the configuration that is passed to the SCContextProvider.');
|
|
271
|
-
} else {
|
|
272
|
-
initialiseState();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (!scUserContext.user && wpSubscription) {
|
|
277
|
-
// Unsubscribe if user not in session
|
|
278
|
-
unsubscribe();
|
|
279
|
-
}
|
|
280
|
-
}, [scUserContext.user, scContext.settings.notifications.webPushMessaging, wpSubscription]);
|
|
281
|
-
return {
|
|
282
|
-
wpSubscription
|
|
283
|
-
};
|
|
284
|
-
}
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (!wpSubscription && !scContext.settings.notifications.webPushMessaging.disableToastMessage && scUserContext.user) {
|
|
241
|
+
if (!webPushEnabled) {
|
|
242
|
+
Logger.warn(SCOPE_SC_CORE, 'This instance is not configured to support notifications. Enable this feature.');
|
|
243
|
+
}
|
|
244
|
+
else if (!applicationServerKey) {
|
|
245
|
+
Logger.warn(SCOPE_SC_CORE, 'Invalid or missing applicationServerKey. Check the configuration that is passed to the SCContextProvider.');
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
initialiseState();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (!scUserContext.user && wpSubscription) {
|
|
252
|
+
// Unsubscribe if user not in session
|
|
253
|
+
unsubscribe();
|
|
254
|
+
}
|
|
255
|
+
}, [scUserContext.user, scContext.settings.notifications.webPushMessaging, wpSubscription]);
|
|
256
|
+
return { wpSubscription };
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=useSCWebPushMessaging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSCWebPushMessaging.js","sourceRoot":"","sources":["../../../src/hooks/useSCWebPushMessaging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAG9D,OAAO,EAAC,YAAY,EAAC,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,uCAAuC,CAAC;AAChE,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAC,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,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,mBAAmB,IAAI,aAAa,CAAC,IAAI,EAAE;YACnH,IAAI,CAAC,cAAc,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,gFAAgF,CAAC,CAAC;aAC9G;iBAAM,IAAI,CAAC,oBAAoB,EAAE;gBAChC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,2GAA2G,CAAC,CAAC;aACzI;iBAAM;gBACL,eAAe,EAAE,CAAC;aACnB;SACF;QACD,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,cAAc,EAAE;YACzC,qCAAqC;YACrC,WAAW,EAAE,CAAC;SACf;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC,CAAC;IAE5F,OAAO,EAAC,cAAc,EAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { WSClientType } from '@selfcommunity/utils';
|
|
3
|
+
/**
|
|
4
|
+
:::info
|
|
5
|
+
This custom hook is used to to init web socket.
|
|
6
|
+
:::
|
|
7
|
+
*/
|
|
8
|
+
export default function useSCWebSocket(): {
|
|
9
|
+
wsInstance: WSClientType;
|
|
10
|
+
setWsInstance: import("react").Dispatch<import("react").SetStateAction<WSClientType>>;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useSCWebSocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSCWebSocket.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSCWebSocket.ts"],"names":[],"mappings":";AAKA,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAMlD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc;;;EAmGrC"}
|