@empathyco/x-components 7.3.0 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/docs/API-reference/api/x-components.basexapi.browse.md +54 -0
- package/docs/API-reference/api/x-components.basexapi.md +14 -0
- package/docs/API-reference/api/x-components.hierarchicalfilter.md +7 -0
- package/docs/API-reference/api/x-components.md +33 -0
- package/docs/API-reference/api/x-components.resetnextqueriesquery.md +13 -0
- package/docs/API-reference/api/x-components.reseturlbrowsecategory.md +13 -0
- package/docs/API-reference/api/x-components.seturlbrowsecategory.md +13 -0
- package/docs/API-reference/api/x-components.simplefilter.md +7 -0
- package/docs/API-reference/api/x-components.snippetcallbacks.md +7 -0
- package/docs/API-reference/api/x-components.urlmutations.md +19 -0
- package/docs/API-reference/api/x-components.urlmutations.setbrowsecategory.md +13 -0
- package/docs/API-reference/api/x-components.urlparams.browsefield.md +11 -0
- package/docs/API-reference/api/x-components.urlparams.browsevalue.md +11 -0
- package/docs/API-reference/api/x-components.urlparams.md +34 -0
- package/docs/API-reference/api/x-components.usealiasapi.browsetotalresults.md +13 -0
- package/docs/API-reference/api/x-components.usealiasapi.md +21 -0
- package/docs/API-reference/api/x-components.xapi.browse.md +13 -0
- package/docs/API-reference/api/x-components.xapi.md +19 -0
- package/docs/API-reference/api/x-components.xeventstypes.md +2 -2
- package/docs/API-reference/api/x-components.xmodulestree.browse.md +11 -0
- package/docs/API-reference/api/x-components.xmodulestree.md +17 -0
- package/docs/API-reference/api/x-types.xcomponentsadapter.browse.md +11 -0
- package/docs/API-reference/api/x-types.xcomponentsadapter.md +17 -0
- package/docs/API-reference/components/browse/x-components.browse-results-list.md +21 -0
- package/docs/API-reference/components/browse/x-components.browse-sort-picker-list.md +24 -0
- package/js/composables/use-alias-api.js +3 -0
- package/js/composables/use-alias-api.js.map +1 -1
- package/js/index.js +2 -2
- package/js/x-installer/api/base-api.js +12 -0
- package/js/x-installer/api/base-api.js.map +1 -1
- package/js/x-modules/next-queries/wiring.js +11 -1
- package/js/x-modules/next-queries/wiring.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue2.js +4 -1
- package/js/x-modules/url/components/url-handler.vue2.js.map +1 -1
- package/js/x-modules/url/store/initial-state.js +2 -0
- package/js/x-modules/url/store/initial-state.js.map +1 -1
- package/js/x-modules/url/store/module.js +4 -0
- package/js/x-modules/url/store/module.js.map +1 -1
- package/js/x-modules/url/wiring.js +34 -1
- package/js/x-modules/url/wiring.js.map +1 -1
- package/next-queries/index.js +1 -1
- package/package.json +4 -4
- package/report/x-components.api.json +543 -5
- package/report/x-components.api.md +72 -3
- package/report/x-types.api.json +50 -0
- package/types/src/components/snippet-callbacks.vue.d.ts +7 -0
- package/types/src/components/snippet-callbacks.vue.d.ts.map +1 -1
- package/types/src/composables/use-alias-api.d.ts +2 -0
- package/types/src/composables/use-alias-api.d.ts.map +1 -1
- package/types/src/types/url-params.d.ts +2 -0
- package/types/src/types/url-params.d.ts.map +1 -1
- package/types/src/wiring/events.types.d.ts +2 -1
- package/types/src/wiring/events.types.d.ts.map +1 -1
- package/types/src/x-installer/api/api.types.d.ts +9 -0
- package/types/src/x-installer/api/api.types.d.ts.map +1 -1
- package/types/src/x-installer/api/base-api.d.ts +9 -0
- package/types/src/x-installer/api/base-api.d.ts.map +1 -1
- package/types/src/x-modules/browse/components/index.d.ts +3 -0
- package/types/src/x-modules/browse/components/index.d.ts.map +1 -0
- package/types/src/x-modules/browse/config.types.d.ts +14 -0
- package/types/src/x-modules/browse/config.types.d.ts.map +1 -0
- package/types/src/x-modules/browse/events.types.d.ts +55 -0
- package/types/src/x-modules/browse/events.types.d.ts.map +1 -0
- package/types/src/x-modules/browse/index.d.ts +8 -0
- package/types/src/x-modules/browse/index.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/fetch-and-save-browse-response.action.d.ts +15 -0
- package/types/src/x-modules/browse/store/actions/fetch-and-save-browse-response.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/fetch-and-save-results-enrichment.action.d.ts +17 -0
- package/types/src/x-modules/browse/store/actions/fetch-and-save-results-enrichment.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/fetch-browse-response.action.d.ts +13 -0
- package/types/src/x-modules/browse/store/actions/fetch-browse-response.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/increase-page-apending-results.action.d.ts +11 -0
- package/types/src/x-modules/browse/store/actions/increase-page-apending-results.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/index.d.ts +9 -0
- package/types/src/x-modules/browse/store/actions/index.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/reset-request-on-refinement.action.d.ts +11 -0
- package/types/src/x-modules/browse/store/actions/reset-request-on-refinement.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/save-browse-response.action.d.ts +11 -0
- package/types/src/x-modules/browse/store/actions/save-browse-response.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/save-origin.action.d.ts +11 -0
- package/types/src/x-modules/browse/store/actions/save-origin.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/actions/set-url-params.action.d.ts +11 -0
- package/types/src/x-modules/browse/store/actions/set-url-params.action.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/emitters.d.ts +35 -0
- package/types/src/x-modules/browse/store/emitters.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/getters/index.d.ts +2 -0
- package/types/src/x-modules/browse/store/getters/index.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/getters/request.getter.d.ts +13 -0
- package/types/src/x-modules/browse/store/getters/request.getter.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/index.d.ts +6 -0
- package/types/src/x-modules/browse/store/index.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/module.d.ts +41 -0
- package/types/src/x-modules/browse/store/module.d.ts.map +1 -0
- package/types/src/x-modules/browse/store/types.d.ts +273 -0
- package/types/src/x-modules/browse/store/types.d.ts.map +1 -0
- package/types/src/x-modules/browse/types.d.ts +35 -0
- package/types/src/x-modules/browse/types.d.ts.map +1 -0
- package/types/src/x-modules/browse/wiring.d.ts +172 -0
- package/types/src/x-modules/browse/wiring.d.ts.map +1 -0
- package/types/src/x-modules/browse/x-module.d.ts +16 -0
- package/types/src/x-modules/browse/x-module.d.ts.map +1 -0
- package/types/src/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts +7 -0
- package/types/src/x-modules/facets/components/filters/hierarchical-filter.vue.d.ts.map +1 -1
- package/types/src/x-modules/facets/components/filters/simple-filter.vue.d.ts +7 -0
- package/types/src/x-modules/facets/components/filters/simple-filter.vue.d.ts.map +1 -1
- package/types/src/x-modules/next-queries/wiring.d.ts +10 -0
- package/types/src/x-modules/next-queries/wiring.d.ts.map +1 -1
- package/types/src/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
- package/types/src/x-modules/url/store/initial-state.d.ts.map +1 -1
- package/types/src/x-modules/url/store/module.d.ts.map +1 -1
- package/types/src/x-modules/url/store/types.d.ts +7 -1
- package/types/src/x-modules/url/store/types.d.ts.map +1 -1
- package/types/src/x-modules/url/wiring.d.ts +30 -0
- package/types/src/x-modules/url/wiring.d.ts.map +1 -1
- package/types/src/x-modules/x-modules.types.d.ts +2 -0
- package/types/src/x-modules/x-modules.types.d.ts.map +1 -1
- package/url/index.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-alias-api.js","sources":["../../../src/composables/use-alias-api.ts"],"sourcesContent":["import type {\n Facet,\n Filter,\n HistoryQuery,\n NextQuery,\n PartialResult,\n Redirection,\n RelatedPrompt,\n RelatedTag,\n Result,\n SemanticQuery,\n Suggestion,\n} from '@empathyco/x-types'\nimport type { RequestStatus } from '../store/utils/status-store.utils'\nimport type { ScrollComponentState } from '../x-modules/scroll/store/types'\nimport type { InputStatus } from '../x-modules/search-box/store/types'\nimport { useStore } from 'vuex'\nimport { getGetterPath } from '../plugins/index'\n\n/* eslint-disable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n\n/**\n * Creates an object containing the alias part of {@link XComponentAPI}.\n *\n * @returns An object containing the alias part of the {@link XComponentAPI}.\n *\n * @internal\n */\nexport function useAliasApi(): UseAliasAPI {\n const queryModules = [\n 'facets',\n 'searchBox',\n 'nextQueries',\n 'querySuggestions',\n 'relatedTags',\n 'search',\n ] as const\n const statusModules = [\n 'identifierResults',\n 'nextQueries',\n 'popularSearches',\n 'querySuggestions',\n 'recommendations',\n 'relatedTags',\n 'search',\n ] as const\n\n const store = useStore()\n\n const query = queryModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): string {\n return store.state.x[moduleName]?.query ?? ''\n },\n enumerable: true,\n })\n }, {} as UseAliasQueryAPI)\n\n const status = statusModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): RequestStatus | undefined {\n return store.state.x[moduleName]?.status\n },\n enumerable: true,\n })\n }, {} as UseAliasStatusAPI)\n\n return {\n query,\n status,\n get device() {\n return store.state.x.device?.name ?? null\n },\n get facets() {\n return store.getters[getGetterPath('facets', 'facets')] ?? {}\n },\n get historyQueries() {\n return store.getters[getGetterPath('historyQueries', 'historyQueries')] ?? []\n },\n get historyQueriesWithResults() {\n return store.getters[getGetterPath('historyQueries', 'historyQueriesWithResults')] ?? []\n },\n get fullHistoryQueries() {\n return store.state.x.historyQueries?.historyQueries ?? []\n },\n get isHistoryQueriesEnabled() {\n return store.state.x.historyQueries?.isEnabled ?? false\n },\n get fromNoResultsWithFilters() {\n return store.state.x.search?.fromNoResultsWithFilters ?? false\n },\n get identifierResults() {\n return store.state.x.identifierResults?.identifierResults ?? []\n },\n get searchBoxStatus() {\n return store.state.x.searchBox?.inputStatus ?? undefined\n },\n get isEmpathizeOpen() {\n return store.state.x.empathize?.isOpen ?? false\n },\n get nextQueries() {\n return store.getters[getGetterPath('nextQueries', 'nextQueries')] ?? []\n },\n get noResults() {\n return store.state.x.search?.isNoResults ?? false\n },\n get lowResults() {\n return (\n store.state.x.search?.totalResults > 0 &&\n store.state.x.search?.totalResults < store.state.x.search?.config?.threshold\n )\n },\n get partialResults() {\n return store.state.x.search?.partialResults ?? []\n },\n get popularSearches() {\n return store.state.x.popularSearches?.popularSearches ?? []\n },\n get querySuggestions() {\n return store.getters[getGetterPath('querySuggestions', 'querySuggestions')] ?? []\n },\n get fullQuerySuggestions() {\n return store.state.x.querySuggestions?.suggestions ?? []\n },\n get recommendations() {\n return store.state.x.recommendations?.recommendations ?? []\n },\n get redirections() {\n return store.state.x.search?.redirections ?? []\n },\n get relatedTags() {\n return store.getters[getGetterPath('relatedTags', 'relatedTags')] ?? []\n },\n get results() {\n return store.state.x.search?.results ?? []\n },\n get scroll() {\n return store.state.x.scroll?.data ?? {}\n },\n get selectedFilters() {\n return store.getters[getGetterPath('facets', 'selectedFilters')] ?? []\n },\n get selectedRelatedTags() {\n return store.state.x.relatedTags?.selectedRelatedTags ?? []\n },\n get selectedPrompt() {\n return store.state.x.relatedPrompts?.selectedPrompt ?? -1\n },\n get semanticQueries() {\n return store.state.x.semanticQueries?.semanticQueries ?? []\n },\n get relatedPrompts() {\n return store.state.x.relatedPrompts?.relatedPrompts ?? []\n },\n get spellcheckedQuery() {\n return store.state.x.search?.spellcheckedQuery ?? null\n },\n get totalResults() {\n return store.state.x.search?.totalResults ?? 0\n },\n get selectedSort() {\n return store.state.x.search?.sort ?? ''\n },\n get priceStats() {\n return store.state.x.search?.stats?.price ?? {}\n },\n }\n}\n\n/**\n * Alias to facilitate retrieving values from the store.\n *\n * @public\n */\nexport interface UseAliasAPI {\n /** The {@link DeviceXModule} detected device. */\n readonly device: string | null\n /** The {@link FacetsXModule} facets. */\n readonly facets: Record<Facet['id'], Facet>\n /** The {@link HistoryQueriesXModule} history queries matching the query. */\n readonly historyQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries with 1 or more results. */\n readonly historyQueriesWithResults: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries. */\n readonly fullHistoryQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries enabled flag. */\n readonly isHistoryQueriesEnabled: Readonly<boolean>\n /** The {@link SearchXModule} no results with filters flag. */\n readonly fromNoResultsWithFilters: Readonly<boolean>\n /** The {@link IdentifierResultsXModule} results. */\n readonly identifierResults: ReadonlyArray<Result>\n /** The {@link SearchBoxXModule } input status. */\n readonly searchBoxStatus: InputStatus | undefined\n /** The {@link Empathize} is open state. */\n readonly isEmpathizeOpen: boolean\n /** The {@link NextQueriesXModule} next queries. */\n readonly nextQueries: ReadonlyArray<NextQuery>\n /** The {@link SearchXModule} no results situation. */\n readonly noResults: boolean\n /** The {@link SearchXModule} low results situation. */\n readonly lowResults: boolean\n /** The {@link SearchXModule} partial results. */\n readonly partialResults: ReadonlyArray<PartialResult>\n /** The {@link PopularSearchesXModule} popular searches. */\n readonly popularSearches: ReadonlyArray<Suggestion>\n /** The query value of the different modules. */\n readonly query: UseAliasQueryAPI\n /** The {@link QuerySuggestionsXModule} query suggestions that should be displayed. */\n readonly querySuggestions: ReadonlyArray<Suggestion>\n /** The {@link QuerySuggestionsXModule} query suggestions. */\n readonly fullQuerySuggestions: ReadonlyArray<Suggestion>\n /** The {@link RecommendationsXModule} recommendations. */\n readonly recommendations: ReadonlyArray<Result>\n /** The {@link SearchXModule} redirections. */\n readonly redirections: ReadonlyArray<Redirection>\n /** The {@link RelatedTagsXModule} related tags (Both selected and deselected). */\n readonly relatedTags: ReadonlyArray<RelatedTag>\n /** The {@link SearchXModule} search results. */\n readonly results: ReadonlyArray<Result>\n /** The {@link ScrollXModule} data state. */\n readonly scroll: Record<string, ScrollComponentState>\n /** The {@link FacetsXModule} selected filters. */\n readonly selectedFilters: Filter[]\n /** The {@link RelatedTagsXModule} selected related tags. */\n readonly selectedRelatedTags: ReadonlyArray<RelatedTag>\n /** The {@link RelatedPromptsXModule} selected prompt. */\n readonly selectedPrompt: number\n /** The {@link SemanticQueriesXModule} queries. */\n readonly semanticQueries: ReadonlyArray<SemanticQuery>\n /** The {@link RelatedPromptsXModule} related prompts. */\n readonly relatedPrompts: ReadonlyArray<RelatedPrompt>\n /** The {@link SearchXModule} spellchecked query. */\n readonly spellcheckedQuery: string | null\n /** The status value of the different modules. */\n readonly status: UseAliasStatusAPI\n /** The {@link SearchXModule} total results. */\n readonly totalResults: number\n /** The {@link SearchXModule} selected sort. */\n readonly selectedSort: string\n /** The {@link SearchXModule} price specific stats. */\n readonly priceStats: { min: number; max: number }\n}\n\n/**\n * Alias to facilitate retrieving the modules with query.\n *\n * @public\n */\nexport interface UseAliasQueryAPI {\n /** The {@link FacetsXModule} query. */\n readonly facets: string\n /** The {@link SearchBoxXModule} query. */\n readonly searchBox: string\n /** The {@link NextQueriesXModule} query. */\n readonly nextQueries: string\n /** The {@link QuerySuggestionsXModule} query. */\n readonly querySuggestions: string\n /** The {@link RelatedTagsXModule} query. */\n readonly relatedTags: string\n /** The {@link SearchXModule} query. */\n readonly search: string\n}\n\n/**\n * Alias to facilitate retrieving the modules with status.\n *\n * @public\n */\nexport interface UseAliasStatusAPI {\n /** The {@link IdentifierResultsXModule} status. */\n readonly identifierResults: RequestStatus | undefined\n /** The {@link NextQueriesXModule} status. */\n readonly nextQueries: RequestStatus | undefined\n /** The {@link PopularSearchesXModule} status. */\n readonly popularSearches: RequestStatus | undefined\n /** The {@link QuerySuggestionsXModule} status. */\n readonly querySuggestions: RequestStatus | undefined\n /** The {@link RecommendationsXModule} status. */\n readonly recommendations: RequestStatus | undefined\n /** The {@link RelatedTagsXModule} status. */\n readonly relatedTags: RequestStatus | undefined\n /** The {@link SearchXModule} status. */\n readonly search: RequestStatus | undefined\n}\n\n/* eslint-enable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n"],"names":[],"mappings":";;;;;;AAmBA;AA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AA,IAAI,UAAU,GAAA;AACZ,YAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE;QACjD,CAAC;KACF;AACH;AAsHA;;;;"}
|
|
1
|
+
{"version":3,"file":"use-alias-api.js","sources":["../../../src/composables/use-alias-api.ts"],"sourcesContent":["import type {\n Facet,\n Filter,\n HistoryQuery,\n NextQuery,\n PartialResult,\n Redirection,\n RelatedPrompt,\n RelatedTag,\n Result,\n SemanticQuery,\n Suggestion,\n} from '@empathyco/x-types'\nimport type { RequestStatus } from '../store/utils/status-store.utils'\nimport type { ScrollComponentState } from '../x-modules/scroll/store/types'\nimport type { InputStatus } from '../x-modules/search-box/store/types'\nimport { useStore } from 'vuex'\nimport { getGetterPath } from '../plugins/index'\n\n/* eslint-disable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n\n/**\n * Creates an object containing the alias part of {@link XComponentAPI}.\n *\n * @returns An object containing the alias part of the {@link XComponentAPI}.\n *\n * @internal\n */\nexport function useAliasApi(): UseAliasAPI {\n const queryModules = [\n 'facets',\n 'searchBox',\n 'nextQueries',\n 'querySuggestions',\n 'relatedTags',\n 'search',\n ] as const\n const statusModules = [\n 'identifierResults',\n 'nextQueries',\n 'popularSearches',\n 'querySuggestions',\n 'recommendations',\n 'relatedTags',\n 'search',\n ] as const\n\n const store = useStore()\n\n const query = queryModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): string {\n return store.state.x[moduleName]?.query ?? ''\n },\n enumerable: true,\n })\n }, {} as UseAliasQueryAPI)\n\n const status = statusModules.reduce((acc, moduleName) => {\n return Object.defineProperty(acc, moduleName, {\n get(): RequestStatus | undefined {\n return store.state.x[moduleName]?.status\n },\n enumerable: true,\n })\n }, {} as UseAliasStatusAPI)\n\n return {\n query,\n status,\n get device() {\n return store.state.x.device?.name ?? null\n },\n get facets() {\n return store.getters[getGetterPath('facets', 'facets')] ?? {}\n },\n get historyQueries() {\n return store.getters[getGetterPath('historyQueries', 'historyQueries')] ?? []\n },\n get historyQueriesWithResults() {\n return store.getters[getGetterPath('historyQueries', 'historyQueriesWithResults')] ?? []\n },\n get fullHistoryQueries() {\n return store.state.x.historyQueries?.historyQueries ?? []\n },\n get isHistoryQueriesEnabled() {\n return store.state.x.historyQueries?.isEnabled ?? false\n },\n get fromNoResultsWithFilters() {\n return store.state.x.search?.fromNoResultsWithFilters ?? false\n },\n get identifierResults() {\n return store.state.x.identifierResults?.identifierResults ?? []\n },\n get searchBoxStatus() {\n return store.state.x.searchBox?.inputStatus ?? undefined\n },\n get isEmpathizeOpen() {\n return store.state.x.empathize?.isOpen ?? false\n },\n get nextQueries() {\n return store.getters[getGetterPath('nextQueries', 'nextQueries')] ?? []\n },\n get noResults() {\n return store.state.x.search?.isNoResults ?? false\n },\n get lowResults() {\n return (\n store.state.x.search?.totalResults > 0 &&\n store.state.x.search?.totalResults < store.state.x.search?.config?.threshold\n )\n },\n get partialResults() {\n return store.state.x.search?.partialResults ?? []\n },\n get popularSearches() {\n return store.state.x.popularSearches?.popularSearches ?? []\n },\n get querySuggestions() {\n return store.getters[getGetterPath('querySuggestions', 'querySuggestions')] ?? []\n },\n get fullQuerySuggestions() {\n return store.state.x.querySuggestions?.suggestions ?? []\n },\n get recommendations() {\n return store.state.x.recommendations?.recommendations ?? []\n },\n get redirections() {\n return store.state.x.search?.redirections ?? []\n },\n get relatedTags() {\n return store.getters[getGetterPath('relatedTags', 'relatedTags')] ?? []\n },\n get results() {\n return store.state.x.search?.results ?? []\n },\n get scroll() {\n return store.state.x.scroll?.data ?? {}\n },\n get selectedFilters() {\n return store.getters[getGetterPath('facets', 'selectedFilters')] ?? []\n },\n get selectedRelatedTags() {\n return store.state.x.relatedTags?.selectedRelatedTags ?? []\n },\n get selectedPrompt() {\n return store.state.x.relatedPrompts?.selectedPrompt ?? -1\n },\n get semanticQueries() {\n return store.state.x.semanticQueries?.semanticQueries ?? []\n },\n get relatedPrompts() {\n return store.state.x.relatedPrompts?.relatedPrompts ?? []\n },\n get spellcheckedQuery() {\n return store.state.x.search?.spellcheckedQuery ?? null\n },\n get totalResults() {\n return store.state.x.search?.totalResults ?? 0\n },\n get browseTotalResults() {\n return store.state.x.browse?.totalResults ?? 0\n },\n get selectedSort() {\n return store.state.x.search?.sort ?? ''\n },\n get priceStats() {\n return store.state.x.search?.stats?.price ?? {}\n },\n }\n}\n\n/**\n * Alias to facilitate retrieving values from the store.\n *\n * @public\n */\nexport interface UseAliasAPI {\n /** The {@link DeviceXModule} detected device. */\n readonly device: string | null\n /** The {@link FacetsXModule} facets. */\n readonly facets: Record<Facet['id'], Facet>\n /** The {@link HistoryQueriesXModule} history queries matching the query. */\n readonly historyQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries with 1 or more results. */\n readonly historyQueriesWithResults: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries. */\n readonly fullHistoryQueries: ReadonlyArray<HistoryQuery>\n /** The {@link HistoryQueriesXModule} history queries enabled flag. */\n readonly isHistoryQueriesEnabled: Readonly<boolean>\n /** The {@link SearchXModule} no results with filters flag. */\n readonly fromNoResultsWithFilters: Readonly<boolean>\n /** The {@link IdentifierResultsXModule} results. */\n readonly identifierResults: ReadonlyArray<Result>\n /** The {@link SearchBoxXModule } input status. */\n readonly searchBoxStatus: InputStatus | undefined\n /** The {@link Empathize} is open state. */\n readonly isEmpathizeOpen: boolean\n /** The {@link NextQueriesXModule} next queries. */\n readonly nextQueries: ReadonlyArray<NextQuery>\n /** The {@link SearchXModule} no results situation. */\n readonly noResults: boolean\n /** The {@link SearchXModule} low results situation. */\n readonly lowResults: boolean\n /** The {@link SearchXModule} partial results. */\n readonly partialResults: ReadonlyArray<PartialResult>\n /** The {@link PopularSearchesXModule} popular searches. */\n readonly popularSearches: ReadonlyArray<Suggestion>\n /** The query value of the different modules. */\n readonly query: UseAliasQueryAPI\n /** The {@link QuerySuggestionsXModule} query suggestions that should be displayed. */\n readonly querySuggestions: ReadonlyArray<Suggestion>\n /** The {@link QuerySuggestionsXModule} query suggestions. */\n readonly fullQuerySuggestions: ReadonlyArray<Suggestion>\n /** The {@link RecommendationsXModule} recommendations. */\n readonly recommendations: ReadonlyArray<Result>\n /** The {@link SearchXModule} redirections. */\n readonly redirections: ReadonlyArray<Redirection>\n /** The {@link RelatedTagsXModule} related tags (Both selected and deselected). */\n readonly relatedTags: ReadonlyArray<RelatedTag>\n /** The {@link SearchXModule} search results. */\n readonly results: ReadonlyArray<Result>\n /** The {@link ScrollXModule} data state. */\n readonly scroll: Record<string, ScrollComponentState>\n /** The {@link FacetsXModule} selected filters. */\n readonly selectedFilters: Filter[]\n /** The {@link RelatedTagsXModule} selected related tags. */\n readonly selectedRelatedTags: ReadonlyArray<RelatedTag>\n /** The {@link RelatedPromptsXModule} selected prompt. */\n readonly selectedPrompt: number\n /** The {@link SemanticQueriesXModule} queries. */\n readonly semanticQueries: ReadonlyArray<SemanticQuery>\n /** The {@link RelatedPromptsXModule} related prompts. */\n readonly relatedPrompts: ReadonlyArray<RelatedPrompt>\n /** The {@link SearchXModule} spellchecked query. */\n readonly spellcheckedQuery: string | null\n /** The status value of the different modules. */\n readonly status: UseAliasStatusAPI\n /** The {@link SearchXModule} total results. */\n readonly totalResults: number\n /** The {@link BrowseXModule} total results. */\n readonly browseTotalResults: number\n /** The {@link SearchXModule} selected sort. */\n readonly selectedSort: string\n /** The {@link SearchXModule} price specific stats. */\n readonly priceStats: { min: number; max: number }\n}\n\n/**\n * Alias to facilitate retrieving the modules with query.\n *\n * @public\n */\nexport interface UseAliasQueryAPI {\n /** The {@link FacetsXModule} query. */\n readonly facets: string\n /** The {@link SearchBoxXModule} query. */\n readonly searchBox: string\n /** The {@link NextQueriesXModule} query. */\n readonly nextQueries: string\n /** The {@link QuerySuggestionsXModule} query. */\n readonly querySuggestions: string\n /** The {@link RelatedTagsXModule} query. */\n readonly relatedTags: string\n /** The {@link SearchXModule} query. */\n readonly search: string\n}\n\n/**\n * Alias to facilitate retrieving the modules with status.\n *\n * @public\n */\nexport interface UseAliasStatusAPI {\n /** The {@link IdentifierResultsXModule} status. */\n readonly identifierResults: RequestStatus | undefined\n /** The {@link NextQueriesXModule} status. */\n readonly nextQueries: RequestStatus | undefined\n /** The {@link PopularSearchesXModule} status. */\n readonly popularSearches: RequestStatus | undefined\n /** The {@link QuerySuggestionsXModule} status. */\n readonly querySuggestions: RequestStatus | undefined\n /** The {@link RecommendationsXModule} status. */\n readonly recommendations: RequestStatus | undefined\n /** The {@link RelatedTagsXModule} status. */\n readonly relatedTags: RequestStatus | undefined\n /** The {@link SearchXModule} status. */\n readonly search: RequestStatus | undefined\n}\n\n/* eslint-enable ts/no-unsafe-return,ts/no-unsafe-member-access,ts/no-unsafe-assignment */\n"],"names":[],"mappings":";;;;;;AAmBA;AAEA;;;;;;AAMG;SACa,WAAW,GAAA;AACzB,IAAA,MAAM,YAAY,GAAG;QACnB,QAAQ;QACR,WAAW;QACX,aAAa;QACb,kBAAkB;QAClB,aAAa;QACb,QAAQ;KACA;AACV,IAAA,MAAM,aAAa,GAAG;QACpB,mBAAmB;QACnB,aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,iBAAiB;QACjB,aAAa;QACb,QAAQ;KACA;AAEV,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;IAExB,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,KAAI;AACpD,QAAA,OAAO,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YAC5C,GAAG,GAAA;AACD,gBAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,KAAK,IAAI,EAAE;YAC/C,CAAC;AACD,YAAA,UAAU,EAAE,IAAI;AACjB,SAAA,CAAC;IACJ,CAAC,EAAE,EAAsB,CAAC;IAE1B,MAAM,MAAM,GA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,KAAK,CAAC,CAAC,CAAC,eAAe,EAAE,eAAe,IAAI,EAAE;QAC7D,CAAC;AACD,QAAA,IAAI,cAAc,GAAA;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,EAAE,cAAc,IAAI,EAAE;QAC3D,CAAC;AACD,QAAA,IAAI,iBAAiB,GAAA;YACnB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,iBAAiB,IAAI,IAAI;QACxD,CAAC;AACD,QAAA,IAAI,YAAY,GAAA;YACd,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,YAAY,IAAI,CAAC;QAChD,CAAC;AACD,QAAA,IAAI,kBAAkB,GAAA;YACpB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,YAAY,IAAI,CAAC;QAChD,CAAC;AACD,QAAA,IAAI,YAAY,GAAA;YACd,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE;QACzC,CAAC;AACD,QAAA,IAAI,UAAU,GAAA;AACZ,YAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE;QACjD,CAAC;KACF;AACH;AAwHA;;;;"}
|
package/js/index.js
CHANGED
|
@@ -315,7 +315,7 @@ export { query } from './x-modules/next-queries/store/getters/next-queries-query
|
|
|
315
315
|
export { nextQueries } from './x-modules/next-queries/store/getters/next-queries.getter.js';
|
|
316
316
|
export { request as nextQueriesRequest } from './x-modules/next-queries/store/getters/request.getter.js';
|
|
317
317
|
export { nextQueriesXStoreModule } from './x-modules/next-queries/store/module.js';
|
|
318
|
-
export { fetchAndSaveNextQueriesWire, fetchAndSaveNextQueryPreviewWire, nextQueriesWiring, resetNextQueriesWire, resetResultsPreviewWire, setNextQueriesExtraParams, setNextQueriesExtraParamsFromPreview, setNextQueriesQuery, setNextQueriesQueryFromPreview, setNextQueriesRelatedTags, setQueryFromLastHistoryQueryWire, setSearchedQueries } from './x-modules/next-queries/wiring.js';
|
|
318
|
+
export { fetchAndSaveNextQueriesWire, fetchAndSaveNextQueryPreviewWire, nextQueriesWiring, resetNextQueriesQuery, resetNextQueriesWire, resetResultsPreviewWire, setNextQueriesExtraParams, setNextQueriesExtraParamsFromPreview, setNextQueriesQuery, setNextQueriesQueryFromPreview, setNextQueriesRelatedTags, setQueryFromLastHistoryQueryWire, setSearchedQueries } from './x-modules/next-queries/wiring.js';
|
|
319
319
|
export { nextQueriesXModule } from './x-modules/next-queries/x-module.js';
|
|
320
320
|
export { default as PopularSearch } from './x-modules/popular-searches/components/popular-search.vue.js';
|
|
321
321
|
export { default as PopularSearches } from './x-modules/popular-searches/components/popular-searches.vue.js';
|
|
@@ -442,6 +442,6 @@ export { taggingXModule } from './x-modules/tagging/x-module.js';
|
|
|
442
442
|
export { default as UrlHandler } from './x-modules/url/components/url-handler.vue.js';
|
|
443
443
|
export { replaceableParams, urlEmitters } from './x-modules/url/store/emitters.js';
|
|
444
444
|
export { urlXStoreModule } from './x-modules/url/store/module.js';
|
|
445
|
-
export { setInitialExtraParams, setParams, setUrlFilters, setUrlPage, setUrlParamsFromPreview, setUrlPrompt, setUrlQuery, setUrlQueryFromPreview, setUrlRelatedTags, setUrlScroll, setUrlSelectedFiltersFromPreview, setUrlSort, urlWiring } from './x-modules/url/wiring.js';
|
|
445
|
+
export { resetUrlBrowseCategory, setInitialExtraParams, setParams, setUrlBrowseCategory, setUrlFilters, setUrlPage, setUrlParamsFromPreview, setUrlPrompt, setUrlQuery, setUrlQueryFromPreview, setUrlRelatedTags, setUrlScroll, setUrlSelectedFiltersFromPreview, setUrlSort, urlWiring } from './x-modules/url/wiring.js';
|
|
446
446
|
export { urlXModule } from './x-modules/url/x-module.js';
|
|
447
447
|
//# sourceMappingURL=index.js.map
|
|
@@ -81,6 +81,18 @@ class BaseXAPI {
|
|
|
81
81
|
}
|
|
82
82
|
void this.bus?.emit('UserClickedOpenX', undefined);
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Browses the browseField and browseValue parameters as a selected category.
|
|
86
|
+
*
|
|
87
|
+
* @param browseCategory - browseField and browseValue to be browsed.
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
browse(browseCategory) {
|
|
92
|
+
if (browseCategory) {
|
|
93
|
+
void this.bus?.emit('UserBrowsedToCategory', browseCategory);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
84
96
|
/**
|
|
85
97
|
* Initializes the Application passing the {@link SnippetConfig}.
|
|
86
98
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-api.js","sources":["../../../../src/x-installer/api/base-api.ts"],"sourcesContent":["import type { WireMetadata, XEventsTypes } from '../../wiring/index'\nimport type { XBus } from '../../x-bus'\nimport type { NormalisedSnippetConfig, SnippetConfig, XAPI } from './api.types'\n\n/**\n * Default implementation for {@link XAPI}.\n *\n * @public\n */\nexport class BaseXAPI implements XAPI {\n /**\n * Flag to check if the initialization was already done.\n *\n * @internal\n */\n protected isXInitialized = false\n\n /**\n * Bus for emitting and listening events.\n *\n * @internal\n */\n protected bus!: XBus<XEventsTypes, WireMetadata>\n\n /**\n * The callback to call from the init method. The logic of initialization is out of this API\n * since this API is just a facade.\n *\n * @internal\n */\n protected initCallback!: (config: SnippetConfig) => any\n\n /**\n * Getter for the snippet config object.\n *\n * @returns The {@link NormalisedSnippetConfig | snippetConfig} object.\n *\n * @public\n */\n public getSnippetConfig!: () => SnippetConfig\n\n /**\n * Callback that allows to update the snippet config. The logic of initialization is out of this\n * API since this API is just a facade.\n *\n * @internal\n */\n protected snippetCallback!: (config: Partial<SnippetConfig>) => void\n\n /**\n * Tracks that a product was added to cart from PDP.\n *\n * @param productId - The product id that was added to cart.\n */\n addProductToCart(productId?: string): void {\n void this.bus?.emit('UserClickedPDPAddToCart', productId)\n }\n\n /**\n * Setter for the XBus.\n *\n * @param bus - The XBus received to emit events.\n *\n * @internal\n */\n setBus(bus: XBus<XEventsTypes, WireMetadata>): void {\n this.bus = bus\n }\n\n /**\n * Setter for the callback to call in the init method.\n *\n * @param initCallback - The callback to call.\n */\n setInitCallback(initCallback: (config: SnippetConfig) => any): void {\n this.initCallback = initCallback\n }\n\n /**\n * Setter for the callback to modify the snippet config.\n *\n * @param snippetCallback - The callback to call.\n *\n * @internal\n */\n setSnippetConfigCallback(snippetCallback: (config: Partial<SnippetConfig>) => void): void {\n this.snippetCallback = snippetCallback\n }\n\n /**\n * Sets or updates the snippet config getter.\n *\n * @param snippetConfigGetter - A function that returns the snippet config.\n *\n * @internal\n */\n setSnippetConfigGetter(snippetConfigGetter: () => NormalisedSnippetConfig): void {\n this.getSnippetConfig = snippetConfigGetter\n }\n\n /**\n * Sets or updates the snippet config.\n *\n * @param config - A part or all the snippet config.\n *\n * @public\n */\n setSnippetConfig(config: Partial<SnippetConfig>): void {\n this?.snippetCallback(config)\n }\n\n /**\n * Searches the query parameter as user query.\n *\n * @param query - Query to be searched.\n *\n * @public\n */\n search(query?: string): void {\n if (query) {\n void this.bus?.emit('UserAcceptedAQuery', query)\n }\n void this.bus?.emit('UserClickedOpenX', undefined)\n }\n\n /**\n * Initializes the Application passing the {@link SnippetConfig}.\n *\n * @param config - The config coming from the customer snippet.\n *\n * @returns A promise that will be resolved once x components are initialized.\n *\n * @public\n */\n async init(config: SnippetConfig): Promise<void> {\n if (!this.isXInitialized) {\n this.isXInitialized = true\n await this?.initCallback(config)\n } else {\n console.warn('We know X is awesome, but you only need to initialize it once.')\n }\n }\n\n /**\n * Closes the Application.\n *\n * @public\n */\n close(): void {\n void this.bus?.emit('UserClickedCloseX', undefined)\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-api.js","sources":["../../../../src/x-installer/api/base-api.ts"],"sourcesContent":["import type { BrowsableRequest } from '@empathyco/x-types'\nimport type { WireMetadata, XEventsTypes } from '../../wiring/index'\nimport type { XBus } from '../../x-bus'\nimport type { NormalisedSnippetConfig, SnippetConfig, XAPI } from './api.types'\n\n/**\n * Default implementation for {@link XAPI}.\n *\n * @public\n */\nexport class BaseXAPI implements XAPI {\n /**\n * Flag to check if the initialization was already done.\n *\n * @internal\n */\n protected isXInitialized = false\n\n /**\n * Bus for emitting and listening events.\n *\n * @internal\n */\n protected bus!: XBus<XEventsTypes, WireMetadata>\n\n /**\n * The callback to call from the init method. The logic of initialization is out of this API\n * since this API is just a facade.\n *\n * @internal\n */\n protected initCallback!: (config: SnippetConfig) => any\n\n /**\n * Getter for the snippet config object.\n *\n * @returns The {@link NormalisedSnippetConfig | snippetConfig} object.\n *\n * @public\n */\n public getSnippetConfig!: () => SnippetConfig\n\n /**\n * Callback that allows to update the snippet config. The logic of initialization is out of this\n * API since this API is just a facade.\n *\n * @internal\n */\n protected snippetCallback!: (config: Partial<SnippetConfig>) => void\n\n /**\n * Tracks that a product was added to cart from PDP.\n *\n * @param productId - The product id that was added to cart.\n */\n addProductToCart(productId?: string): void {\n void this.bus?.emit('UserClickedPDPAddToCart', productId)\n }\n\n /**\n * Setter for the XBus.\n *\n * @param bus - The XBus received to emit events.\n *\n * @internal\n */\n setBus(bus: XBus<XEventsTypes, WireMetadata>): void {\n this.bus = bus\n }\n\n /**\n * Setter for the callback to call in the init method.\n *\n * @param initCallback - The callback to call.\n */\n setInitCallback(initCallback: (config: SnippetConfig) => any): void {\n this.initCallback = initCallback\n }\n\n /**\n * Setter for the callback to modify the snippet config.\n *\n * @param snippetCallback - The callback to call.\n *\n * @internal\n */\n setSnippetConfigCallback(snippetCallback: (config: Partial<SnippetConfig>) => void): void {\n this.snippetCallback = snippetCallback\n }\n\n /**\n * Sets or updates the snippet config getter.\n *\n * @param snippetConfigGetter - A function that returns the snippet config.\n *\n * @internal\n */\n setSnippetConfigGetter(snippetConfigGetter: () => NormalisedSnippetConfig): void {\n this.getSnippetConfig = snippetConfigGetter\n }\n\n /**\n * Sets or updates the snippet config.\n *\n * @param config - A part or all the snippet config.\n *\n * @public\n */\n setSnippetConfig(config: Partial<SnippetConfig>): void {\n this?.snippetCallback(config)\n }\n\n /**\n * Searches the query parameter as user query.\n *\n * @param query - Query to be searched.\n *\n * @public\n */\n search(query?: string): void {\n if (query) {\n void this.bus?.emit('UserAcceptedAQuery', query)\n }\n void this.bus?.emit('UserClickedOpenX', undefined)\n }\n\n /**\n * Browses the browseField and browseValue parameters as a selected category.\n *\n * @param browseCategory - browseField and browseValue to be browsed.\n *\n * @public\n */\n browse(browseCategory?: BrowsableRequest): void {\n if (browseCategory) {\n void this.bus?.emit('UserBrowsedToCategory', browseCategory)\n }\n }\n\n /**\n * Initializes the Application passing the {@link SnippetConfig}.\n *\n * @param config - The config coming from the customer snippet.\n *\n * @returns A promise that will be resolved once x components are initialized.\n *\n * @public\n */\n async init(config: SnippetConfig): Promise<void> {\n if (!this.isXInitialized) {\n this.isXInitialized = true\n await this?.initCallback(config)\n } else {\n console.warn('We know X is awesome, but you only need to initialize it once.')\n }\n }\n\n /**\n * Closes the Application.\n *\n * @public\n */\n close(): void {\n void this.bus?.emit('UserClickedCloseX', undefined)\n }\n}\n"],"names":[],"mappings":"AAKA;;;;AAIG;MACU,QAAQ,CAAA;AAArB,IAAA,WAAA,GAAA;AACE;;;;AAIG;QACO,IAAA,CAAA,cAAc,GAAG,KAAK;IAqJlC;AAnHE;;;;AAIG;AACH,IAAA,gBAAgB,CAAC,SAAkB,EAAA;QACjC,KAAK,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC;IAC3D;AAEA;;;;;;AAMG;AACH,IAAA,MAAM,CAAC,GAAqC,EAAA;AAC1C,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;IAChB;AAEA;;;;AAIG;AACH,IAAA,eAAe,CAAC,YAA4C,EAAA;AAC1D,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY;IAClC;AAEA;;;;;;AAMG;AACH,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uery');
|
|
32
|
+
/**
|
|
33
|
+
* Reset the next queries state `query`.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
const resetNextQueriesQuery = wireCommit('setQuery', '');
|
|
32
38
|
/**
|
|
33
39
|
* Sets the next queries state `relatedTags`.
|
|
34
40
|
*
|
|
@@ -116,6 +122,10 @@ const nextQueriesWiring = createWiring({
|
|
|
116
122
|
resetNextQueriesWire,
|
|
117
123
|
setNextQueriesQuery,
|
|
118
124
|
},
|
|
125
|
+
UserClearedQuery: {
|
|
126
|
+
resetNextQueriesWire,
|
|
127
|
+
resetNextQueriesQuery,
|
|
128
|
+
},
|
|
119
129
|
SelectedRelatedTagsChanged: {
|
|
120
130
|
setNextQueriesRelatedTags,
|
|
121
131
|
},
|
|
@@ -139,5 +149,5 @@ const nextQueriesWiring = createWiring({
|
|
|
139
149
|
},
|
|
140
150
|
});
|
|
141
151
|
|
|
142
|
-
export { fetchAndSaveNextQueriesWire, fetchAndSaveNextQueryPreviewWire, nextQueriesWiring, resetNextQueriesWire, resetResultsPreviewWire, setNextQueriesExtraParams, setNextQueriesExtraParamsFromPreview, setNextQueriesQuery, setNextQueriesQueryFromPreview, setNextQueriesRelatedTags, setQueryFromLastHistoryQueryWire, setSearchedQueries };
|
|
152
|
+
export { fetchAndSaveNextQueriesWire, fetchAndSaveNextQueryPreviewWire, nextQueriesWiring, resetNextQueriesQuery, resetNextQueriesWire, resetResultsPreviewWire, setNextQueriesExtraParams, setNextQueriesExtraParamsFromPreview, setNextQueriesQuery, setNextQueriesQueryFromPreview, setNextQueriesRelatedTags, setQueryFromLastHistoryQueryWire, setSearchedQueries };
|
|
143
153
|
//# sourceMappingURL=wiring.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiring.js","sources":["../../../../src/x-modules/next-queries/wiring.ts"],"sourcesContent":["import type {\n NamespacedWireCommit,\n NamespacedWireCommitWithoutPayload,\n NamespacedWireDispatch,\n NamespacedWiringData,\n} from '../../wiring/namespaced-wiring.types'\nimport {\n namespacedWireCommit,\n namespacedWireCommitWithoutPayload,\n namespacedWireDispatch,\n} from '../../wiring/namespaced-wires.factory'\nimport { createWiring } from '../../wiring/wiring.utils'\n\n/**\n * `nextQueries` {@link XModuleName | XModule name}.\n *\n * @internal\n */\nconst moduleName = 'nextQueries'\n\n/**\n * WireCommit for {@link NextQueriesXModule}.\n *\n * @internal\n */\nconst wireCommit: NamespacedWireCommit<typeof moduleName> = namespacedWireCommit(moduleName)\n\n/**\n * WireCommitWithoutPayload for {@link NextQueriesXModule}.\n */\nconst wireCommitWithoutPayload: NamespacedWireCommitWithoutPayload<typeof moduleName> =\n namespacedWireCommitWithoutPayload(moduleName)\n\n/**\n * WireDispatch for {@link NextQueriesXModule}.\n *\n * @internal\n */\nconst wireDispatch: NamespacedWireDispatch<typeof moduleName> = namespacedWireDispatch(moduleName)\n\n/**\n * Sets the next queries state `query`.\n *\n * @public\n */\nexport const setNextQueriesQuery = wireCommit('setQuery')\n\n/**\n * Sets the next queries state `relatedTags`.\n *\n * @public\n */\nexport const setNextQueriesRelatedTags = wireCommit('setRelatedTags')\n\n/**\n * Sets the next queries state `query` with a selectedQueryPreview's query.\n *\n * @public\n */\nexport const setNextQueriesQueryFromPreview = wireCommit(\n 'setParams',\n ({ eventPayload: { query } }) => query,\n)\n\n/**\n * Sets the next queries state `query` from url.\n *\n * @public\n */\nconst setUrlParams = wireDispatch('setUrlParams')\n\n/**\n * Sets the next queries state `params`.\n *\n * @public\n */\nexport const setNextQueriesExtraParams = wireCommit('setParams')\n\n/**\n * Sets the next queries state `params` with a selectedQueryPreview's extraParams.\n *\n * @public\n */\nexport const setNextQueriesExtraParamsFromPreview = wireCommit(\n 'setParams',\n ({ eventPayload: { extraParams } }) => extraParams,\n)\n\n/**\n * Requests and stores the next queries.\n *\n * @public\n */\nexport const fetchAndSaveNextQueriesWire = wireDispatch('fetchAndSaveNextQueries')\n\n/**\n * Sets the next queries state `query` with the last query in history queries.\n *\n * @public\n */\nexport const setQueryFromLastHistoryQueryWire = wireDispatch('setQueryFromLastHistoryQuery')\n\n/**\n * Requests and store the next query preview results.\n *\n * @public\n */\nexport const fetchAndSaveNextQueryPreviewWire = wireDispatch(\n 'fetchAndSaveNextQueryPreview',\n ({ eventPayload: query, metadata: { location } }: NamespacedWiringData<'nextQueries'>) => {\n return {\n query,\n location,\n }\n },\n)\n/**\n * Resets the next query preview results.\n *\n * @public\n */\nexport const resetResultsPreviewWire = wireCommitWithoutPayload('resetResultsPreview')\n\n/**\n * Resets the next queries list to an empty array.\n *\n * @public\n */\nexport const resetNextQueriesWire = wireCommitWithoutPayload('resetNextQueries')\n\n/**\n * Sets the next queries state `searchedQueries` with the list of history queries.\n *\n * @public\n */\nexport const setSearchedQueries = wireCommit('setSearchedQueries')\n\n/**\n * Wiring configuration for the {@link NextQueriesXModule | next queries module}.\n *\n * @internal\n */\nexport const nextQueriesWiring = createWiring({\n ParamsLoadedFromUrl: {\n setUrlParams,\n },\n NextQueriesChanged: {\n resetResultsPreviewWire,\n },\n UserAcceptedAQuery: {\n resetNextQueriesWire,\n setNextQueriesQuery,\n },\n SelectedRelatedTagsChanged: {\n setNextQueriesRelatedTags,\n },\n SessionHistoryQueriesChanged: {\n setSearchedQueries,\n // TODO setQueryFromLastHistoryQuery it has to be called only one time\n setQueryFromLastHistoryQueryWire,\n },\n NextQueriesRequestUpdated: {\n fetchAndSaveNextQueriesWire,\n },\n ExtraParamsChanged: {\n setNextQueriesExtraParams,\n },\n NextQueryPreviewMountedHook: {\n fetchAndSaveNextQueryPreviewWire,\n },\n UserAcceptedAQueryPreview: {\n setNextQueriesQueryFromPreview,\n setNextQueriesExtraParamsFromPreview,\n },\n})\n"],"names":[],"mappings":";;;AAaA;;;;AAIG;AACH,MAAM,UAAU,GAAG,aAAa;AAEhC;;;;AAIG;AACH,MAAM,UAAU,GAA4C,oBAAoB,CAAC,UAAU,CAAC;AAE5F;;AAEG;AACH,MAAM,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,EAAE;QAClB,oBAAoB;QACpB,mBAAmB;AACpB,KAAA;AACD,IAAA,0BAA0B,EAAE;QAC1B,yBAAyB;AAC1B,KAAA;AACD,IAAA,4BAA4B,EAAE;QAC5B,kBAAkB;;QAElB,gCAAgC;AACjC,KAAA;AACD,IAAA,yBAAyB,EAAE;QACzB,2BAA2B;AAC5B,KAAA;AACD,IAAA,kBAAkB,EAAE;QAClB,yBAAyB;AAC1B,KAAA;AACD,IAAA,2BAA2B,EAAE;QAC3B,gCAAgC;AACjC,KAAA;AACD,IAAA,yBAAyB,EAAE;QACzB,8BAA8B;QAC9B,oCAAoC;AACrC,KAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"wiring.js","sources":["../../../../src/x-modules/next-queries/wiring.ts"],"sourcesContent":["import type {\n NamespacedWireCommit,\n NamespacedWireCommitWithoutPayload,\n NamespacedWireDispatch,\n NamespacedWiringData,\n} from '../../wiring/namespaced-wiring.types'\nimport {\n namespacedWireCommit,\n namespacedWireCommitWithoutPayload,\n namespacedWireDispatch,\n} from '../../wiring/namespaced-wires.factory'\nimport { createWiring } from '../../wiring/wiring.utils'\n\n/**\n * `nextQueries` {@link XModuleName | XModule name}.\n *\n * @internal\n */\nconst moduleName = 'nextQueries'\n\n/**\n * WireCommit for {@link NextQueriesXModule}.\n *\n * @internal\n */\nconst wireCommit: NamespacedWireCommit<typeof moduleName> = namespacedWireCommit(moduleName)\n\n/**\n * WireCommitWithoutPayload for {@link NextQueriesXModule}.\n */\nconst wireCommitWithoutPayload: NamespacedWireCommitWithoutPayload<typeof moduleName> =\n namespacedWireCommitWithoutPayload(moduleName)\n\n/**\n * WireDispatch for {@link NextQueriesXModule}.\n *\n * @internal\n */\nconst wireDispatch: NamespacedWireDispatch<typeof moduleName> = namespacedWireDispatch(moduleName)\n\n/**\n * Sets the next queries state `query`.\n *\n * @public\n */\nexport const setNextQueriesQuery = wireCommit('setQuery')\n\n/**\n * Reset the next queries state `query`.\n *\n * @public\n */\nexport const resetNextQueriesQuery = wireCommit('setQuery', '')\n\n/**\n * Sets the next queries state `relatedTags`.\n *\n * @public\n */\nexport const setNextQueriesRelatedTags = wireCommit('setRelatedTags')\n\n/**\n * Sets the next queries state `query` with a selectedQueryPreview's query.\n *\n * @public\n */\nexport const setNextQueriesQueryFromPreview = wireCommit(\n 'setParams',\n ({ eventPayload: { query } }) => query,\n)\n\n/**\n * Sets the next queries state `query` from url.\n *\n * @public\n */\nconst setUrlParams = wireDispatch('setUrlParams')\n\n/**\n * Sets the next queries state `params`.\n *\n * @public\n */\nexport const setNextQueriesExtraParams = wireCommit('setParams')\n\n/**\n * Sets the next queries state `params` with a selectedQueryPreview's extraParams.\n *\n * @public\n */\nexport const setNextQueriesExtraParamsFromPreview = wireCommit(\n 'setParams',\n ({ eventPayload: { extraParams } }) => extraParams,\n)\n\n/**\n * Requests and stores the next queries.\n *\n * @public\n */\nexport const fetchAndSaveNextQueriesWire = wireDispatch('fetchAndSaveNextQueries')\n\n/**\n * Sets the next queries state `query` with the last query in history queries.\n *\n * @public\n */\nexport const setQueryFromLastHistoryQueryWire = wireDispatch('setQueryFromLastHistoryQuery')\n\n/**\n * Requests and store the next query preview results.\n *\n * @public\n */\nexport const fetchAndSaveNextQueryPreviewWire = wireDispatch(\n 'fetchAndSaveNextQueryPreview',\n ({ eventPayload: query, metadata: { location } }: NamespacedWiringData<'nextQueries'>) => {\n return {\n query,\n location,\n }\n },\n)\n/**\n * Resets the next query preview results.\n *\n * @public\n */\nexport const resetResultsPreviewWire = wireCommitWithoutPayload('resetResultsPreview')\n\n/**\n * Resets the next queries list to an empty array.\n *\n * @public\n */\nexport const resetNextQueriesWire = wireCommitWithoutPayload('resetNextQueries')\n\n/**\n * Sets the next queries state `searchedQueries` with the list of history queries.\n *\n * @public\n */\nexport const setSearchedQueries = wireCommit('setSearchedQueries')\n\n/**\n * Wiring configuration for the {@link NextQueriesXModule | next queries module}.\n *\n * @internal\n */\nexport const nextQueriesWiring = createWiring({\n ParamsLoadedFromUrl: {\n setUrlParams,\n },\n NextQueriesChanged: {\n resetResultsPreviewWire,\n },\n UserAcceptedAQuery: {\n resetNextQueriesWire,\n setNextQueriesQuery,\n },\n UserClearedQuery: {\n resetNextQueriesWire,\n resetNextQueriesQuery,\n },\n SelectedRelatedTagsChanged: {\n setNextQueriesRelatedTags,\n },\n SessionHistoryQueriesChanged: {\n setSearchedQueries,\n // TODO setQueryFromLastHistoryQuery it has to be called only one time\n setQueryFromLastHistoryQueryWire,\n },\n NextQueriesRequestUpdated: {\n fetchAndSaveNextQueriesWire,\n },\n ExtraParamsChanged: {\n setNextQueriesExtraParams,\n },\n NextQueryPreviewMountedHook: {\n fetchAndSaveNextQueryPreviewWire,\n },\n UserAcceptedAQueryPreview: {\n setNextQueriesQueryFromPreview,\n setNextQueriesExtraParamsFromPreview,\n },\n})\n"],"names":[],"mappings":";;;AAaA;;;;AAIG;AACH,MAAM,UAAU,GAAG,aAAa;AAEhC;;;;AAIG;AACH,MAAM,UAAU,GAA4C,oBAAoB,CAAC,UAAU,CAAC;AAE5F;;AAEG;AACH,MAAM,wBAAwB,GAC5B,kCAAkC,CAAC,UAAU,CAAC;AAEhD;;;;AAIG;AACH,MAAM,YAAY,GAA8C,sBAAsB,CAAC,UAAU,CAAC;AAElG;;;;AAIG;MACU,mBAAmB,GAAG,UAAU,CAAC,UAAU;AAExD;;;;AAIG;AACI,MAAM,qBAAqB,GAAG,UAAU,CAAC,UAAU,EAAE,EAAE;AAE9D;;;;AAIG;MACU,yBAAyB,GAAG,UAAU,CAAC,gBAAgB;AAEpE;;;;AAIG;MACU,8BAA8B,GAAG,UAAU,CACtD,WAAW,EACX,CAAC,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,KAAK;AAGxC;;;;AAIG;AACH,MAAM,YAAY,GAAG,YAAY,CAAC,cAAc,CAAC;AAEjD;;;;AAIG;MACU,yBAAyB,GAAG,UAAU,CAAC,WAAW;AAE/D;;;;AAIG;MACU,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;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-handler.vue.js","sources":["../../../../../src/x-modules/url/components/url-handler.vue"],"sourcesContent":["<template>\n <GlobalEvents target=\"window\" @pageshow=\"onPageShow\" @popstate=\"emitEvents\" />\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { FeatureLocation } from '../../../types/origin'\nimport type { UrlParams } from '../../../types/url-params'\nimport type { WireMetadata } from '../../../wiring/wiring.types'\nimport type { SnippetConfig } from '../../../x-installer/api/api.types'\nimport type { UrlParamValue } from '../store/types'\nimport { objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent, inject, onMounted, ref } from 'vue'\nimport { GlobalEvents } from 'vue-global-events'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { initialUrlState } from '../store/initial-state'\nimport { urlXModule } from '../x-module'\n\ninterface ParsedUrlParams {\n all: UrlParams\n extra: Dictionary<unknown>\n}\n\n/**\n * This component manages the browser URL parameters to preserve them through reloads and browser\n * history navigation. It allow to configure the default url parameter names using its attributes.\n * This component doesn't render elements to the DOM.\n *\n * @public\n */\nexport default defineComponent({\n name: 'UrlHandler',\n components: {\n GlobalEvents,\n },\n xModule: urlXModule.name,\n inheritAttrs: false,\n setup(_, { attrs }) {\n const $x = use$x()\n\n const { initialExtraParams } = useState('url')\n\n /**\n * The {@link SnippetConfig} provided by an ancestor.\n *\n * @internal\n */\n const snippetConfig = inject<SnippetConfig | undefined>('snippetConfig')\n\n /**\n * Flag to know if the params were already loaded from the URL.\n *\n * @internal\n */\n const urlLoaded = ref(false)\n\n /**\n * The page URL. It is used to compare against the current URL to check navigation state.\n *\n * @internal\n */\n const url = ref<URL | undefined>(undefined)\n\n /**\n * Flag to know if the page has been persisted by the browser's back-forward cache.\n *\n * @internal\n */\n const isPagePersisted = ref(false)\n\n /**\n * Computed to know which params we must get from URL. It gets the params names from the initial\n * state, to get all default params names, and also from the `$attrs` to get the extra params\n * names to take into account.\n *\n * @returns An array with the name of the params.\n *\n * @internal\n */\n const managedParamsNames = computed(() => Object.keys({ ...initialUrlState, ...attrs }))\n\n /**\n * Returns the mapping of the param keys used in the URL is configured through $attrs. This way\n * we can support any param and extra param, no matters its name.\n *\n * @param paramName - The param name to get the Url key.\n * @returns The key used in the URL for the `paramName` passed.\n *\n * @internal\n */\n const getUrlKey = (paramName: string) => {\n const paramValue = attrs[paramName]\n return typeof paramValue === 'string' ? paramValue : paramName\n }\n\n /**\n * Deletes all the parameters in the passed URL.\n *\n * @param url - The URL to remove parameters from.\n * @internal\n */\n const deleteUrlParameters = (url: URL) => {\n managedParamsNames.value.forEach(paramName => url.searchParams.delete(getUrlKey(paramName)))\n }\n\n /**\n * Sorts the params in a tuple array [key,value] to generate always the same URL with the params\n * in the same order.\n *\n * @param urlParams - The {@link UrlParams} to sort.\n * @returns An array of tuples with the key-value of each paramter, sorted by key.\n * @internal\n */\n const sortParams = (urlParams: UrlParams): Array<[string, unknown]> => {\n return Object.entries(urlParams).sort(([param1], [param2]) => {\n return param1 < param2 ? -1 : 1\n })\n }\n\n /**\n * Set all the provided parameters to the url with the mapped key.\n *\n * @param url - The current URL.\n * @param urlParams - The list of parameters to add.\n * @remarks The params are filtered because there maybe received extra params which will not be\n * managed by URL. This is defined by the `managedParamsNames` computed. Also, the parameters\n * are sorted Alphabetically to produce always the same URL with the same parameters.This is\n * important for SEO purposes.\n *\n * @internal\n */\n const setUrlParameters = (url: URL, urlParams: UrlParams): void => {\n // Only when there is a query the rest of the parameters are valid.\n if (!urlParams.query) {\n return\n }\n const filteredParams = objectFilter(urlParams, paramName =>\n managedParamsNames.value.includes(paramName as string),\n )\n const sortedParameters = sortParams(filteredParams)\n sortedParameters.forEach(([paramName, paramValue]) => {\n const urlParamKey = getUrlKey(paramName)\n if (Array.isArray(paramValue)) {\n paramValue.forEach(value => {\n url.searchParams.append(urlParamKey, String(value))\n })\n } else {\n url.searchParams.set(urlParamKey, String(paramValue))\n }\n })\n }\n\n /**\n * Updates the browser URL with the passed `newUrlParams` and using the browser history method\n * passed as `historyMethod`. It only updates the browser history if the new URL is different\n * from the current.\n *\n * @param newUrlParams - The new params to add to the browser URL.\n * @param historyMethod - The browser history method used to add the new URL.\n *\n * @internal\n */\n const updateUrl = (\n newUrlParams: UrlParams,\n historyMethod: History['pushState'] | History['replaceState'],\n ): void => {\n if (urlLoaded.value) {\n const newUrl = new URL(window.location.href)\n deleteUrlParameters(newUrl)\n setUrlParameters(newUrl, newUrlParams)\n\n // Normalize '+' characters into '%20' for spaces in url params.\n newUrl.search = newUrl.search.replace(/\\+/g, '%20')\n\n if (newUrl.href !== window.location.href) {\n historyMethod({ ...window.history.state }, document.title, newUrl.href)\n }\n url.value = newUrl\n }\n }\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `pushState` method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('PushableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.pushState.bind(window.history))\n })\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `replaceState`\n * method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('ReplaceableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.replaceState.bind(window.history))\n })\n\n /**\n * Handler of the\n * [pageshow](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event)\n * event.\n *\n * @remarks The pageshow event is listened to check if the browser has performed a navigation\n * using the back-forward cache. This information is available in the\n * PageTransitionEvent.persisted property.\n *\n * @param event - The page transition event.\n * @internal\n */\n const onPageShow = (event: PageTransitionEvent) => {\n isPagePersisted.value = event.persisted\n if (event.persisted) {\n // The internal url is reset due to the back-forward cache storing the previous value which\n // is no longer valid.\n url.value = undefined\n }\n }\n\n /**\n * Returns the URL param value parsed depending on its type in the initial store state. As we\n * can not know what type can have an extra param, all extra params are parsed as strings. We\n * know if it is an extra param because it is not in the initial state.\n *\n * @param name - The name of the param in {@link UrlParams}.\n * @param value - The `URLSearchParams` value as an arry of strings.\n * @returns The parsed value.\n *\n * @internal\n */\n const parseUrlParam = (name: string, value: string[]): UrlParamValue => {\n switch (typeof initialUrlState[name]) {\n case 'number':\n return Number(value[0])\n case 'boolean':\n return value[0].toLowerCase() === 'true'\n case 'string':\n return value[0]\n default:\n // array\n return value\n }\n }\n\n /**\n * Gets the {@link UrlParams} from the URL, including only the params defined by `paramsNames`.\n *\n * @returns ParsedUrlParams obtained from URL.\n * @internal\n */\n const parseUrlParams = (): ParsedUrlParams => {\n const urlSearchParams = new URL(window.location.href).searchParams\n return managedParamsNames.value.reduce<ParsedUrlParams>(\n (params, name) => {\n const urlKey = getUrlKey(name)\n if (urlSearchParams.has(urlKey)) {\n if (name in initialUrlState) {\n const urlValue = urlSearchParams.getAll(urlKey)\n params.all[name] = parseUrlParam(name, urlValue)\n } else {\n params.all[name] = params.extra[name] = urlSearchParams.get(urlKey)\n }\n }\n return params\n },\n { all: { ...initialUrlState }, extra: { ...initialExtraParams.value } },\n )\n }\n\n /**\n * Check if the navigation is from a product page.\n *\n * @remarks Due to Safari 14 not supporting the new and standard PerformanceNavigationTiming\n * API, we are falling back to the deprecated one, PerformanceNavigation. We also fallback to\n * this API whenever we get a navigationType equal to reload, because Safari has a bug that the\n * navigationType is permanently set to reload after you have reload the page and it never\n * resets. As some browsers have a back-forward cache implemented, we also take into account if\n * the page is persisted.\n *\n * @returns True if the navigation is from a product page, false otherwise.\n * @internal\n */\n const isNavigatingFromPdp = (): boolean => {\n const isPagePersistedValue = isPagePersisted.value\n const navigationEntries = window.performance.getEntriesByType('navigation')\n const navigationType = (navigationEntries[0] as PerformanceNavigationTiming)?.type\n const useFallbackStrategy =\n !navigationEntries.length &&\n (isArrayEmpty(navigationEntries) || navigationType === 'reload')\n\n // Reset internal isPagePersisted property value\n isPagePersisted.value = false\n\n if (useFallbackStrategy) {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n } else {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n }\n }\n\n /**\n * Detects the {@link FeatureLocation} used to build the\n * {@link QueryOriginInit} data.\n *\n * @returns The {@link FeatureLocation}.\n * @internal\n */\n const detectLocation = (): FeatureLocation => {\n const currentUrl = new URL(window.location.href)\n const previousUrl = url.value\n url.value = currentUrl\n\n const isInternalNavigation =\n previousUrl?.search !== currentUrl.search && previousUrl?.pathname === currentUrl.pathname\n if (isInternalNavigation) {\n return 'url_history'\n }\n\n if (isNavigatingFromPdp()) {\n return 'url_history_pdp'\n }\n\n return 'external'\n }\n\n /**\n * Creates the wire metadata to include in every emitted {@link XEvent}.\n *\n * @returns The {@link WireMetadata}.\n * @internal\n */\n const createWireMetadata = (): Pick<WireMetadata, 'feature' | 'location'> => {\n return {\n feature: 'url',\n location: detectLocation(),\n }\n }\n\n /**\n * Emits the {@link UrlXEvents.ParamsLoadedFromUrl} XEvent,\n * the {@link UrlXEvents.ExtraParamsLoadedFromUrl} XEvent and, if there is query, also emits\n * the {@link XEventsTypes.UserOpenXProgrammatically}.\n *\n * @internal\n */\n const emitEvents = () => {\n const { all, extra } = parseUrlParams()\n const metadata = createWireMetadata()\n $x.emit('ParamsLoadedFromUrl', all, metadata)\n $x.emit('ExtraParamsLoadedFromUrl', extra, metadata)\n if (all.query) {\n $x.emit('UserOpenXProgrammatically', undefined, metadata)\n }\n urlLoaded.value = true\n }\n\n /**\n * To emit the Url events just when the URL is load, and before the components mounted events\n * and state changes, we do it in the created of this component.\n */\n onMounted(() => {\n emitEvents()\n })\n\n return {\n onPageShow,\n emitEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`ParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`ExtraParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`UserOpenXProgrammatically`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component manages the browser URL parameters to preserve them through reloads and browser\nhistory navigation. It allows you to configure the default URL parameter names using its attributes. This\ncomponent doesn't render elements to the DOM.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with props\n\nIn this example, the `UrlHandler` component changes the following query parameter names:\n\n- `query` to be `q`.\n- `page` to be `p`.\n- `filter` to be `f`.\n- `sort` to be `s`.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with events\n\nThe `UrlHandler` will emit the `ParamsLoadedFromUrl` when the page is loaded.\n\nThe `UrlHandler` will emit the `ExtraParamsLoadedFromUrl` when the page is loaded with an extra\nparam configured and with a value in the URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":["_createBlock"],"mappings":";;;;;;sBACEA,WAAA,CAA8E,uBAAA,EAAA;AAAA,IAAhE,MAAA,EAAO,QAAA;AAAA,IAAU,UAAA,EAAU,IAAA,CAAA,UAAA;AAAA,IAAa,UAAA,EAAU,IAAA,CAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,YAAA,EAAA,YAAA,CAAA,CAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"url-handler.vue.js","sources":["../../../../../src/x-modules/url/components/url-handler.vue"],"sourcesContent":["<template>\n <GlobalEvents target=\"window\" @pageshow=\"onPageShow\" @popstate=\"emitEvents\" />\n</template>\n\n<script lang=\"ts\">\nimport type { Dictionary } from '@empathyco/x-utils'\nimport type { FeatureLocation } from '../../../types/origin'\nimport type { UrlParams } from '../../../types/url-params'\nimport type { WireMetadata } from '../../../wiring/wiring.types'\nimport type { SnippetConfig } from '../../../x-installer/api/api.types'\nimport type { UrlParamValue } from '../store/types'\nimport { objectFilter } from '@empathyco/x-utils'\nimport { computed, defineComponent, inject, onMounted, ref } from 'vue'\nimport { GlobalEvents } from 'vue-global-events'\nimport { use$x } from '../../../composables/use-$x'\nimport { useState } from '../../../composables/use-state'\nimport { isArrayEmpty } from '../../../utils/array'\nimport { initialUrlState } from '../store/initial-state'\nimport { urlXModule } from '../x-module'\n\ninterface ParsedUrlParams {\n all: UrlParams\n extra: Dictionary<unknown>\n}\n\n/**\n * This component manages the browser URL parameters to preserve them through reloads and browser\n * history navigation. It allow to configure the default url parameter names using its attributes.\n * This component doesn't render elements to the DOM.\n *\n * @public\n */\nexport default defineComponent({\n name: 'UrlHandler',\n components: {\n GlobalEvents,\n },\n xModule: urlXModule.name,\n inheritAttrs: false,\n setup(_, { attrs }) {\n const $x = use$x()\n\n const { initialExtraParams } = useState('url')\n\n /**\n * The {@link SnippetConfig} provided by an ancestor.\n *\n * @internal\n */\n const snippetConfig = inject<SnippetConfig | undefined>('snippetConfig')\n\n /**\n * Flag to know if the params were already loaded from the URL.\n *\n * @internal\n */\n const urlLoaded = ref(false)\n\n /**\n * The page URL. It is used to compare against the current URL to check navigation state.\n *\n * @internal\n */\n const url = ref<URL | undefined>(undefined)\n\n /**\n * Flag to know if the page has been persisted by the browser's back-forward cache.\n *\n * @internal\n */\n const isPagePersisted = ref(false)\n\n /**\n * Computed to know which params we must get from URL. It gets the params names from the initial\n * state, to get all default params names, and also from the `$attrs` to get the extra params\n * names to take into account.\n *\n * @returns An array with the name of the params.\n *\n * @internal\n */\n const managedParamsNames = computed(() => Object.keys({ ...initialUrlState, ...attrs }))\n\n /**\n * Returns the mapping of the param keys used in the URL is configured through $attrs. This way\n * we can support any param and extra param, no matters its name.\n *\n * @param paramName - The param name to get the Url key.\n * @returns The key used in the URL for the `paramName` passed.\n *\n * @internal\n */\n const getUrlKey = (paramName: string) => {\n const paramValue = attrs[paramName]\n return typeof paramValue === 'string' ? paramValue : paramName\n }\n\n /**\n * Deletes all the parameters in the passed URL.\n *\n * @param url - The URL to remove parameters from.\n * @internal\n */\n const deleteUrlParameters = (url: URL) => {\n managedParamsNames.value.forEach(paramName => url.searchParams.delete(getUrlKey(paramName)))\n }\n\n /**\n * Sorts the params in a tuple array [key,value] to generate always the same URL with the params\n * in the same order.\n *\n * @param urlParams - The {@link UrlParams} to sort.\n * @returns An array of tuples with the key-value of each paramter, sorted by key.\n * @internal\n */\n const sortParams = (urlParams: UrlParams): Array<[string, unknown]> => {\n return Object.entries(urlParams).sort(([param1], [param2]) => {\n return param1 < param2 ? -1 : 1\n })\n }\n\n /**\n * Set all the provided parameters to the url with the mapped key.\n *\n * @param url - The current URL.\n * @param urlParams - The list of parameters to add.\n * @remarks The params are filtered because there maybe received extra params which will not be\n * managed by URL. This is defined by the `managedParamsNames` computed. Also, the parameters\n * are sorted Alphabetically to produce always the same URL with the same parameters.This is\n * important for SEO purposes.\n *\n * @internal\n */\n const setUrlParameters = (url: URL, urlParams: UrlParams): void => {\n // Only when there is a query the rest of the parameters are valid.\n if (!urlParams.query && !urlParams.browseField && !urlParams.browseValue) {\n return\n }\n const filteredParams = objectFilter(urlParams, paramName =>\n managedParamsNames.value.includes(paramName as string),\n )\n const sortedParameters = sortParams(filteredParams)\n sortedParameters.forEach(([paramName, paramValue]) => {\n const urlParamKey = getUrlKey(paramName)\n if (Array.isArray(paramValue)) {\n paramValue.forEach(value => {\n url.searchParams.append(urlParamKey, String(value))\n })\n } else {\n url.searchParams.set(urlParamKey, String(paramValue))\n }\n })\n }\n\n /**\n * Updates the browser URL with the passed `newUrlParams` and using the browser history method\n * passed as `historyMethod`. It only updates the browser history if the new URL is different\n * from the current.\n *\n * @param newUrlParams - The new params to add to the browser URL.\n * @param historyMethod - The browser history method used to add the new URL.\n *\n * @internal\n */\n const updateUrl = (\n newUrlParams: UrlParams,\n historyMethod: History['pushState'] | History['replaceState'],\n ): void => {\n if (urlLoaded.value) {\n const newUrl = new URL(window.location.href)\n deleteUrlParameters(newUrl)\n setUrlParameters(newUrl, newUrlParams)\n\n // Normalize '+' characters into '%20' for spaces in url params.\n newUrl.search = newUrl.search.replace(/\\+/g, '%20')\n\n if (newUrl.href !== window.location.href) {\n historyMethod({ ...window.history.state }, document.title, newUrl.href)\n }\n url.value = newUrl\n }\n }\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `pushState` method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('PushableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.pushState.bind(window.history))\n })\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `replaceState`\n * method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('ReplaceableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.replaceState.bind(window.history))\n })\n\n /**\n * Handler of the\n * [pageshow](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event)\n * event.\n *\n * @remarks The pageshow event is listened to check if the browser has performed a navigation\n * using the back-forward cache. This information is available in the\n * PageTransitionEvent.persisted property.\n *\n * @param event - The page transition event.\n * @internal\n */\n const onPageShow = (event: PageTransitionEvent) => {\n isPagePersisted.value = event.persisted\n if (event.persisted) {\n // The internal url is reset due to the back-forward cache storing the previous value which\n // is no longer valid.\n url.value = undefined\n }\n }\n\n /**\n * Returns the URL param value parsed depending on its type in the initial store state. As we\n * can not know what type can have an extra param, all extra params are parsed as strings. We\n * know if it is an extra param because it is not in the initial state.\n *\n * @param name - The name of the param in {@link UrlParams}.\n * @param value - The `URLSearchParams` value as an arry of strings.\n * @returns The parsed value.\n *\n * @internal\n */\n const parseUrlParam = (name: string, value: string[]): UrlParamValue => {\n switch (typeof initialUrlState[name]) {\n case 'number':\n return Number(value[0])\n case 'boolean':\n return value[0].toLowerCase() === 'true'\n case 'string':\n return value[0]\n default:\n // array\n return value\n }\n }\n\n /**\n * Gets the {@link UrlParams} from the URL, including only the params defined by `paramsNames`.\n *\n * @returns ParsedUrlParams obtained from URL.\n * @internal\n */\n const parseUrlParams = (): ParsedUrlParams => {\n const urlSearchParams = new URL(window.location.href).searchParams\n return managedParamsNames.value.reduce<ParsedUrlParams>(\n (params, name) => {\n const urlKey = getUrlKey(name)\n if (urlSearchParams.has(urlKey)) {\n if (name in initialUrlState) {\n const urlValue = urlSearchParams.getAll(urlKey)\n params.all[name] = parseUrlParam(name, urlValue)\n } else {\n params.all[name] = params.extra[name] = urlSearchParams.get(urlKey)\n }\n }\n return params\n },\n { all: { ...initialUrlState }, extra: { ...initialExtraParams.value } },\n )\n }\n\n /**\n * Check if the navigation is from a product page.\n *\n * @remarks Due to Safari 14 not supporting the new and standard PerformanceNavigationTiming\n * API, we are falling back to the deprecated one, PerformanceNavigation. We also fallback to\n * this API whenever we get a navigationType equal to reload, because Safari has a bug that the\n * navigationType is permanently set to reload after you have reload the page and it never\n * resets. As some browsers have a back-forward cache implemented, we also take into account if\n * the page is persisted.\n *\n * @returns True if the navigation is from a product page, false otherwise.\n * @internal\n */\n const isNavigatingFromPdp = (): boolean => {\n const isPagePersistedValue = isPagePersisted.value\n const navigationEntries = window.performance.getEntriesByType('navigation')\n const navigationType = (navigationEntries[0] as PerformanceNavigationTiming)?.type\n const useFallbackStrategy =\n !navigationEntries.length &&\n (isArrayEmpty(navigationEntries) || navigationType === 'reload')\n\n // Reset internal isPagePersisted property value\n isPagePersisted.value = false\n\n if (useFallbackStrategy) {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n } else {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n }\n }\n\n /**\n * Detects the {@link FeatureLocation} used to build the\n * {@link QueryOriginInit} data.\n *\n * @returns The {@link FeatureLocation}.\n * @internal\n */\n const detectLocation = (): FeatureLocation => {\n const currentUrl = new URL(window.location.href)\n const previousUrl = url.value\n url.value = currentUrl\n\n const isInternalNavigation =\n previousUrl?.search !== currentUrl.search && previousUrl?.pathname === currentUrl.pathname\n if (isInternalNavigation) {\n return 'url_history'\n }\n\n if (isNavigatingFromPdp()) {\n return 'url_history_pdp'\n }\n\n return 'external'\n }\n\n /**\n * Creates the wire metadata to include in every emitted {@link XEvent}.\n *\n * @returns The {@link WireMetadata}.\n * @internal\n */\n const createWireMetadata = (): Pick<WireMetadata, 'feature' | 'location'> => {\n return {\n feature: 'url',\n location: detectLocation(),\n }\n }\n\n /**\n * Emits the {@link UrlXEvents.ParamsLoadedFromUrl} XEvent,\n * the {@link UrlXEvents.ExtraParamsLoadedFromUrl} XEvent and, if there is query, also emits\n * the {@link XEventsTypes.UserOpenXProgrammatically}.\n *\n * @internal\n */\n const emitEvents = () => {\n const { all, extra } = parseUrlParams()\n const metadata = createWireMetadata()\n $x.emit('ParamsLoadedFromUrl', all, metadata)\n $x.emit('ExtraParamsLoadedFromUrl', extra, metadata)\n if (all.query) {\n $x.emit('UserOpenXProgrammatically', undefined, metadata)\n } else if (all.browseField && all.browseValue) {\n $x.emit(\n 'UserBrowsedToCategory',\n { browseValue: all.browseValue, browseField: all.browseField },\n metadata,\n )\n }\n urlLoaded.value = true\n }\n\n /**\n * To emit the Url events just when the URL is load, and before the components mounted events\n * and state changes, we do it in the created of this component.\n */\n onMounted(() => {\n emitEvents()\n })\n\n return {\n onPageShow,\n emitEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`ParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`ExtraParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`UserOpenXProgrammatically`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component manages the browser URL parameters to preserve them through reloads and browser\nhistory navigation. It allows you to configure the default URL parameter names using its attributes. This\ncomponent doesn't render elements to the DOM.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with props\n\nIn this example, the `UrlHandler` component changes the following query parameter names:\n\n- `query` to be `q`.\n- `page` to be `p`.\n- `filter` to be `f`.\n- `sort` to be `s`.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with events\n\nThe `UrlHandler` will emit the `ParamsLoadedFromUrl` when the page is loaded.\n\nThe `UrlHandler` will emit the `ExtraParamsLoadedFromUrl` when the page is loaded with an extra\nparam configured and with a value in the URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":["_createBlock"],"mappings":";;;;;;sBACEA,WAAA,CAA8E,uBAAA,EAAA;AAAA,IAAhE,MAAA,EAAO,QAAA;AAAA,IAAU,UAAA,EAAU,IAAA,CAAA,UAAA;AAAA,IAAa,UAAA,EAAU,IAAA,CAAA;AAAA,GAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,YAAA,EAAA,YAAA,CAAA,CAAA;;;;;;"}
|
|
@@ -107,7 +107,7 @@ var _sfc_main = defineComponent({
|
|
|
107
107
|
*/
|
|
108
108
|
const setUrlParameters = (url, urlParams) => {
|
|
109
109
|
// Only when there is a query the rest of the parameters are valid.
|
|
110
|
-
if (!urlParams.query) {
|
|
110
|
+
if (!urlParams.query && !urlParams.browseField && !urlParams.browseValue) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
const filteredParams = objectFilter(urlParams, paramName => managedParamsNames.value.includes(paramName));
|
|
@@ -307,6 +307,9 @@ var _sfc_main = defineComponent({
|
|
|
307
307
|
if (all.query) {
|
|
308
308
|
$x.emit('UserOpenXProgrammatically', undefined, metadata);
|
|
309
309
|
}
|
|
310
|
+
else if (all.browseField && all.browseValue) {
|
|
311
|
+
$x.emit('UserBrowsedToCategory', { browseValue: all.browseValue, browseField: all.browseField }, metadata);
|
|
312
|
+
}
|
|
310
313
|
urlLoaded.value = true;
|
|
311
314
|
};
|
|
312
315
|
/**
|
|
@@ -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 inheritAttrs: false,\n setup(_, { attrs }) {\n const $x = use$x()\n\n const { initialExtraParams } = useState('url')\n\n /**\n * The {@link SnippetConfig} provided by an ancestor.\n *\n * @internal\n */\n const snippetConfig = inject<SnippetConfig | undefined>('snippetConfig')\n\n /**\n * Flag to know if the params were already loaded from the URL.\n *\n * @internal\n */\n const urlLoaded = ref(false)\n\n /**\n * The page URL. It is used to compare against the current URL to check navigation state.\n *\n * @internal\n */\n const url = ref<URL | undefined>(undefined)\n\n /**\n * Flag to know if the page has been persisted by the browser's back-forward cache.\n *\n * @internal\n */\n const isPagePersisted = ref(false)\n\n /**\n * Computed to know which params we must get from URL. It gets the params names from the initial\n * state, to get all default params names, and also from the `$attrs` to get the extra params\n * names to take into account.\n *\n * @returns An array with the name of the params.\n *\n * @internal\n */\n const managedParamsNames = computed(() => Object.keys({ ...initialUrlState, ...attrs }))\n\n /**\n * Returns the mapping of the param keys used in the URL is configured through $attrs. This way\n * we can support any param and extra param, no matters its name.\n *\n * @param paramName - The param name to get the Url key.\n * @returns The key used in the URL for the `paramName` passed.\n *\n * @internal\n */\n const getUrlKey = (paramName: string) => {\n const paramValue = attrs[paramName]\n return typeof paramValue === 'string' ? paramValue : paramName\n }\n\n /**\n * Deletes all the parameters in the passed URL.\n *\n * @param url - The URL to remove parameters from.\n * @internal\n */\n const deleteUrlParameters = (url: URL) => {\n managedParamsNames.value.forEach(paramName => url.searchParams.delete(getUrlKey(paramName)))\n }\n\n /**\n * Sorts the params in a tuple array [key,value] to generate always the same URL with the params\n * in the same order.\n *\n * @param urlParams - The {@link UrlParams} to sort.\n * @returns An array of tuples with the key-value of each paramter, sorted by key.\n * @internal\n */\n const sortParams = (urlParams: UrlParams): Array<[string, unknown]> => {\n return Object.entries(urlParams).sort(([param1], [param2]) => {\n return param1 < param2 ? -1 : 1\n })\n }\n\n /**\n * Set all the provided parameters to the url with the mapped key.\n *\n * @param url - The current URL.\n * @param urlParams - The list of parameters to add.\n * @remarks The params are filtered because there maybe received extra params which will not be\n * managed by URL. This is defined by the `managedParamsNames` computed. Also, the parameters\n * are sorted Alphabetically to produce always the same URL with the same parameters.This is\n * important for SEO purposes.\n *\n * @internal\n */\n const setUrlParameters = (url: URL, urlParams: UrlParams): void => {\n // Only when there is a query the rest of the parameters are valid.\n if (!urlParams.query) {\n return\n }\n const filteredParams = objectFilter(urlParams, paramName =>\n managedParamsNames.value.includes(paramName as string),\n )\n const sortedParameters = sortParams(filteredParams)\n sortedParameters.forEach(([paramName, paramValue]) => {\n const urlParamKey = getUrlKey(paramName)\n if (Array.isArray(paramValue)) {\n paramValue.forEach(value => {\n url.searchParams.append(urlParamKey, String(value))\n })\n } else {\n url.searchParams.set(urlParamKey, String(paramValue))\n }\n })\n }\n\n /**\n * Updates the browser URL with the passed `newUrlParams` and using the browser history method\n * passed as `historyMethod`. It only updates the browser history if the new URL is different\n * from the current.\n *\n * @param newUrlParams - The new params to add to the browser URL.\n * @param historyMethod - The browser history method used to add the new URL.\n *\n * @internal\n */\n const updateUrl = (\n newUrlParams: UrlParams,\n historyMethod: History['pushState'] | History['replaceState'],\n ): void => {\n if (urlLoaded.value) {\n const newUrl = new URL(window.location.href)\n deleteUrlParameters(newUrl)\n setUrlParameters(newUrl, newUrlParams)\n\n // Normalize '+' characters into '%20' for spaces in url params.\n newUrl.search = newUrl.search.replace(/\\+/g, '%20')\n\n if (newUrl.href !== window.location.href) {\n historyMethod({ ...window.history.state }, document.title, newUrl.href)\n }\n url.value = newUrl\n }\n }\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `pushState` method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('PushableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.pushState.bind(window.history))\n })\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `replaceState`\n * method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('ReplaceableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.replaceState.bind(window.history))\n })\n\n /**\n * Handler of the\n * [pageshow](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event)\n * event.\n *\n * @remarks The pageshow event is listened to check if the browser has performed a navigation\n * using the back-forward cache. This information is available in the\n * PageTransitionEvent.persisted property.\n *\n * @param event - The page transition event.\n * @internal\n */\n const onPageShow = (event: PageTransitionEvent) => {\n isPagePersisted.value = event.persisted\n if (event.persisted) {\n // The internal url is reset due to the back-forward cache storing the previous value which\n // is no longer valid.\n url.value = undefined\n }\n }\n\n /**\n * Returns the URL param value parsed depending on its type in the initial store state. As we\n * can not know what type can have an extra param, all extra params are parsed as strings. We\n * know if it is an extra param because it is not in the initial state.\n *\n * @param name - The name of the param in {@link UrlParams}.\n * @param value - The `URLSearchParams` value as an arry of strings.\n * @returns The parsed value.\n *\n * @internal\n */\n const parseUrlParam = (name: string, value: string[]): UrlParamValue => {\n switch (typeof initialUrlState[name]) {\n case 'number':\n return Number(value[0])\n case 'boolean':\n return value[0].toLowerCase() === 'true'\n case 'string':\n return value[0]\n default:\n // array\n return value\n }\n }\n\n /**\n * Gets the {@link UrlParams} from the URL, including only the params defined by `paramsNames`.\n *\n * @returns ParsedUrlParams obtained from URL.\n * @internal\n */\n const parseUrlParams = (): ParsedUrlParams => {\n const urlSearchParams = new URL(window.location.href).searchParams\n return managedParamsNames.value.reduce<ParsedUrlParams>(\n (params, name) => {\n const urlKey = getUrlKey(name)\n if (urlSearchParams.has(urlKey)) {\n if (name in initialUrlState) {\n const urlValue = urlSearchParams.getAll(urlKey)\n params.all[name] = parseUrlParam(name, urlValue)\n } else {\n params.all[name] = params.extra[name] = urlSearchParams.get(urlKey)\n }\n }\n return params\n },\n { all: { ...initialUrlState }, extra: { ...initialExtraParams.value } },\n )\n }\n\n /**\n * Check if the navigation is from a product page.\n *\n * @remarks Due to Safari 14 not supporting the new and standard PerformanceNavigationTiming\n * API, we are falling back to the deprecated one, PerformanceNavigation. We also fallback to\n * this API whenever we get a navigationType equal to reload, because Safari has a bug that the\n * navigationType is permanently set to reload after you have reload the page and it never\n * resets. As some browsers have a back-forward cache implemented, we also take into account if\n * the page is persisted.\n *\n * @returns True if the navigation is from a product page, false otherwise.\n * @internal\n */\n const isNavigatingFromPdp = (): boolean => {\n const isPagePersistedValue = isPagePersisted.value\n const navigationEntries = window.performance.getEntriesByType('navigation')\n const navigationType = (navigationEntries[0] as PerformanceNavigationTiming)?.type\n const useFallbackStrategy =\n !navigationEntries.length &&\n (isArrayEmpty(navigationEntries) || navigationType === 'reload')\n\n // Reset internal isPagePersisted property value\n isPagePersisted.value = false\n\n if (useFallbackStrategy) {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n } else {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n }\n }\n\n /**\n * Detects the {@link FeatureLocation} used to build the\n * {@link QueryOriginInit} data.\n *\n * @returns The {@link FeatureLocation}.\n * @internal\n */\n const detectLocation = (): FeatureLocation => {\n const currentUrl = new URL(window.location.href)\n const previousUrl = url.value\n url.value = currentUrl\n\n const isInternalNavigation =\n previousUrl?.search !== currentUrl.search && previousUrl?.pathname === currentUrl.pathname\n if (isInternalNavigation) {\n return 'url_history'\n }\n\n if (isNavigatingFromPdp()) {\n return 'url_history_pdp'\n }\n\n return 'external'\n }\n\n /**\n * Creates the wire metadata to include in every emitted {@link XEvent}.\n *\n * @returns The {@link WireMetadata}.\n * @internal\n */\n const createWireMetadata = (): Pick<WireMetadata, 'feature' | 'location'> => {\n return {\n feature: 'url',\n location: detectLocation(),\n }\n }\n\n /**\n * Emits the {@link UrlXEvents.ParamsLoadedFromUrl} XEvent,\n * the {@link UrlXEvents.ExtraParamsLoadedFromUrl} XEvent and, if there is query, also emits\n * the {@link XEventsTypes.UserOpenXProgrammatically}.\n *\n * @internal\n */\n const emitEvents = () => {\n const { all, extra } = parseUrlParams()\n const metadata = createWireMetadata()\n $x.emit('ParamsLoadedFromUrl', all, metadata)\n $x.emit('ExtraParamsLoadedFromUrl', extra, metadata)\n if (all.query) {\n $x.emit('UserOpenXProgrammatically', undefined, metadata)\n }\n urlLoaded.value = true\n }\n\n /**\n * To emit the Url events just when the URL is load, and before the components mounted events\n * and state changes, we do it in the created of this component.\n */\n onMounted(() => {\n emitEvents()\n })\n\n return {\n onPageShow,\n emitEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`ParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`ExtraParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`UserOpenXProgrammatically`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component manages the browser URL parameters to preserve them through reloads and browser\nhistory navigation. It allows you to configure the default URL parameter names using its attributes. This\ncomponent doesn't render elements to the DOM.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with props\n\nIn this example, the `UrlHandler` component changes the following query parameter names:\n\n- `query` to be `q`.\n- `page` to be `p`.\n- `filter` to be `f`.\n- `sort` to be `s`.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with events\n\nThe `UrlHandler` will emit the `ParamsLoadedFromUrl` when the page is loaded.\n\nThe `UrlHandler` will emit the `ExtraParamsLoadedFromUrl` when the page is loaded with an extra\nparam configured and with a value in the URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":[],"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;QAEjB,MAAM,EAAE,kBAAiB,EAAE,GAAI,QAAQ,CAAC,KAAK,CAAA;AAE7C;;;;AAIE;AACF,QAAA,MAAM,aAAY,GAAI,MAAM,CAA4B,eAAe,CAAA;AAEvE;;;;AAIE;AACF,QAAA,MAAM,SAAQ,GAAI,GAAG,CAAC,KAAK,CAAA;AAE3B;;;;AAIE;AACF,QAAA,MAAM,GAAE,GAAI,GAAG,CAAkB,SAAS,CAAA;AAE1C;;;;AAIE;AACF,QAAA,MAAM,eAAc,GAAI,GAAG,CAAC,KAAK,CAAA;AAEjC;;;;;;;;AAQE;QACF,MAAM,kBAAiB,GAAI,QAAQ,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,eAAe,EAAE,GAAG,KAAI,EAAG,CAAC,CAAA;AAEvF;;;;;;;;AAQE;AACF,QAAA,MAAM,SAAQ,GAAI,CAAC,SAAiB,KAAG;AACrC,YAAA,MAAM,UAAS,GAAI,KAAK,CAAC,SAAS,CAAA;AAClC,YAAA,OAAO,OAAO,UAAS,KAAM,QAAO,GAAI,UAAS,GAAI,SAAQ;AAC/D,QAAA,CAAA;AAEA;;;;;AAKE;AACF,QAAA,MAAM,mBAAkB,GAAI,CAAC,GAAQ,KAAG;YACtC,kBAAkB,CAAC,KAAK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I,UAAS;AAErB,YAAA,MAAM,oBAAmB,GACvB,WAAW,EAAE,MAAK,KAAM,UAAU,CAAC,UAAU,WAAW,EAAE,QAAO,KAAM,UAAU,CAAC,QAAO;YAC3F,IAAI,oBAAoB,EAAE;AACxB,gBAAA,OAAO,aAAY;YACrB;YAEA,IAAI,mBAAmB,EAAE,EAAE;AACzB,gBAAA,OAAO,iBAAgB;YACzB;AAEA,YAAA,OAAO,UAAS;AAClB,QAAA,CAAA;AAEA;;;;;AAKE;QACF,MAAM,qBAAqB,MAAgD;YACzE,OAAO;AACL,gBAAA,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,cAAc,EAAE;aAC5B;AACF,QAAA,CAAA;AAEA;;;;;;AAME;QACF,MAAM,UAAS,GAAI,MAAI;YACrB,MAAM,EAAE,GAAG,EAAE,KAAI,EAAE,GAAI,cAAc,EAAC;AACtC,YAAA,MAAM,QAAO,GAAI,kBAAkB,EAAC;YACpC,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE,QAAQ,CAAA;YAC5C,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,EAAE,QAAQ,CAAA;AACnD,YAAA,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,SAAS,EAAE,QAAQ,CAAA;YAC1D;AACA,YAAA,SAAS,CAAC,QAAQ,IAAG;AACvB,QAAA,CAAA;AAEA;;;AAGE;QACF,SAAS,CAAC,MAAI;AACZ,YAAA,UAAU,EAAC;AACb,QAAA,CAAC,CAAA;QAED,OAAO;YACL,UAAU;YACV,UAAU;SACZ;IACF,CAAC;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 && !urlParams.browseField && !urlParams.browseValue) {\n return\n }\n const filteredParams = objectFilter(urlParams, paramName =>\n managedParamsNames.value.includes(paramName as string),\n )\n const sortedParameters = sortParams(filteredParams)\n sortedParameters.forEach(([paramName, paramValue]) => {\n const urlParamKey = getUrlKey(paramName)\n if (Array.isArray(paramValue)) {\n paramValue.forEach(value => {\n url.searchParams.append(urlParamKey, String(value))\n })\n } else {\n url.searchParams.set(urlParamKey, String(paramValue))\n }\n })\n }\n\n /**\n * Updates the browser URL with the passed `newUrlParams` and using the browser history method\n * passed as `historyMethod`. It only updates the browser history if the new URL is different\n * from the current.\n *\n * @param newUrlParams - The new params to add to the browser URL.\n * @param historyMethod - The browser history method used to add the new URL.\n *\n * @internal\n */\n const updateUrl = (\n newUrlParams: UrlParams,\n historyMethod: History['pushState'] | History['replaceState'],\n ): void => {\n if (urlLoaded.value) {\n const newUrl = new URL(window.location.href)\n deleteUrlParameters(newUrl)\n setUrlParameters(newUrl, newUrlParams)\n\n // Normalize '+' characters into '%20' for spaces in url params.\n newUrl.search = newUrl.search.replace(/\\+/g, '%20')\n\n if (newUrl.href !== window.location.href) {\n historyMethod({ ...window.history.state }, document.title, newUrl.href)\n }\n url.value = newUrl\n }\n }\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `pushState` method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('PushableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.pushState.bind(window.history))\n })\n\n /**\n * Updates the browser URL with the new {@link UrlParams} using the history `replaceState`\n * method.\n *\n * @param newUrlParams - The new params to update browser URL.\n */\n $x.on('ReplaceableUrlStateUpdated', false).subscribe((newUrlParams: UrlParams) => {\n updateUrl(newUrlParams, window.history.replaceState.bind(window.history))\n })\n\n /**\n * Handler of the\n * [pageshow](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageshow_event)\n * event.\n *\n * @remarks The pageshow event is listened to check if the browser has performed a navigation\n * using the back-forward cache. This information is available in the\n * PageTransitionEvent.persisted property.\n *\n * @param event - The page transition event.\n * @internal\n */\n const onPageShow = (event: PageTransitionEvent) => {\n isPagePersisted.value = event.persisted\n if (event.persisted) {\n // The internal url is reset due to the back-forward cache storing the previous value which\n // is no longer valid.\n url.value = undefined\n }\n }\n\n /**\n * Returns the URL param value parsed depending on its type in the initial store state. As we\n * can not know what type can have an extra param, all extra params are parsed as strings. We\n * know if it is an extra param because it is not in the initial state.\n *\n * @param name - The name of the param in {@link UrlParams}.\n * @param value - The `URLSearchParams` value as an arry of strings.\n * @returns The parsed value.\n *\n * @internal\n */\n const parseUrlParam = (name: string, value: string[]): UrlParamValue => {\n switch (typeof initialUrlState[name]) {\n case 'number':\n return Number(value[0])\n case 'boolean':\n return value[0].toLowerCase() === 'true'\n case 'string':\n return value[0]\n default:\n // array\n return value\n }\n }\n\n /**\n * Gets the {@link UrlParams} from the URL, including only the params defined by `paramsNames`.\n *\n * @returns ParsedUrlParams obtained from URL.\n * @internal\n */\n const parseUrlParams = (): ParsedUrlParams => {\n const urlSearchParams = new URL(window.location.href).searchParams\n return managedParamsNames.value.reduce<ParsedUrlParams>(\n (params, name) => {\n const urlKey = getUrlKey(name)\n if (urlSearchParams.has(urlKey)) {\n if (name in initialUrlState) {\n const urlValue = urlSearchParams.getAll(urlKey)\n params.all[name] = parseUrlParam(name, urlValue)\n } else {\n params.all[name] = params.extra[name] = urlSearchParams.get(urlKey)\n }\n }\n return params\n },\n { all: { ...initialUrlState }, extra: { ...initialExtraParams.value } },\n )\n }\n\n /**\n * Check if the navigation is from a product page.\n *\n * @remarks Due to Safari 14 not supporting the new and standard PerformanceNavigationTiming\n * API, we are falling back to the deprecated one, PerformanceNavigation. We also fallback to\n * this API whenever we get a navigationType equal to reload, because Safari has a bug that the\n * navigationType is permanently set to reload after you have reload the page and it never\n * resets. As some browsers have a back-forward cache implemented, we also take into account if\n * the page is persisted.\n *\n * @returns True if the navigation is from a product page, false otherwise.\n * @internal\n */\n const isNavigatingFromPdp = (): boolean => {\n const isPagePersistedValue = isPagePersisted.value\n const navigationEntries = window.performance.getEntriesByType('navigation')\n const navigationType = (navigationEntries[0] as PerformanceNavigationTiming)?.type\n const useFallbackStrategy =\n !navigationEntries.length &&\n (isArrayEmpty(navigationEntries) || navigationType === 'reload')\n\n // Reset internal isPagePersisted property value\n isPagePersisted.value = false\n\n if (useFallbackStrategy) {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n } else {\n const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate'\n return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue\n }\n }\n\n /**\n * Detects the {@link FeatureLocation} used to build the\n * {@link QueryOriginInit} data.\n *\n * @returns The {@link FeatureLocation}.\n * @internal\n */\n const detectLocation = (): FeatureLocation => {\n const currentUrl = new URL(window.location.href)\n const previousUrl = url.value\n url.value = currentUrl\n\n const isInternalNavigation =\n previousUrl?.search !== currentUrl.search && previousUrl?.pathname === currentUrl.pathname\n if (isInternalNavigation) {\n return 'url_history'\n }\n\n if (isNavigatingFromPdp()) {\n return 'url_history_pdp'\n }\n\n return 'external'\n }\n\n /**\n * Creates the wire metadata to include in every emitted {@link XEvent}.\n *\n * @returns The {@link WireMetadata}.\n * @internal\n */\n const createWireMetadata = (): Pick<WireMetadata, 'feature' | 'location'> => {\n return {\n feature: 'url',\n location: detectLocation(),\n }\n }\n\n /**\n * Emits the {@link UrlXEvents.ParamsLoadedFromUrl} XEvent,\n * the {@link UrlXEvents.ExtraParamsLoadedFromUrl} XEvent and, if there is query, also emits\n * the {@link XEventsTypes.UserOpenXProgrammatically}.\n *\n * @internal\n */\n const emitEvents = () => {\n const { all, extra } = parseUrlParams()\n const metadata = createWireMetadata()\n $x.emit('ParamsLoadedFromUrl', all, metadata)\n $x.emit('ExtraParamsLoadedFromUrl', extra, metadata)\n if (all.query) {\n $x.emit('UserOpenXProgrammatically', undefined, metadata)\n } else if (all.browseField && all.browseValue) {\n $x.emit(\n 'UserBrowsedToCategory',\n { browseValue: all.browseValue, browseField: all.browseField },\n metadata,\n )\n }\n urlLoaded.value = true\n }\n\n /**\n * To emit the Url events just when the URL is load, and before the components mounted events\n * and state changes, we do it in the created of this component.\n */\n onMounted(() => {\n emitEvents()\n })\n\n return {\n onPageShow,\n emitEvents,\n }\n },\n})\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits the following events:\n\n- [`ParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`ExtraParamsLoadedFromUrl`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n- [`UserOpenXProgrammatically`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)\n\n## See it in action\n\nThis component manages the browser URL parameters to preserve them through reloads and browser\nhistory navigation. It allows you to configure the default URL parameter names using its attributes. This\ncomponent doesn't render elements to the DOM.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with props\n\nIn this example, the `UrlHandler` component changes the following query parameter names:\n\n- `query` to be `q`.\n- `page` to be `p`.\n- `filter` to be `f`.\n- `sort` to be `s`.\n\n_Try to make some requests and take a look at the URL!_\n\n```vue\n<template>\n <UrlHandler query=\"q\" page=\"p\" filter=\"f\" sort=\"s\" />\n</template>\n\n<script setup>\nimport { UrlHandler } from '@empathyco/x-components/url-handler'\n</script>\n```\n\n### Play with events\n\nThe `UrlHandler` will emit the `ParamsLoadedFromUrl` when the page is loaded.\n\nThe `UrlHandler` will emit the `ExtraParamsLoadedFromUrl` when the page is loaded with an extra\nparam configured and with a value in the URL.\n\nThe `UrlHandler` will emit the `UserOpenXProgrammatically` when the page is loaded with a query in\nthe URL.\n</docs>\n"],"names":[],"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;QAEjB,MAAM,EAAE,kBAAiB,EAAE,GAAI,QAAQ,CAAC,KAAK,CAAA;AAE7C;;;;AAIE;AACF,QAAA,MAAM,aAAY,GAAI,MAAM,CAA4B,eAAe,CAA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KAAI,EAAE,GAAI,cAAc,EAAC;AACtC,YAAA,MAAM,QAAO,GAAI,kBAAkB,EAAC;YACpC,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE,QAAQ,CAAA;YAC5C,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,EAAE,QAAQ,CAAA;AACnD,YAAA,IAAI,GAAG,CAAC,KAAK,EAAE;gBACb,EAAE,CAAC,IAAI,CAAC,2BAA2B,EAAE,SAAS,EAAE,QAAQ,CAAA;YAC1D;iBAAO,IAAI,GAAG,CAAC,eAAe,GAAG,CAAC,WAAW,EAAE;gBAC7C,EAAE,CAAC,IAAI,CACL,uBAAuB,EACvB,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,CAAC,WAAU,EAAG,EAC9D,QAAQ,CACV;YACF;AACA,YAAA,SAAS,CAAC,QAAQ,IAAG;AACvB,QAAA,CAAA;AAEA;;;AAGE;QACF,SAAS,CAAC,MAAI;AACZ,YAAA,UAAU,EAAC;AACb,QAAA,CAAC,CAAA;QAED,OAAO;YACL,UAAU;YACV,UAAU;SACZ;IACF,CAAC;AACF,CAAA,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initial-state.js","sources":["../../../../../src/x-modules/url/store/initial-state.ts"],"sourcesContent":["import type { UrlParams } from '../../../types/url-params'\n\n/**\n * The initial state of the Url store module. This is exported and used in other parts of the code\n * to use as default values for {@link UrlState}.\n *\n * @internal\n */\nexport const initialUrlState: Readonly<UrlParams> = {\n query: '',\n page: 1,\n filter: [],\n sort: '',\n scroll: '',\n tag: [],\n prompt: -1,\n}\n"],"names":[],"mappings":"AAEA;;;;;AAKG;AACI,MAAM,eAAe,GAAwB;AAClD,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,IAAI,EAAE,CAAC;AACP,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,EAAE;;;;;"}
|
|
1
|
+
{"version":3,"file":"initial-state.js","sources":["../../../../../src/x-modules/url/store/initial-state.ts"],"sourcesContent":["import type { UrlParams } from '../../../types/url-params'\n\n/**\n * The initial state of the Url store module. This is exported and used in other parts of the code\n * to use as default values for {@link UrlState}.\n *\n * @internal\n */\nexport const initialUrlState: Readonly<UrlParams> = {\n query: '',\n page: 1,\n filter: [],\n sort: '',\n scroll: '',\n tag: [],\n prompt: -1,\n browseValue: '',\n browseField: '',\n}\n"],"names":[],"mappings":"AAEA;;;;;AAKG;AACI,MAAM,eAAe,GAAwB;AAClD,IAAA,KAAK,EAAE,EAAE;AACT,IAAA,IAAI,EAAE,CAAC;AACP,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,EAAE;AACV,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,WAAW,EAAE,EAAE;;;;;"}
|
|
@@ -34,6 +34,10 @@ const urlXStoreModule = {
|
|
|
34
34
|
setSort(state, sort) {
|
|
35
35
|
state.sort = sort;
|
|
36
36
|
},
|
|
37
|
+
setBrowseCategory(state, { browseValue, browseField }) {
|
|
38
|
+
state.browseValue = browseValue;
|
|
39
|
+
state.browseField = browseField;
|
|
40
|
+
},
|
|
37
41
|
setInitialExtraParams(state, extraParams) {
|
|
38
42
|
state.initialExtraParams = extraParams;
|
|
39
43
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/url/store/module.ts"],"sourcesContent":["import type { UrlXStoreModule } from './types'\nimport { setQuery } from '../../../store/utils/query.utils'\nimport { urlParams } from './getters/url-params.getter'\nimport { initialUrlState } from './initial-state'\nimport { setParams } from './mutations/set-params.mutation'\n\n/**\n * {@link XStoreModule} For the URL module.\n *\n * @internal\n */\nexport const urlXStoreModule: UrlXStoreModule = {\n state: () => ({\n ...initialUrlState,\n initialExtraParams: {},\n }),\n getters: {\n urlParams,\n },\n mutations: {\n setParams,\n setQuery,\n setRelatedTags(state, relatedTags) {\n state.tag = relatedTags.map(relatedTag => relatedTag.tag)\n },\n setPrompt(state, prompt) {\n state.prompt = prompt\n },\n setFilters(state, newFilters) {\n state.filter = newFilters.map(filter => filter.id as string)\n },\n setPage(state, page) {\n state.page = page\n },\n setSort(state, sort) {\n state.sort = sort\n },\n setInitialExtraParams(state, extraParams) {\n state.initialExtraParams = extraParams\n },\n setScroll(state, scroll) {\n state.scroll = scroll\n },\n },\n actions: {},\n}\n"],"names":[],"mappings":";;;;;AAMA;;;;AAIG;AACI,MAAM,eAAe,GAAoB;AAC9C,IAAA,KAAK,EAAE,OAAO;AACZ,QAAA,GAAG,eAAe;AAClB,QAAA,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACF,IAAA,OAAO,EAAE;QACP,SAAS;AACV,KAAA;AACD,IAAA,SAAS,EAAE;QACT,SAAS;QACT,QAAQ;QACR,cAAc,CAAC,KAAK,EAAE,WAAW,EAAA;AAC/B,YAAA,KAAK,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,IAAI,UAAU,CAAC,GAAG,CAAC;QAC3D,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAA;AACrB,YAAA,KAAK,CAAC,MAAM,GAAG,MAAM;QACvB,CAAC;QACD,UAAU,CAAC,KAAK,EAAE,UAAU,EAAA;AAC1B,YAAA,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,EAAY,CAAC;QAC9D,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAA;AACjB,YAAA,KAAK,CAAC,IAAI,GAAG,IAAI;QACnB,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAA;AACjB,YAAA,KAAK,CAAC,IAAI,GAAG,IAAI;QACnB,CAAC;QACD,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAA;AACtC,YAAA,KAAK,CAAC,kBAAkB,GAAG,WAAW;QACxC,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAA;AACrB,YAAA,KAAK,CAAC,MAAM,GAAG,MAAM;QACvB,CAAC;AACF,KAAA;AACD,IAAA,OAAO,EAAE,EAAE;;;;;"}
|
|
1
|
+
{"version":3,"file":"module.js","sources":["../../../../../src/x-modules/url/store/module.ts"],"sourcesContent":["import type { UrlXStoreModule } from './types'\nimport { setQuery } from '../../../store/utils/query.utils'\nimport { urlParams } from './getters/url-params.getter'\nimport { initialUrlState } from './initial-state'\nimport { setParams } from './mutations/set-params.mutation'\n\n/**\n * {@link XStoreModule} For the URL module.\n *\n * @internal\n */\nexport const urlXStoreModule: UrlXStoreModule = {\n state: () => ({\n ...initialUrlState,\n initialExtraParams: {},\n }),\n getters: {\n urlParams,\n },\n mutations: {\n setParams,\n setQuery,\n setRelatedTags(state, relatedTags) {\n state.tag = relatedTags.map(relatedTag => relatedTag.tag)\n },\n setPrompt(state, prompt) {\n state.prompt = prompt\n },\n setFilters(state, newFilters) {\n state.filter = newFilters.map(filter => filter.id as string)\n },\n setPage(state, page) {\n state.page = page\n },\n setSort(state, sort) {\n state.sort = sort\n },\n setBrowseCategory(state, { browseValue, browseField }) {\n state.browseValue = browseValue\n state.browseField = browseField\n },\n setInitialExtraParams(state, extraParams) {\n state.initialExtraParams = extraParams\n },\n setScroll(state, scroll) {\n state.scroll = scroll\n },\n },\n actions: {},\n}\n"],"names":[],"mappings":";;;;;AAMA;;;;AAIG;AACI,MAAM,eAAe,GAAoB;AAC9C,IAAA,KAAK,EAAE,OAAO;AACZ,QAAA,GAAG,eAAe;AAClB,QAAA,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACF,IAAA,OAAO,EAAE;QACP,SAAS;AACV,KAAA;AACD,IAAA,SAAS,EAAE;QACT,SAAS;QACT,QAAQ;QACR,cAAc,CAAC,KAAK,EAAE,WAAW,EAAA;AAC/B,YAAA,KAAK,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,IAAI,UAAU,CAAC,GAAG,CAAC;QAC3D,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAA;AACrB,YAAA,KAAK,CAAC,MAAM,GAAG,MAAM;QACvB,CAAC;QACD,UAAU,CAAC,KAAK,EAAE,UAAU,EAAA;AAC1B,YAAA,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,EAAY,CAAC;QAC9D,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAA;AACjB,YAAA,KAAK,CAAC,IAAI,GAAG,IAAI;QACnB,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,IAAI,EAAA;AACjB,YAAA,KAAK,CAAC,IAAI,GAAG,IAAI;QACnB,CAAC;AACD,QAAA,iBAAiB,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,EAAA;AACnD,YAAA,KAAK,CAAC,WAAW,GAAG,WAAW;AAC/B,YAAA,KAAK,CAAC,WAAW,GAAG,WAAW;QACjC,CAAC;QACD,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAA;AACtC,YAAA,KAAK,CAAC,kBAAkB,GAAG,WAAW;QACxC,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAA;AACrB,YAAA,KAAK,CAAC,MAAM,GAAG,MAAM;QACvB,CAAC;AACF,KAAA;AACD,IAAA,OAAO,EAAE,EAAE;;;;;"}
|
|
@@ -68,6 +68,21 @@ const setUrlSelectedFiltersFromPreview = wireCommit('setFilters', ({ eventPayloa
|
|
|
68
68
|
* @public
|
|
69
69
|
*/
|
|
70
70
|
const setUrlScroll = wireCommit('setScroll');
|
|
71
|
+
/**
|
|
72
|
+
* Sets the browseCategory of the url module.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
const resetUrlBrowseCategory = wireCommit('setBrowseCategory', {
|
|
77
|
+
browseField: '',
|
|
78
|
+
browseValue: '',
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Sets the browseCategory of the url module.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
const setUrlBrowseCategory = wireCommit('setBrowseCategory');
|
|
71
86
|
/**
|
|
72
87
|
* Sets the initial provided extra params.
|
|
73
88
|
*
|
|
@@ -124,7 +139,25 @@ const urlWiring = createWiring({
|
|
|
124
139
|
UserScrolledToElement: {
|
|
125
140
|
setUrlScroll,
|
|
126
141
|
},
|
|
142
|
+
UserBrowsedToCategory: {
|
|
143
|
+
setUrlBrowseCategory,
|
|
144
|
+
},
|
|
145
|
+
UserClickedCloseX: {
|
|
146
|
+
resetUrlBrowseCategory,
|
|
147
|
+
},
|
|
148
|
+
UserClickedOpenX: {
|
|
149
|
+
resetUrlBrowseCategory,
|
|
150
|
+
},
|
|
151
|
+
SelectedBrowseSortProvided: {
|
|
152
|
+
setUrlSort,
|
|
153
|
+
},
|
|
154
|
+
UserClickedABrowseSort: {
|
|
155
|
+
setUrlSort,
|
|
156
|
+
},
|
|
157
|
+
UserSelectedABrowsePage: {
|
|
158
|
+
setUrlPage,
|
|
159
|
+
},
|
|
127
160
|
});
|
|
128
161
|
|
|
129
|
-
export { setInitialExtraParams, setParams, setUrlFilters, setUrlPage, setUrlParamsFromPreview, setUrlPrompt, setUrlQuery, setUrlQueryFromPreview, setUrlRelatedTags, setUrlScroll, setUrlSelectedFiltersFromPreview, setUrlSort, urlWiring };
|
|
162
|
+
export { resetUrlBrowseCategory, setInitialExtraParams, setParams, setUrlBrowseCategory, setUrlFilters, setUrlPage, setUrlParamsFromPreview, setUrlPrompt, setUrlQuery, setUrlQueryFromPreview, setUrlRelatedTags, setUrlScroll, setUrlSelectedFiltersFromPreview, setUrlSort, urlWiring };
|
|
130
163
|
//# sourceMappingURL=wiring.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiring.js","sources":["../../../../src/x-modules/url/wiring.ts"],"sourcesContent":["import { createRawFilters } from '../../utils/filters'\nimport { namespacedWireCommit } from '../../wiring/namespaced-wires.factory'\nimport { createWiring } from '../../wiring/wiring.utils'\n\n/**\n * WireCommit for {@link UrlXModule}.\n *\n * @internal\n */\nconst wireCommit = namespacedWireCommit('url')\n\n/**\n * Sets the {@link RelatedTag | related tags }.\n *\n * @public\n */\nexport const setUrlRelatedTags = wireCommit('setRelatedTags')\n\n/**\n * Sets the related prompt of the URL module.\n *\n * @public\n */\nexport const setUrlPrompt = wireCommit('setPrompt')\n\n/**\n * Sets the query of the url module.\n *\n * @public\n */\nexport const setUrlQuery = wireCommit('setQuery')\n\n/**\n * Sets the url state `query` with a selectedQueryPreview's query.\n *\n * @public\n */\nexport const setUrlQueryFromPreview = wireCommit('setQuery', ({ eventPayload: { query } }) => query)\n\n/**\n * Sets the page of the url module.\n *\n * @public\n */\nexport const setUrlPage = wireCommit('setPage')\n\n/**\n * Sets the sort of the url module.\n *\n * @public\n */\nexport const setUrlSort = wireCommit('setSort')\n\n/**\n * Sets the extra params of the url module.\n *\n * @public\n */\nexport const setParams = wireCommit('setParams')\n\n/**\n * Sets the extra params of the url module from a selectedQueryPreview's extraParams.\n *\n * @public\n */\nexport const setUrlParamsFromPreview = wireCommit(\n 'setParams',\n ({ eventPayload: { extraParams } }) => extraParams,\n)\n\n/**\n * Sets the filters of the url module from a selectedQueryPreview's filters.\n *\n * @public\n */\nexport const setUrlSelectedFiltersFromPreview = wireCommit(\n 'setFilters',\n ({ eventPayload: { filters } }) => (filters ? createRawFilters(filters) : []),\n)\n\n/**\n * Sets the scroll of the url module.\n *\n * @public\n */\nexport const setUrlScroll = wireCommit('setScroll')\n\n/**\n * Sets the initial provided extra params.\n *\n * @public\n */\nexport const setInitialExtraParams = wireCommit('setInitialExtraParams')\n\n/**\n * Sets the filters of the url module.\n *\n * @public\n */\nexport const setUrlFilters = wireCommit('setFilters')\n\n/**\n * Wiring configuration for the {@link UrlXModule | url module}.\n *\n * @internal\n */\nexport const urlWiring = createWiring({\n ParamsLoadedFromUrl: {\n setParams,\n },\n UserAcceptedAQuery: {\n setUrlQuery,\n },\n UserAcceptedAQueryPreview: {\n setUrlQueryFromPreview,\n setUrlParamsFromPreview,\n setUrlSelectedFiltersFromPreview,\n },\n UserClearedQuery: {\n setUrlQuery,\n },\n SelectedRelatedTagsChanged: {\n setUrlRelatedTags,\n },\n SelectedRelatedPromptChanged: {\n setUrlPrompt,\n },\n SelectedFiltersForRequestChanged: {\n setUrlFilters,\n },\n PageChanged: {\n setUrlPage,\n },\n SortChanged: {\n setUrlSort,\n },\n ExtraParamsChanged: {\n setParams,\n },\n ExtraParamsInitialized: {\n setInitialExtraParams,\n },\n UserScrolledToElement: {\n setUrlScroll,\n },\n})\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;AACH,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,CAAC;AAE9C;;;;AAIG;MACU,iBAAiB,GAAG,UAAU,CAAC,gBAAgB;AAE5D;;;;AAIG;MACU,YAAY,GAAG,UAAU,CAAC,WAAW;AAElD;;;;AAIG;MACU,WAAW,GAAG,UAAU,CAAC,UAAU;AAEhD;;;;AAIG;MACU,sBAAsB,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,KAAK;AAEnG;;;;AAIG;MACU,UAAU,GAAG,UAAU,CAAC,SAAS;AAE9C;;;;AAIG;MACU,UAAU,GAAG,UAAU,CAAC,SAAS;AAE9C;;;;AAIG;MACU,SAAS,GAAG,UAAU,CAAC,WAAW;AAE/C;;;;AAIG;MACU,uBAAuB,GAAG,UAAU,CAC/C,WAAW,EACX,CAAC,EAAE,YAAY,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,WAAW;AAGpD;;;;AAIG;AACI,MAAM,gCAAgC,GAAG,UAAU,CACxD,YAAY,EACZ,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;AAG/E;;;;AAIG;MACU,YAAY,GAAG,UAAU,CAAC,WAAW;AAElD;;;;AAIG;MACU,qBAAqB,GAAG,UAAU,CAAC,uBAAuB;AAEvE;;;;AAIG;MACU,aAAa,GAAG,UAAU,CAAC,YAAY;AAEpD;;;;AAIG;AACI,MAAM,SAAS,GAAG,YAAY,CAAC;AACpC,IAAA,mBAAmB,EAAE;QACnB,SAAS;AACV,KAAA;AACD,IAAA,kBAAkB,EAAE;QAClB,WAAW;AACZ,KAAA;AACD,IAAA,yBAAyB,EAAE;QACzB,sBAAsB;QACtB,uBAAuB;QACvB,gCAAgC;AACjC,KAAA;AACD,IAAA,gBAAgB,EAAE;QAChB,WAAW;AACZ,KAAA;AACD,IAAA,0BAA0B,EAAE;QAC1B,iBAAiB;AAClB,KAAA;AACD,IAAA,4BAA4B,EAAE;QAC5B,YAAY;AACb,KAAA;AACD,IAAA,gCAAgC,EAAE;QAChC,aAAa;AACd,KAAA;AACD,IAAA,WAAW,EAAE;QACX,UAAU;AACX,KAAA;AACD,IAAA,WAAW,EAAE;QACX,UAAU;AACX,KAAA;AACD,IAAA,kBAAkB,EAAE;QAClB,SAAS;AACV,KAAA;AACD,IAAA,sBAAsB,EAAE;QACtB,qBAAqB;AACtB,KAAA;AACD,IAAA,qBAAqB,EAAE;QACrB,YAAY;AACb,KAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"wiring.js","sources":["../../../../src/x-modules/url/wiring.ts"],"sourcesContent":["import { createRawFilters } from '../../utils/filters'\nimport { namespacedWireCommit } from '../../wiring/namespaced-wires.factory'\nimport { createWiring } from '../../wiring/wiring.utils'\n\n/**\n * WireCommit for {@link UrlXModule}.\n *\n * @internal\n */\nconst wireCommit = namespacedWireCommit('url')\n\n/**\n * Sets the {@link RelatedTag | related tags }.\n *\n * @public\n */\nexport const setUrlRelatedTags = wireCommit('setRelatedTags')\n\n/**\n * Sets the related prompt of the URL module.\n *\n * @public\n */\nexport const setUrlPrompt = wireCommit('setPrompt')\n\n/**\n * Sets the query of the url module.\n *\n * @public\n */\nexport const setUrlQuery = wireCommit('setQuery')\n\n/**\n * Sets the url state `query` with a selectedQueryPreview's query.\n *\n * @public\n */\nexport const setUrlQueryFromPreview = wireCommit('setQuery', ({ eventPayload: { query } }) => query)\n\n/**\n * Sets the page of the url module.\n *\n * @public\n */\nexport const setUrlPage = wireCommit('setPage')\n\n/**\n * Sets the sort of the url module.\n *\n * @public\n */\nexport const setUrlSort = wireCommit('setSort')\n\n/**\n * Sets the extra params of the url module.\n *\n * @public\n */\nexport const setParams = wireCommit('setParams')\n\n/**\n * Sets the extra params of the url module from a selectedQueryPreview's extraParams.\n *\n * @public\n */\nexport const setUrlParamsFromPreview = wireCommit(\n 'setParams',\n ({ eventPayload: { extraParams } }) => extraParams,\n)\n\n/**\n * Sets the filters of the url module from a selectedQueryPreview's filters.\n *\n * @public\n */\nexport const setUrlSelectedFiltersFromPreview = wireCommit(\n 'setFilters',\n ({ eventPayload: { filters } }) => (filters ? createRawFilters(filters) : []),\n)\n\n/**\n * Sets the scroll of the url module.\n *\n * @public\n */\nexport const setUrlScroll = wireCommit('setScroll')\n\n/**\n * Sets the browseCategory of the url module.\n *\n * @public\n */\nexport const resetUrlBrowseCategory = wireCommit('setBrowseCategory', {\n browseField: '',\n browseValue: '',\n})\n\n/**\n * Sets the browseCategory of the url module.\n *\n * @public\n */\nexport const setUrlBrowseCategory = wireCommit('setBrowseCategory')\n\n/**\n * Sets the initial provided extra params.\n *\n * @public\n */\nexport const setInitialExtraParams = wireCommit('setInitialExtraParams')\n\n/**\n * Sets the filters of the url module.\n *\n * @public\n */\nexport const setUrlFilters = wireCommit('setFilters')\n\n/**\n * Wiring configuration for the {@link UrlXModule | url module}.\n *\n * @internal\n */\nexport const urlWiring = createWiring({\n ParamsLoadedFromUrl: {\n setParams,\n },\n UserAcceptedAQuery: {\n setUrlQuery,\n },\n UserAcceptedAQueryPreview: {\n setUrlQueryFromPreview,\n setUrlParamsFromPreview,\n setUrlSelectedFiltersFromPreview,\n },\n UserClearedQuery: {\n setUrlQuery,\n },\n SelectedRelatedTagsChanged: {\n setUrlRelatedTags,\n },\n SelectedRelatedPromptChanged: {\n setUrlPrompt,\n },\n SelectedFiltersForRequestChanged: {\n setUrlFilters,\n },\n PageChanged: {\n setUrlPage,\n },\n SortChanged: {\n setUrlSort,\n },\n ExtraParamsChanged: {\n setParams,\n },\n ExtraParamsInitialized: {\n setInitialExtraParams,\n },\n UserScrolledToElement: {\n setUrlScroll,\n },\n UserBrowsedToCategory: {\n setUrlBrowseCategory,\n },\n UserClickedCloseX: {\n resetUrlBrowseCategory,\n },\n UserClickedOpenX: {\n resetUrlBrowseCategory,\n },\n SelectedBrowseSortProvided: {\n setUrlSort,\n },\n UserClickedABrowseSort: {\n setUrlSort,\n },\n UserSelectedABrowsePage: {\n setUrlPage,\n },\n})\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;AACH,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,CAAC;AAE9C;;;;AAIG;MACU,iBAAiB,GAAG,UAAU,CAAC,gBAAgB;AAE5D;;;;AAIG;MACU,YAAY,GAAG,UAAU,CAAC,WAAW;AAElD;;;;AAIG;MACU,WAAW,GAAG,UAAU,CAAC,UAAU;AAEhD;;;;AAIG;MACU,sBAAsB,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,KAAK;AAEnG;;;;AAIG;MACU,UAAU,GAAG,UAAU,CAAC,SAAS;AAE9C;;;;AAIG;MACU,UAAU,GAAG,UAAU,CAAC,SAAS;AAE9C;;;;AAIG;MACU,SAAS,GAAG,UAAU,CAAC,WAAW;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sB,EAAE;QACtB,qBAAqB;AACtB,KAAA;AACD,IAAA,qBAAqB,EAAE;QACrB,YAAY;AACb,KAAA;AACD,IAAA,qBAAqB,EAAE;QACrB,oBAAoB;AACrB,KAAA;AACD,IAAA,iBAAiB,EAAE;QACjB,sBAAsB;AACvB,KAAA;AACD,IAAA,gBAAgB,EAAE;QAChB,sBAAsB;AACvB,KAAA;AACD,IAAA,0BAA0B,EAAE;QAC1B,UAAU;AACX,KAAA;AACD,IAAA,sBAAsB,EAAE;QACtB,UAAU;AACX,KAAA;AACD,IAAA,uBAAuB,EAAE;QACvB,UAAU;AACX,KAAA;AACF,CAAA;;;;"}
|
package/next-queries/index.js
CHANGED
|
@@ -10,5 +10,5 @@ export { query } from '../js/x-modules/next-queries/store/getters/next-queries-q
|
|
|
10
10
|
export { nextQueries } from '../js/x-modules/next-queries/store/getters/next-queries.getter.js';
|
|
11
11
|
export { request as nextQueriesRequest } from '../js/x-modules/next-queries/store/getters/request.getter.js';
|
|
12
12
|
export { nextQueriesXStoreModule } from '../js/x-modules/next-queries/store/module.js';
|
|
13
|
-
export { fetchAndSaveNextQueriesWire, fetchAndSaveNextQueryPreviewWire, nextQueriesWiring, resetNextQueriesWire, resetResultsPreviewWire, setNextQueriesExtraParams, setNextQueriesExtraParamsFromPreview, setNextQueriesQuery, setNextQueriesQueryFromPreview, setNextQueriesRelatedTags, setQueryFromLastHistoryQueryWire, setSearchedQueries } from '../js/x-modules/next-queries/wiring.js';
|
|
13
|
+
export { fetchAndSaveNextQueriesWire, fetchAndSaveNextQueryPreviewWire, nextQueriesWiring, resetNextQueriesQuery, resetNextQueriesWire, resetResultsPreviewWire, setNextQueriesExtraParams, setNextQueriesExtraParamsFromPreview, setNextQueriesQuery, setNextQueriesQueryFromPreview, setNextQueriesRelatedTags, setQueryFromLastHistoryQueryWire, setSearchedQueries } from '../js/x-modules/next-queries/wiring.js';
|
|
14
14
|
export { nextQueriesXModule } from '../js/x-modules/next-queries/x-module.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-components",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "Empathy X Components",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@empathyco/x-adapter": "8.1.8",
|
|
71
|
-
"@empathyco/x-adapter-platform": "1.
|
|
72
|
-
"@empathyco/x-types": "10.
|
|
71
|
+
"@empathyco/x-adapter-platform": "1.7.0",
|
|
72
|
+
"@empathyco/x-types": "10.5.0",
|
|
73
73
|
"@empathyco/x-utils": "1.0.9",
|
|
74
74
|
"@vue/devtools-api": "~6.6.4",
|
|
75
75
|
"@vueuse/core": "~12.8.2",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"access": "public",
|
|
118
118
|
"directory": "dist"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "23e3552d048891be2001b0ba6264f694b1d54618"
|
|
121
121
|
}
|