@empathyco/x-components 6.0.0-alpha.164 → 6.0.0-alpha.166

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 (32) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/ai/index.js +7 -0
  3. package/core/index.js.map +1 -1
  4. package/docs/API-reference/api/x-components.aiquery.md +13 -0
  5. package/docs/API-reference/api/x-components.aisuggestionsrequest.md +13 -0
  6. package/docs/API-reference/api/x-components.aisuggestionssearchrequest.md +13 -0
  7. package/docs/API-reference/api/x-components.fetchandsaveaisuggestions.md +13 -0
  8. package/docs/API-reference/api/x-components.fetchandsaveaisuggestionssearch.md +13 -0
  9. package/docs/API-reference/api/x-components.md +7 -0
  10. package/docs/API-reference/api/x-components.saveaiorigin.md +13 -0
  11. package/docs/API-reference/api/x-components.setaiurlparams.md +13 -0
  12. package/js/index.js +7 -0
  13. package/js/index.js.map +1 -1
  14. package/js/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.js +9 -0
  15. package/js/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.js.map +1 -1
  16. package/js/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.js +0 -1
  17. package/js/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.js.map +1 -1
  18. package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
  19. package/js/x-modules/url/components/url-handler.vue2.js +1 -0
  20. package/js/x-modules/url/components/url-handler.vue2.js.map +1 -1
  21. package/package.json +2 -2
  22. package/report/x-components.api.json +196 -0
  23. package/report/x-components.api.md +21 -0
  24. package/types/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.d.ts +9 -0
  25. package/types/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.d.ts.map +1 -1
  26. package/types/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.d.ts +0 -1
  27. package/types/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.d.ts.map +1 -1
  28. package/types/x-modules/ai/store/actions/index.d.ts +5 -0
  29. package/types/x-modules/ai/store/actions/index.d.ts.map +1 -0
  30. package/types/x-modules/ai/store/index.d.ts +2 -0
  31. package/types/x-modules/ai/store/index.d.ts.map +1 -1
  32. package/types/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.0.0-alpha.166 (2025-10-24)
