@selfcommunity/react-core 0.1.7 → 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.
Files changed (395) hide show
  1. package/lib/{types → cjs}/components/provider/SCAlertMessagesProvider/index.d.ts +0 -0
  2. package/lib/{types → cjs}/components/provider/SCAlertMessagesProvider/index.d.ts.map +0 -0
  3. package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js +37 -35
  4. package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js.map +1 -0
  5. package/lib/{types → cjs}/components/provider/SCContextProvider/index.d.ts +0 -0
  6. package/lib/{types → cjs}/components/provider/SCContextProvider/index.d.ts.map +0 -0
  7. package/lib/cjs/components/provider/SCContextProvider/index.js +74 -81
  8. package/lib/cjs/components/provider/SCContextProvider/index.js.map +1 -0
  9. package/lib/{types → cjs}/components/provider/SCLocaleProvider/index.d.ts +0 -0
  10. package/lib/{types → cjs}/components/provider/SCLocaleProvider/index.d.ts.map +0 -0
  11. package/lib/cjs/components/provider/SCLocaleProvider/index.js +86 -121
  12. package/lib/cjs/components/provider/SCLocaleProvider/index.js.map +1 -0
  13. package/lib/{types → cjs}/components/provider/SCNotificationProvider/index.d.ts +0 -0
  14. package/lib/{types → cjs}/components/provider/SCNotificationProvider/index.d.ts.map +0 -0
  15. package/lib/cjs/components/provider/SCNotificationProvider/index.js +41 -41
  16. package/lib/cjs/components/provider/SCNotificationProvider/index.js.map +1 -0
  17. package/lib/{types → cjs}/components/provider/SCPreferencesProvider/index.d.ts +0 -0
  18. package/lib/{types → cjs}/components/provider/SCPreferencesProvider/index.d.ts.map +0 -0
  19. package/lib/cjs/components/provider/SCPreferencesProvider/index.js +61 -62
  20. package/lib/cjs/components/provider/SCPreferencesProvider/index.js.map +1 -0
  21. package/lib/{types → cjs}/components/provider/SCRoutingProvider/index.d.ts +0 -0
  22. package/lib/{types → cjs}/components/provider/SCRoutingProvider/index.d.ts.map +1 -1
  23. package/lib/cjs/components/provider/SCRoutingProvider/index.js +104 -111
  24. package/lib/cjs/components/provider/SCRoutingProvider/index.js.map +1 -0
  25. package/lib/{types → cjs}/components/provider/SCThemeProvider/index.d.ts +0 -0
  26. package/lib/{types → cjs}/components/provider/SCThemeProvider/index.d.ts.map +0 -0
  27. package/lib/cjs/components/provider/SCThemeProvider/index.js +66 -79
  28. package/lib/cjs/components/provider/SCThemeProvider/index.js.map +1 -0
  29. package/lib/{types → cjs}/components/provider/SCUserProvider/index.d.ts +0 -0
  30. package/lib/{types → cjs}/components/provider/SCUserProvider/index.d.ts.map +0 -0
  31. package/lib/cjs/components/provider/SCUserProvider/index.js +215 -270
  32. package/lib/cjs/components/provider/SCUserProvider/index.js.map +1 -0
  33. package/lib/{types → cjs}/components/router/index.d.ts +0 -0
  34. package/lib/{types → cjs}/components/router/index.d.ts.map +0 -0
  35. package/lib/cjs/components/router/index.js +48 -49
  36. package/lib/cjs/components/router/index.js.map +1 -0
  37. package/lib/{types → cjs}/constants/Actions.d.ts +0 -0
  38. package/lib/{types → cjs}/constants/Actions.d.ts.map +0 -0
  39. package/lib/cjs/constants/Actions.js +3 -4
  40. package/lib/cjs/constants/Actions.js.map +1 -0
  41. package/lib/{types → cjs}/constants/ContextProviders.d.ts +0 -0
  42. package/lib/{types → cjs}/constants/ContextProviders.d.ts.map +0 -0
  43. package/lib/cjs/constants/ContextProviders.js +22 -24
  44. package/lib/cjs/constants/ContextProviders.js.map +1 -0
  45. package/lib/{types → cjs}/constants/Device.d.ts +0 -0
  46. package/lib/{types → cjs}/constants/Device.d.ts.map +0 -0
  47. package/lib/cjs/constants/Device.js +3 -5
  48. package/lib/cjs/constants/Device.js.map +1 -0
  49. package/lib/{types → cjs}/constants/Errors.d.ts +0 -0
  50. package/lib/{types → cjs}/constants/Errors.d.ts.map +0 -0
  51. package/lib/cjs/constants/Errors.js +3 -5
  52. package/lib/cjs/constants/Errors.js.map +1 -0
  53. package/lib/{types → cjs}/constants/Features.d.ts +0 -0
  54. package/lib/{types → cjs}/constants/Features.d.ts.map +0 -0
  55. package/lib/cjs/constants/Features.js +43 -83
  56. package/lib/cjs/constants/Features.js.map +1 -0
  57. package/lib/{types → cjs}/constants/Locale.d.ts +0 -0
  58. package/lib/{types → cjs}/constants/Locale.d.ts.map +0 -0
  59. package/lib/cjs/constants/Locale.js +10 -17
  60. package/lib/cjs/constants/Locale.js.map +1 -0
  61. package/lib/{types → cjs}/constants/Notification.d.ts +0 -0
  62. package/lib/{types → cjs}/constants/Notification.d.ts.map +0 -0
  63. package/lib/cjs/constants/Notification.js +44 -53
  64. package/lib/cjs/constants/Notification.js.map +1 -0
  65. package/lib/{types → cjs}/constants/Notifications.d.ts +0 -0
  66. package/lib/{types → cjs}/constants/Notifications.d.ts.map +0 -0
  67. package/lib/cjs/constants/Notifications.js +11 -25
  68. package/lib/cjs/constants/Notifications.js.map +1 -0
  69. package/lib/cjs/constants/Preferences.d.ts +201 -0
  70. package/lib/cjs/constants/Preferences.d.ts.map +1 -0
  71. package/lib/cjs/constants/Preferences.js +184 -292
  72. package/lib/cjs/constants/Preferences.js.map +1 -0
  73. package/lib/{types → cjs}/constants/Routes.d.ts +0 -0
  74. package/lib/{types → cjs}/constants/Routes.d.ts.map +0 -0
  75. package/lib/cjs/constants/Routes.js +38 -59
  76. package/lib/cjs/constants/Routes.js.map +1 -0
  77. package/lib/{types → cjs}/constants/Session.d.ts +0 -0
  78. package/lib/{types → cjs}/constants/Session.d.ts.map +0 -0
  79. package/lib/cjs/constants/Session.js +12 -21
  80. package/lib/cjs/constants/Session.js.map +1 -0
  81. package/lib/{types → cjs}/constants/Theme.d.ts +0 -0
  82. package/lib/{types → cjs}/constants/Theme.d.ts.map +0 -0
  83. package/lib/cjs/constants/Theme.js +3 -4
  84. package/lib/cjs/constants/Theme.js.map +1 -0
  85. package/lib/cjs/constants/WebSocket.d.ts +4 -0
  86. package/lib/cjs/constants/WebSocket.d.ts.map +1 -0
  87. package/lib/cjs/constants/WebSocket.js +6 -9
  88. package/lib/cjs/constants/WebSocket.js.map +1 -0
  89. package/lib/{types → cjs}/hooks/useSCAuth.d.ts +0 -0
  90. package/lib/{types → cjs}/hooks/useSCAuth.d.ts.map +0 -0
  91. package/lib/cjs/hooks/useSCAuth.js +212 -282
  92. package/lib/cjs/hooks/useSCAuth.js.map +1 -0
  93. package/lib/{types → cjs}/hooks/useSCCachingManager.d.ts +0 -0
  94. package/lib/{types → cjs}/hooks/useSCCachingManager.d.ts.map +0 -0
  95. package/lib/cjs/hooks/useSCCachingManager.js +37 -51
  96. package/lib/cjs/hooks/useSCCachingManager.js.map +1 -0
  97. package/lib/{types → cjs}/hooks/useSCConnectionsManager.d.ts +0 -0
  98. package/lib/{types → cjs}/hooks/useSCConnectionsManager.d.ts.map +0 -0
  99. package/lib/cjs/hooks/useSCConnectionsManager.js +190 -254
  100. package/lib/cjs/hooks/useSCConnectionsManager.js.map +1 -0
  101. package/lib/{types → cjs}/hooks/useSCFetchAddressingTagList.d.ts +0 -0
  102. package/lib/{types → cjs}/hooks/useSCFetchAddressingTagList.d.ts.map +0 -0
  103. package/lib/cjs/hooks/useSCFetchAddressingTagList.js +64 -55
  104. package/lib/cjs/hooks/useSCFetchAddressingTagList.js.map +1 -0
  105. package/lib/{types → cjs}/hooks/useSCFetchCategories.d.ts +0 -0
  106. package/lib/{types → cjs}/hooks/useSCFetchCategories.d.ts.map +0 -0
  107. package/lib/cjs/hooks/useSCFetchCategories.js +46 -56
  108. package/lib/cjs/hooks/useSCFetchCategories.js.map +1 -0
  109. package/lib/{types → cjs}/hooks/useSCFetchCategory.d.ts +0 -0
  110. package/lib/{types → cjs}/hooks/useSCFetchCategory.d.ts.map +0 -0
  111. package/lib/cjs/hooks/useSCFetchCategory.js +44 -59
  112. package/lib/cjs/hooks/useSCFetchCategory.js.map +1 -0
  113. package/lib/{types → cjs}/hooks/useSCFetchCommentObject.d.ts +0 -0
  114. package/lib/{types → cjs}/hooks/useSCFetchCommentObject.d.ts.map +0 -0
  115. package/lib/cjs/hooks/useSCFetchCommentObject.js +44 -59
  116. package/lib/cjs/hooks/useSCFetchCommentObject.js.map +1 -0
  117. package/lib/{types → cjs}/hooks/useSCFetchCommentObjects.d.ts +0 -0
  118. package/lib/{types → cjs}/hooks/useSCFetchCommentObjects.d.ts.map +0 -0
  119. package/lib/cjs/hooks/useSCFetchCommentObjects.js +157 -254
  120. package/lib/cjs/hooks/useSCFetchCommentObjects.js.map +1 -0
  121. package/lib/{types → cjs}/hooks/useSCFetchCustomAdv.d.ts +0 -0
  122. package/lib/{types → cjs}/hooks/useSCFetchCustomAdv.d.ts.map +0 -0
  123. package/lib/cjs/hooks/useSCFetchCustomAdv.js +57 -75
  124. package/lib/cjs/hooks/useSCFetchCustomAdv.js.map +1 -0
  125. package/lib/{types → cjs}/hooks/useSCFetchFeedObject.d.ts +0 -0
  126. package/lib/{types → cjs}/hooks/useSCFetchFeedObject.d.ts.map +0 -0
  127. package/lib/cjs/hooks/useSCFetchFeedObject.js +49 -69
  128. package/lib/cjs/hooks/useSCFetchFeedObject.js.map +1 -0
  129. package/lib/{types → cjs}/hooks/useSCFetchIncubator.d.ts +0 -0
  130. package/lib/{types → cjs}/hooks/useSCFetchIncubator.d.ts.map +0 -0
  131. package/lib/cjs/hooks/useSCFetchIncubator.js +44 -59
  132. package/lib/cjs/hooks/useSCFetchIncubator.js.map +1 -0
  133. package/lib/{types → cjs}/hooks/useSCFetchTag.d.ts +0 -0
  134. package/lib/{types → cjs}/hooks/useSCFetchTag.d.ts.map +0 -0
  135. package/lib/cjs/hooks/useSCFetchTag.js +44 -59
  136. package/lib/cjs/hooks/useSCFetchTag.js.map +1 -0
  137. package/lib/{types → cjs}/hooks/useSCFetchUser.d.ts +0 -0
  138. package/lib/{types → cjs}/hooks/useSCFetchUser.d.ts.map +1 -1
  139. package/lib/cjs/hooks/useSCFetchUser.js +47 -59
  140. package/lib/cjs/hooks/useSCFetchUser.js.map +1 -0
  141. package/lib/{types → cjs}/hooks/useSCFollowedCategoriesManager.d.ts +0 -0
  142. package/lib/{types → cjs}/hooks/useSCFollowedCategoriesManager.d.ts.map +0 -0
  143. package/lib/cjs/hooks/useSCFollowedCategoriesManager.js +105 -147
  144. package/lib/cjs/hooks/useSCFollowedCategoriesManager.js.map +1 -0
  145. package/lib/{types → cjs}/hooks/useSCFollowersManager.d.ts +0 -0
  146. package/lib/{types → cjs}/hooks/useSCFollowersManager.d.ts.map +0 -0
  147. package/lib/cjs/hooks/useSCFollowersManager.js +154 -204
  148. package/lib/cjs/hooks/useSCFollowersManager.js.map +1 -0
  149. package/lib/{types → cjs}/hooks/useSCMediaClick.d.ts +0 -0
  150. package/lib/{types → cjs}/hooks/useSCMediaClick.d.ts.map +0 -0
  151. package/lib/cjs/hooks/useSCMediaClick.js +18 -25
  152. package/lib/cjs/hooks/useSCMediaClick.js.map +1 -0
  153. package/lib/{types → cjs}/hooks/useSCSubscribedIncubatorsManager.d.ts +0 -0
  154. package/lib/{types → cjs}/hooks/useSCSubscribedIncubatorsManager.d.ts.map +0 -0
  155. package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js +118 -148
  156. package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js.map +1 -0
  157. package/lib/{types → cjs}/hooks/useSCWebPushMessaging.d.ts +0 -0
  158. package/lib/{types → cjs}/hooks/useSCWebPushMessaging.d.ts.map +0 -0
  159. package/lib/cjs/hooks/useSCWebPushMessaging.js +268 -268
  160. package/lib/cjs/hooks/useSCWebPushMessaging.js.map +1 -0
  161. package/lib/{types → cjs}/hooks/useSCWebSocket.d.ts +0 -0
  162. package/lib/{types → cjs}/hooks/useSCWebSocket.d.ts.map +0 -0
  163. package/lib/cjs/hooks/useSCWebSocket.js +103 -125
  164. package/lib/cjs/hooks/useSCWebSocket.js.map +1 -0
  165. package/lib/{types → cjs}/index.d.ts +0 -0
  166. package/lib/{types → cjs}/index.d.ts.map +0 -0
  167. package/lib/cjs/index.js +131 -144
  168. package/lib/cjs/index.js.map +1 -0
  169. package/lib/cjs/themes/theme.d.ts +9 -0
  170. package/lib/cjs/themes/theme.d.ts.map +1 -0
  171. package/lib/cjs/themes/theme.js +132 -143
  172. package/lib/cjs/themes/theme.js.map +1 -0
  173. package/lib/{types → cjs}/types/context.d.ts +0 -0
  174. package/lib/{types → cjs}/types/context.d.ts.map +0 -0
  175. package/lib/cjs/types/context.js +2 -2
  176. package/lib/cjs/types/context.js.map +1 -0
  177. package/lib/{types → cjs}/types/index.d.ts +0 -0
  178. package/lib/{types → cjs}/types/index.d.ts.map +0 -0
  179. package/lib/cjs/types/index.js +2 -21
  180. package/lib/cjs/types/index.js.map +1 -0
  181. package/lib/{types → cjs}/utils/errors.d.ts +0 -0
  182. package/lib/{types → cjs}/utils/errors.d.ts.map +0 -0
  183. package/lib/cjs/utils/errors.js +138 -149
  184. package/lib/cjs/utils/errors.js.map +1 -0
  185. package/lib/{types → cjs}/utils/locale.d.ts +0 -0
  186. package/lib/{types → cjs}/utils/locale.d.ts.map +0 -0
  187. package/lib/cjs/utils/locale.js +32 -48
  188. package/lib/cjs/utils/locale.js.map +1 -0
  189. package/lib/{types → cjs}/utils/user.d.ts +0 -0
  190. package/lib/{types → cjs}/utils/user.d.ts.map +0 -0
  191. package/lib/cjs/utils/user.js +25 -40
  192. package/lib/cjs/utils/user.js.map +1 -0
  193. package/lib/{types → cjs}/utils/validator.d.ts +0 -0
  194. package/lib/{types → cjs}/utils/validator.d.ts.map +0 -0
  195. package/lib/cjs/utils/validator.js +386 -576
  196. package/lib/cjs/utils/validator.js.map +1 -0
  197. package/lib/esm/components/provider/SCAlertMessagesProvider/index.d.ts +37 -0
  198. package/lib/esm/components/provider/SCAlertMessagesProvider/index.d.ts.map +1 -0
  199. package/lib/esm/components/provider/SCAlertMessagesProvider/index.js +11 -37
  200. package/lib/esm/components/provider/SCAlertMessagesProvider/index.js.map +1 -0
  201. package/lib/esm/components/provider/SCContextProvider/index.d.ts +35 -0
  202. package/lib/esm/components/provider/SCContextProvider/index.d.ts.map +1 -0
  203. package/lib/esm/components/provider/SCContextProvider/index.js +48 -83
  204. package/lib/esm/components/provider/SCContextProvider/index.js.map +1 -0
  205. package/lib/esm/components/provider/SCLocaleProvider/index.d.ts +42 -0
  206. package/lib/esm/components/provider/SCLocaleProvider/index.d.ts.map +1 -0
  207. package/lib/esm/components/provider/SCLocaleProvider/index.js +59 -123
  208. package/lib/esm/components/provider/SCLocaleProvider/index.js.map +1 -0
  209. package/lib/esm/components/provider/SCNotificationProvider/index.d.ts +37 -0
  210. package/lib/esm/components/provider/SCNotificationProvider/index.d.ts.map +1 -0
  211. package/lib/esm/components/provider/SCNotificationProvider/index.js +12 -43
  212. package/lib/esm/components/provider/SCNotificationProvider/index.js.map +1 -0
  213. package/lib/esm/components/provider/SCPreferencesProvider/index.d.ts +38 -0
  214. package/lib/esm/components/provider/SCPreferencesProvider/index.d.ts.map +1 -0
  215. package/lib/esm/components/provider/SCPreferencesProvider/index.js +35 -64
  216. package/lib/esm/components/provider/SCPreferencesProvider/index.js.map +1 -0
  217. package/lib/esm/components/provider/SCRoutingProvider/index.d.ts +39 -0
  218. package/lib/esm/components/provider/SCRoutingProvider/index.d.ts.map +1 -0
  219. package/lib/esm/components/provider/SCRoutingProvider/index.js +78 -113
  220. package/lib/esm/components/provider/SCRoutingProvider/index.js.map +1 -0
  221. package/lib/esm/components/provider/SCThemeProvider/index.d.ts +49 -0
  222. package/lib/esm/components/provider/SCThemeProvider/index.d.ts.map +1 -0
  223. package/lib/esm/components/provider/SCThemeProvider/index.js +36 -81
  224. package/lib/esm/components/provider/SCThemeProvider/index.js.map +1 -0
  225. package/lib/esm/components/provider/SCUserProvider/index.d.ts +38 -0
  226. package/lib/esm/components/provider/SCUserProvider/index.d.ts.map +1 -0
  227. package/lib/esm/components/provider/SCUserProvider/index.js +186 -272
  228. package/lib/esm/components/provider/SCUserProvider/index.js.map +1 -0
  229. package/lib/esm/components/router/index.d.ts +34 -0
  230. package/lib/esm/components/router/index.d.ts.map +1 -0
  231. package/lib/esm/components/router/index.js +24 -50
  232. package/lib/esm/components/router/index.js.map +1 -0
  233. package/lib/esm/constants/Actions.d.ts +2 -0
  234. package/lib/esm/constants/Actions.d.ts.map +1 -0
  235. package/lib/esm/constants/Actions.js +2 -6
  236. package/lib/esm/constants/Actions.js.map +1 -0
  237. package/lib/esm/constants/ContextProviders.d.ts +6 -0
  238. package/lib/esm/constants/ContextProviders.d.ts.map +1 -0
  239. package/lib/esm/constants/ContextProviders.js +18 -26
  240. package/lib/esm/constants/ContextProviders.js.map +1 -0
  241. package/lib/esm/constants/Device.d.ts +6 -0
  242. package/lib/esm/constants/Device.d.ts.map +1 -0
  243. package/lib/esm/constants/Device.js +2 -7
  244. package/lib/esm/constants/Device.js.map +1 -0
  245. package/lib/esm/constants/Errors.d.ts +5 -0
  246. package/lib/esm/constants/Errors.d.ts.map +1 -0
  247. package/lib/esm/constants/Errors.js +2 -7
  248. package/lib/esm/constants/Errors.js.map +1 -0
  249. package/lib/esm/constants/Features.d.ts +41 -0
  250. package/lib/esm/constants/Features.d.ts.map +1 -0
  251. package/lib/esm/constants/Features.js +41 -84
  252. package/lib/esm/constants/Features.js.map +1 -0
  253. package/lib/esm/constants/Locale.d.ts +8 -0
  254. package/lib/esm/constants/Locale.d.ts.map +1 -0
  255. package/lib/esm/constants/Locale.js +8 -18
  256. package/lib/esm/constants/Locale.js.map +1 -0
  257. package/lib/esm/constants/Notification.d.ts +55 -0
  258. package/lib/esm/constants/Notification.d.ts.map +1 -0
  259. package/lib/esm/constants/Notification.js +42 -54
  260. package/lib/esm/constants/Notification.js.map +1 -0
  261. package/lib/esm/constants/Notifications.d.ts +11 -0
  262. package/lib/esm/constants/Notifications.d.ts.map +1 -0
  263. package/lib/esm/constants/Notifications.js +9 -26
  264. package/lib/esm/constants/Notifications.js.map +1 -0
  265. package/lib/esm/constants/Preferences.d.ts +201 -0
  266. package/lib/esm/constants/Preferences.d.ts.map +1 -0
  267. package/lib/esm/constants/Preferences.js +181 -296
  268. package/lib/esm/constants/Preferences.js.map +1 -0
  269. package/lib/esm/constants/Routes.d.ts +29 -0
  270. package/lib/esm/constants/Routes.d.ts.map +1 -0
  271. package/lib/esm/constants/Routes.js +36 -60
  272. package/lib/esm/constants/Routes.js.map +1 -0
  273. package/lib/esm/constants/Session.d.ts +10 -0
  274. package/lib/esm/constants/Session.d.ts.map +1 -0
  275. package/lib/esm/constants/Session.js +10 -22
  276. package/lib/esm/constants/Session.js.map +1 -0
  277. package/lib/esm/constants/Theme.d.ts +2 -0
  278. package/lib/esm/constants/Theme.d.ts.map +1 -0
  279. package/lib/esm/constants/Theme.js +2 -6
  280. package/lib/esm/constants/Theme.js.map +1 -0
  281. package/lib/esm/constants/WebSocket.d.ts +4 -0
  282. package/lib/esm/constants/WebSocket.d.ts.map +1 -0
  283. package/lib/esm/constants/WebSocket.js +4 -10
  284. package/lib/esm/constants/WebSocket.js.map +1 -0
  285. package/lib/esm/hooks/useSCAuth.d.ts +56 -0
  286. package/lib/esm/hooks/useSCAuth.d.ts.map +1 -0
  287. package/lib/esm/hooks/useSCAuth.js +185 -285
  288. package/lib/esm/hooks/useSCAuth.js.map +1 -0
  289. package/lib/esm/hooks/useSCCachingManager.d.ts +19 -0
  290. package/lib/esm/hooks/useSCCachingManager.d.ts.map +1 -0
  291. package/lib/esm/hooks/useSCCachingManager.js +36 -53
  292. package/lib/esm/hooks/useSCCachingManager.js.map +1 -0
  293. package/lib/esm/hooks/useSCConnectionsManager.d.ts +40 -0
  294. package/lib/esm/hooks/useSCConnectionsManager.d.ts.map +1 -0
  295. package/lib/esm/hooks/useSCConnectionsManager.js +186 -256
  296. package/lib/esm/hooks/useSCConnectionsManager.js.map +1 -0
  297. package/lib/esm/hooks/useSCFetchAddressingTagList.d.ts +14 -0
  298. package/lib/esm/hooks/useSCFetchAddressingTagList.d.ts.map +1 -0
  299. package/lib/esm/hooks/useSCFetchAddressingTagList.js +39 -56
  300. package/lib/esm/hooks/useSCFetchAddressingTagList.js.map +1 -0
  301. package/lib/esm/hooks/useSCFetchCategories.d.ts +17 -0
  302. package/lib/esm/hooks/useSCFetchCategories.d.ts.map +1 -0
  303. package/lib/esm/hooks/useSCFetchCategories.js +45 -57
  304. package/lib/esm/hooks/useSCFetchCategories.js.map +1 -0
  305. package/lib/esm/hooks/useSCFetchCategory.d.ts +19 -0
  306. package/lib/esm/hooks/useSCFetchCategory.d.ts.map +1 -0
  307. package/lib/esm/hooks/useSCFetchCategory.js +42 -60
  308. package/lib/esm/hooks/useSCFetchCategory.js.map +1 -0
  309. package/lib/esm/hooks/useSCFetchCommentObject.d.ts +19 -0
  310. package/lib/esm/hooks/useSCFetchCommentObject.d.ts.map +1 -0
  311. package/lib/esm/hooks/useSCFetchCommentObject.js +42 -60
  312. package/lib/esm/hooks/useSCFetchCommentObject.js.map +1 -0
  313. package/lib/esm/hooks/useSCFetchCommentObjects.d.ts +53 -0
  314. package/lib/esm/hooks/useSCFetchCommentObjects.d.ts.map +1 -0
  315. package/lib/esm/hooks/useSCFetchCommentObjects.js +153 -257
  316. package/lib/esm/hooks/useSCFetchCommentObjects.js.map +1 -0
  317. package/lib/esm/hooks/useSCFetchCustomAdv.d.ts +19 -0
  318. package/lib/esm/hooks/useSCFetchCustomAdv.d.ts.map +1 -0
  319. package/lib/esm/hooks/useSCFetchCustomAdv.js +55 -76
  320. package/lib/esm/hooks/useSCFetchCustomAdv.js.map +1 -0
  321. package/lib/esm/hooks/useSCFetchFeedObject.d.ts +21 -0
  322. package/lib/esm/hooks/useSCFetchFeedObject.d.ts.map +1 -0
  323. package/lib/esm/hooks/useSCFetchFeedObject.js +47 -70
  324. package/lib/esm/hooks/useSCFetchFeedObject.js.map +1 -0
  325. package/lib/esm/hooks/useSCFetchIncubator.d.ts +19 -0
  326. package/lib/esm/hooks/useSCFetchIncubator.d.ts.map +1 -0
  327. package/lib/esm/hooks/useSCFetchIncubator.js +42 -60
  328. package/lib/esm/hooks/useSCFetchIncubator.js.map +1 -0
  329. package/lib/esm/hooks/useSCFetchTag.d.ts +19 -0
  330. package/lib/esm/hooks/useSCFetchTag.d.ts.map +1 -0
  331. package/lib/esm/hooks/useSCFetchTag.js +42 -60
  332. package/lib/esm/hooks/useSCFetchTag.js.map +1 -0
  333. package/lib/esm/hooks/useSCFetchUser.d.ts +19 -0
  334. package/lib/esm/hooks/useSCFetchUser.d.ts.map +1 -0
  335. package/lib/esm/hooks/useSCFetchUser.js +45 -60
  336. package/lib/esm/hooks/useSCFetchUser.js.map +1 -0
  337. package/lib/esm/hooks/useSCFollowedCategoriesManager.d.ts +37 -0
  338. package/lib/esm/hooks/useSCFollowedCategoriesManager.d.ts.map +1 -0
  339. package/lib/esm/hooks/useSCFollowedCategoriesManager.js +101 -149
  340. package/lib/esm/hooks/useSCFollowedCategoriesManager.js.map +1 -0
  341. package/lib/esm/hooks/useSCFollowersManager.d.ts +37 -0
  342. package/lib/esm/hooks/useSCFollowersManager.d.ts.map +1 -0
  343. package/lib/esm/hooks/useSCFollowersManager.js +150 -206
  344. package/lib/esm/hooks/useSCFollowersManager.js.map +1 -0
  345. package/lib/esm/hooks/useSCMediaClick.d.ts +4 -0
  346. package/lib/esm/hooks/useSCMediaClick.d.ts.map +1 -0
  347. package/lib/esm/hooks/useSCMediaClick.js +17 -27
  348. package/lib/esm/hooks/useSCMediaClick.js.map +1 -0
  349. package/lib/esm/hooks/useSCSubscribedIncubatorsManager.d.ts +27 -0
  350. package/lib/esm/hooks/useSCSubscribedIncubatorsManager.d.ts.map +1 -0
  351. package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js +114 -150
  352. package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js.map +1 -0
  353. package/lib/esm/hooks/useSCWebPushMessaging.d.ts +9 -0
  354. package/lib/esm/hooks/useSCWebPushMessaging.d.ts.map +1 -0
  355. package/lib/esm/hooks/useSCWebPushMessaging.js +244 -270
  356. package/lib/esm/hooks/useSCWebPushMessaging.js.map +1 -0
  357. package/lib/esm/hooks/useSCWebSocket.d.ts +12 -0
  358. package/lib/esm/hooks/useSCWebSocket.d.ts.map +1 -0
  359. package/lib/esm/hooks/useSCWebSocket.js +99 -127
  360. package/lib/esm/hooks/useSCWebSocket.js.map +1 -0
  361. package/lib/esm/index.d.ts +73 -0
  362. package/lib/esm/index.d.ts.map +1 -0
  363. package/lib/esm/index.js +69 -151
  364. package/lib/esm/index.js.map +1 -0
  365. package/lib/esm/themes/theme.d.ts +9 -0
  366. package/lib/esm/themes/theme.d.ts.map +1 -0
  367. package/lib/esm/themes/theme.js +128 -144
  368. package/lib/esm/themes/theme.js.map +1 -0
  369. package/lib/esm/types/context.d.ts +428 -0
  370. package/lib/esm/types/context.d.ts.map +1 -0
  371. package/lib/esm/types/context.js +2 -3
  372. package/lib/esm/types/context.js.map +1 -0
  373. package/lib/esm/types/index.d.ts +3 -0
  374. package/lib/esm/types/index.d.ts.map +1 -0
  375. package/lib/esm/types/index.js +2 -22
  376. package/lib/esm/types/index.js.map +1 -0
  377. package/lib/esm/utils/errors.d.ts +98 -0
  378. package/lib/esm/utils/errors.d.ts.map +1 -0
  379. package/lib/esm/utils/errors.js +114 -155
  380. package/lib/esm/utils/errors.js.map +1 -0
  381. package/lib/esm/utils/locale.d.ts +10 -0
  382. package/lib/esm/utils/locale.d.ts.map +1 -0
  383. package/lib/esm/utils/locale.js +27 -50
  384. package/lib/esm/utils/locale.js.map +1 -0
  385. package/lib/esm/utils/user.d.ts +41 -0
  386. package/lib/esm/utils/user.d.ts.map +1 -0
  387. package/lib/esm/utils/user.js +23 -46
  388. package/lib/esm/utils/user.js.map +1 -0
  389. package/lib/esm/utils/validator.d.ts +239 -0
  390. package/lib/esm/utils/validator.d.ts.map +1 -0
  391. package/lib/esm/utils/validator.js +352 -588
  392. package/lib/esm/utils/validator.js.map +1 -0
  393. package/lib/umd/react-core.js +1 -1
  394. package/package.json +9 -11
  395. package/lib/types/tsconfig.build.tsbuildinfo +0 -1
