@empathyco/x-components 7.3.1 → 7.4.1

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 (264) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/browse/index.d.ts +1 -0
  3. package/browse/index.js +15 -0
  4. package/core/index.js.map +1 -1
  5. package/docs/API-reference/api/x-components.basexapi.browse.md +54 -0
  6. package/docs/API-reference/api/x-components.basexapi.md +14 -0
  7. package/docs/API-reference/api/x-components.browseactioncontext.md +15 -0
  8. package/docs/API-reference/api/x-components.browseactions.cancelfetchandsavebrowseresponse.md +13 -0
  9. package/docs/API-reference/api/x-components.browseactions.fetchandsavebrowseresponse.md +13 -0
  10. package/docs/API-reference/api/x-components.browseactions.fetchandsaveresultsenrichment.md +13 -0
  11. package/docs/API-reference/api/x-components.browseactions.fetchbrowseresponse.md +13 -0
  12. package/docs/API-reference/api/x-components.browseactions.increasepageappendingresults.md +18 -0
  13. package/docs/API-reference/api/x-components.browseactions.md +210 -0
  14. package/docs/API-reference/api/x-components.browseactions.resetrequestonrefinement.md +13 -0
  15. package/docs/API-reference/api/x-components.browseactions.savebrowseresponse.md +13 -0
  16. package/docs/API-reference/api/x-components.browseactions.saveorigin.md +13 -0
  17. package/docs/API-reference/api/x-components.browseactions.seturlparams.md +13 -0
  18. package/docs/API-reference/api/x-components.browseconfig.md +75 -0
  19. package/docs/API-reference/api/x-components.browseconfig.pagemode.md +11 -0
  20. package/docs/API-reference/api/x-components.browseconfig.pagesize.md +13 -0
  21. package/docs/API-reference/api/x-components.browsegetters.md +58 -0
  22. package/docs/API-reference/api/x-components.browsegetters.request.md +13 -0
  23. package/docs/API-reference/api/x-components.browsemutations.appendresults.md +13 -0
  24. package/docs/API-reference/api/x-components.browsemutations.md +458 -0
  25. package/docs/API-reference/api/x-components.browsemutations.resetstate.md +13 -0
  26. package/docs/API-reference/api/x-components.browsemutations.resetstateforreload.md +13 -0
  27. package/docs/API-reference/api/x-components.browsemutations.setbanners.md +13 -0
  28. package/docs/API-reference/api/x-components.browsemutations.setbrowsetagging.md +13 -0
  29. package/docs/API-reference/api/x-components.browsemutations.setdisplaybrowsetagging.md +13 -0
  30. package/docs/API-reference/api/x-components.browsemutations.setfacets.md +13 -0
  31. package/docs/API-reference/api/x-components.browsemutations.setfromnoresultswithfilters.md +13 -0
  32. package/docs/API-reference/api/x-components.browsemutations.setisappendresults.md +13 -0
  33. package/docs/API-reference/api/x-components.browsemutations.setisnoresults.md +13 -0
  34. package/docs/API-reference/api/x-components.browsemutations.setorigin.md +13 -0
  35. package/docs/API-reference/api/x-components.browsemutations.setpage.md +13 -0
  36. package/docs/API-reference/api/x-components.browsemutations.setparams.md +13 -0
  37. package/docs/API-reference/api/x-components.browsemutations.setpromoteds.md +13 -0
  38. package/docs/API-reference/api/x-components.browsemutations.setresults.md +13 -0
  39. package/docs/API-reference/api/x-components.browsemutations.setselectedcategory.md +13 -0
  40. package/docs/API-reference/api/x-components.browsemutations.setselectedfilters.md +13 -0
  41. package/docs/API-reference/api/x-components.browsemutations.setsort.md +13 -0
  42. package/docs/API-reference/api/x-components.browsemutations.setstats.md +13 -0
  43. package/docs/API-reference/api/x-components.browsemutations.settotalresults.md +13 -0
  44. package/docs/API-reference/api/x-components.browsemutations.updateresult.md +13 -0
  45. package/docs/API-reference/api/x-components.browsemutations.updateresultsfromenrichment.md +13 -0
  46. package/docs/API-reference/api/x-components.browserequest.md +13 -0
  47. package/docs/API-reference/api/x-components.browseresultslist.md +31 -0
  48. package/docs/API-reference/api/x-components.browsesortpickerlist.md +45 -0
  49. package/docs/API-reference/api/x-components.browsestate.banners.md +13 -0
  50. package/docs/API-reference/api/x-components.browsestate.browsetagging.md +13 -0
  51. package/docs/API-reference/api/x-components.browsestate.config.md +13 -0
  52. package/docs/API-reference/api/x-components.browsestate.displaybrowsetagging.md +13 -0
  53. package/docs/API-reference/api/x-components.browsestate.facets.md +13 -0
  54. package/docs/API-reference/api/x-components.browsestate.fromnoresultswithfilters.md +13 -0
  55. package/docs/API-reference/api/x-components.browsestate.isappendresults.md +13 -0
  56. package/docs/API-reference/api/x-components.browsestate.isnoresults.md +13 -0
  57. package/docs/API-reference/api/x-components.browsestate.md +382 -0
  58. package/docs/API-reference/api/x-components.browsestate.origin.md +13 -0
  59. package/docs/API-reference/api/x-components.browsestate.page.md +13 -0
  60. package/docs/API-reference/api/x-components.browsestate.params.md +13 -0
  61. package/docs/API-reference/api/x-components.browsestate.promoteds.md +13 -0
  62. package/docs/API-reference/api/x-components.browsestate.results.md +13 -0
  63. package/docs/API-reference/api/x-components.browsestate.selectedcategory.md +13 -0
  64. package/docs/API-reference/api/x-components.browsestate.selectedfilters.md +13 -0
  65. package/docs/API-reference/api/x-components.browsestate.sort.md +13 -0
  66. package/docs/API-reference/api/x-components.browsestate.stats.md +13 -0
  67. package/docs/API-reference/api/x-components.browsestate.totalresults.md +13 -0
  68. package/docs/API-reference/api/x-components.browsexevents.browserequestchanged.md +13 -0
  69. package/docs/API-reference/api/x-components.browsexevents.browserequestupdated.md +18 -0
  70. package/docs/API-reference/api/x-components.browsexevents.browseresponsechanged.md +13 -0
  71. package/docs/API-reference/api/x-components.browsexevents.browsetaggingchanged.md +13 -0
  72. package/docs/API-reference/api/x-components.browsexevents.md +172 -0
  73. package/docs/API-reference/api/x-components.browsexevents.selectedbrowsesortprovided.md +18 -0
  74. package/docs/API-reference/api/x-components.browsexevents.userbrowsedtocategory.md +13 -0
  75. package/docs/API-reference/api/x-components.browsexevents.userclickedabrowsesort.md +13 -0
  76. package/docs/API-reference/api/x-components.browsexmodule.md +13 -0
  77. package/docs/API-reference/api/x-components.browsexstoremodule.md +15 -0
  78. package/docs/API-reference/api/x-components.cancelfetchandsavebrowseresponse.md +17 -0
  79. package/docs/API-reference/api/x-components.cancelfetchandsavebrowseresponsewire.md +13 -0
  80. package/docs/API-reference/api/x-components.clearbrowsequery.md +13 -0
  81. package/docs/API-reference/api/x-components.fetchandsavebrowseresponse.md +66 -0
  82. package/docs/API-reference/api/x-components.fetchandsavebrowseresponsewire.md +13 -0
  83. package/docs/API-reference/api/x-components.fetchandsavebrowseresultsenrichment.md +66 -0
  84. package/docs/API-reference/api/x-components.fetchandsavebrowseresultsenrichmentwire.md +13 -0
  85. package/docs/API-reference/api/x-components.fetchbrowseresponse.md +13 -0
  86. package/docs/API-reference/api/x-components.hierarchicalfilter.md +7 -0
  87. package/docs/API-reference/api/x-components.increasebrowsepageappendingresults.md +13 -0
  88. package/docs/API-reference/api/x-components.increasebrowsepageappendingresultswire.md +13 -0
  89. package/docs/API-reference/api/x-components.internalbrowserequest.md +59 -0
  90. package/docs/API-reference/api/x-components.internalbrowserequest.page.md +13 -0
  91. package/docs/API-reference/api/x-components.internalbrowseresponse.md +78 -0
  92. package/docs/API-reference/api/x-components.internalbrowseresponse.request.md +13 -0
  93. package/docs/API-reference/api/x-components.internalbrowseresponse.status.md +13 -0
  94. package/docs/API-reference/api/x-components.md +499 -0
  95. package/docs/API-reference/api/x-components.resetbrowseappending.md +13 -0
  96. package/docs/API-reference/api/x-components.resetbrowserequestonrefinement.md +13 -0
  97. package/docs/API-reference/api/x-components.resetbrowserequestonrefinementwire.md +13 -0
  98. package/docs/API-reference/api/x-components.resetbrowsestateforreloadwire.md +13 -0
  99. package/docs/API-reference/api/x-components.resetbrowsestateifnorequestwire.md +13 -0
  100. package/docs/API-reference/api/x-components.resetfromnobrowseresultswithfilters.md +13 -0
  101. package/docs/API-reference/api/x-components.resetisnobrowseresults.md +13 -0
  102. package/docs/API-reference/api/x-components.reseturlbrowsecategory.md +13 -0
  103. package/docs/API-reference/api/x-components.savebrowseorigin.md +13 -0
  104. package/docs/API-reference/api/x-components.savebrowseoriginwire.md +13 -0
  105. package/docs/API-reference/api/x-components.savebrowseresponse.md +13 -0
  106. package/docs/API-reference/api/x-components.setbrowsecategory.md +13 -0
  107. package/docs/API-reference/api/x-components.setbrowseextraparams.md +13 -0
  108. package/docs/API-reference/api/x-components.setbrowsepage.md +13 -0
  109. package/docs/API-reference/api/x-components.setbrowseselectedfilters.md +13 -0
  110. package/docs/API-reference/api/x-components.setbrowsesort.md +13 -0
  111. package/docs/API-reference/api/x-components.setbrowseurlparams.md +13 -0
  112. package/docs/API-reference/api/x-components.setbrowseurlparamswire.md +13 -0
  113. package/docs/API-reference/api/x-components.seturlbrowsecategory.md +13 -0
  114. package/docs/API-reference/api/x-components.simplefilter.md +7 -0
  115. package/docs/API-reference/api/x-components.snippetcallbacks.md +7 -0
  116. package/docs/API-reference/api/x-components.urlmutations.md +19 -0
  117. package/docs/API-reference/api/x-components.urlmutations.setbrowsecategory.md +13 -0
  118. package/docs/API-reference/api/x-components.urlparams.browsefield.md +11 -0
  119. package/docs/API-reference/api/x-components.urlparams.browsevalue.md +11 -0
  120. package/docs/API-reference/api/x-components.urlparams.md +34 -0
  121. package/docs/API-reference/api/x-components.usealiasapi.browsetotalresults.md +13 -0
  122. package/docs/API-reference/api/x-components.usealiasapi.md +21 -0
  123. package/docs/API-reference/api/x-components.watchedinternalbrowserequest.md +73 -0
  124. package/docs/API-reference/api/x-components.watchedinternalbrowserequest.newrequest.md +11 -0
  125. package/docs/API-reference/api/x-components.watchedinternalbrowserequest.oldrequest.md +11 -0
  126. package/docs/API-reference/api/x-components.xapi.browse.md +13 -0
  127. package/docs/API-reference/api/x-components.xapi.md +19 -0
  128. package/docs/API-reference/api/x-components.xeventstypes.md +2 -2
  129. package/docs/API-reference/api/x-components.xmodulestree.browse.md +11 -0
  130. package/docs/API-reference/api/x-components.xmodulestree.md +17 -0
  131. package/docs/API-reference/api/x-types.xcomponentsadapter.browse.md +11 -0
  132. package/docs/API-reference/api/x-types.xcomponentsadapter.md +17 -0
  133. package/docs/API-reference/components/browse/x-components.browse-results-list.md +21 -0
  134. package/docs/API-reference/components/browse/x-components.browse-sort-picker-list.md +24 -0
  135. package/js/composables/use-alias-api.js +3 -0
  136. package/js/composables/use-alias-api.js.map +1 -1
  137. package/js/index.js +16 -1
  138. package/js/index.js.map +1 -1
  139. package/js/wiring/namespaced-wires.factory.js +1 -1
  140. package/js/x-installer/api/base-api.js +12 -0
  141. package/js/x-installer/api/base-api.js.map +1 -1
  142. package/js/x-modules/browse/components/browse-results-list.vue.js +46 -0
  143. package/js/x-modules/browse/components/browse-results-list.vue.js.map +1 -0
  144. package/js/x-modules/browse/components/browse-results-list.vue2.js +6 -0
  145. package/js/x-modules/browse/components/browse-results-list.vue2.js.map +1 -0
  146. package/js/x-modules/browse/components/browse-sort-picker-list.vue.js +73 -0
  147. package/js/x-modules/browse/components/browse-sort-picker-list.vue.js.map +1 -0
  148. package/js/x-modules/browse/components/browse-sort-picker-list.vue2.js +6 -0
  149. package/js/x-modules/browse/components/browse-sort-picker-list.vue2.js.map +1 -0
  150. package/js/x-modules/browse/store/actions/fetch-and-save-browse-response.action.js +57 -0
  151. package/js/x-modules/browse/store/actions/fetch-and-save-browse-response.action.js.map +1 -0
  152. package/js/x-modules/browse/store/actions/fetch-and-save-results-enrichment.action.js +21 -0
  153. package/js/x-modules/browse/store/actions/fetch-and-save-results-enrichment.action.js.map +1 -0
  154. package/js/x-modules/browse/store/actions/fetch-browse-response.action.js +16 -0
  155. package/js/x-modules/browse/store/actions/fetch-browse-response.action.js.map +1 -0
  156. package/js/x-modules/browse/store/actions/increase-page-apending-results.action.js +18 -0
  157. package/js/x-modules/browse/store/actions/increase-page-apending-results.action.js.map +1 -0
  158. package/js/x-modules/browse/store/actions/reset-request-on-refinement.action.js +36 -0
  159. package/js/x-modules/browse/store/actions/reset-request-on-refinement.action.js.map +1 -0
  160. package/js/x-modules/browse/store/actions/save-browse-response.action.js +42 -0
  161. package/js/x-modules/browse/store/actions/save-browse-response.action.js.map +1 -0
  162. package/js/x-modules/browse/store/actions/save-origin.action.js +16 -0
  163. package/js/x-modules/browse/store/actions/save-origin.action.js.map +1 -0
  164. package/js/x-modules/browse/store/actions/set-url-params.action.js +20 -0
  165. package/js/x-modules/browse/store/actions/set-url-params.action.js.map +1 -0
  166. package/js/x-modules/browse/store/emitters.js +48 -0
  167. package/js/x-modules/browse/store/emitters.js.map +1 -0
  168. package/js/x-modules/browse/store/getters/request.getter.js +27 -0
  169. package/js/x-modules/browse/store/getters/request.getter.js.map +1 -0
  170. package/js/x-modules/browse/store/module.js +163 -0
  171. package/js/x-modules/browse/store/module.js.map +1 -0
  172. package/js/x-modules/browse/wiring.js +213 -0
  173. package/js/x-modules/browse/wiring.js.map +1 -0
  174. package/js/x-modules/browse/x-module.js +21 -0
  175. package/js/x-modules/browse/x-module.js.map +1 -0
  176. package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
  177. package/js/x-modules/url/components/url-handler.vue2.js +4 -1
  178. package/js/x-modules/url/components/url-handler.vue2.js.map +1 -1
  179. package/js/x-modules/url/store/initial-state.js +2 -0
  180. package/js/x-modules/url/store/initial-state.js.map +1 -1
  181. package/js/x-modules/url/store/module.js +4 -0
  182. package/js/x-modules/url/store/module.js.map +1 -1
  183. package/js/x-modules/url/wiring.js +34 -1
  184. package/js/x-modules/url/wiring.js.map +1 -1
  185. package/package.json +4 -4
  186. package/report/x-components.api.json +4505 -192
  187. package/report/x-components.api.md +432 -6
  188. package/report/x-types.api.json +50 -0
  189. package/types/src/components/snippet-callbacks.vue.d.ts +7 -0
  190. package/types/src/components/snippet-callbacks.vue.d.ts.map +1 -1
  191. package/types/src/composables/use-alias-api.d.ts +2 -0
  192. package/types/src/composables/use-alias-api.d.ts.map +1 -1
  193. package/types/src/index.d.ts +1 -0
  194. package/types/src/index.d.ts.map +1 -1
  195. package/types/src/types/url-params.d.ts +2 -0
  196. package/types/src/types/url-params.d.ts.map +1 -1
  197. package/types/src/wiring/events.types.d.ts +2 -1
  198. package/types/src/wiring/events.types.d.ts.map +1 -1
  199. package/types/src/x-installer/api/api.types.d.ts +9 -0
  200. package/types/src/x-installer/api/api.types.d.ts.map +1 -1
  201. package/types/src/x-installer/api/base-api.d.ts +9 -0
  202. package/types/src/x-installer/api/base-api.d.ts.map +1 -1
  203. package/types/src/x-modules/browse/components/browse-results-list.vue.d.ts +30 -0
  204. package/types/src/x-modules/browse/components/browse-results-list.vue.d.ts.map +1 -0
  205. package/types/src/x-modules/browse/components/browse-sort-picker-list.vue.d.ts +50 -0
  206. package/types/src/x-modules/browse/components/browse-sort-picker-list.vue.d.ts.map +1 -0
  207. package/types/src/x-modules/browse/components/index.d.ts +3 -0
  208. package/types/src/x-modules/browse/components/index.d.ts.map +1 -0
  209. package/types/src/x-modules/browse/config.types.d.ts +14 -0
  210. package/types/src/x-modules/browse/config.types.d.ts.map +1 -0
  211. package/types/src/x-modules/browse/events.types.d.ts +55 -0
  212. package/types/src/x-modules/browse/events.types.d.ts.map +1 -0
  213. package/types/src/x-modules/browse/index.d.ts +8 -0
  214. package/types/src/x-modules/browse/index.d.ts.map +1 -0
  215. package/types/src/x-modules/browse/store/actions/fetch-and-save-browse-response.action.d.ts +15 -0
  216. package/types/src/x-modules/browse/store/actions/fetch-and-save-browse-response.action.d.ts.map +1 -0
  217. package/types/src/x-modules/browse/store/actions/fetch-and-save-results-enrichment.action.d.ts +17 -0
  218. package/types/src/x-modules/browse/store/actions/fetch-and-save-results-enrichment.action.d.ts.map +1 -0
  219. package/types/src/x-modules/browse/store/actions/fetch-browse-response.action.d.ts +13 -0
  220. package/types/src/x-modules/browse/store/actions/fetch-browse-response.action.d.ts.map +1 -0
  221. package/types/src/x-modules/browse/store/actions/increase-page-apending-results.action.d.ts +11 -0
  222. package/types/src/x-modules/browse/store/actions/increase-page-apending-results.action.d.ts.map +1 -0
  223. package/types/src/x-modules/browse/store/actions/index.d.ts +9 -0
  224. package/types/src/x-modules/browse/store/actions/index.d.ts.map +1 -0
  225. package/types/src/x-modules/browse/store/actions/reset-request-on-refinement.action.d.ts +11 -0
  226. package/types/src/x-modules/browse/store/actions/reset-request-on-refinement.action.d.ts.map +1 -0
  227. package/types/src/x-modules/browse/store/actions/save-browse-response.action.d.ts +11 -0
  228. package/types/src/x-modules/browse/store/actions/save-browse-response.action.d.ts.map +1 -0
  229. package/types/src/x-modules/browse/store/actions/save-origin.action.d.ts +11 -0
  230. package/types/src/x-modules/browse/store/actions/save-origin.action.d.ts.map +1 -0
  231. package/types/src/x-modules/browse/store/actions/set-url-params.action.d.ts +11 -0
  232. package/types/src/x-modules/browse/store/actions/set-url-params.action.d.ts.map +1 -0
  233. package/types/src/x-modules/browse/store/emitters.d.ts +35 -0
  234. package/types/src/x-modules/browse/store/emitters.d.ts.map +1 -0
  235. package/types/src/x-modules/browse/store/getters/index.d.ts +2 -0
  236. package/types/src/x-modules/browse/store/getters/index.d.ts.map +1 -0
  237. package/types/src/x-modules/browse/store/getters/request.getter.d.ts +13 -0
  238. package/types/src/x-modules/browse/store/getters/request.getter.d.ts.map +1 -0
  239. package/types/src/x-modules/browse/store/index.d.ts +6 -0
  240. package/types/src/x-modules/browse/store/index.d.ts.map +1 -0
  241. package/types/src/x-modules/browse/store/module.d.ts +41 -0
  242. package/types/src/x-modules/browse/store/module.d.ts.map +1 -0
  243. package/types/src/x-modules/browse/store/types.d.ts +273 -0
  244. package/types/src/x-modules/browse/store/types.d.ts.map +1 -0
  245. package/types/src/x-modules/browse/types.d.ts +35 -0
  246. package/types/src/x-modules/browse/types.d.ts.map +1 -0
  247. package/types/src/x-modules/browse/wiring.d.ts +172 -0
  248. package/types/src/x-modules/browse/wiring.d.ts.map +1 -0
  249. package/types/src/x-modules/browse/x-module.d.ts +16 -0
  250. package/types/src/x-modules/browse/x-module.d.ts.map +1 -0
  251. package/types/src/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +7 -0
  252. package/types/src/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
  253. package/types/src/x-modules/facets/components/filters/simple-filter.vue.d.ts +7 -0
  254. package/types/src/x-modules/facets/components/filters/simple-filter.vue.d.ts.map +1 -1
  255. package/types/src/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
  256. package/types/src/x-modules/url/store/initial-state.d.ts.map +1 -1
  257. package/types/src/x-modules/url/store/module.d.ts.map +1 -1
  258. package/types/src/x-modules/url/store/types.d.ts +7 -1
  259. package/types/src/x-modules/url/store/types.d.ts.map +1 -1
  260. package/types/src/x-modules/url/wiring.d.ts +30 -0
  261. package/types/src/x-modules/url/wiring.d.ts.map +1 -1
  262. package/types/src/x-modules/x-modules.types.d.ts +2 -0
  263. package/types/src/x-modules/x-modules.types.d.ts.map +1 -1
  264. package/url/index.js +1 -1
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Default implementation for the {@link BrowseActions.setUrlParams}.
3
+ *
4
+ * @param context - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions,
5
+ * provided by Vuex.
6
+ * @param urlParams - List of params from the url.
7
+ * @public
8
+ */
9
+ const setUrlParams = ({ commit, state }, { browseValue, browseField, page, sort }) => {
10
+ const currentCategory = state.selectedCategory;
11
+ commit('setSelectedCategory', { browseValue, browseField });
12
+ commit('setPage', !currentCategory ||
13
+ (currentCategory.browseValue === browseValue && currentCategory.browseField === browseField)
14
+ ? page
15
+ : 1);
16
+ commit('setSort', sort);
17
+ };
18
+
19
+ export { setUrlParams };
20
+ //# sourceMappingURL=set-url-params.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-url-params.action.js","sources":["../../../../../../src/x-modules/browse/store/actions/set-url-params.action.ts"],"sourcesContent":["import type { BrowseXStoreModule } from '../types'\n\n/**\n * Default implementation for the {@link BrowseActions.setUrlParams}.\n *\n * @param context - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions,\n * provided by Vuex.\n * @param urlParams - List of params from the url.\n * @public\n */\nexport const setUrlParams: BrowseXStoreModule['actions']['setUrlParams'] = (\n { commit, state },\n { browseValue, browseField, page, sort },\n) => {\n const currentCategory = state.selectedCategory\n\n commit('setSelectedCategory', { browseValue, browseField })\n commit(\n 'setPage',\n !currentCategory ||\n (currentCategory.browseValue === browseValue && currentCategory.browseField === browseField)\n ? page\n : 1,\n )\n commit('setSort', sort)\n}\n"],"names":[],"mappings":"AAEA;;;;;;;AAOG;MACU,YAAY,GAAkD,CACzE,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,KACtC;AACF,IAAA,MAAM,eAAe,GAAG,KAAK,CAAC,gBAAgB;IAE9C,MAAM,CAAC,qBAAqB,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAC3D,IAAA,MAAM,CACJ,SAAS,EACT,CAAC,eAAe;SACb,eAAe,CAAC,WAAW,KAAK,WAAW,IAAI,eAAe,CAAC,WAAW,KAAK,WAAW;AAC3F,UAAE;UACA,CAAC,CACN;AACD,IAAA,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC;AACzB;;;;"}
@@ -0,0 +1,48 @@
1
+ import '@empathyco/x-utils';
2
+ import { createStoreEmitters } from '../../../store/utils/store-emitters.utils.js';
3
+ import { isStringEmpty } from '../../../utils/string.js';
4
+ import { browseXStoreModule } from './module.js';
5
+
6
+ /**
7
+ * {@link StoreEmitters} For the browse module.
8
+ *
9
+ * @internal
10
+ */
11
+ const browseEmitters = createStoreEmitters(browseXStoreModule, {
12
+ FacetsChanged: {
13
+ selector: state => state.facets,
14
+ filter(newValue, oldValue) {
15
+ return newValue.length !== 0 || oldValue.length !== 0;
16
+ },
17
+ },
18
+ PageChanged: state => state.page,
19
+ ResultsChanged: state => state.results,
20
+ BrowseRequestChanged: (_, getters) => getters.request,
21
+ BrowseRequestUpdated: (_, getters) => getters.request,
22
+ BrowseResponseChanged: {
23
+ selector: (state, getters) => {
24
+ return {
25
+ request: getters.request,
26
+ status: state.status,
27
+ banners: state.banners,
28
+ facets: state.facets,
29
+ promoteds: state.promoteds,
30
+ browseTagging: state.browseTagging,
31
+ displayBrowseTagging: state.displayBrowseTagging,
32
+ results: state.results,
33
+ totalResults: state.totalResults,
34
+ };
35
+ },
36
+ filter: (newValue, oldValue) => {
37
+ return (newValue.status !== oldValue.status && oldValue.status === 'loading' && !!newValue.request);
38
+ },
39
+ },
40
+ BrowseTaggingChanged: {
41
+ selector: state => state.browseTagging,
42
+ filter: ({ url }) => !isStringEmpty(url),
43
+ },
44
+ SortChanged: state => state.sort,
45
+ });
46
+
47
+ export { browseEmitters };
48
+ //# sourceMappingURL=emitters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitters.js","sources":["../../../../../src/x-modules/browse/store/emitters.ts"],"sourcesContent":["import { createStoreEmitters } from '../../../store'\nimport { isStringEmpty } from '../../../utils/string'\nimport { browseXStoreModule } from './module'\n\n/**\n * {@link StoreEmitters} For the browse module.\n *\n * @internal\n */\nexport const browseEmitters = createStoreEmitters(browseXStoreModule, {\n FacetsChanged: {\n selector: state => state.facets,\n filter(newValue, oldValue): boolean {\n return newValue.length !== 0 || oldValue.length !== 0\n },\n },\n PageChanged: state => state.page,\n ResultsChanged: state => state.results,\n BrowseRequestChanged: (_, getters) => getters.request,\n BrowseRequestUpdated: (_, getters) => getters.request,\n BrowseResponseChanged: {\n selector: (state, getters) => {\n return {\n request: getters.request!,\n status: state.status,\n banners: state.banners,\n facets: state.facets,\n promoteds: state.promoteds,\n browseTagging: state.browseTagging,\n displayBrowseTagging: state.displayBrowseTagging,\n results: state.results,\n totalResults: state.totalResults,\n }\n },\n filter: (newValue, oldValue) => {\n return (\n newValue.status !== oldValue.status && oldValue.status === 'loading' && !!newValue.request\n )\n },\n },\n BrowseTaggingChanged: {\n selector: state => state.browseTagging,\n filter: ({ url }) => !isStringEmpty(url),\n },\n SortChanged: state => state.sort,\n})\n"],"names":[],"mappings":";;;;;AAIA;;;;AAIG;AACI,MAAM,cAAc,GAAG,mBAAmB,CAAC,kBAAkB,EAAE;AACpE,IAAA,aAAa,EAAE;AACb,QAAA,QAAQ,EAAE,KAAK,IAAI,KAAK,CAAC,MAAM;QAC/B,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAA;YACvB,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI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1
+ /**
2
+ * Default implementation for the {@link BrowseGetters.request} getter.
3
+ *
4
+ * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the browse
5
+ * module.
6
+ * @param getters - Current {@link https://vuex.vuejs.org/guide/getters.html | getters} of the
7
+ * browse module.
8
+ * @returns The browse request to fetch data from the API.
9
+ * @public
10
+ */
11
+ const request = ({ page, params, selectedFilters: filters, sort, selectedCategory, }) => {
12
+ const browseValue = selectedCategory?.browseValue?.trim();
13
+ const browseField = selectedCategory?.browseField?.trim();
14
+ return browseValue && browseField
15
+ ? {
16
+ browseField,
17
+ browseValue,
18
+ sort,
19
+ page,
20
+ filters,
21
+ extraParams: params,
22
+ }
23
+ : null;
24
+ };
25
+
26
+ export { request };
27
+ //# sourceMappingURL=request.getter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.getter.js","sources":["../../../../../../src/x-modules/browse/store/getters/request.getter.ts"],"sourcesContent":["import type { BrowseXStoreModule } from '../types'\n\n/**\n * Default implementation for the {@link BrowseGetters.request} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the browse\n * module.\n * @param getters - Current {@link https://vuex.vuejs.org/guide/getters.html | getters} of the\n * browse module.\n * @returns The browse request to fetch data from the API.\n * @public\n */\nexport const request: BrowseXStoreModule['getters']['request'] = ({\n page,\n params,\n selectedFilters: filters,\n sort,\n selectedCategory,\n}) => {\n const browseValue = selectedCategory?.browseValue?.trim()\n const browseField = selectedCategory?.browseField?.trim()\n\n return browseValue && browseField\n ? {\n browseField,\n browseValue,\n sort,\n page,\n filters,\n extraParams: params,\n }\n : null\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;;AASG;AACI,MAAM,OAAO,GAA6C,CAAC,EAChE,IAAI,EACJ,MAAM,EACN,eAAe,EAAE,OAAO,EACxB,IAAI,EACJ,gBAAgB,GACjB,KAAI;IACH,MAAM,WAAW,GAAG,gBAAgB,EAAE,WAAW,EAAE,IAAI,EAAE;IACzD,MAAM,WAAW,GAAG,gBAAgB,EAAE,WAAW,EAAE,IAAI,EAAE;IAEzD,OAAO,WAAW,IAAI;AACpB,UAAE;YACE,WAAW;YACX,WAAW;YACX,IAAI;YACJ,IAAI;YACJ,OAAO;AACP,YAAA,WAAW,EAAE,MAAM;AACpB;UACD,IAAI;AACV;;;;"}
@@ -0,0 +1,163 @@
1
+ import { isFacetFilter } from '@empathyco/x-types';
2
+ import { DefaultResultsEnrichmentService } from '../../../services/results-enrichment.service.js';
3
+ import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils.js';
4
+ import '@empathyco/x-utils';
5
+ import { setStatus } from '../../../store/utils/status-store.utils.js';
6
+ import { groupItemsBy } from '../../../utils/array.js';
7
+ import { UNKNOWN_FACET_KEY } from '../../facets/store/constants.js';
8
+ import { fetchAndSaveBrowseResponse, cancelFetchAndSaveBrowseResponse } from './actions/fetch-and-save-browse-response.action.js';
9
+ import { fetchAndSaveResultsEnrichment } from './actions/fetch-and-save-results-enrichment.action.js';
10
+ import { fetchBrowseResponse } from './actions/fetch-browse-response.action.js';
11
+ import { increasePageAppendingResults } from './actions/increase-page-apending-results.action.js';
12
+ import { resetRequestOnRefinement } from './actions/reset-request-on-refinement.action.js';
13
+ import { saveBrowseResponse } from './actions/save-browse-response.action.js';
14
+ import { saveOrigin } from './actions/save-origin.action.js';
15
+ import { setUrlParams } from './actions/set-url-params.action.js';
16
+ import { request } from './getters/request.getter.js';
17
+
18
+ /**
19
+ * {@link XStoreModule} For the browse module.
20
+ *
21
+ * @internal
22
+ */
23
+ const browseXStoreModule = {
24
+ state: () => ({
25
+ ...resettableBrowseState(),
26
+ selectedFilters: {},
27
+ params: {},
28
+ config: {
29
+ threshold: 24,
30
+ pageSize: 24,
31
+ pageMode: 'infinite_scroll',
32
+ },
33
+ status: 'initial',
34
+ isNoResults: false,
35
+ fromNoResultsWithFilters: false,
36
+ }),
37
+ getters: {
38
+ request,
39
+ },
40
+ mutations: {
41
+ appendResults(state, results) {
42
+ state.results = [...state.results, ...results];
43
+ },
44
+ resetState(state) {
45
+ Object.assign(state, resettableBrowseState());
46
+ },
47
+ resetStateForReload(state) {
48
+ const { selectedCategory, facets, sort, page, ...resettable } = resettableBrowseState();
49
+ Object.assign(state, resettable);
50
+ },
51
+ setResults(state, results) {
52
+ state.results = results;
53
+ },
54
+ setFacets(state, facets) {
55
+ state.facets = facets;
56
+ },
57
+ setSelectedFilters(state, selectedFilters) {
58
+ state.selectedFilters = groupItemsBy(selectedFilters, filter => isFacetFilter(filter) ? filter.facetId : UNKNOWN_FACET_KEY);
59
+ },
60
+ setBanners(state, banners) {
61
+ state.banners = banners;
62
+ },
63
+ setPromoteds(state, promoteds) {
64
+ state.promoteds = promoteds;
65
+ },
66
+ setTotalResults(state, totalResults) {
67
+ state.totalResults = totalResults;
68
+ },
69
+ setSort(state, sort) {
70
+ state.sort = sort;
71
+ },
72
+ setPage(state, page) {
73
+ state.page = page;
74
+ },
75
+ setSelectedCategory(state, selectedCategory) {
76
+ state.selectedCategory = selectedCategory;
77
+ },
78
+ setConfig,
79
+ mergeConfig,
80
+ setIsAppendResults(state, isAppendResults) {
81
+ state.isAppendResults = isAppendResults;
82
+ },
83
+ setIsNoResults(state, isNoResults) {
84
+ state.isNoResults = isNoResults;
85
+ },
86
+ setFromNoResultsWithFilters(state, fromNoResultsWithFilters) {
87
+ state.fromNoResultsWithFilters = fromNoResultsWithFilters;
88
+ },
89
+ setStatus,
90
+ setParams(state, params) {
91
+ state.params = params;
92
+ },
93
+ setOrigin(state, origin = null) {
94
+ state.origin = origin;
95
+ },
96
+ setBrowseTagging(state, browseTagging) {
97
+ state.browseTagging = browseTagging;
98
+ },
99
+ setDisplayBrowseTagging(state, displayBrowseTagging) {
100
+ state.displayBrowseTagging = displayBrowseTagging;
101
+ },
102
+ updateResult(state, result) {
103
+ const stateResult = state.results.find(stateResult => result.id === stateResult.id);
104
+ if (stateResult) {
105
+ Object.assign(stateResult, result);
106
+ }
107
+ },
108
+ updateResultsFromEnrichment(state, enrichmentResults) {
109
+ DefaultResultsEnrichmentService.instance.updateResults(state.results, enrichmentResults);
110
+ },
111
+ setStats(state, stats) {
112
+ state.stats = stats;
113
+ },
114
+ },
115
+ actions: {
116
+ cancelFetchAndSaveBrowseResponse,
117
+ fetchBrowseResponse,
118
+ fetchAndSaveBrowseResponse,
119
+ fetchAndSaveResultsEnrichment,
120
+ increasePageAppendingResults,
121
+ resetRequestOnRefinement,
122
+ saveBrowseResponse,
123
+ setUrlParams,
124
+ saveOrigin,
125
+ },
126
+ };
127
+ /**
128
+ * Function to return the "resettable" part of the state. This will be used in the `resetState`
129
+ * mutation to reset to the initial state.
130
+ *
131
+ * @returns The "resettable" part of the {@link BrowseState}.
132
+ *
133
+ * @internal
134
+ */
135
+ function resettableBrowseState() {
136
+ return {
137
+ selectedCategory: {
138
+ browseValue: '',
139
+ browseField: '',
140
+ },
141
+ results: [],
142
+ facets: [],
143
+ banners: [],
144
+ promoteds: [],
145
+ totalResults: 0,
146
+ sort: '',
147
+ page: 1,
148
+ origin: null,
149
+ isAppendResults: false,
150
+ browseTagging: {
151
+ url: '',
152
+ params: {},
153
+ },
154
+ displayBrowseTagging: {
155
+ url: '',
156
+ params: {},
157
+ },
158
+ stats: {},
159
+ };
160
+ }
161
+
162
+ export { browseXStoreModule, resettableBrowseState };
163
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sources":["../../../../../src/x-modules/browse/store/module.ts"],"sourcesContent":["import type { Stats } from '@empathyco/x-types'\nimport type { BrowseXStoreModule } from './types'\nimport { isFacetFilter } from '@empathyco/x-types'\nimport { DefaultResultsEnrichmentService } from '../../../services/results-enrichment.service'\nimport { setStatus } from '../../../store'\nimport { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'\nimport { groupItemsBy } from '../../../utils/array'\nimport { UNKNOWN_FACET_KEY } from '../../facets/store/constants'\nimport {\n cancelFetchAndSaveBrowseResponse,\n fetchAndSaveBrowseResponse,\n fetchBrowseResponse,\n saveBrowseResponse,\n} from './actions'\nimport { fetchAndSaveResultsEnrichment } from './actions/fetch-and-save-results-enrichment.action'\nimport { increasePageAppendingResults } from './actions/increase-page-apending-results.action'\nimport { resetRequestOnRefinement } from './actions/reset-request-on-refinement.action'\nimport { saveOrigin } from './actions/save-origin.action'\nimport { setUrlParams } from './actions/set-url-params.action'\nimport { request } from './getters/request.getter'\n\n/**\n * {@link XStoreModule} For the browse module.\n *\n * @internal\n */\nexport const browseXStoreModule: BrowseXStoreModule = {\n state: () => ({\n ...resettableBrowseState(),\n selectedFilters: {},\n params: {},\n config: {\n threshold: 24,\n pageSize: 24,\n pageMode: 'infinite_scroll',\n },\n status: 'initial',\n isNoResults: false,\n fromNoResultsWithFilters: false,\n }),\n getters: {\n request,\n },\n mutations: {\n appendResults(state, results) {\n state.results = [...state.results, ...results]\n },\n resetState(state) {\n Object.assign(state, resettableBrowseState())\n },\n resetStateForReload(state) {\n const { selectedCategory, facets, sort, page, ...resettable } = resettableBrowseState()\n Object.assign(state, resettable)\n },\n setResults(state, results) {\n state.results = results\n },\n setFacets(state, facets) {\n state.facets = facets\n },\n setSelectedFilters(state, selectedFilters) {\n state.selectedFilters = groupItemsBy(selectedFilters, filter =>\n isFacetFilter(filter) ? filter.facetId : UNKNOWN_FACET_KEY,\n )\n },\n setBanners(state, banners) {\n state.banners = banners\n },\n setPromoteds(state, promoteds) {\n state.promoteds = promoteds\n },\n setTotalResults(state, totalResults) {\n state.totalResults = totalResults\n },\n setSort(state, sort) {\n state.sort = sort\n },\n setPage(state, page) {\n state.page = page\n },\n setSelectedCategory(state, selectedCategory) {\n state.selectedCategory = selectedCategory\n },\n setConfig,\n mergeConfig,\n setIsAppendResults(state, isAppendResults) {\n state.isAppendResults = isAppendResults\n },\n setIsNoResults(state, isNoResults) {\n state.isNoResults = isNoResults\n },\n setFromNoResultsWithFilters(state, fromNoResultsWithFilters) {\n state.fromNoResultsWithFilters = fromNoResultsWithFilters\n },\n setStatus,\n setParams(state, params) {\n state.params = params\n },\n setOrigin(state, origin = null) {\n state.origin = origin\n },\n setBrowseTagging(state, browseTagging) {\n state.browseTagging = browseTagging\n },\n setDisplayBrowseTagging(state, displayBrowseTagging) {\n state.displayBrowseTagging = displayBrowseTagging\n },\n updateResult(state, result) {\n const stateResult = state.results.find(stateResult => result.id === stateResult.id)\n if (stateResult) {\n Object.assign(stateResult, result)\n }\n },\n updateResultsFromEnrichment(state, enrichmentResults) {\n DefaultResultsEnrichmentService.instance.updateResults(state.results, enrichmentResults)\n },\n setStats(state, stats) {\n state.stats = stats\n },\n },\n actions: {\n cancelFetchAndSaveBrowseResponse,\n fetchBrowseResponse,\n fetchAndSaveBrowseResponse,\n fetchAndSaveResultsEnrichment,\n increasePageAppendingResults,\n resetRequestOnRefinement,\n saveBrowseResponse,\n setUrlParams,\n saveOrigin,\n },\n}\n\n/**\n * Function to return the \"resettable\" part of the state. This will be used in the `resetState`\n * mutation to reset to the initial state.\n *\n * @returns The \"resettable\" part of the {@link BrowseState}.\n *\n * @internal\n */\nexport function resettableBrowseState() {\n return {\n selectedCategory: {\n browseValue: '',\n browseField: '',\n },\n results: [],\n facets: [],\n banners: [],\n promoteds: [],\n totalResults: 0,\n sort: '',\n page: 1,\n origin: null,\n isAppendResults: false,\n browseTagging: {\n url: '',\n params: {},\n },\n displayBrowseTagging: {\n url: '',\n params: {},\n },\n stats: {} as Stats,\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAqBA;;;;AAIG;AACI,MAAM,kBAAkB,GAAuB;AACpD,IAAA,KAAK,EAAE,OAAO;AACZ,QAAA,GAAG,qBAAqB,EAAE;AAC1B,QAAA,eAAe,EAAE,EAAE;AACnB,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,MAAM,EAAE;AACN,YAAA,SAAS,EAAE,EAAE;AACb,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,QAAQ,EAAE,iBAAiB;AAC5B,SAAA;AACD,QAAA,MAAM,EAAE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ireDispatchWithoutPayload, namespacedWireCommitWithoutPayload, namespacedWireDispatch } from '../../wiring/namespaced-wires.factory.js';
2
+ import { filterTruthyPayload } from '../../wiring/wires.operators.js';
3
+ import { createWiring } from '../../wiring/wiring.utils.js';
4
+
5
+ /**
6
+ * `browse` {@link XModuleName | XModule name}.
7
+ *
8
+ * @internal
9
+ */
10
+ const moduleName = 'browse';
11
+ /**
12
+ * WireCommit for {@link BrowseXModule}.
13
+ *
14
+ * @internal
15
+ */
16
+ const wireCommit = namespacedWireCommit(moduleName);
17
+ /**
18
+ * WireCommit without Payload for {@link BrowseXModule}.
19
+ *
20
+ * @internal
21
+ */
22
+ const wireCommitWithoutPayload = namespacedWireCommitWithoutPayload(moduleName);
23
+ /**
24
+ * WireDispatch for {@link BrowseXModule}.
25
+ *
26
+ * @internal
27
+ */
28
+ const wireDispatch = namespacedWireDispatch(moduleName);
29
+ /**
30
+ * WireDispatchWithoutPayload for {@link BrowseXModule}.
31
+ *
32
+ * @internal
33
+ */
34
+ const wireDispatchWithoutPayload = namespacedWireDispatchWithoutPayload(moduleName);
35
+ /**
36
+ * Cancels the {@link BrowseActions.fetchAndSaveBrowseResponse} request promise.
37
+ *
38
+ * @public
39
+ */
40
+ const cancelFetchAndSaveBrowseResponseWire = wireDispatchWithoutPayload('cancelFetchAndSaveBrowseResponse');
41
+ /**
42
+ * Sets the browse state `origin`.
43
+ *
44
+ * @public
45
+ */
46
+ const saveBrowseOriginWire = wireDispatch('saveOrigin', ({ metadata }) => metadata);
47
+ /**
48
+ * Requests and stores the browse response.
49
+ *
50
+ * @public
51
+ */
52
+ const fetchAndSaveBrowseResponseWire = wireDispatch('fetchAndSaveBrowseResponse');
53
+ /**
54
+ * Requests and stores the enrichment results for the results.
55
+ *
56
+ * @public
57
+ */
58
+ const fetchAndSaveBrowseResultsEnrichmentWire = wireDispatch('fetchAndSaveResultsEnrichment');
59
+ /**
60
+ * Sets the browse state `selectedCategory`.
61
+ *
62
+ * @public
63
+ */
64
+ const setBrowseCategory = wireCommit('setSelectedCategory');
65
+ /**
66
+ * Clears the browse state `selectedCategory`.
67
+ *
68
+ * @public
69
+ */
70
+ const clearBrowseQuery = wireCommit('setSelectedCategory', {
71
+ browseField: '',
72
+ browseValue: '',
73
+ });
74
+ /**
75
+ * Sets the browse state `selectedFilters`.
76
+ *
77
+ * @public
78
+ */
79
+ const setBrowseSelectedFilters = wireCommit('setSelectedFilters');
80
+ /**
81
+ * Sets the browse state `sort`.
82
+ *
83
+ * @public
84
+ */
85
+ const setBrowseSort = wireCommit('setSort');
86
+ /**
87
+ * Sets the browse state `query`.
88
+ *
89
+ * @public
90
+ */
91
+ const setBrowseUrlParamsWire = wireDispatch('setUrlParams');
92
+ /**
93
+ * Sets the browse state `page`.
94
+ *
95
+ * @public
96
+ */
97
+ const setBrowsePage = wireCommit('setPage');
98
+ /**
99
+ * Sets the browse state `params`.
100
+ *
101
+ * @public
102
+ */
103
+ const setBrowseExtraParams = wireCommit('setParams');
104
+ /**
105
+ * Resets the browse state to reload the current browse.
106
+ *
107
+ * @public
108
+ */
109
+ const resetBrowseStateForReloadWire = wireCommitWithoutPayload('resetStateForReload');
110
+ /**
111
+ * Resets the browse state `isNoResults`.
112
+ *
113
+ * @public
114
+ */
115
+ const resetIsNoBrowseResults = wireCommit('setIsNoResults', false);
116
+ /**
117
+ * Resets the browse state `fromNoResultsWithFilters`.
118
+ *
119
+ * @public
120
+ */
121
+ const resetFromNoBrowseResultsWithFilters = wireCommit('setFromNoResultsWithFilters', false);
122
+ /**
123
+ * Increases the current browse state `page` by one.
124
+ *
125
+ * @public
126
+ */
127
+ const increaseBrowsePageAppendingResultsWire = wireDispatchWithoutPayload('increasePageAppendingResults');
128
+ /**
129
+ * Resets the browse state `isAppendingResults`.
130
+ *
131
+ * @public
132
+ */
133
+ const resetBrowseAppending = wireCommit('setIsAppendResults', false);
134
+ /**
135
+ * Resets the {@link BrowseGetters.request} parameters when refining request and before the actual
136
+ * request is launched.
137
+ *
138
+ * @public
139
+ */
140
+ const resetBrowseRequestOnRefinementWire = wireDispatch('resetRequestOnRefinement', ({ eventPayload: newRequest, metadata: { oldValue } }) => ({
141
+ newRequest,
142
+ oldRequest: oldValue,
143
+ }));
144
+ /**
145
+ * Resets the browse state when the request is changed to null. See the
146
+ * {@link BrowseXStoreModule} for details.
147
+ *
148
+ * @public
149
+ */
150
+ const resetBrowseStateIfNoRequestWire = filterTruthyPayload(wireCommitWithoutPayload('resetState'));
151
+ /**
152
+ * Browse wiring.
153
+ *
154
+ * @internal
155
+ */
156
+ const browseWiring = createWiring({
157
+ ParamsLoadedFromUrl: {
158
+ setBrowseUrlParamsWire,
159
+ saveBrowseOriginWire,
160
+ },
161
+ UserClickedABrowseSort: {
162
+ setBrowseSort,
163
+ },
164
+ UserReachedResultsListEnd: {
165
+ increaseBrowsePageAppendingResultsWire,
166
+ },
167
+ BrowseRequestUpdated: {
168
+ resetBrowseStateIfNoRequestWire,
169
+ fetchAndSaveBrowseResponseWire,
170
+ },
171
+ BrowseRequestChanged: {
172
+ resetBrowseRequestOnRefinementWire,
173
+ },
174
+ SelectedFiltersForRequestChanged: {
175
+ setBrowseSelectedFilters,
176
+ },
177
+ ResultsChanged: {
178
+ resetBrowseAppending,
179
+ fetchAndSaveBrowseResultsEnrichmentWire,
180
+ },
181
+ ReloadBrowseRequested: {
182
+ resetBrowseStateForReloadWire,
183
+ },
184
+ SelectedSortProvided: {
185
+ setBrowseSort,
186
+ },
187
+ ExtraParamsChanged: {
188
+ setBrowseExtraParams,
189
+ },
190
+ UserClickedCloseX: {
191
+ clearBrowseQuery,
192
+ resetBrowseStateForReloadWire,
193
+ cancelFetchAndSaveBrowseResponseWire,
194
+ },
195
+ UserClickedOpenX: {
196
+ clearBrowseQuery,
197
+ resetBrowseStateForReloadWire,
198
+ cancelFetchAndSaveBrowseResponseWire,
199
+ },
200
+ UserClickedOutOfMainModal: {
201
+ clearBrowseQuery,
202
+ },
203
+ UserSelectedAPage: {
204
+ setBrowsePage,
205
+ resetBrowseAppending,
206
+ },
207
+ UserBrowsedToCategory: {
208
+ setBrowseCategory,
209
+ },
210
+ });
211
+
212
+ export { browseWiring, cancelFetchAndSaveBrowseResponseWire, clearBrowseQuery, fetchAndSaveBrowseResponseWire, fetchAndSaveBrowseResultsEnrichmentWire, increaseBrowsePageAppendingResultsWire, resetBrowseAppending, resetBrowseRequestOnRefinementWire, resetBrowseStateForReloadWire, resetBrowseStateIfNoRequestWire, resetFromNoBrowseResultsWithFilters, resetIsNoBrowseResults, saveBrowseOriginWire, setBrowseCategory, setBrowseExtraParams, setBrowsePage, setBrowseSelectedFilters, setBrowseSort, setBrowseUrlParamsWire };
213
+ //# sourceMappingURL=wiring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiring.js","sources":["../../../../src/x-modules/browse/wiring.ts"],"sourcesContent":["import type { WirePayload } from '../../wiring'\nimport type { InternalBrowseRequest } from './types'\nimport {\n createWiring,\n filterTruthyPayload,\n namespacedWireCommit,\n namespacedWireCommitWithoutPayload,\n namespacedWireDispatch,\n namespacedWireDispatchWithoutPayload,\n} from '../../wiring'\n\n/**\n * `browse` {@link XModuleName | XModule name}.\n *\n * @internal\n */\nconst moduleName = 'browse'\n\n/**\n * WireCommit for {@link BrowseXModule}.\n *\n * @internal\n */\nconst wireCommit = namespacedWireCommit(moduleName)\n\n/**\n * WireCommit without Payload for {@link BrowseXModule}.\n *\n * @internal\n */\nconst wireCommitWithoutPayload = namespacedWireCommitWithoutPayload(moduleName)\n\n/**\n * WireDispatch for {@link BrowseXModule}.\n *\n * @internal\n */\nconst wireDispatch = namespacedWireDispatch(moduleName)\n\n/**\n * WireDispatchWithoutPayload for {@link BrowseXModule}.\n *\n * @internal\n */\nconst wireDispatchWithoutPayload = namespacedWireDispatchWithoutPayload(moduleName)\n\n/**\n * Cancels the {@link BrowseActions.fetchAndSaveBrowseResponse} request promise.\n *\n * @public\n */\nexport const cancelFetchAndSaveBrowseResponseWire = wireDispatchWithoutPayload(\n 'cancelFetchAndSaveBrowseResponse',\n)\n\n/**\n * Sets the browse state `origin`.\n *\n * @public\n */\nexport const saveBrowseOriginWire = wireDispatch('saveOrigin', ({ metadata }) => metadata)\n\n/**\n * Requests and stores the browse response.\n *\n * @public\n */\nexport const fetchAndSaveBrowseResponseWire = wireDispatch('fetchAndSaveBrowseResponse')\n\n/**\n * Requests and stores the enrichment results for the results.\n *\n * @public\n */\nexport const fetchAndSaveBrowseResultsEnrichmentWire = wireDispatch('fetchAndSaveResultsEnrichment')\n\n/**\n * Sets the browse state `selectedCategory`.\n *\n * @public\n */\nexport const setBrowseCategory = wireCommit('setSelectedCategory')\n\n/**\n * Clears the browse state `selectedCategory`.\n *\n * @public\n */\nexport const clearBrowseQuery = wireCommit('setSelectedCategory', {\n browseField: '',\n browseValue: '',\n})\n\n/**\n * Sets the browse state `selectedFilters`.\n *\n * @public\n */\nexport const setBrowseSelectedFilters = wireCommit('setSelectedFilters')\n\n/**\n * Sets the browse state `sort`.\n *\n * @public\n */\nexport const setBrowseSort = wireCommit('setSort')\n\n/**\n * Sets the browse state `query`.\n *\n * @public\n */\nexport const setBrowseUrlParamsWire = wireDispatch('setUrlParams')\n\n/**\n * Sets the browse state `page`.\n *\n * @public\n */\nexport const setBrowsePage = wireCommit('setPage')\n\n/**\n * Sets the browse state `params`.\n *\n * @public\n */\nexport const setBrowseExtraParams = wireCommit('setParams')\n\n/**\n * Resets the browse state to reload the current browse.\n *\n * @public\n */\nexport const resetBrowseStateForReloadWire = wireCommitWithoutPayload('resetStateForReload')\n\n/**\n * Resets the browse state `isNoResults`.\n *\n * @public\n */\nexport const resetIsNoBrowseResults = wireCommit('setIsNoResults', false)\n\n/**\n * Resets the browse state `fromNoResultsWithFilters`.\n *\n * @public\n */\nexport const resetFromNoBrowseResultsWithFilters = wireCommit('setFromNoResultsWithFilters', false)\n\n/**\n * Increases the current browse state `page` by one.\n *\n * @public\n */\nexport const increaseBrowsePageAppendingResultsWire = wireDispatchWithoutPayload(\n 'increasePageAppendingResults',\n)\n\n/**\n * Resets the browse state `isAppendingResults`.\n *\n * @public\n */\nexport const resetBrowseAppending = wireCommit('setIsAppendResults', false)\n\n/**\n * Resets the {@link BrowseGetters.request} parameters when refining request and before the actual\n * request is launched.\n *\n * @public\n */\nexport const resetBrowseRequestOnRefinementWire = wireDispatch(\n 'resetRequestOnRefinement',\n ({ eventPayload: newRequest, metadata: { oldValue } }: WirePayload<InternalBrowseRequest>) => ({\n newRequest,\n oldRequest: oldValue as InternalBrowseRequest,\n }),\n)\n\n/**\n * Resets the browse state when the request is changed to null. See the\n * {@link BrowseXStoreModule} for details.\n *\n * @public\n */\nexport const resetBrowseStateIfNoRequestWire = filterTruthyPayload<InternalBrowseRequest | null>(\n wireCommitWithoutPayload('resetState'),\n)\n\n/**\n * Browse wiring.\n *\n * @internal\n */\nexport const browseWiring = createWiring({\n ParamsLoadedFromUrl: {\n setBrowseUrlParamsWire,\n saveBrowseOriginWire,\n },\n UserClickedABrowseSort: {\n setBrowseSort,\n },\n UserReachedResultsListEnd: {\n increaseBrowsePageAppendingResultsWire,\n },\n BrowseRequestUpdated: {\n resetBrowseStateIfNoRequestWire,\n fetchAndSaveBrowseResponseWire,\n },\n BrowseRequestChanged: {\n resetBrowseRequestOnRefinementWire,\n },\n SelectedFiltersForRequestChanged: {\n setBrowseSelectedFilters,\n },\n ResultsChanged: {\n resetBrowseAppending,\n fetchAndSaveBrowseResultsEnrichmentWire,\n },\n ReloadBrowseRequested: {\n resetBrowseStateForReloadWire,\n },\n SelectedSortProvided: {\n setBrowseSort,\n },\n ExtraParamsChanged: {\n setBrowseExtraParams,\n },\n UserClickedCloseX: {\n clearBrowseQuery,\n resetBrowseStateForReloadWire,\n cancelFetchAndSaveBrowseResponseWire,\n },\n UserClickedOpenX: {\n clearBrowseQuery,\n resetBrowseStateForReloadWire,\n cancelFetchAndSaveBrowseResponseWire,\n },\n UserClickedOutOfMainModal: {\n clearBrowseQuery,\n },\n UserSelectedAPage: {\n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A;AACD,IAAA,gBAAgB,EAAE;QAChB,gBAAgB;QAChB,6BAA6B;QAC7B,oCAAoC;AACrC,KAAA;AACD,IAAA,yBAAyB,EAAE;QACzB,gBAAgB;AACjB,KAAA;AACD,IAAA,iBAAiB,EAAE;QACjB,aAAa;QACb,oBAAoB;AACrB,KAAA;AACD,IAAA,qBAAqB,EAAE;QACrB,iBAAiB;AAClB,KAAA;AACF,CAAA;;;;"}
@@ -0,0 +1,21 @@
1
+ import { XPlugin } from '../../plugins/x-plugin.js';
2
+ import { browseEmitters } from './store/emitters.js';
3
+ import { browseXStoreModule } from './store/module.js';
4
+ import { browseWiring } from './wiring.js';
5
+
6
+ /**
7
+ * Search {@link XModule} implementation. This module is auto-registered as soon as you
8
+ * import any component from the `browse` entry point.
9
+ *
10
+ * @public
11
+ */
12
+ const browseXModule = {
13
+ name: 'browse',
14
+ storeModule: browseXStoreModule,
15
+ storeEmitters: browseEmitters,
16
+ wiring: browseWiring,
17
+ };
18
+ XPlugin.registerXModule(browseXModule);
19
+
20
+ export { browseXModule };
21
+ //# sourceMappingURL=x-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-module.js","sources":["../../../../src/x-modules/browse/x-module.ts"],"sourcesContent":["// XModule\nimport type { XModule } from '../x-modules.types'\nimport type { BrowseXStoreModule } from './store/types'\nimport { XPlugin } from '../../plugins/x-plugin'\nimport { browseEmitters } from './store/emitters'\nimport { browseXStoreModule } from './store/module'\nimport { browseWiring } from './wiring'\n\n/**\n * Search {@link XModule} alias.\n *\n * @public\n */\nexport type BrowseXModule = XModule<BrowseXStoreModule>\n\n/**\n * Search {@link XModule} implementation. This module is auto-registered as soon as you\n * import any component from the `browse` entry point.\n *\n * @public\n */\nexport const browseXModule: BrowseXModule = {\n name: 'browse',\n storeModule: browseXStoreModule,\n storeEmitters: browseEmitters,\n wiring: browseWiring,\n}\n\nXPlugin.registerXModule(browseXModule)\n"],"names":[],"mappings":";;;;;AAeA;;;;;AAKG;AACI,MAAM,aAAa,GAAkB;AAC1C,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,WAAW,EAAE,kBAAkB;AAC/B,IAAA,aAAa,EAAE,cAAc;AAC7B,IAAA,MAAM,EAAE,YAAY;;AAGtB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"url-handler.vue.js","sources":["../../../../../src/x-modules/url/components/url-handler.vue"],"sourcesContent":["<template>\n <GlobalEvents target=\"window\" @pageshow=\"onPageShow\" @popstate=\"emitEvents\" />\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { FeatureLocation } from '../../../types/origin'\nimport type { UrlParams } from '../../../types/url-params'\nimport type { WireMetadata } from '../../../wiring/wiring.types'\nimport type { SnippetConfig } from '../../../x-installer/api/api.types'\nimport type { UrlParamValue } from '../store/types'\nimport { objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent, inject, onMounted, ref } from 'vue'\nimport { GlobalEvents } from 'vue-global-events'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { initialUrlState } from '../store/initial-state'\nimport { urlXModule } from '../x-module'\n\ninterface ParsedUrlParams {\n all: UrlParams\n extra: Dictionary<unknown>\n}\n\n/**\n * This component manages the browser URL parameters to preserve them through reloads and browser\n * history navigation. It allow to configure the default url parameter names using its attributes.\n * This component doesn't render elements to the DOM.\n *\n * @public\n */\nexport default defineComponent({\n name: 'UrlHandler',\n components: {\n GlobalEvents,\n },\n xModule: urlXModule.name,\n inheritAttrs: false,\n setup(_, { attrs }) {\n const $x = use$x()\n\n const { initialExtraParams } = useState('url')\n\n /**\n * The {@link SnippetConfig} provided by an ancestor.\n *\n * @internal\n */\n const snippetConfig = inject<SnippetConfig | undefined>('snippetConfig')\n\n /**\n * Flag to know if the params were already loaded from the URL.\n *\n * @internal\n */\n const urlLoaded = ref(false)\n\n /**\n * The page URL. It is used to compare against the current URL to check navigation state.\n *\n * @internal\n */\n const url = ref<URL | undefined>(undefined)\n\n /**\n * Flag to know if the page has been persisted by the browser's back-forward cache.\n *\n * @internal\n */\n const isPagePersisted = ref(false)\n\n /**\n * Computed to know which params we must get from URL. It gets the params names from the initial\n * state, to get all default params names, and also from the `$attrs` to get the extra params\n * names to take into account.\n *\n * @returns An array with the name of the params.\n *\n * @internal\n */\n const managedParamsNames = computed(() => Object.keys({ ...initialUrlState, ...attrs }))\n\n /**\n * Returns the mapping of the param keys used in the URL is configured through $attrs. This way\n * we can support any param and extra param, no matters its name.\n *\n * @param paramName - The param name to get the Url key.\n * @returns The key used in the URL for the `paramName` passed.\n *\n * @internal\n */\n const getUrlKey = (paramName: string) => {\n const paramValue = attrs[paramName]\n return typeof paramValue === 'string' ? paramValue : paramName\n }\n\n /**\n * Deletes all the parameters in the passed URL.\n *\n * @param url - The URL to remove parameters from.\n * @internal\n */\n const deleteUrlParameters = (url: URL) => {\n managedParamsNames.value.forEach(paramName => url.searchParams.delete(getUrlKey(paramName)))\n }\n\n /**\n * Sorts the params in a tuple array [key,value] to generate always the same URL with the params\n * in the same order.\n *\n * @param urlParams - The {@link UrlParams} to sort.\n * @returns An array of tuples with the key-value of each paramter, sorted by key.\n * @internal\n */\n const sortParams = (urlParams: UrlParams): Array<[string, unknown]> => {\n return Object.entries(urlParams).sort(([param1], [param2]) => {\n return param1 < param2 ? -1 : 1\n })\n }\n\n /**\n * Set all the provided parameters to the url with the mapped key.\n *\n * @param url - The current URL.\n * @param urlParams - The list of parameters to add.\n * @remarks The params are filtered because there maybe received extra params which will not be\n * managed by URL. This is defined by the `managedParamsNames` computed. Also, the parameters\n * are sorted Alphabetically to produce always the same URL with the same parameters.This is\n * important for SEO purposes.\n *\n * @internal\n */\n const setUrlParameters = (url: URL, urlParams: UrlParams): void => {\n // Only when there is a query the rest of the parameters are valid.\n if (!urlParams.query) {\n return\n }\n const filteredParams = objectFilter(urlParams, paramName =>\n managedParamsNames.value.includes(paramName as string),\n )\n const sortedParameters = sortParams(filteredParams)\n sortedParameters.forEach(([paramName, paramValue]) => {\n const urlParamKey = getUrlKey(paramName)\n if (Array.isArray(paramValue)) {\n paramValue.forEach(value => {\n url.searchParams.append(urlParamKey, String(value))\n })\n } else {\n url.searchParams.set(urlParamKey, String(paramValue))\n }\n })\n }\n\n /**\n * Updates the browser URL with the passed `newUrlParams` and using the browser history method\n * passed as `historyMethod`. It only updates the browser history if the new URL is different\n * from the current.\n *\n * @param newUrlParams - The new params to add to the browser URL.\n * @param historyMethod - The browser history method used to add the new URL.\n *\n * @internal\n */\n const updateUrl = (\n newUrlParams: UrlParams,\n historyMethod: History['pushState'] | History['replaceState'],\n ): void => {\n if (urlLoaded.value) {\n const newUrl = new URL(window.location.href)\n deleteUrlParameters(newUrl)\n setUrlParameters(newUrl, newUrlParams)\n\n // Normalize '+' characters into '%20' for spaces in url params.\n newUrl.search = newUrl.search.replace(/\\+/g, '%20')\n\n if (newUrl.href !== window.location.href) {\n historyMethod({ ...window.history.state }, document.title, newUrl.href)\n }\n url.value = newUrl\n }\n }\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `pushState` method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('PushableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.pushState.bind(window.history))\n })\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `replaceState`\n * method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('ReplaceableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.replaceState.bind(window.history))\n })\n\n /**\n * Handler of the\n * [pageshow](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event)\n * event.\n *\n * @remarks The pageshow event is listened to check if the browser has performed a navigation\n * using the back-forward cache. This information is available in the\n * PageTransitionEvent.persisted property.\n *\n * @param event - The page transition event.\n * @internal\n */\n const onPageShow = (event: PageTransitionEvent) => {\n isPagePersisted.value = event.persisted\n if (event.persisted) {\n // The internal url is reset due to the back-forward cache storing the previous value which\n // is no longer valid.\n url.value = undefined\n }\n }\n\n /**\n * Returns the URL param value parsed depending on its type in the initial store state. As we\n * can not know what type can have an extra param, all extra params are parsed as strings. We\n * know if it is an extra param because it is not in the initial state.\n *\n * @param name - The name of the param in {@link UrlParams}.\n * @param value - The `URLSearchParams` value as an arry of strings.\n * @returns The parsed value.\n *\n * @internal\n */\n const parseUrlParam = (name: string, value: string[]): UrlParamValue => {\n switch (typeof initialUrlState[name]) {\n case 'number':\n return Number(value[0])\n case 'boolean':\n return value[0].toLowerCase() === 'true'\n case 'string':\n return value[0]\n default:\n // array\n return value\n }\n }\n\n /**\n * Gets the {@link UrlParams} from the URL, including only the params defined by `paramsNames`.\n *\n * @returns ParsedUrlParams obtained from URL.\n * @internal\n */\n const parseUrlParams = (): ParsedUrlParams => {\n const urlSearchParams = new URL(window.location.href).searchParams\n return managedParamsNames.value.reduce<ParsedUrlParams>(\n (params, name) => {\n const urlKey = getUrlKey(name)\n if (urlSearchParams.has(urlKey)) {\n if (name in initialUrlState) {\n const urlValue = urlSearchParams.getAll(urlKey)\n params.all[name] = parseUrlParam(name, urlValue)\n } else {\n params.all[name] = params.extra[name] = urlSearchParams.get(urlKey)\n }\n }\n return params\n },\n { all: { ...initialUrlState }, extra: { ...initialExtraParams.value } },\n )\n }\n\n /**\n * Check if the navigation is from a product page.\n *\n * @remarks Due to Safari 14 not supporting the new and standard PerformanceNavigationTiming\n * API, we are falling back to the deprecated one, PerformanceNavigation. We also fallback to\n * this API whenever we get a navigationType equal to reload, because Safari has a bug that the\n * navigationType is permanently set to reload after you have reload the page and it never\n * resets. As some browsers have a back-forward cache implemented, we also take into account if\n * the page is persisted.\n *\n * @returns True if the navigation is from a product page, false otherwise.\n * @internal\n */\n const isNavigatingFromPdp = (): boolean => {\n const isPagePersistedValue = isPagePersisted.value\n const navigationEntries = window.performance.getEntriesByType('navigation')\n const navigationType = (navigationEntries[0] as PerformanceNavigationTiming)?.type\n const useFallbackStrategy =\n !navigationEntries.length &&\n (isArrayEmpty(navigationEntries) || navigationType === 'reload')\n\n // Reset internal isPagePersisted property value\n isPagePersisted.value = false\n\n if (useFallbackStrategy) {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n } else {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n }\n }\n\n /**\n * Detects the {@link FeatureLocation} used to build the\n * {@link QueryOriginInit} data.\n *\n * @returns The {@link FeatureLocation}.\n * @internal\n */\n const detectLocation = (): FeatureLocation => {\n const currentUrl = new URL(window.location.href)\n const previousUrl = url.value\n url.value = currentUrl\n\n const isInternalNavigation =\n previousUrl?.search !== currentUrl.search && previousUrl?.pathname === currentUrl.pathname\n if (isInternalNavigation) {\n return 'url_history'\n }\n\n if (isNavigatingFromPdp()) {\n return 'url_history_pdp'\n }\n\n return 'external'\n }\n\n /**\n * Creates the wire metadata to include in every emitted {@link XEvent}.\n *\n * @returns The {@link WireMetadata}.\n * @internal\n */\n const createWireMetadata = (): Pick<WireMetadata, 'feature' | 'location'> => {\n return {\n feature: 'url',\n location: detectLocation(),\n }\n }\n\n /**\n * Emits the {@link UrlXEvents.ParamsLoadedFromUrl} XEvent,\n * the {@link UrlXEvents.ExtraParamsLoadedFromUrl} XEvent and, if there is query, also emits\n * the {@link XEventsTypes.UserOpenXProgrammatically}.\n *\n * @internal\n */\n const emitEvents = () => {\n const { all, extra } = parseUrlParams()\n const metadata = createWireMetadata()\n $x.emit('ParamsLoadedFromUrl', all, metadata)\n $x.emit('ExtraParamsLoadedFromUrl', extra, metadata)\n if (all.query) {\n $x.emit('UserOpenXProgrammatically', undefined, metadata)\n }\n urlLoaded.value = true\n }\n\n /**\n * To emit the Url events just when the URL is load, and before the components mounted events\n * and state changes, we do it in the created of this component.\n */\n onMounted(() => {\n emitEvents()\n })\n\n return {\n onPageShow,\n emitEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`ParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`ExtraParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`UserOpenXProgrammatically`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component manages the browser URL parameters to preserve them through reloads and browser\nhistory navigation. It allows you to configure the default URL parameter names using its attributes. This\ncomponent doesn't render elements to the DOM.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with props\n\nIn this example, the `UrlHandler` component changes the following query parameter names:\n\n- `query` to be `q`.\n- `page` to be `p`.\n- `filter` to be `f`.\n- `sort` to be `s`.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with events\n\nThe `UrlHandler` will emit the `ParamsLoadedFromUrl` when the page is loaded.\n\nThe `UrlHandler` will emit the `ExtraParamsLoadedFromUrl` when the page is loaded with an extra\nparam configured and with a value in the URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":["_createBlock"],"mappings":";;;;;;sBACEA,WAAA,CAA8E,uBAAA,EAAA;AAAA,IAAhE,MAAA,EAAO,QAAA;AAAA,IAAU,UAAA,EAAU,IAAA,CAAA,UAAA;AAAA,IAAa,UAAA,EAAU,IAAA,CAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,YAAA,EAAA,YAAA,CAAA,CAAA;;;;;;"}
1
+ {"version":3,"file":"url-handler.vue.js","sources":["../../../../../src/x-modules/url/components/url-handler.vue"],"sourcesContent":["<template>\n <GlobalEvents target=\"window\" @pageshow=\"onPageShow\" @popstate=\"emitEvents\" />\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { FeatureLocation } from '../../../types/origin'\nimport type { UrlParams } from '../../../types/url-params'\nimport type { WireMetadata } from '../../../wiring/wiring.types'\nimport type { SnippetConfig } from '../../../x-installer/api/api.types'\nimport type { UrlParamValue } from '../store/types'\nimport { objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent, inject, onMounted, ref } from 'vue'\nimport { GlobalEvents } from 'vue-global-events'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { initialUrlState } from '../store/initial-state'\nimport { urlXModule } from '../x-module'\n\ninterface ParsedUrlParams {\n all: UrlParams\n extra: Dictionary<unknown>\n}\n\n/**\n * This component manages the browser URL parameters to preserve them through reloads and browser\n * history navigation. It allow to configure the default url parameter names using its attributes.\n * This component doesn't render elements to the DOM.\n *\n * @public\n */\nexport default defineComponent({\n name: 'UrlHandler',\n components: {\n GlobalEvents,\n },\n xModule: urlXModule.name,\n inheritAttrs: false,\n setup(_, { attrs }) {\n const $x = use$x()\n\n const { initialExtraParams } = useState('url')\n\n /**\n * The {@link SnippetConfig} provided by an ancestor.\n *\n * @internal\n */\n const snippetConfig = inject<SnippetConfig | undefined>('snippetConfig')\n\n /**\n * Flag to know if the params were already loaded from the URL.\n *\n * @internal\n */\n const urlLoaded = ref(false)\n\n /**\n * The page URL. It is used to compare against the current URL to check navigation state.\n *\n * @internal\n */\n const url = ref<URL | undefined>(undefined)\n\n /**\n * Flag to know if the page has been persisted by the browser's back-forward cache.\n *\n * @internal\n */\n const isPagePersisted = ref(false)\n\n /**\n * Computed to know which params we must get from URL. It gets the params names from the initial\n * state, to get all default params names, and also from the `$attrs` to get the extra params\n * names to take into account.\n *\n * @returns An array with the name of the params.\n *\n * @internal\n */\n const managedParamsNames = computed(() => Object.keys({ ...initialUrlState, ...attrs }))\n\n /**\n * Returns the mapping of the param keys used in the URL is configured through $attrs. This way\n * we can support any param and extra param, no matters its name.\n *\n * @param paramName - The param name to get the Url key.\n * @returns The key used in the URL for the `paramName` passed.\n *\n * @internal\n */\n const getUrlKey = (paramName: string) => {\n const paramValue = attrs[paramName]\n return typeof paramValue === 'string' ? paramValue : paramName\n }\n\n /**\n * Deletes all the parameters in the passed URL.\n *\n * @param url - The URL to remove parameters from.\n * @internal\n */\n const deleteUrlParameters = (url: URL) => {\n managedParamsNames.value.forEach(paramName => url.searchParams.delete(getUrlKey(paramName)))\n }\n\n /**\n * Sorts the params in a tuple array [key,value] to generate always the same URL with the params\n * in the same order.\n *\n * @param urlParams - The {@link UrlParams} to sort.\n * @returns An array of tuples with the key-value of each paramter, sorted by key.\n * @internal\n */\n const sortParams = (urlParams: UrlParams): Array<[string, unknown]> => {\n return Object.entries(urlParams).sort(([param1], [param2]) => {\n return param1 < param2 ? -1 : 1\n })\n }\n\n /**\n * Set all the provided parameters to the url with the mapped key.\n *\n * @param url - The current URL.\n * @param urlParams - The list of parameters to add.\n * @remarks The params are filtered because there maybe received extra params which will not be\n * managed by URL. This is defined by the `managedParamsNames` computed. Also, the parameters\n * are sorted Alphabetically to produce always the same URL with the same parameters.This is\n * important for SEO purposes.\n *\n * @internal\n */\n const setUrlParameters = (url: URL, urlParams: UrlParams): void => {\n // Only when there is a query the rest of the parameters are valid.\n if (!urlParams.query && !urlParams.browseField && !urlParams.browseValue) {\n return\n }\n const filteredParams = objectFilter(urlParams, paramName =>\n managedParamsNames.value.includes(paramName as string),\n )\n const sortedParameters = sortParams(filteredParams)\n sortedParameters.forEach(([paramName, paramValue]) => {\n const urlParamKey = getUrlKey(paramName)\n if (Array.isArray(paramValue)) {\n paramValue.forEach(value => {\n url.searchParams.append(urlParamKey, String(value))\n })\n } else {\n url.searchParams.set(urlParamKey, String(paramValue))\n }\n })\n }\n\n /**\n * Updates the browser URL with the passed `newUrlParams` and using the browser history method\n * passed as `historyMethod`. It only updates the browser history if the new URL is different\n * from the current.\n *\n * @param newUrlParams - The new params to add to the browser URL.\n * @param historyMethod - The browser history method used to add the new URL.\n *\n * @internal\n */\n const updateUrl = (\n newUrlParams: UrlParams,\n historyMethod: History['pushState'] | History['replaceState'],\n ): void => {\n if (urlLoaded.value) {\n const newUrl = new URL(window.location.href)\n deleteUrlParameters(newUrl)\n setUrlParameters(newUrl, newUrlParams)\n\n // Normalize '+' characters into '%20' for spaces in url params.\n newUrl.search = newUrl.search.replace(/\\+/g, '%20')\n\n if (newUrl.href !== window.location.href) {\n historyMethod({ ...window.history.state }, document.title, newUrl.href)\n }\n url.value = newUrl\n }\n }\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `pushState` method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('PushableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.pushState.bind(window.history))\n })\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `replaceState`\n * method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('ReplaceableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.replaceState.bind(window.history))\n })\n\n /**\n * Handler of the\n * [pageshow](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event)\n * event.\n *\n * @remarks The pageshow event is listened to check if the browser has performed a navigation\n * using the back-forward cache. This information is available in the\n * PageTransitionEvent.persisted property.\n *\n * @param event - The page transition event.\n * @internal\n */\n const onPageShow = (event: PageTransitionEvent) => {\n isPagePersisted.value = event.persisted\n if (event.persisted) {\n // The internal url is reset due to the back-forward cache storing the previous value which\n // is no longer valid.\n url.value = undefined\n }\n }\n\n /**\n * Returns the URL param value parsed depending on its type in the initial store state. As we\n * can not know what type can have an extra param, all extra params are parsed as strings. We\n * know if it is an extra param because it is not in the initial state.\n *\n * @param name - The name of the param in {@link UrlParams}.\n * @param value - The `URLSearchParams` value as an arry of strings.\n * @returns The parsed value.\n *\n * @internal\n */\n const parseUrlParam = (name: string, value: string[]): UrlParamValue => {\n switch (typeof initialUrlState[name]) {\n case 'number':\n return Number(value[0])\n case 'boolean':\n return value[0].toLowerCase() === 'true'\n case 'string':\n return value[0]\n default:\n // array\n return value\n }\n }\n\n /**\n * Gets the {@link UrlParams} from the URL, including only the params defined by `paramsNames`.\n *\n * @returns ParsedUrlParams obtained from URL.\n * @internal\n */\n const parseUrlParams = (): ParsedUrlParams => {\n const urlSearchParams = new URL(window.location.href).searchParams\n return managedParamsNames.value.reduce<ParsedUrlParams>(\n (params, name) => {\n const urlKey = getUrlKey(name)\n if (urlSearchParams.has(urlKey)) {\n if (name in initialUrlState) {\n const urlValue = urlSearchParams.getAll(urlKey)\n params.all[name] = parseUrlParam(name, urlValue)\n } else {\n params.all[name] = params.extra[name] = urlSearchParams.get(urlKey)\n }\n }\n return params\n },\n { all: { ...initialUrlState }, extra: { ...initialExtraParams.value } },\n )\n }\n\n /**\n * Check if the navigation is from a product page.\n *\n * @remarks Due to Safari 14 not supporting the new and standard PerformanceNavigationTiming\n * API, we are falling back to the deprecated one, PerformanceNavigation. We also fallback to\n * this API whenever we get a navigationType equal to reload, because Safari has a bug that the\n * navigationType is permanently set to reload after you have reload the page and it never\n * resets. As some browsers have a back-forward cache implemented, we also take into account if\n * the page is persisted.\n *\n * @returns True if the navigation is from a product page, false otherwise.\n * @internal\n */\n const isNavigatingFromPdp = (): boolean => {\n const isPagePersistedValue = isPagePersisted.value\n const navigationEntries = window.performance.getEntriesByType('navigation')\n const navigationType = (navigationEntries[0] as PerformanceNavigationTiming)?.type\n const useFallbackStrategy =\n !navigationEntries.length &&\n (isArrayEmpty(navigationEntries) || navigationType === 'reload')\n\n // Reset internal isPagePersisted property value\n isPagePersisted.value = false\n\n if (useFallbackStrategy) {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n } else {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n }\n }\n\n /**\n * Detects the {@link FeatureLocation} used to build the\n * {@link QueryOriginInit} data.\n *\n * @returns The {@link FeatureLocation}.\n * @internal\n */\n const detectLocation = (): FeatureLocation => {\n const currentUrl = new URL(window.location.href)\n const previousUrl = url.value\n url.value = currentUrl\n\n const isInternalNavigation =\n previousUrl?.search !== currentUrl.search && previousUrl?.pathname === currentUrl.pathname\n if (isInternalNavigation) {\n return 'url_history'\n }\n\n if (isNavigatingFromPdp()) {\n return 'url_history_pdp'\n }\n\n return 'external'\n }\n\n /**\n * Creates the wire metadata to include in every emitted {@link XEvent}.\n *\n * @returns The {@link WireMetadata}.\n * @internal\n */\n const createWireMetadata = (): Pick<WireMetadata, 'feature' | 'location'> => {\n return {\n feature: 'url',\n location: detectLocation(),\n }\n }\n\n /**\n * Emits the {@link UrlXEvents.ParamsLoadedFromUrl} XEvent,\n * the {@link UrlXEvents.ExtraParamsLoadedFromUrl} XEvent and, if there is query, also emits\n * the {@link XEventsTypes.UserOpenXProgrammatically}.\n *\n * @internal\n */\n const emitEvents = () => {\n const { all, extra } = parseUrlParams()\n const metadata = createWireMetadata()\n $x.emit('ParamsLoadedFromUrl', all, metadata)\n $x.emit('ExtraParamsLoadedFromUrl', extra, metadata)\n if (all.query) {\n $x.emit('UserOpenXProgrammatically', undefined, metadata)\n } else if (all.browseField && all.browseValue) {\n $x.emit(\n 'UserBrowsedToCategory',\n { browseValue: all.browseValue, browseField: all.browseField },\n metadata,\n )\n }\n urlLoaded.value = true\n }\n\n /**\n * To emit the Url events just when the URL is load, and before the components mounted events\n * and state changes, we do it in the created of this component.\n */\n onMounted(() => {\n emitEvents()\n })\n\n return {\n onPageShow,\n emitEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`ParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`ExtraParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`UserOpenXProgrammatically`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component manages the browser URL parameters to preserve them through reloads and browser\nhistory navigation. It allows you to configure the default URL parameter names using its attributes. This\ncomponent doesn't render elements to the DOM.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with props\n\nIn this example, the `UrlHandler` component changes the following query parameter names:\n\n- `query` to be `q`.\n- `page` to be `p`.\n- `filter` to be `f`.\n- `sort` to be `s`.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with events\n\nThe `UrlHandler` will emit the `ParamsLoadedFromUrl` when the page is loaded.\n\nThe `UrlHandler` will emit the `ExtraParamsLoadedFromUrl` when the page is loaded with an extra\nparam configured and with a value in the URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":["_createBlock"],"mappings":";;;;;;sBACEA,WAAA,CAA8E,uBAAA,EAAA;AAAA,IAAhE,MAAA,EAAO,QAAA;AAAA,IAAU,UAAA,EAAU,IAAA,CAAA,UAAA;AAAA,IAAa,UAAA,EAAU,IAAA,CAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,YAAA,EAAA,YAAA,CAAA,CAAA;;;;;;"}