@selfcommunity/react-core 0.1.7 → 0.1.8-alpha.2
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,284 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const react_1 = require("react");
|
|
27
|
+
const SCContextProvider_1 = require("../components/provider/SCContextProvider");
|
|
28
|
+
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
29
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
30
|
+
const utils_2 = require("@selfcommunity/utils");
|
|
31
|
+
const Errors_1 = require("../constants/Errors");
|
|
32
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
33
|
+
const Device_1 = require("../constants/Device");
|
|
34
|
+
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
35
|
+
const SCPreferences = __importStar(require("../constants/Preferences"));
|
|
28
36
|
/**
|
|
29
37
|
:::info
|
|
30
38
|
This custom hook is used to to init web push messaging.
|
|
31
39
|
:::
|
|
32
40
|
*/
|
|
33
41
|
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
|
|
42
|
+
// CONTEXT
|
|
43
|
+
const scContext = (0, SCContextProvider_1.useSCContext)();
|
|
44
|
+
const scUserContext = (0, SCUserProvider_1.useSCUser)();
|
|
45
|
+
const scPreferencesContext = (0, react_1.useContext)(SCPreferencesProvider_1.SCPreferencesContext);
|
|
46
|
+
// STATE
|
|
47
|
+
const [wpSubscription, setWpSubscription] = (0, react_1.useState)(null);
|
|
48
|
+
// REFS
|
|
49
|
+
const subAttempts = (0, react_1.useRef)(0);
|
|
50
|
+
// CONST
|
|
51
|
+
const applicationServerKey = scContext.settings.notifications.webPushMessaging.applicationServerKey !== undefined
|
|
52
|
+
? scContext.settings.notifications.webPushMessaging.applicationServerKey
|
|
53
|
+
: SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY in scPreferencesContext.preferences
|
|
54
|
+
? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY].value
|
|
55
|
+
: null;
|
|
56
|
+
const webPushEnabled = SCPreferences.PROVIDERS_WEB_PUSH_ENABLED in scPreferencesContext.preferences &&
|
|
57
|
+
scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value
|
|
58
|
+
? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value
|
|
59
|
+
: false;
|
|
60
|
+
/**
|
|
61
|
+
* perform update the Subscription
|
|
62
|
+
* @param data
|
|
63
|
+
* @param remove
|
|
64
|
+
*/
|
|
65
|
+
const performUpdateSubscription = (data, remove) => {
|
|
66
|
+
const url = remove
|
|
67
|
+
? api_services_1.Endpoints.DeleteDevice.url({ type: Device_1.WEB_PUSH_NOTIFICATION_DEVICE_TYPE, id: data.registration_id })
|
|
68
|
+
: api_services_1.Endpoints.NewDevice.url({ type: Device_1.WEB_PUSH_NOTIFICATION_DEVICE_TYPE });
|
|
69
|
+
const method = remove ? api_services_1.Endpoints.DeleteDevice.method : api_services_1.Endpoints.NewDevice.method;
|
|
70
|
+
return api_services_1.http
|
|
71
|
+
.request(Object.assign({ url,
|
|
72
|
+
method }, (remove ? {} : { data: data })))
|
|
73
|
+
.then((res) => {
|
|
74
|
+
if (res.status >= 300) {
|
|
75
|
+
return Promise.reject(res);
|
|
76
|
+
}
|
|
77
|
+
return Promise.resolve(res.data);
|
|
78
|
+
});
|
|
88
79
|
};
|
|
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);
|
|
80
|
+
/**
|
|
81
|
+
* updateSubscriptionOnServer to sync current subscription
|
|
82
|
+
* @param sub
|
|
83
|
+
*/
|
|
84
|
+
const updateSubscriptionOnServer = (sub, remove) => {
|
|
85
|
+
const browser = (0, utils_2.loadVersionBrowser)();
|
|
86
|
+
const endpointParts = sub.endpoint.split('/');
|
|
87
|
+
const registration_id = endpointParts[endpointParts.length - 1];
|
|
88
|
+
const data = {
|
|
89
|
+
browser: browser.name.toUpperCase(),
|
|
90
|
+
p256dh: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('p256dh')))),
|
|
91
|
+
auth: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('auth')))),
|
|
92
|
+
user: scUserContext.user ? scUserContext.user.username : '',
|
|
93
|
+
registration_id: registration_id,
|
|
94
|
+
};
|
|
95
|
+
return performUpdateSubscription(data, remove)
|
|
96
|
+
.then((res) => {
|
|
97
|
+
if (remove) {
|
|
98
|
+
setWpSubscription(null);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
setWpSubscription(res);
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.catch((e) => {
|
|
105
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, e);
|
|
135
106
|
});
|
|
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);
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Unsubscribe
|
|
110
|
+
* @param callback
|
|
111
|
+
*/
|
|
112
|
+
const unsubscribe = (callback = null) => {
|
|
113
|
+
navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
|
|
114
|
+
// To unsubscribe from push messaging, you need get the
|
|
115
|
+
// subcription object, which you can call unsubscribe() on.
|
|
116
|
+
serviceWorkerRegistration.pushManager
|
|
117
|
+
.getSubscription()
|
|
118
|
+
.then((pushSubscription) => {
|
|
119
|
+
// Check we have a subscription to unsubscribe
|
|
120
|
+
if (!pushSubscription) {
|
|
121
|
+
// No subscription object, so set the state
|
|
122
|
+
// to allow the user to subscribe to push
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// We have a subscription, so call unsubscribe on it
|
|
126
|
+
pushSubscription
|
|
127
|
+
.unsubscribe()
|
|
128
|
+
.then(() => {
|
|
129
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, 'Unsubscription successfully');
|
|
130
|
+
// Request to server to remove
|
|
131
|
+
// the users data from your data store so you
|
|
132
|
+
// don't attempt to send them push messages anymore
|
|
133
|
+
updateSubscriptionOnServer(pushSubscription, true).then(() => {
|
|
134
|
+
callback && callback();
|
|
135
|
+
});
|
|
136
|
+
})
|
|
137
|
+
.catch(function (e) {
|
|
138
|
+
// We failed to unsubscribe, this can lead to
|
|
139
|
+
// an unusual state, so may be best to remove
|
|
140
|
+
// the subscription id from your data store and
|
|
141
|
+
// inform the user that you disabled push
|
|
142
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, `Unsubscription error.`);
|
|
143
|
+
console.log(e);
|
|
144
|
+
});
|
|
145
|
+
})
|
|
146
|
+
.catch(function (e) {
|
|
147
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, `Error thrown while unsubscribing from push messaging. ${e}`);
|
|
205
148
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
_utils.Logger.info(_Errors.SCOPE_SC_CORE, 'Permission for Notifications was denied');
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Initialize state
|
|
215
|
-
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const initialiseState = () => {
|
|
149
|
+
});
|
|
150
|
+
};
|
|
219
151
|
/**
|
|
220
|
-
*
|
|
152
|
+
* Get subscription
|
|
221
153
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
154
|
+
const subscribe = () => {
|
|
155
|
+
navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
|
|
156
|
+
serviceWorkerRegistration.pushManager
|
|
157
|
+
.subscribe({ userVisibleOnly: true, applicationServerKey: (0, utils_2.urlB64ToUint8Array)(applicationServerKey) })
|
|
158
|
+
.then(function (subscription) {
|
|
159
|
+
if (!subscription) {
|
|
160
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, 'We aren’t subscribed to push.');
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
updateSubscriptionOnServer(subscription, false);
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
.catch(function (e) {
|
|
167
|
+
if (Notification.permission === 'denied') {
|
|
168
|
+
// The user denied the notification permission which
|
|
169
|
+
// means we failed to subscribe and the user will need
|
|
170
|
+
// to manually change the notification permission to
|
|
171
|
+
// subscribe to push messages
|
|
172
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, 'Permission for Notifications was denied');
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
// A problem occurred with the subscription
|
|
176
|
+
subAttempts.current += 1;
|
|
177
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, `Unable to subscribe(${subAttempts.current}) to push. ${e}`);
|
|
178
|
+
if (subAttempts.current < 3) {
|
|
179
|
+
unsubscribe(() => subscribe());
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, `Unable to subscribe to push. ${e}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
};
|
|
227
188
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* Check if push messaging is supported.
|
|
189
|
+
* Request web push notification permission
|
|
190
|
+
* @type {(function(): void)|*}
|
|
231
191
|
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
192
|
+
const requestNotificationPermission = () => {
|
|
193
|
+
if (Notification.permission !== 'granted') {
|
|
194
|
+
Notification.requestPermission().then(function (permission) {
|
|
195
|
+
if (permission === 'granted') {
|
|
196
|
+
navigator.serviceWorker.ready.then((serviceWorkerRegistration) => {
|
|
197
|
+
// Do we already have a push message subscription?
|
|
198
|
+
serviceWorkerRegistration.pushManager
|
|
199
|
+
.getSubscription()
|
|
200
|
+
.then(function (subscription) {
|
|
201
|
+
// Enable any UI which subscribes / unsubscribes from
|
|
202
|
+
// push messages.
|
|
203
|
+
if (!subscription) {
|
|
204
|
+
subscribe();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
// Keep your server in sync with the latest subscription
|
|
208
|
+
updateSubscriptionOnServer(subscription, false);
|
|
209
|
+
})
|
|
210
|
+
.catch((err) => {
|
|
211
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, 'Error during getSubscription()');
|
|
212
|
+
console.log(err);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, 'Permission for Notifications was denied');
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
};
|
|
239
222
|
/**
|
|
240
|
-
*
|
|
241
|
-
* If its denied, it's a permanent block until the user changes the permission
|
|
223
|
+
* Initialize state
|
|
242
224
|
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
225
|
+
const initialiseState = () => {
|
|
226
|
+
/**
|
|
227
|
+
* Check if Notifications supported in the service worker
|
|
228
|
+
*/
|
|
229
|
+
if (!('showNotification' in ServiceWorkerRegistration.prototype)) {
|
|
230
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, "Notifications aren't supported.");
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Features, such as service workers and push notifications, require HTTPS secure domains,
|
|
235
|
+
* so your development environment must serve content over HTTPS to match a production environment.
|
|
236
|
+
* Check if push messaging is supported.
|
|
237
|
+
*/
|
|
238
|
+
if (!('PushManager' in window && 'serviceWorker' in navigator)) {
|
|
239
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, "Service Worker or Push messaging aren't supported.");
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Check the current Notification permission.
|
|
244
|
+
* If its denied, it's a permanent block until the user changes the permission
|
|
245
|
+
*/
|
|
246
|
+
if (Notification.permission === 'denied') {
|
|
247
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, 'The user has blocked notifications.');
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
if (Notification.permission === 'default') {
|
|
252
|
+
utils_1.Logger.info(Errors_1.SCOPE_SC_CORE, 'Request permission.');
|
|
253
|
+
requestNotificationPermission();
|
|
254
|
+
}
|
|
255
|
+
else if (Notification.permission === 'granted') {
|
|
256
|
+
subscribe();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Init state web push subscription
|
|
262
|
+
* If web push enabled, applicationServerKey and user is logged, check subscription
|
|
263
|
+
*/
|
|
264
|
+
(0, react_1.useEffect)(() => {
|
|
265
|
+
if (!wpSubscription && !scContext.settings.notifications.webPushMessaging.disableToastMessage && scUserContext.user) {
|
|
266
|
+
if (!webPushEnabled) {
|
|
267
|
+
utils_1.Logger.warn(Errors_1.SCOPE_SC_CORE, 'This instance is not configured to support notifications. Enable this feature.');
|
|
268
|
+
}
|
|
269
|
+
else if (!applicationServerKey) {
|
|
270
|
+
utils_1.Logger.warn(Errors_1.SCOPE_SC_CORE, 'Invalid or missing applicationServerKey. Check the configuration that is passed to the SCContextProvider.');
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
initialiseState();
|
|
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 { wpSubscription };
|
|
282
|
+
}
|
|
283
|
+
exports.default = useSCWebPushMessaging;
|
|
284
|
+
//# sourceMappingURL=useSCWebPushMessaging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSCWebPushMessaging.js","sourceRoot":"","sources":["../../../src/hooks/useSCWebPushMessaging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA8D;AAG9D,gFAAsE;AACtE,0EAAgE;AAChE,gDAA4C;AAC5C,gDAA4E;AAC5E,gDAAkD;AAClD,8DAA0E;AAC1E,gDAAsE;AACtE,wFAAkF;AA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