@@ -1,284 +1,258 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = useSCWebPushMessaging;
5
-
6
- var _react = require("react");
7
-
8
- var _SCContextProvider = require("../components/provider/SCContextProvider");
9
-
10
- var _SCUserProvider = require("../components/provider/SCUserProvider");
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
- // CONTEXT
35
- const scContext = (0, _SCContextProvider.useSCContext)();
36
- const scUserContext = (0, _SCUserProvider.useSCUser)();
37
- const scPreferencesContext = (0, _react.useContext)(_SCPreferencesProvider.SCPreferencesContext); // STATE
38
-
39
- const [wpSubscription, setWpSubscription] = (0, _react.useState)(null); // REFS
40
-
41
- const subAttempts = (0, _react.useRef)(0); // CONST
42
-
43
- const applicationServerKey = scContext.settings.notifications.webPushMessaging.applicationServerKey !== undefined ? scContext.settings.notifications.webPushMessaging.applicationServerKey : SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY in scPreferencesContext.preferences ? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY].value : null;
44
- const webPushEnabled = SCPreferences.PROVIDERS_WEB_PUSH_ENABLED in scPreferencesContext.preferences && scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value ? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value : false;
45
- /**
46
- * perform update the Subscription
47
- * @param data
48
- * @param remove
49
- */
50
-
51
- const performUpdateSubscription = (data, remove) => {
52
- const url = remove ? _apiServices.Endpoints.DeleteDevice.url({
53
- type: _Device.WEB_PUSH_NOTIFICATION_DEVICE_TYPE,
54
- id: data.registration_id
55
- }) : _apiServices.Endpoints.NewDevice.url({
56
- type: _Device.WEB_PUSH_NOTIFICATION_DEVICE_TYPE
57
- });
58
- const method = remove ? _apiServices.Endpoints.DeleteDevice.method : _apiServices.Endpoints.NewDevice.method;
59
- return _apiServices.http.request(Object.assign({
60
- url,
61
- method
62
- }, remove ? {} : {
63
- data: data
64
- })).then(res => {
65
- if (res.status >= 300) {
66
- return Promise.reject(res);
67
- }
68
-
69
- return Promise.resolve(res.data);
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
- return performUpdateSubscription(data, remove).then(res => {
90
- if (remove) {
91
- setWpSubscription(null);
92
- } else {
93
- setWpSubscription(res);
94
- }
95
- }).catch(e => {
96
- _utils.Logger.error(_Errors.SCOPE_SC_CORE, e);
97
- });
98
- };
99
- /**
100
- * Unsubscribe
101
- * @param callback
102
- */
103
-
104
-
105
- const unsubscribe = (callback = null) => {
106
- navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
107
- // To unsubscribe from push messaging, you need get the
108
- // subcription object, which you can call unsubscribe() on.
109
- serviceWorkerRegistration.pushManager.getSubscription().then(pushSubscription => {
110
- // Check we have a subscription to unsubscribe
111
- if (!pushSubscription) {
112
- // No subscription object, so set the state
113
- // to allow the user to subscribe to push
114
- return;
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
- }).catch(function (e) {
137
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, `Error thrown while unsubscribing from push messaging. ${e}`);
138
- });
139
- });
140
- };
141
- /**
142
- * Get subscription
143
- */
144
-
145
-
146
- const subscribe = () => {
147
- navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
148
- serviceWorkerRegistration.pushManager.subscribe({
149
- userVisibleOnly: true,
150
- applicationServerKey: (0, _utils.urlB64ToUint8Array)(applicationServerKey)
151
- }).then(function (subscription) {
152
- if (!subscription) {
153
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, 'We aren’t subscribed to push.');
154
- } else {
155
- updateSubscriptionOnServer(subscription, false);
156
- }
157
- }).catch(function (e) {
158
- if (Notification.permission === 'denied') {
159
- // The user denied the notification permission which
160
- // means we failed to subscribe and the user will need
161
- // to manually change the notification permission to
162
- // subscribe to push messages
163
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, 'Permission for Notifications was denied');
164
- } else {
165
- // A problem occurred with the subscription
166
- subAttempts.current += 1;
167
-
168
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, `Unable to subscribe(${subAttempts.current}) to push. ${e}`);
169
-
170
- if (subAttempts.current < 3) {
171
- unsubscribe(() => subscribe());
172
- } else {
173
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, `Unable to subscribe to push. ${e}`);
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
- } else {
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 = () => {
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
- * Check if Notifications supported in the service worker
164
+ * Request web push notification permission
165
+ * @type {(function(): void)|*}
221
166
  */
222
- if (!('showNotification' in ServiceWorkerRegistration.prototype)) {
223
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, "Notifications aren't supported.");
224
-
225
- return;
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
- * Features, such as service workers and push notifications, require HTTPS secure domains,
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
- if (!('PushManager' in window && 'serviceWorker' in navigator)) {
235
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, "Service Worker or Push messaging aren't supported.");
236
-
237
- return;
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
- * Check the current Notification permission.
241
- * If its denied, it's a permanent block until the user changes the permission
236
+ * Init state web push subscription
237
+ * If web push enabled, applicationServerKey and user is logged, check subscription
242
238
  */
243
-
244
-
245
- if (Notification.permission === 'denied') {
246
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, 'The user has blocked notifications.');
247
-
248
- return;
249
- } else {
250
- if (Notification.permission === 'default') {
251
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, 'Request permission.');
252
-
253
- requestNotificationPermission();
254
- } else if (Notification.permission === 'granted') {
255
- subscribe();
256
- }
257
- }
258
- };
259
- /**
260
- * Init state web push subscription
261
- * If web push enabled, applicationServerKey and user is logged, check subscription
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,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAC,IAAI,EAAE,SAAS,EAAe,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAC,iCAAiC,EAAC,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,8CAA8C,CAAC;AAClF,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB;IAC3C,UA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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"}