7
+
8
+ * fix(ai): export missing store things (#1907) ([ac5f37a](https://github.com/empathyco/x/commit/ac5f37a)), closes [#1907](https://github.com/empathyco/x/issues/1907)
9
+
10
+
11
+
12
+
13
+
14
+ ## 6.0.0-alpha.165 (2025-10-22)
15
+
16
+ * fix(url-handler): disable attribute inheritance to avoid error with GlobalEvents ([dfa0979](https://github.com/empathyco/x/commit/dfa0979))
17
+
18
+
19
+
20
+
21
+
6
22
  ## 6.0.0-alpha.164 (2025-10-20)
7
23
 
8
24
  * feat(ai): connect query preview selection with ai module (#1904) ([400bacb](https://github.com/empathyco/x/commit/400bacb)), closes [#1904](https://github.com/empathyco/x/issues/1904)
package/ai/index.js CHANGED
@@ -1,5 +1,12 @@
1
1
  export { default as AiOverview } from '../js/x-modules/ai/components/ai-overview.vue.js';
2
+ export { fetchAndSaveAiSuggestionsSearch } from '../js/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.js';
3
+ export { fetchAndSaveAiSuggestions } from '../js/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.js';
4
+ export { saveOrigin as saveAiOrigin } from '../js/x-modules/ai/store/actions/save-origin.action.js';
5
+ export { setUrlParams as setAiUrlParams } from '../js/x-modules/ai/store/actions/set-url-params.action.js';
2
6
  export { aiEmitters } from '../js/x-modules/ai/store/emitters.js';
7
+ export { query as aiQuery } from '../js/x-modules/ai/store/getters/ai-query.getter.js';
8
+ export { suggestionsRequest as aiSuggestionsRequest } from '../js/x-modules/ai/store/getters/suggestions-request.getter.js';
9
+ export { suggestionsSearchRequest as aiSuggestionsSearchRequest } from '../js/x-modules/ai/store/getters/suggestions-search-request.getter.js';
3
10
  export { aiXStoreModule } from '../js/x-modules/ai/store/module.js';
4
11
  export { aiWiring } from '../js/x-modules/ai/wiring.js';
5
12
  export { aiXModule } from '../js/x-modules/ai/x-module.js';
package/core/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [aiQuery](./x-components.aiquery.md)
4
+
5
+ ## aiQuery variable
6
+
7
+ Default implementation for the related prompts query getter.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ query: AiXStoreModule['getters']['query']
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [aiSuggestionsRequest](./x-components.aisuggestionsrequest.md)
4
+
5
+ ## aiSuggestionsRequest variable
6
+
7
+ Default implementation for the [AiGetters.suggestionsRequest](./x-components.aigetters.suggestionsrequest.md) getter.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ suggestionsRequest: AiXStoreModule['getters']['suggestionsRequest']
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [aiSuggestionsSearchRequest](./x-components.aisuggestionssearchrequest.md)
4
+
5
+ ## aiSuggestionsSearchRequest variable
6
+
7
+ Default implementation for the [AiGetters.suggestionsSearchRequest](./x-components.aigetters.suggestionssearchrequest.md) getter.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ suggestionsSearchRequest: AiXStoreModule['getters']['suggestionsSearchRequest']
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [fetchAndSaveAiSuggestions](./x-components.fetchandsaveaisuggestions.md)
4
+
5
+ ## fetchAndSaveAiSuggestions variable
6
+
7
+ Default implementation for the [AiActions.fetchAndSaveAiSuggestions](./x-components.aiactions.fetchandsaveaisuggestions.md)<!-- -->.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ fetchAndSaveAiSuggestions: AiXStoreModule['actions']['fetchAndSaveAiSuggestions']
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [fetchAndSaveAiSuggestionsSearch](./x-components.fetchandsaveaisuggestionssearch.md)
4
+
5
+ ## fetchAndSaveAiSuggestionsSearch variable
6
+
7
+ Default implementation for the [AiActions.fetchAndSaveAiSuggestionsSearch](./x-components.aiactions.fetchandsaveaisuggestionssearch.md)<!-- -->.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ fetchAndSaveAiSuggestionsSearch: AiXStoreModule['actions']['fetchAndSaveAiSuggestionsSearch']
13
+ ```
@@ -340,6 +340,9 @@ X-Components is a library usable everywhere not only for search experiences.
340
340
  | [addQueryToHistoryQueries](./x-components.addquerytohistoryqueries.md) | Saves a new query into the history queries. |
341
341
  | [addQueryToHistoryQueriesFromPreview](./x-components.addquerytohistoryqueriesfrompreview.md) | Saves the selectedQueryPreview query into the history queries. |
342
342
  | [AiOverview](./x-components.aioverview.md) | |
343
+ | [aiQuery](./x-components.aiquery.md) | Default implementation for the related prompts query getter. |
344
+ | [aiSuggestionsRequest](./x-components.aisuggestionsrequest.md) | Default implementation for the [AiGetters.suggestionsRequest](./x-components.aigetters.suggestionsrequest.md) getter. |
345
+ | [aiSuggestionsSearchRequest](./x-components.aisuggestionssearchrequest.md) | Default implementation for the [AiGetters.suggestionsSearchRequest](./x-components.aigetters.suggestionssearchrequest.md) getter. |
343
346
  | [aiXModule](./x-components.aixmodule.md) | AI [XModule](./x-components.xmodule.md) implementation. This module is auto-registered as soon as you import any component from the <code>AI</code> entry point. |
344
347
  | [AllFilter](./x-components.allfilter.md) | This component receives a required <code>facet</code> with [BooleanFilter](./x-types.booleanfilter.md) as prop and renders a button, which on clicked emits the [FacetsXEvents.UserClickedAllFilter](./x-components.facetsxevents.userclickedallfilter.md) event. By default the rendered button displays a message with the facet label but this content is customizable through the default slot. |
345
348
  | [AnimateWidth](./x-components.animatewidth.md) | Renders a transition wrapping an element passed in the default slot and animating its width. |
@@ -426,6 +429,8 @@ X-Components is a library usable everywhere not only for search experiences.
426
429
  | [Fade](./x-components.fade.md) | Renders a transition wrapping the element passed in the default slot. The animation just fades in/out the element by changing its opacity. |
427
430
  | [FadeAndSlide](./x-components.fadeandslide.md) | Renders a transition group wrapping the elements passed in the default slot and animating them with a fade and slide animation. |
428
431
  | [FallbackDisclaimer](./x-components.fallbackdisclaimer.md) | The <code>FallbackDisclaimer</code> component shows a message if the filters have been removed from the current search because there were no results. |
432
+ | [fetchAndSaveAiSuggestions](./x-components.fetchandsaveaisuggestions.md) | Default implementation for the [AiActions.fetchAndSaveAiSuggestions](./x-components.aiactions.fetchandsaveaisuggestions.md)<!-- -->. |
433
+ | [fetchAndSaveAiSuggestionsSearch](./x-components.fetchandsaveaisuggestionssearch.md) | Default implementation for the [AiActions.fetchAndSaveAiSuggestionsSearch](./x-components.aiactions.fetchandsaveaisuggestionssearch.md)<!-- -->. |
429
434
  | [fetchAndSaveExperienceControlsWire](./x-components.fetchandsaveexperiencecontrolswire.md) | Requests and stores a new set of controls results. |
430
435
  | [fetchAndSaveIdentifierResultsWire](./x-components.fetchandsaveidentifierresultswire.md) | Requests and stores a new set of identifier results for the query. |
431
436
  | [fetchAndSaveNextQueriesWire](./x-components.fetchandsavenextquerieswire.md) | Requests and stores the next queries. |
@@ -544,6 +549,7 @@ X-Components is a library usable everywhere not only for search experiences.
544
549
  | [ResultsList](./x-components.resultslist.md) | <p>It renders a [ItemsList](./x-components.itemslist.md) list with the results from [SearchState.results](./x-components.searchstate.results.md) by default.</p><p>The component provides a default slot which wraps the whole component with the <code>results</code> bound.</p><p>It also provides the slot result to customize the item, which is within the default slot, with the result bound.</p> |
545
550
  | [ResultVariantSelector](./x-components.resultvariantselector.md) | Component to show and select the available variants of a product for a given nest level. TODO: Log warning on mount when result is not injected. |
546
551
  | [ResultVariantsProvider](./x-components.resultvariantsprovider.md) | <p>Component that exposes the result merged with its selected variant in the default slot.</p><p>It receives the original result and keeps track of the selected variant.</p><p>It provides the original result, the array containing the selected variants and a callback to set the selected variant to be used from a child.</p> |
552
+ | [saveAiOrigin](./x-components.saveaiorigin.md) | Default implementation for the [AiActions.saveOrigin](./x-components.aiactions.saveorigin.md)<!-- -->. |
547
553
  | [saveIdentifierResultsOrigin](./x-components.saveidentifierresultsorigin.md) | Default implementation for the [IdentifierResultsActions.saveOrigin](./x-components.identifierresultsactions.saveorigin.md)<!-- -->. |
548
554
  | [saveIdentifierResultsOriginWire](./x-components.saveidentifierresultsoriginwire.md) | Sets the identifier results state <code>origin</code>. |
549
555
  | [saveOriginWire](./x-components.saveoriginwire.md) | Sets the search state <code>origin</code>. |
@@ -568,6 +574,7 @@ X-Components is a library usable everywhere not only for search experiences.
568
574
  | [semanticQueriesXModule](./x-components.semanticqueriesxmodule.md) | SemanticQueries [XModule](./x-components.xmodule.md) implementation. This module is auto-registered as soon as you import any component from the <code>semantic-queries</code>entry point. |
569
575
  | [SemanticQuery](./x-components.semanticquery.md) | This component renders a semantic query. A semantic query is a recommended query that is similar in its meaning to another one. It contains the query and the distance, which indicates how similar the query is compared to the searched query. |
570
576
  | [sessionHistoryQueries](./x-components.sessionhistoryqueries.md) | Default implementation for the [HistoryQueriesGetters.sessionHistoryQueries](./x-components.historyqueriesgetters.sessionhistoryqueries.md) getter. |
577
+ | [setAiUrlParams](./x-components.setaiurlparams.md) | Default implementation setUrlParams. |
571
578
  | [setConsent](./x-components.setconsent.md) | Sets the tagging state <code>consent</code>. |
572
579
  | [setExtraParams](./x-components.setextraparams.md) | Sets the extra params of the [ExtraParamsXModule](./x-components.extraparamsxmodule.md)<!-- -->. |
573
580
  | [setFiltersFromHistoryQueries](./x-components.setfiltersfromhistoryqueries.md) | Sets the filters of the facets module from a selectedHistoryQuery's filters. |
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [saveAiOrigin](./x-components.saveaiorigin.md)
4
+
5
+ ## saveAiOrigin variable
6
+
7
+ Default implementation for the [AiActions.saveOrigin](./x-components.aiactions.saveorigin.md)<!-- -->.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ saveOrigin: AiXStoreModule['actions']['saveOrigin']
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [setAiUrlParams](./x-components.setaiurlparams.md)
4
+
5
+ ## setAiUrlParams variable
6
+
7
+ Default implementation setUrlParams.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ setUrlParams: AiXStoreModule['actions']['setUrlParams']
13
+ ```
package/js/index.js CHANGED
@@ -200,7 +200,14 @@ export { BaseXPriorityQueue, BaseXPriorityQueueNode } from './x-bus/x-priority-q
200
200
  export { BaseXAPI } from './x-installer/api/base-api.js';
201
201
  export { XInstaller } from './x-installer/x-installer/x-installer.js';
202
202
  export { default as AiOverview } from './x-modules/ai/components/ai-overview.vue.js';
203
+ export { fetchAndSaveAiSuggestionsSearch } from './x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.js';
204
+ export { fetchAndSaveAiSuggestions } from './x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.js';
205
+ export { saveOrigin as saveAiOrigin } from './x-modules/ai/store/actions/save-origin.action.js';
206
+ export { setUrlParams as setAiUrlParams } from './x-modules/ai/store/actions/set-url-params.action.js';
203
207
  export { aiEmitters } from './x-modules/ai/store/emitters.js';
208
+ export { query as aiQuery } from './x-modules/ai/store/getters/ai-query.getter.js';
209
+ export { suggestionsRequest as aiSuggestionsRequest } from './x-modules/ai/store/getters/suggestions-request.getter.js';
210
+ export { suggestionsSearchRequest as aiSuggestionsSearchRequest } from './x-modules/ai/store/getters/suggestions-search-request.getter.js';
204
211
  export { aiXStoreModule } from './x-modules/ai/store/module.js';
205
212
  export { aiWiring } from './x-modules/ai/wiring.js';
206
213
  export { aiXModule } from './x-modules/ai/x-module.js';
package/js/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -7,6 +7,15 @@ import '../../../../plugins/devtools/colors.utils.js';
7
7
  import '../../../../plugins/x-bus.js';
8
8
  import { XPlugin } from '../../../../plugins/x-plugin.js';
9
9
 
10
+ /**
11
+ * Default implementation for the {@link AiActions.fetchAndSaveAiSuggestionsSearch}.
12
+ *
13
+ * @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the commits,
14
+ * provided by Vuex.
15
+ * @param request - The AI search request to make.
16
+ * @returns The AI search response.
17
+ * @public
18
+ */
10
19
  const fetchAndSaveAiSuggestionsSearch = async ({ commit }, request) => {
11
20
  if (!request) {
12
21
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-and-save-ai-suggestions-search.action.js","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.ts"],"sourcesContent":["import type { AiXStoreModule } from '../types'\nimport { XPlugin } from '../../../../plugins'\n\nexport const fetchAndSaveAiSuggestionsSearch: AiXStoreModule['actions']['fetchAndSaveAiSuggestionsSearch'] =\n async ({ commit }, request) => {\n if (!request) {\n return\n }\n commit('setSuggestionsSearchLoading', true)\n return XPlugin.adapter\n .aiSuggestionsSearch(request)\n .then(response => {\n if (response) {\n commit('setSuggestionsSearch', response.suggestions)\n }\n })\n .catch(error => {\n console.error(error)\n })\n .finally(() => {\n commit('setSuggestionsSearchLoading', false)\n })\n }\n"],"names":[],"mappings":";;;;;;;;;AAGO,MAAM,+BAA+B,GAC1C,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,KAAI;IAC5B,IAAI,CAAC,OAAO,EAAE;QACZ,OAAM;KACP;AACD,IAAA,MAAM,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,OAAO,CAAC,OAAO;SACnB,mBAAmB,CAAC,OAAO,CAAC;SAC5B,IAAI,CAAC,QAAQ,IAAG;QACf,IAAI,QAAQ,EAAE;AACZ,YAAA,MAAM,CAAC,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;SACrD;AACH,KAAC,CAAC;SACD,KAAK,CAAC,KAAK,IAAG;AACb,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AACtB,KAAC,CAAC;SACD,OAAO,CAAC,MAAK;AACZ,QAAA,MAAM,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;AAC9C,KAAC,CAAC,CAAA;AACN;;;;"}
1
+ {"version":3,"file":"fetch-and-save-ai-suggestions-search.action.js","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.ts"],"sourcesContent":["import type { AiXStoreModule } from '../types'\nimport { XPlugin } from '../../../../plugins'\n\n/**\n * Default implementation for the {@link AiActions.fetchAndSaveAiSuggestionsSearch}.\n *\n * @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the commits,\n * provided by Vuex.\n * @param request - The AI search request to make.\n * @returns The AI search response.\n * @public\n */\nexport const fetchAndSaveAiSuggestionsSearch: AiXStoreModule['actions']['fetchAndSaveAiSuggestionsSearch'] =\n async ({ commit }, request) => {\n if (!request) {\n return\n }\n commit('setSuggestionsSearchLoading', true)\n return XPlugin.adapter\n .aiSuggestionsSearch(request)\n .then(response => {\n if (response) {\n commit('setSuggestionsSearch', response.suggestions)\n }\n })\n .catch(error => {\n console.error(error)\n })\n .finally(() => {\n commit('setSuggestionsSearchLoading', false)\n })\n }\n"],"names":[],"mappings":";;;;;;;;;AAGA;;;;;;;;AAQG;AACI,MAAM,+BAA+B,GAC1C,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,KAAI;IAC5B,IAAI,CAAC,OAAO,EAAE;QACZ,OAAM;KACP;AACD,IAAA,MAAM,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,OAAO,CAAC,OAAO;SACnB,mBAAmB,CAAC,OAAO,CAAC;SAC5B,IAAI,CAAC,QAAQ,IAAG;QACf,IAAI,QAAQ,EAAE;AACZ,YAAA,MAAM,CAAC,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;SACrD;AACH,KAAC,CAAC;SACD,KAAK,CAAC,KAAK,IAAG;AACb,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AACtB,KAAC,CAAC;SACD,OAAO,CAAC,MAAK;AACZ,QAAA,MAAM,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;AAC9C,KAAC,CAAC,CAAA;AACN;;;;"}
@@ -15,7 +15,6 @@ import { XPlugin } from '../../../../plugins/x-plugin.js';
15
15
  * provided by Vuex.
16
16
  * @param request - The AI request to make.
17
17
  * @returns The AI response.
18
- *
19
18
  * @public
20
19
  */
21
20
  const fetchAndSaveAiSuggestions = async ({ commit }, request) => {
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-and-save-ai-suggestions.action.js","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.ts"],"sourcesContent":["import type { AiSuggestionQuery, AiSuggestionTagging } from '@empathyco/x-types'\nimport type { AiActionContext, AiXStoreModule } from '../types'\nimport { getTaggingInfoFromUrl } from '@empathyco/x-adapter-platform'\nimport { XPlugin } from '../../../../plugins'\n\ninterface TaggingData {\n tagging: {\n toolingDisplay: string\n toolingDisplayClick: string\n searchQueries: Record<\n string,\n {\n toolingDisplay: string\n toolingDisplayClick: string\n toolingDisplayAdd2Cart: string\n }\n >\n }[]\n}\n\ntype AnswerData =\n | { responseText: string }\n | { suggestionText: string }\n | { queries: AiSuggestionQuery[] }\n | TaggingData\n\n/**\n * Default implementation for the {@link AiActions.fetchAndSaveAiSuggestions}.\n *\n * @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions,\n * provided by Vuex.\n * @param request - The AI request to make.\n * @returns The AI response.\n *\n * @public\n */\nexport const fetchAndSaveAiSuggestions: AiXStoreModule['actions']['fetchAndSaveAiSuggestions'] =\n async ({ commit }, request) => {\n if (!request) {\n return\n }\n commit('setSuggestionsLoading', true)\n return XPlugin.adapter.aiSuggestions(request).then(({ body, status }) => {\n if (status !== 200) {\n return\n }\n if (body) {\n const reader = body.getReader()\n readAnswer(reader, commit)\n }\n })\n }\n\nfunction mapTaggingData(tangingData: TaggingData): AiSuggestionTagging {\n const { toolingDisplay, toolingDisplayClick, searchQueries } = tangingData.tagging[0]\n // TODO: Using the getTaggingInfoFromUrl util here is a temporary solution.\n // It creates a dependency with the x-adapter-platform project that should be avoided.\n return {\n toolingDisplay: getTaggingInfoFromUrl(toolingDisplay),\n toolingDisplayClick: getTaggingInfoFromUrl(toolingDisplayClick),\n searchQueries: Object.fromEntries(\n Object.entries(searchQueries).map(\n ([query, { toolingDisplay, toolingDisplayClick, toolingDisplayAdd2Cart }]) => [\n query,\n {\n toolingDisplay: getTaggingInfoFromUrl(toolingDisplay),\n toolingDisplayClick: getTaggingInfoFromUrl(toolingDisplayClick),\n toolingDisplayAdd2Cart: getTaggingInfoFromUrl(toolingDisplayAdd2Cart),\n },\n ],\n ),\n ),\n }\n}\n\nfunction readAnswer(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n commit: AiActionContext['commit'],\n): void {\n reader\n .read()\n .then(({ value, done }) => {\n if (done) {\n commit('setSuggestionsLoading', false)\n return\n }\n\n const result = new TextDecoder().decode(value, { stream: true })\n const parts = result.split('\\n\\n')\n for (const part of parts) {\n const lines = part.split('\\n')\n\n for (const line of lines) {\n // line.length check to avoid event lines or empty lines\n if (line.length <= 5 || line.startsWith('event:')) continue\n\n const raw = line.startsWith('data:') ? line.slice(5).trim() : line.trim()\n const data = JSON.parse(raw) as AnswerData\n\n if ('suggestionText' in data) {\n commit('setIsNoResults', false)\n commit('setSuggestionText', data.suggestionText)\n }\n if ('responseText' in data) {\n commit('setResponseText', data.responseText)\n }\n if ('queries' in data) {\n commit('setQueries', data.queries)\n }\n if ('tagging' in data) {\n commit('setTagging', mapTaggingData(data))\n }\n }\n }\n readAnswer(reader, commit)\n })\n .catch((error: { code: number }) => {\n commit('setSuggestionsLoading', false)\n // AbortError code === 20\n if (error.code !== 20) {\n console.error(error)\n }\n })\n}\n"],"names":[],"mappings":";;;;;;;;;;AA0BA;;;;;;;;;AASG;AACI,MAAM,yBAAyB,GACpC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,KAAI;IAC5B,IAAI,CAAC,OAAO,EAAE;QACZ,OAAM;KACP;AACD,IAAA,MAAM,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAA;AACrC,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAI;AACtE,QAAA,IAAI,MAAM,KAAK,GAAG,EAAE;YAClB,OAAM;SACP;QACD,IAAI,IAAI,EAAE;AACR,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;AAC/B,YAAA,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;SAC3B;AACH,KAAC,CAAC,CAAA;AACJ,EAAC;AAEH,SAAS,cAAc,CAAC,WAAwB,EAAA;AAC9C,IAAA,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;;;IAGrF,OAAO;AACL,QAAA,cAAc,EAAE,qBAAqB,CAAC,cAAc,CAAC;AACrD,QAAA,mBAAmB,EAAE,qBAAqB,CAAC,mBAAm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CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;gBACzE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAe,CAAA;AAE1C,gBAAA,IAAI,gBAAgB,IAAI,IAAI,EAAE;AAC5B,oBAAA,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;AAC/B,oBAAA,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;iBACjD;AACD,gBAAA,IAAI,cAAc,IAAI,IAAI,EAAE;AAC1B,oBAAA,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;iBAC7C;AACD,gBAAA,IAAI,SAAS,IAAI,IAAI,EAAE;AACrB,oBAAA,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;iBACnC;AACD,gBAAA,IAAI,SAAS,IAAI,IAAI,EAAE;oBACrB,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;iBAC3C;aACF;SACF;AACD,QAAA,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC5B,KAAC,CAAC;AACD,SAAA,KAAK,CAAC,CAAC,KAAuB,KAAI;AACjC,QAAA,MAAM,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;;AAEtC,QAAA,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,EAAE;AACrB,YAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;SACrB;AACH,KAAC,CAAC,CAAA;AACN;;;;"}
1
+ {"version":3,"file":"fetch-and-save-ai-suggestions.action.js","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.ts"],"sourcesContent":["import type { AiSuggestionQuery, AiSuggestionTagging } from '@empathyco/x-types'\nimport type { AiActionContext, AiXStoreModule } from '../types'\nimport { getTaggingInfoFromUrl } from '@empathyco/x-adapter-platform'\nimport { XPlugin } from '../../../../plugins'\n\ninterface TaggingData {\n tagging: {\n toolingDisplay: string\n toolingDisplayClick: string\n searchQueries: Record<\n string,\n {\n toolingDisplay: string\n toolingDisplayClick: string\n toolingDisplayAdd2Cart: string\n }\n >\n }[]\n}\n\ntype AnswerData =\n | { responseText: string }\n | { suggestionText: string }\n | { queries: AiSuggestionQuery[] }\n | TaggingData\n\n/**\n * Default implementation for the {@link AiActions.fetchAndSaveAiSuggestions}.\n *\n * @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions,\n * provided by Vuex.\n * @param request - The AI request to make.\n * @returns The AI response.\n * @public\n */\nexport const fetchAndSaveAiSuggestions: AiXStoreModule['actions']['fetchAndSaveAiSuggestions'] =\n async ({ commit }, request) => {\n if (!request) {\n return\n }\n commit('setSuggestionsLoading', true)\n return XPlugin.adapter.aiSuggestions(request).then(({ body, status }) => {\n if (status !== 200) {\n return\n }\n if (body) {\n const reader = body.getReader()\n readAnswer(reader, commit)\n }\n })\n }\n\nfunction mapTaggingData(tangingData: TaggingData): AiSuggestionTagging {\n const { toolingDisplay, toolingDisplayClick, searchQueries } = tangingData.tagging[0]\n // TODO: Using the getTaggingInfoFromUrl util here is a temporary solution.\n // It creates a dependency with the x-adapter-platform project that should be avoided.\n return {\n toolingDisplay: getTaggingInfoFromUrl(toolingDisplay),\n toolingDisplayClick: getTaggingInfoFromUrl(toolingDisplayClick),\n searchQueries: Object.fromEntries(\n Object.entries(searchQueries).map(\n ([query, { toolingDisplay, toolingDisplayClick, toolingDisplayAdd2Cart }]) => [\n query,\n {\n toolingDisplay: getTaggingInfoFromUrl(toolingDisplay),\n toolingDisplayClick: getTaggingInfoFromUrl(toolingDisplayClick),\n toolingDisplayAdd2Cart: getTaggingInfoFromUrl(toolingDisplayAdd2Cart),\n },\n ],\n ),\n ),\n }\n}\n\nfunction readAnswer(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n commit: AiActionContext['commit'],\n): void {\n reader\n .read()\n .then(({ value, done }) => {\n if (done) {\n commit('setSuggestionsLoading', false)\n return\n }\n\n const result = new TextDecoder().decode(value, { stream: true })\n const parts = result.split('\\n\\n')\n for (const part of parts) {\n const lines = part.split('\\n')\n\n for (const line of lines) {\n // line.length check to avoid event lines or empty lines\n if (line.length <= 5 || line.startsWith('event:')) continue\n\n const raw = line.startsWith('data:') ? line.slice(5).trim() : line.trim()\n const data = JSON.parse(raw) as AnswerData\n\n if ('suggestionText' in data) {\n commit('setIsNoResults', false)\n commit('setSuggestionText', data.suggestionText)\n }\n if ('responseText' in data) {\n commit('setResponseText', data.responseText)\n }\n if ('queries' in data) {\n commit('setQueries', data.queries)\n }\n if ('tagging' in data) {\n commit('setTagging', mapTaggingData(data))\n }\n }\n }\n readAnswer(reader, commit)\n })\n .catch((error: { code: number }) => {\n commit('setSuggestionsLoading', false)\n // AbortError code === 20\n if (error.code !== 20) {\n console.error(error)\n }\n })\n}\n"],"names":[],"mappings":";;;;;;;;;;AA0BA;;;;;;;;AAQG;AACI,MAAM,yBAAyB,GACpC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,KAAI;IAC5B,IAAI,CAAC,OAAO,EAAE;QACZ,OAAM;KACP;AACD,IAAA,MAAM,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAA;AACrC,IAAA,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAI;AACtE,QAAA,IAAI,MAAM,KAAK,GAAG,EAAE;YAClB,OAAM;SACP;QACD,IAAI,IAAI,EAAE;AACR,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;AAC/B,YAAA,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;SAC3B;AACH,KAAC,CAAC,CAAA;AACJ,EAAC;AAEH,SAAS,cAAc,CAAC,WAAwB,EAAA;AAC9C,IAAA,MAAM,EAAE,cAAc,EAAE,mB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../../../../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 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 allow 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 to the url!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 to the url!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 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,WAA8E,CAAA,uBAAA,EAAA;AAAA,IAAhE,MAAO,EAAA,QAAA;AAAA,IAAU,UAAU,EAAA,IAAA,CAAA,UAAA;AAAA,IAAa,UAAU,EAAA,IAAA,CAAA,UAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,YAAA,EAAA,YAAA,CAAA,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) {\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 allow 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 to the url!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 to the url!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 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,WAA8E,CAAA,uBAAA,EAAA;AAAA,IAAhE,MAAO,EAAA,QAAA;AAAA,IAAU,UAAU,EAAA,IAAA,CAAA,UAAA;AAAA,IAAa,UAAU,EAAA,IAAA,CAAA,UAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,YAAA,EAAA,YAAA,CAAA,CAAA,CAAA;;;;;;"}
@@ -20,6 +20,7 @@ var _sfc_main = defineComponent({
20
20
  GlobalEvents,
21
21
  },
22
22
  xModule: urlXModule.name,
23
+ inheritAttrs: false,
23
24
  setup(_, { attrs }) {
24
25
  const $x = use$x();
25
26
  const { initialExtraParams } = useState('url');
@@ -1 +1 @@
1
- {"version":3,"file":"url-handler.vue2.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 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 allow 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 to the url!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 to the url!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":[],"mappings":";;;;;;;;;AAyBA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,UAAU,EAAE;QACV,YAAY;AACb,KAAA;IACD,OAAO,EAAE,UAAU,CAAC,IAAI;AACxB,IAAA,KAAK,CAAC,CAAC,EAAE,EAAE,KAAI,EAAG,EAAA;A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AAE,QAAO,KAAM,UAAU,CAAC,QAAO,CAAA;YAC3F,IAAI,oBAAoB,EAAE;AACxB,gBAAA,OAAO,aAAY,CAAA;aACrB;YAEA,IAAI,mBAAmB,EAAE,EAAE;AACzB,gBAAA,OAAO,iBAAgB,CAAA;aACzB;AAEA,YAAA,OAAO,UAAS,CAAA;AAClB,SAAA,CAAA;AAEA;;;;;AAKE;QACF,MAAM,qBAAqB,MAAkD;YAC3E,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,cAAc,EAAE;aAC5B,CAAA;AACF,SAAA,CAAA;AAEA;;;;;;AAME;QACF,MAAM,UAAS,GAAI,MAAM;YACvB,MAAM,EAAE,GAAG,EAAE,KAAM,EAAA,GAAI,cAAc,EAAC,CAAA;AACtC,YAAA,MAAM,QAAO,GAAI,kBAAkB,EAAC,CAAA;YACpC,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE,QAAQ,CAAA,CAAA;YAC5C,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,EAAE,QAAQ,CAAA,CAAA;AACnD,YAAA,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,SAAS,EAAE,QAAQ,CAAA,CAAA;aAC1D;AACA,YAAA,SAAS,CAAC,QAAQ,IAAG,CAAA;AACvB,SAAA,CAAA;AAEA;;;AAGE;QACF,SAAS,CAAC,MAAM;AACd,YAAA,UAAU,EAAC,CAAA;AACb,SAAC,CAAA,CAAA;QAED,OAAO;YACL,UAAU;YACV,UAAU;SACZ,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"url-handler.vue2.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 allow 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 to the url!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 to the url!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n\nexport default {\n name: 'UrlHandlerDemo',\n components: {\n UrlHandler,\n },\n}\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 URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":[],"mappings":";;;;;;;;;AAyBA;;;;;;AAME;AACF,gBAAe,eAAe,CAAC;AAC7B,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,UAAU,EAAE;QACV,YAAY;AACb,KAAA;IACD,OAAO,EAAE,UAAU,CAAC,IAAI;AACxB,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,KAAK,CAAC,CAAC,EAAE,EAAE,KAAI,EAAG,EAAA;AAChB,QAAA,MAAM,EAAC,GAAI,KAAK,EAAC,CAAA;QAEjB,MAAM,EAAE,kBAAmB,EAAA,GAAI,QAAQ,CAAC,KAAK,CAAA,CAAA;AAE7C;;;;AAIE;AACF,QAAA,MAAM,aAAY,GAAI,MAAM,CAA4B,eAAe,CAAA,CAAA;AAEvE;;;;AAIE;AACF,QAAA,M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A;AAEA;;;;;AAKE;QACF,MAAM,qBAAqB,MAAkD;YAC3E,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,cAAc,EAAE;aAC5B,CAAA;AACF,SAAA,CAAA;AAEA;;;;;;AAME;QACF,MAAM,UAAS,GAAI,MAAM;YACvB,MAAM,EAAE,GAAG,EAAE,KAAM,EAAA,GAAI,cAAc,EAAC,CAAA;AACtC,YAAA,MAAM,QAAO,GAAI,kBAAkB,EAAC,CAAA;YACpC,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE,QAAQ,CAAA,CAAA;YAC5C,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,EAAE,QAAQ,CAAA,CAAA;AACnD,YAAA,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,SAAS,EAAE,QAAQ,CAAA,CAAA;aAC1D;AACA,YAAA,SAAS,CAAC,QAAQ,IAAG,CAAA;AACvB,SAAA,CAAA;AAEA;;;AAGE;QACF,SAAS,CAAC,MAAM;AACd,YAAA,UAAU,EAAC,CAAA;AACb,SAAC,CAAA,CAAA;QAED,OAAO;YACL,UAAU;YACV,UAAU;SACZ,CAAA;KACD;AACF,CAAA,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-components",
3
- "version": "6.0.0-alpha.164",
3
+ "version": "6.0.0-alpha.166",
4
4
  "description": "Empathy X Components",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -142,5 +142,5 @@
142
142
  "access": "public",
143
143
  "directory": "dist"
144
144
  },
145
- "gitHead": "9f60598d4b342654beb077e7dc524a8505c5d229"
145
+ "gitHead": "c6c61dd1376954c65223388333d6e2cff559eddb"
146
146
  }
@@ -1954,6 +1954,34 @@
1954
1954
  "endIndex": 76
1955
1955
  }
1956
1956
  },
1957
+ {
1958
+ "kind": "Variable",
1959
+ "canonicalReference": "@empathyco/x-components!aiQuery:var",
1960
+ "docComment": "/**\n * Default implementation for the related prompts query getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the related prompts' module.\n *\n * @returns The query with the selected related tags concatenated.\n *\n * @public\n */\n",
1961
+ "excerptTokens": [
1962
+ {
1963
+ "kind": "Content",
1964
+ "text": "query: "
1965
+ },
1966
+ {
1967
+ "kind": "Reference",
1968
+ "text": "AiXStoreModule",
1969
+ "canonicalReference": "@empathyco/x-components!AiXStoreModule:type"
1970
+ },
1971
+ {
1972
+ "kind": "Content",
1973
+ "text": "['getters']['query']"
1974
+ }
1975
+ ],
1976
+ "fileUrlPath": "src/x-modules/ai/store/getters/ai-query.getter.ts",
1977
+ "isReadonly": true,
1978
+ "releaseTag": "Public",
1979
+ "name": "aiQuery",
1980
+ "variableTypeTokenRange": {
1981
+ "startIndex": 1,
1982
+ "endIndex": 3
1983
+ }
1984
+ },
1957
1985
  {
1958
1986
  "kind": "Interface",
1959
1987
  "canonicalReference": "@empathyco/x-components!AiState:interface",
@@ -2382,6 +2410,62 @@
2382
2410
  }
2383
2411
  ]
2384
2412
  },
2413
+ {
2414
+ "kind": "Variable",
2415
+ "canonicalReference": "@empathyco/x-components!aiSuggestionsRequest:var",
2416
+ "docComment": "/**\n * Default implementation for the {@link AiGetters.suggestionsRequest} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the ai module.\n *\n * @param getters - Current {@link https://vuex.vuejs.org/guide/getters.html | getters} of the ai module.\n *\n * @returns The ai request to fetch data from the API.\n *\n * @public\n */\n",
2417
+ "excerptTokens": [
2418
+ {
2419
+ "kind": "Content",
2420
+ "text": "suggestionsRequest: "
2421
+ },
2422
+ {
2423
+ "kind": "Reference",
2424
+ "text": "AiXStoreModule",
2425
+ "canonicalReference": "@empathyco/x-components!AiXStoreModule:type"
2426
+ },
2427
+ {
2428
+ "kind": "Content",
2429
+ "text": "['getters']['suggestionsRequest']"
2430
+ }
2431
+ ],
2432
+ "fileUrlPath": "src/x-modules/ai/store/getters/suggestions-request.getter.ts",
2433
+ "isReadonly": true,
2434
+ "releaseTag": "Public",
2435
+ "name": "aiSuggestionsRequest",
2436
+ "variableTypeTokenRange": {
2437
+ "startIndex": 1,
2438
+ "endIndex": 3
2439
+ }
2440
+ },
2441
+ {
2442
+ "kind": "Variable",
2443
+ "canonicalReference": "@empathyco/x-components!aiSuggestionsSearchRequest:var",
2444
+ "docComment": "/**\n * Default implementation for the {@link AiGetters.suggestionsSearchRequest} getter.\n *\n * @param state - Current {@link https://vuex.vuejs.org/guide/state.html | state} of the ai module.\n *\n * @returns The ai request to fetch data from the API.\n *\n * @public\n */\n",
2445
+ "excerptTokens": [
2446
+ {
2447
+ "kind": "Content",
2448
+ "text": "suggestionsSearchRequest: "
2449
+ },
2450
+ {
2451
+ "kind": "Reference",
2452
+ "text": "AiXStoreModule",
2453
+ "canonicalReference": "@empathyco/x-components!AiXStoreModule:type"
2454
+ },
2455
+ {
2456
+ "kind": "Content",
2457
+ "text": "['getters']['suggestionsSearchRequest']"
2458
+ }
2459
+ ],
2460
+ "fileUrlPath": "src/x-modules/ai/store/getters/suggestions-search-request.getter.ts",
2461
+ "isReadonly": true,
2462
+ "releaseTag": "Public",
2463
+ "name": "aiSuggestionsSearchRequest",
2464
+ "variableTypeTokenRange": {
2465
+ "startIndex": 1,
2466
+ "endIndex": 3
2467
+ }
2468
+ },
2385
2469
  {
2386
2470
  "kind": "Interface",
2387
2471
  "canonicalReference": "@empathyco/x-components!AiXEvents:interface",
@@ -25758,6 +25842,62 @@
25758
25842
  ],
25759
25843
  "extendsTokenRanges": []
25760
25844
  },
25845
+ {
25846
+ "kind": "Variable",
25847
+ "canonicalReference": "@empathyco/x-components!fetchAndSaveAiSuggestions:var",
25848
+ "docComment": "/**\n * Default implementation for the {@link AiActions.fetchAndSaveAiSuggestions}.\n *\n * @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions, provided by Vuex.\n *\n * @param request - The AI request to make.\n *\n * @returns The AI response.\n *\n * @public\n */\n",
25849
+ "excerptTokens": [
25850
+ {
25851
+ "kind": "Content",
25852
+ "text": "fetchAndSaveAiSuggestions: "
25853
+ },
25854
+ {
25855
+ "kind": "Reference",
25856
+ "text": "AiXStoreModule",
25857
+ "canonicalReference": "@empathyco/x-components!AiXStoreModule:type"
25858
+ },
25859
+ {
25860
+ "kind": "Content",
25861
+ "text": "['actions']['fetchAndSaveAiSuggestions']"
25862
+ }
25863
+ ],
25864
+ "fileUrlPath": "src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.ts",
25865
+ "isReadonly": true,
25866
+ "releaseTag": "Public",
25867
+ "name": "fetchAndSaveAiSuggestions",
25868
+ "variableTypeTokenRange": {
25869
+ "startIndex": 1,
25870
+ "endIndex": 3
25871
+ }
25872
+ },
25873
+ {
25874
+ "kind": "Variable",
25875
+ "canonicalReference": "@empathyco/x-components!fetchAndSaveAiSuggestionsSearch:var",
25876
+ "docComment": "/**\n * Default implementation for the {@link AiActions.fetchAndSaveAiSuggestionsSearch}.\n *\n * @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the commits, provided by Vuex.\n *\n * @param request - The AI search request to make.\n *\n * @returns The AI search response.\n *\n * @public\n */\n",
25877
+ "excerptTokens": [
25878
+ {
25879
+ "kind": "Content",
25880
+ "text": "fetchAndSaveAiSuggestionsSearch: "
25881
+ },
25882
+ {
25883
+ "kind": "Reference",
25884
+ "text": "AiXStoreModule",
25885
+ "canonicalReference": "@empathyco/x-components!AiXStoreModule:type"
25886
+ },
25887
+ {
25888
+ "kind": "Content",
25889
+ "text": "['actions']['fetchAndSaveAiSuggestionsSearch']"
25890
+ }
25891
+ ],
25892
+ "fileUrlPath": "src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.ts",
25893
+ "isReadonly": true,
25894
+ "releaseTag": "Public",
25895
+ "name": "fetchAndSaveAiSuggestionsSearch",
25896
+ "variableTypeTokenRange": {
25897
+ "startIndex": 1,
25898
+ "endIndex": 3
25899
+ }
25900
+ },
25761
25901
  {
25762
25902
  "kind": "Function",
25763
25903
  "canonicalReference": "@empathyco/x-components!fetchAndSaveExperienceControlsResponse:function(1)",
@@ -54996,6 +55136,34 @@
54996
55136
  ],
54997
55137
  "name": "sanitize"
54998
55138
  },
55139
+ {
55140
+ "kind": "Variable",
55141
+ "canonicalReference": "@empathyco/x-components!saveAiOrigin:var",
55142
+ "docComment": "/**\n * Default implementation for the {@link AiActions.saveOrigin}.\n *\n * @param context - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the actions, provided by Vuex.\n *\n * @param queryOriginInit - The object to create the {@link QueryOrigin} with.\n *\n * @public\n */\n",
55143
+ "excerptTokens": [
55144
+ {
55145
+ "kind": "Content",
55146
+ "text": "saveOrigin: "
55147
+ },
55148
+ {
55149
+ "kind": "Reference",
55150
+ "text": "AiXStoreModule",
55151
+ "canonicalReference": "@empathyco/x-components!AiXStoreModule:type"
55152
+ },
55153
+ {
55154
+ "kind": "Content",
55155
+ "text": "['actions']['saveOrigin']"
55156
+ }
55157
+ ],
55158
+ "fileUrlPath": "src/x-modules/ai/store/actions/save-origin.action.ts",
55159
+ "isReadonly": true,
55160
+ "releaseTag": "Public",
55161
+ "name": "saveAiOrigin",
55162
+ "variableTypeTokenRange": {
55163
+ "startIndex": 1,
55164
+ "endIndex": 3
55165
+ }
55166
+ },
54999
55167
  {
55000
55168
  "kind": "Variable",
55001
55169
  "canonicalReference": "@empathyco/x-components!saveIdentifierResultsOrigin:var",
@@ -62243,6 +62411,34 @@
62243
62411
  "endIndex": 3
62244
62412
  }
62245
62413
  },
