@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.
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,284 @@
1
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
-
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
- // 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
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
- 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);
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
- }).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);
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
- } 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 = () => {
149
+ });
150
+ };
219
151
  /**
220
- * Check if Notifications supported in the service worker
152
+ * Get subscription
221
153
  */
222
- if (!('showNotification' in ServiceWorkerRegistration.prototype)) {
223
- _utils.Logger.info(_Errors.SCOPE_SC_CORE, "Notifications aren't supported.");
224
-
225
- return;
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
- * 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.
189
+ * Request web push notification permission
190
+ * @type {(function(): void)|*}
231
191
  */
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
- }
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
- * Check the current Notification permission.
241
- * If its denied, it's a permanent block until the user changes the permission
223
+ * Initialize state
242
224
  */
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
- }
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;AAClF,wEAA0D;AAE1D;;;;GAIG;AACH,SAAwB,qBAAqB;IAC3C,UAAU;IACV,MAAM,SAAS,GAAkB,IAAA,gCAAY,GAAE,CAAC;IAChD,MAAM,aAAa,GAAsB,IAAA,0BAAS,GAAE,CAAC;IACrD,MAAM,oBAAoB,GAA6B,IAAA,kBAAU,EAAC,4CAAoB,CAAC,CAAC;IAExF,QAAQ;IACR,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC;IAE3D,OAAO;IACP,MAAM,WAAW,GAAG,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC;IAE9B,QAAQ;IACR,MAAM,oBAAoB,GACxB,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,oBAAoB,KAAK,SAAS;QAClF,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,oBAAoB;QACxE,CAAC,CAAC,aAAa,CAAC,6BAA6B,IAAI,oBAAoB,CAAC,WAAW;YACjF,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,aAA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