diff --git a/packages/x-components/src/composables/__tests__/use-getter.spec.ts b/packages/x-components/src/composables/__tests__/use-getter.spec.ts index 3c103d9160..70019a0803 100644 --- a/packages/x-components/src/composables/__tests__/use-getter.spec.ts +++ b/packages/x-components/src/composables/__tests__/use-getter.spec.ts @@ -2,7 +2,6 @@ import { defineComponent } from 'vue'; import { mount } from '@vue/test-utils'; import { installNewXPlugin } from '../../__tests__/utils'; import { useGetter } from '../use-getter'; -import { useRegisterXModule } from '../use-register-x-module'; import { ExtractGetters } from '../../x-modules/x-modules.types'; import { useStore } from '../use-store'; import { XPlugin } from '../../plugins'; @@ -17,7 +16,7 @@ function render(modulePaths: (keyof ExtractGetters<'historyQueries'>)[]) { const component = defineComponent({ xModule: 'historyQueries', setup: () => { - useRegisterXModule(historyQueriesXModule); + XPlugin.registerXModule(historyQueriesXModule); const historyQueriesGetter = useGetter('historyQueries', modulePaths); return { historyQueriesGetter }; }, diff --git a/packages/x-components/src/composables/__tests__/use-state.spec.ts b/packages/x-components/src/composables/__tests__/use-state.spec.ts index 771870e030..ef124b8559 100644 --- a/packages/x-components/src/composables/__tests__/use-state.spec.ts +++ b/packages/x-components/src/composables/__tests__/use-state.spec.ts @@ -3,7 +3,6 @@ import { mount } from '@vue/test-utils'; import { installNewXPlugin } from '../../__tests__/utils'; import { XPlugin } from '../../plugins'; import { ExtractState } from '../../x-modules/x-modules.types'; -import { useRegisterXModule } from '../use-register-x-module'; import { useState } from '../use-state'; import { searchBoxXModule } from '../../x-modules/search-box/x-module'; import { useStore } from '../use-store'; @@ -17,7 +16,7 @@ function render(modulePaths: (keyof ExtractState<'searchBox'> & string)[]) { const component = defineComponent({ xModule: 'searchBox', setup: () => { - useRegisterXModule(searchBoxXModule); + XPlugin.registerXModule(searchBoxXModule); const searchBoxUseState = useState('searchBox', modulePaths); return { searchBoxUseState }; }, diff --git a/packages/x-components/src/composables/use-register-x-module.ts b/packages/x-components/src/composables/use-register-x-module.ts index 41bfc0b665..2d421e8cef 100644 --- a/packages/x-components/src/composables/use-register-x-module.ts +++ b/packages/x-components/src/composables/use-register-x-module.ts @@ -8,6 +8,7 @@ import { XPlugin } from '../plugins/x-plugin'; * * @param module - The module associated to the X-Component that is being registered. * @public + * @deprecated Use `XPlugin.registerXModule(xModule)` instead. */ export function useRegisterXModule(module: AnyXModule): void { XPlugin.registerXModule(module); diff --git a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts index 217e16ea97..41baa25128 100644 --- a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts +++ b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts @@ -46,10 +46,10 @@ describe('testing plugin alias', () => { }, status: { identifierResults: undefined, - nextQueries: undefined, + nextQueries: 'initial', // It is already registered by the `nextQueriesXModule` import itself popularSearches: undefined, querySuggestions: 'initial', // It is already registered by the `querySuggestionsXModule` import itself - recommendations: 'initial', // It is already registered by the `relatedTagsXModule` import itself + recommendations: 'initial', // It is already registered by the `recommendationsXModule` import itself relatedTags: 'initial', // It is already registered by the `relatedTagsXModule` import itself search: 'initial' // It is already registered by the `searchXModule` import itself }, @@ -61,7 +61,7 @@ describe('testing plugin alias', () => { isHistoryQueriesEnabled: false, fromNoResultsWithFilters: false, identifierResults: [], - searchBoxStatus: undefined, + searchBoxStatus: 'initial', // It is already registered by the `searchBoxXModule` import itself isEmpathizeOpen: false, nextQueries: [], noResults: false, diff --git a/packages/x-components/src/x-modules/empathize/components/empathize.vue b/packages/x-components/src/x-modules/empathize/components/empathize.vue index 96c205ed40..4a9f5150e7 100644 --- a/packages/x-components/src/x-modules/empathize/components/empathize.vue +++ b/packages/x-components/src/x-modules/empathize/components/empathize.vue @@ -19,7 +19,6 @@ import { defineComponent, PropType, ref } from 'vue'; import { NoElement } from '../../../components/no-element'; import { useDebounce } from '../../../composables/use-debounce'; - import { useRegisterXModule } from '../../../composables/use-register-x-module'; import { use$x } from '../../../composables/use-$x'; import { AnimationProp } from '../../../types'; import { XEvent } from '../../../wiring'; @@ -58,7 +57,6 @@ } }, setup(props) { - useRegisterXModule(empathizeXModule); const $x = use$x(); const empathizeRef = ref(); diff --git a/packages/x-components/src/x-modules/empathize/x-module.ts b/packages/x-components/src/x-modules/empathize/x-module.ts index 7c48dc9111..16542a9101 100644 --- a/packages/x-components/src/x-modules/empathize/x-module.ts +++ b/packages/x-components/src/x-modules/empathize/x-module.ts @@ -1,3 +1,4 @@ +import { XPlugin } from '../../plugins/x-plugin'; import { XModule } from '../x-modules.types'; import { empathizeEmitters } from './store/emitters'; import { empathizeXStoreModule } from './store/module'; @@ -23,3 +24,5 @@ export const empathizeXModule: EmpathizeXModule = { storeEmitters: empathizeEmitters, wiring: empathizeWiring }; + +XPlugin.registerXModule(empathizeXModule); diff --git a/packages/x-components/src/x-modules/facets/components/clear-filters.vue b/packages/x-components/src/x-modules/facets/components/clear-filters.vue index 265393de7b..9b1e188002 100644 --- a/packages/x-components/src/x-modules/facets/components/clear-filters.vue +++ b/packages/x-components/src/x-modules/facets/components/clear-filters.vue @@ -15,7 +15,6 @@ import { Facet } from '@empathyco/x-types'; import { computed, defineComponent, PropType } from 'vue'; import BaseEventButton from '../../../components/base-event-button.vue'; - import { useRegisterXModule } from '../../../composables/use-register-x-module'; import { VueCSSClasses } from '../../../utils/types'; import { XEventsTypes } from '../../../wiring/events.types'; import { useFacets } from '../composables/use-facets'; @@ -37,8 +36,6 @@ alwaysVisible: Boolean }, setup: function (props) { - useRegisterXModule(facetsXModule); - const { selectedFilters, hasSelectedFilters, isVisible } = useFacets(props); /** diff --git a/packages/x-components/src/x-modules/facets/components/facets/facets.vue b/packages/x-components/src/x-modules/facets/components/facets/facets.vue index 9cc6d91ef4..7cb66653b1 100644 --- a/packages/x-components/src/x-modules/facets/components/facets/facets.vue +++ b/packages/x-components/src/x-modules/facets/components/facets/facets.vue @@ -58,7 +58,6 @@ import { Dictionary, map, objectFilter } from '@empathyco/x-utils'; import Vue, { computed, ComputedRef, defineComponent, PropType } from 'vue'; import { useGetter } from '../../../../composables/use-getter'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { toKebabCase } from '../../../../utils/string'; import { useFacets } from '../../composables/use-facets'; import { facetsXModule } from '../../x-module'; @@ -118,8 +117,6 @@ renderableFacets: String }, setup: function (props, { slots }) { - useRegisterXModule(facetsXModule); - const { selectedFiltersByFacet } = useFacets(props); const { facets } = useGetter('facets', ['facets']) as { diff --git a/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue b/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue index bf29ecb616..fbc832e5de 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue @@ -2,7 +2,6 @@ import { Filter, isBooleanFilter } from '@empathyco/x-types'; import { computed, defineComponent, PropType, provide, h } from 'vue'; import { facetsXModule } from '../../x-module'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { useFiltersInjection } from '../../composables/use-filters-injection'; /** @@ -37,7 +36,6 @@ } }, setup(props, { slots }) { - useRegisterXModule(facetsXModule); const renderedFilters = useFiltersInjection(props); /** diff --git a/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue b/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue index 52f1dde2f3..41b7be589a 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue @@ -28,7 +28,6 @@ import { VueCSSClasses } from '../../../../utils/types'; import { facetsXModule } from '../../x-module'; import { AnimationProp } from '../../../../types/animation-prop'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { useFiltersInjection } from '../../composables/use-filters-injection'; /** @@ -71,8 +70,6 @@ } }, setup(props) { - useRegisterXModule(facetsXModule); - const renderedFilters = useFiltersInjection(props); /** diff --git a/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue b/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue index 7bccb66310..e67e47874e 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue @@ -32,7 +32,6 @@ import { normalizeString } from '../../../../utils/normalize'; import { DebouncedFunction, VueCSSClasses } from '../../../../utils/types'; import { facetsXModule } from '../../x-module'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { useFiltersInjection } from '../../composables/use-filters-injection'; /** @@ -69,7 +68,6 @@ } }, setup(props) { - useRegisterXModule(facetsXModule); const renderedFilters = useFiltersInjection(props); let query = ref(''); diff --git a/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue b/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue index 8515fff460..98f123fb14 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue @@ -40,7 +40,6 @@