62414
+ {
62415
+ "kind": "Variable",
62416
+ "canonicalReference": "@empathyco/x-components!setAiUrlParams:var",
62417
+ "docComment": "/**\n * Default implementation setUrlParams.\n *\n * @param context - The context of the actions, provided by Vuex.\n *\n * @param urlParams - List of params from the url.\n *\n * @public\n */\n",
62418
+ "excerptTokens": [
62419
+ {
62420
+ "kind": "Content",
62421
+ "text": "setUrlParams: "
62422
+ },
62423
+ {
62424
+ "kind": "Reference",
62425
+ "text": "AiXStoreModule",
62426
+ "canonicalReference": "@empathyco/x-components!AiXStoreModule:type"
62427
+ },
62428
+ {
62429
+ "kind": "Content",
62430
+ "text": "['actions']['setUrlParams']"
62431
+ }
62432
+ ],
62433
+ "fileUrlPath": "src/x-modules/ai/store/actions/set-url-params.action.ts",
62434
+ "isReadonly": true,
62435
+ "releaseTag": "Public",
62436
+ "name": "setAiUrlParams",
62437
+ "variableTypeTokenRange": {
62438
+ "startIndex": 1,
62439
+ "endIndex": 3
62440
+ }
62441
+ },
62246
62442
  {
62247
62443
  "kind": "Function",
62248
62444
  "canonicalReference": "@empathyco/x-components!setConfig:function(1)",
@@ -295,6 +295,9 @@ expandText: string;
295
295
  collapseText: string;
296
296
  }, {}>;
297
297
 
298
+ // @public
299
+ export const aiQuery: AiXStoreModule['getters']['query'];
300
+
298
301
  export { AIStarIcon }
299
302
 
300
303
  // @public
@@ -318,6 +321,12 @@ export interface AiState extends QueryState {
318
321
  tagging: AiSuggestionTagging | undefined;
319
322
  }
320
323
 
324
+ // @public
325
+ export const aiSuggestionsRequest: AiXStoreModule['getters']['suggestionsRequest'];
326
+
327
+ // @public
328
+ export const aiSuggestionsSearchRequest: AiXStoreModule['getters']['suggestionsSearchRequest'];
329
+
321
330
  // @internal
322
331
  export const aiWiring: {
323
332
  ParamsLoadedFromUrl: {
@@ -3036,6 +3045,12 @@ export interface FetchAndSaveActions<Context extends XActionContext<StatusState,
3036
3045
  fetchAndSave: (context: Context, request: Request) => void | Promise<void>;
3037
3046
  }
3038
3047
 
3048
+ // @public
3049
+ export const fetchAndSaveAiSuggestions: AiXStoreModule['actions']['fetchAndSaveAiSuggestions'];
3050
+
3051
+ // @public
3052
+ export const fetchAndSaveAiSuggestionsSearch: AiXStoreModule['actions']['fetchAndSaveAiSuggestionsSearch'];
3053
+
3039
3054
  // @public
3040
3055
  export const fetchAndSaveExperienceControlsResponse: (context: ExperienceControlsActionContext, request: ExperienceControlsRequest | null) => void | Promise<void>;
3041
3056
 
@@ -6334,6 +6349,9 @@ export interface RootXStoreState {
6334
6349
  // @public
6335
6350
  export const sanitize: (str: string) => string;
6336
6351
 
6352
+ // @public
6353
+ export const saveAiOrigin: AiXStoreModule['actions']['saveOrigin'];
6354
+
6337
6355
  // @public
6338
6356
  export const saveIdentifierResultsOrigin: IdentifierResultsXStoreModule['actions']['saveOrigin'];
6339
6357
 
@@ -7101,6 +7119,9 @@ required: true;
7101
7119
  // @public
7102
7120
  export const sessionHistoryQueries: HistoryQueriesXStoreModule['getters']['sessionHistoryQueries'];
7103
7121
 
7122
+ // @public
7123
+ export const setAiUrlParams: AiXStoreModule['actions']['setUrlParams'];
7124
+
7104
7125
  // @public
7105
7126
  export function setConfig<T extends {
7106
7127
  config: T['config'];
@@ -1,3 +1,12 @@
1
1
  import type { AiXStoreModule } from '../types';
2
+ /**
3
+ * Default implementation for the {@link AiActions.fetchAndSaveAiSuggestionsSearch}.
4
+ *
5
+ * @param _ - The {@link https://vuex.vuejs.org/guide/actions.html | context} of the commits,
6
+ * provided by Vuex.
7
+ * @param request - The AI search request to make.
8
+ * @returns The AI search response.
9
+ * @public
10
+ */
2
11
  export declare const fetchAndSaveAiSuggestionsSearch: AiXStoreModule['actions']['fetchAndSaveAiSuggestionsSearch'];
3
12
  //# sourceMappingURL=fetch-and-save-ai-suggestions-search.action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-and-save-ai-suggestions-search.action.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,eAAO,MAAM,+BAA+B,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,iCAAiC,CAmBtG,CAAA"}
1
+ {"version":3,"file":"fetch-and-save-ai-suggestions-search.action.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions-search.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,iCAAiC,CAmBtG,CAAA"}
@@ -6,7 +6,6 @@ import type { AiXStoreModule } from '../types';
6
6
  * provided by Vuex.
7
7
  * @param request - The AI request to make.
8
8
  * @returns The AI response.
9
- *
10
9
  * @public
11
10
  */
12
11
  export declare const fetchAndSaveAiSuggestions: AiXStoreModule['actions']['fetchAndSaveAiSuggestions'];
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-and-save-ai-suggestions.action.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,UAAU,CAAA;AAyB/D;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,2BAA2B,CAe1F,CAAA"}
1
+ {"version":3,"file":"fetch-and-save-ai-suggestions.action.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/ai/store/actions/fetch-and-save-ai-suggestions.action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,UAAU,CAAA;AAyB/D;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,2BAA2B,CAe1F,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './fetch-and-save-ai-suggestions-search.action';
2
+ export * from './fetch-and-save-ai-suggestions.action';
3
+ export { saveOrigin as saveAiOrigin } from './save-origin.action';
4
+ export { setUrlParams as setAiUrlParams } from './set-url-params.action';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/x-modules/ai/store/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAA;AAC7D,cAAc,wCAAwC,CAAA;AACtD,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1,4 +1,6 @@
1
+ export * from './actions';
1
2
  export * from './emitters';
3
+ export * from './getters';
2
4
  export * from './module';
3
5
  export * from './types';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/ai/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/ai/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"url-handler.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/url/components/url-handler.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;;wBAsL4B,mBAAmB;;;AArLlD,wBAsVE"}
1
+ {"version":3,"file":"url-handler.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/url/components/url-handler.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;;wBAuL4B,mBAAmB;;;AAtLlD,wBAuVE"}