@envive-ai/react-hooks 0.2.6-alpha-7 → 0.2.6-alpha-8
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/dist/{AmplitudeOperations-DbUiR0N_.cjs → AmplitudeOperations-DgBejCXT.cjs} +2 -2
- package/dist/{AmplitudeOperations-DjqOM3uE.js → AmplitudeOperations-jbYI0Gt9.js} +2 -2
- package/dist/{NewOrgConfig-C_1T1iOt.js → NewOrgConfig-CUQGpmw9.js} +2 -2
- package/dist/{NewOrgConfig-D2Kvqa1z.cjs → NewOrgConfig-DD0oloeK.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-BxOhr9Da.js → TrackComponentVisibleEvent-BTDRmqYu.js} +2 -2
- package/dist/{TrackComponentVisibleEvent-CDbecFPM.cjs → TrackComponentVisibleEvent-BmM2CED5.cjs} +2 -2
- package/dist/{amplitudeContext-BWmXliMI.cjs → amplitudeContext-BeKYPEAO.cjs} +9 -8
- package/dist/{amplitudeContext-BjMlg5RV.js → amplitudeContext-CfMnZGa7.js} +9 -8
- package/dist/{amplitudeTrackEventAtom-D66l5oFp.js → amplitudeTrackEventAtom-DXnFiWnV.js} +1 -1
- package/dist/{amplitudeTrackEventAtom-f22P2U0u.cjs → amplitudeTrackEventAtom-UVBKhOuI.cjs} +1 -1
- package/dist/{app-Bs2KxG_8.js → app-BT3g-mDp.js} +5 -5
- package/dist/{app-DSnDDqcW.cjs → app-DxwdFQlv.cjs} +5 -5
- package/dist/application/utils/index.cjs +4 -4
- package/dist/application/utils/index.d.cts +2 -2
- package/dist/application/utils/index.d.ts +2 -2
- package/dist/application/utils/index.js +4 -4
- package/dist/{atomStore-CfzCqWB9.js → atomStore-BuopbV9k.js} +1 -1
- package/dist/{atomStore-BQVO5haU.cjs → atomStore-CZKe3itM.cjs} +1 -1
- package/dist/atoms/app/index.cjs +9 -9
- package/dist/atoms/app/index.d.cts +6 -6
- package/dist/atoms/app/index.d.ts +7 -7
- package/dist/atoms/app/index.js +9 -9
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.d.ts +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +12 -12
- package/dist/atoms/chat/index.d.cts +32 -32
- package/dist/atoms/chat/index.d.ts +27 -27
- package/dist/atoms/chat/index.js +12 -12
- package/dist/atoms/globalSearch/index.cjs +1 -1
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/globalSearch/index.js +1 -1
- package/dist/atoms/org/index.cjs +2 -2
- package/dist/atoms/org/index.d.cts +15 -15
- package/dist/atoms/org/index.d.ts +16 -16
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/search/index.cjs +5 -5
- package/dist/atoms/search/index.d.cts +15 -15
- package/dist/atoms/search/index.d.ts +13 -13
- package/dist/atoms/search/index.js +5 -5
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/{cdnContext-CJ2BNLAD.js → cdnContext-D-qi0lub.js} +2 -2
- package/dist/{cdnContext-lkC-AE6A.cjs → cdnContext-DIVgBnsl.cjs} +2 -2
- package/dist/{chat-CCjM6fS_.cjs → chat-CgF81Y5r.cjs} +5 -5
- package/dist/{chat-EJbfGWRr.js → chat-ClvJ9xEj.js} +1 -1
- package/dist/{chat-CJ9D8n7g.cjs → chat-DCGriB7h.cjs} +1 -1
- package/dist/{chat-C5afTKUY.js → chat-WdMVMjQh.js} +5 -5
- package/dist/{chatState-DlJpHAsW.cjs → chatState-B57-id1_.cjs} +1 -1
- package/dist/{chatState-BbI93m6r.js → chatState-DAP9YIWn.js} +1 -1
- package/dist/{common-CuwWqIJ1.cjs → common-DQPvV_S_.cjs} +1 -1
- package/dist/{common-Df2bwzd2.js → common-c_4eX0qn.js} +1 -1
- package/dist/{components-QGCWJ26c.js → components-CDpaMUjK.js} +1 -1
- package/dist/{components-BCfFLf9X.cjs → components-DKwVHIjq.cjs} +1 -1
- package/dist/config/index.cjs +4 -4
- package/dist/config/index.js +4 -4
- package/dist/config/locators/components/chat/index.cjs +1 -1
- package/dist/config/locators/components/chat/index.js +1 -1
- package/dist/config/locators/components/common/index.cjs +1 -1
- package/dist/config/locators/components/common/index.js +1 -1
- package/dist/config/locators/components/index.cjs +1 -1
- package/dist/config/locators/components/index.js +1 -1
- package/dist/config/locators/index.cjs +4 -4
- package/dist/config/locators/index.js +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +13 -13
- package/dist/contexts/amplitudeContext/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/index.js +13 -13
- package/dist/contexts/cdnContext/index.cjs +2 -2
- package/dist/contexts/cdnContext/index.d.cts +1 -1
- package/dist/contexts/cdnContext/index.js +2 -2
- package/dist/contexts/enviveConfigContext/index.cjs +2 -2
- package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
- package/dist/contexts/enviveConfigContext/index.js +2 -2
- package/dist/contexts/enviveCssContext/index.cjs +7 -7
- package/dist/contexts/enviveCssContext/index.d.cts +1 -1
- package/dist/contexts/enviveCssContext/index.js +7 -7
- package/dist/contexts/featureFlagContext/index.cjs +2 -2
- package/dist/contexts/featureFlagContext/index.js +2 -2
- package/dist/contexts/featureFlagServiceContext/index.cjs +1 -1
- package/dist/contexts/featureFlagServiceContext/index.js +1 -1
- package/dist/contexts/graphqlContext/index.cjs +2 -2
- package/dist/contexts/graphqlContext/index.js +2 -2
- package/dist/contexts/newOrgConfigContext/index.cjs +6 -6
- package/dist/contexts/newOrgConfigContext/index.d.cts +1 -1
- package/dist/contexts/newOrgConfigContext/index.js +6 -6
- package/dist/contexts/searchContext/index.cjs +15 -15
- package/dist/contexts/searchContext/index.js +15 -15
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +1 -1
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +2 -2
- package/dist/contexts/systemSettingsContext/index.d.ts +2 -2
- package/dist/contexts/systemSettingsContext/index.js +2 -2
- package/dist/contexts/userIdentityContext/index.cjs +9 -9
- package/dist/contexts/userIdentityContext/index.js +9 -9
- package/dist/{domObserver-DNeeSh1F.js → domObserver-CVhsCSkS.js} +1 -1
- package/dist/{domObserver-C2oQO8vi.cjs → domObserver-LCBj1xw4.cjs} +1 -1
- package/dist/{enviveConfig-Dp80h9yu.cjs → enviveConfig-CQ_8mT-g.cjs} +1 -1
- package/dist/{enviveConfig-Ciq4ASoV.js → enviveConfig-Cwlp7-Qz.js} +1 -1
- package/dist/{enviveConfigContext-CCjJUmwp.js → enviveConfigContext-BG1ihSHO.js} +2 -2
- package/dist/{enviveConfigContext-DoYP8KSw.cjs → enviveConfigContext-Cn83IoUd.cjs} +2 -2
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/{events-DBin1Z7o.cjs → events-CgFGtanE.cjs} +1 -1
- package/dist/{events-CXiS1aTc.js → events-WOOrnUAx.js} +1 -1
- package/dist/exceptions/index.d.cts +1 -1
- package/dist/{featureFlagServiceContext-Cvp7NlpC.js → featureFlagServiceContext-Dr8Cw23n.js} +1 -1
- package/dist/{featureFlagServiceContext-DHtkQAtq.cjs → featureFlagServiceContext-rxZhpdEj.cjs} +1 -1
- package/dist/{globalSearch-Cpc8egsM.cjs → globalSearch-DEKvpWV-.cjs} +1 -1
- package/dist/{globalSearch-nmrfGLOn.js → globalSearch-D_nMjrlf.js} +1 -1
- package/dist/{graphqlContext-ChXlE8Ul.cjs → graphqlContext-B8wuRZcp.cjs} +2 -2
- package/dist/{graphqlContext-0cg9fEUw.js → graphqlContext-CpHMbKoX.js} +2 -2
- package/dist/hooks/AmplitudeOperations/index.cjs +14 -14
- package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/index.js +14 -14
- package/dist/hooks/AppDetails/index.cjs +12 -12
- package/dist/hooks/AppDetails/index.js +12 -12
- package/dist/hooks/BlockBackButton/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.cjs +2 -2
- package/dist/hooks/CdnOperations/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.d.ts +1 -1
- package/dist/hooks/CdnOperations/index.js +2 -2
- package/dist/hooks/ChatToggle/index.cjs +16 -16
- package/dist/hooks/ChatToggle/index.d.cts +1 -1
- package/dist/hooks/ChatToggle/index.js +16 -16
- package/dist/hooks/ChatToggleAnalytics/index.cjs +15 -15
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.js +15 -15
- package/dist/hooks/Debounce/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +3 -3
- package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
- package/dist/hooks/GraphQLConfig/index.js +3 -3
- package/dist/hooks/IdentifyUser/index.cjs +9 -9
- package/dist/hooks/IdentifyUser/index.d.cts +1 -1
- package/dist/hooks/IdentifyUser/index.js +9 -9
- package/dist/hooks/ImageResolver/index.cjs +1 -1
- package/dist/hooks/ImageResolver/index.d.cts +1 -1
- package/dist/hooks/ImageResolver/index.js +1 -1
- package/dist/hooks/IsSmallScreen/index.d.cts +1 -1
- package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
- package/dist/hooks/MessageFilter/index.d.cts +1 -1
- package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
- package/dist/hooks/NewOrgConfig/index.cjs +7 -7
- package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
- package/dist/hooks/NewOrgConfig/index.js +7 -7
- package/dist/hooks/Search/index.cjs +20 -20
- package/dist/hooks/Search/index.js +20 -20
- package/dist/hooks/SearchOperations/index.cjs +15 -15
- package/dist/hooks/SearchOperations/index.js +15 -15
- package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
- package/dist/hooks/SystemSettingsContext/index.cjs +2 -2
- package/dist/hooks/SystemSettingsContext/index.d.cts +4 -4
- package/dist/hooks/SystemSettingsContext/index.d.ts +2 -2
- package/dist/hooks/SystemSettingsContext/index.js +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +14 -14
- package/dist/hooks/TrackComponentVisibleEvent/index.js +14 -14
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +13 -13
- package/dist/hooks/UpdateAnalyticsProps/index.js +13 -13
- package/dist/hooks/utils.cjs +1 -1
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/hooks/utils.js +1 -1
- package/dist/index-BVZbvpx_.d.cts +1 -1
- package/dist/index-CMZcE7pk.d.cts +1 -1
- package/dist/index-ChiZg0yw.d.cts +1 -1
- package/dist/index-DtzPIcQp.d.ts +1 -1
- package/dist/index-bEjLKG_Q.d.ts +1 -1
- package/dist/{locators-C2fWd-74.js → locators-BMQGmGLq.js} +1 -1
- package/dist/{locators-Cx3q6Z_h.cjs → locators-DxYdak1F.cjs} +1 -1
- package/dist/{newOrgConfigAtom-BuQE_zPK.js → newOrgConfigAtom-C8h3w_Ji.js} +1 -1
- package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-CDttTiuu.cjs} +1 -1
- package/dist/{newOrgConfigContext-D-gU5ppl.js → newOrgConfigContext-BdzDnzUM.js} +5 -5
- package/dist/{newOrgConfigContext-d3RHl430.cjs → newOrgConfigContext-cWeJAT6E.cjs} +5 -5
- package/dist/{org-CIFgIcO4.cjs → org-BNs_maoW.cjs} +1 -1
- package/dist/{org-15F128Ah.js → org-CScQqL4k.js} +1 -1
- package/dist/{search-Ch6LKNh4.cjs → search-B8HIKjWF.cjs} +4 -4
- package/dist/{search--80x6CfL.js → search-BFXfnniE.js} +4 -4
- package/dist/{searchContext-BkPoTq1o.js → searchContext-C3qxKrms.js} +5 -5
- package/dist/{searchContext-B0qEUoKb.cjs → searchContext-sVRHEtSD.cjs} +5 -5
- package/dist/{searchServiceAdapter-BclWy4fE.cjs → searchServiceAdapter-6Mjz87ZL.cjs} +1 -1
- package/dist/{searchServiceAdapter-B0h7psvh.js → searchServiceAdapter-BpmMMb01.js} +1 -1
- package/dist/{shopifyUrlContext-Bw1kAZ2P.cjs → shopifyUrlContext-COc1eDR_.cjs} +2 -2
- package/dist/{shopifyUrlContext-DnJiUmMA.js → shopifyUrlContext-CToAt_98.js} +2 -2
- package/dist/{systemSettingsContext-DPdDfVhj.js → systemSettingsContext-D9iNGz5v.js} +2 -2
- package/dist/{systemSettingsContext-068vQuP2.cjs → systemSettingsContext-DdV7Yte8.cjs} +2 -2
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +1 -1
- package/dist/{types-B8HZYWV3.cjs → types-1iJ_FnQQ.cjs} +1 -1
- package/dist/{types-y3mhxOUA.js → types-D5du68Vp.js} +1 -1
- package/dist/{urlsParser-bb8ciRFg.cjs → urlsParser-Dax4iVNC.cjs} +1 -1
- package/dist/{urlsParser-v_1DKvyf.js → urlsParser-NAp2LwWP.js} +1 -1
- package/dist/{useAppDetails-eP2hBuid.cjs → useAppDetails-D3T6kJY_.cjs} +4 -4
- package/dist/{useAppDetails-BPXln8UE.js → useAppDetails-xPVs6fW7.js} +4 -4
- package/dist/{useGraphQLConfig-v9veUbvJ.cjs → useGraphQLConfig-B1DaVvFx.cjs} +2 -2
- package/dist/{useGraphQLConfig-Btszi6cG.js → useGraphQLConfig-BtPxjtxw.js} +2 -2
- package/dist/{utils-D_nGHczN.js → utils-BZT_oZ3n.js} +1 -1
- package/dist/{utils-CqVRbvfN.cjs → utils-C8_J5a8M.cjs} +1 -1
- package/dist/{utils-DQhbbAnt.js → utils-CkYtC91V.js} +1 -1
- package/dist/{utils-SjlIHajO.cjs → utils-D3MjNkd3.cjs} +2 -2
- package/dist/{utils-CWzuvlOR.js → utils-DMwh3QbT.js} +2 -2
- package/dist/{utils-CJk5iwQI.cjs → utils-qtHPLFby.cjs} +1 -1
- package/package.json +1 -1
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +11 -3
- package/src/contexts/cdnContext/cdnContext.tsx +11 -9
- package/dist/src/application/commerce-api.js +0 -408
- package/dist/src/application/logging/logger.js +0 -16
- package/dist/src/application/models/graphql/index.js +0 -3
- package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +0 -13
- package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +0 -13
- package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +0 -10
- package/dist/src/application/models/guards/api/index.js +0 -12
- package/dist/src/application/models/guards/api/isApiFormResponse.js +0 -59
- package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +0 -22
- package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +0 -91
- package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +0 -188
- package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +0 -115
- package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +0 -16
- package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +0 -26
- package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +0 -15
- package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +0 -65
- package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +0 -15
- package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +0 -10
- package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiResponse.js +0 -33
- package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +0 -22
- package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +0 -23
- package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +0 -20
- package/dist/src/application/models/guards/api/isApiSuggestion.js +0 -24
- package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiUserEvent.js +0 -18
- package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +0 -41
- package/dist/src/application/models/guards/isBaseEcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isGA4EcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +0 -4
- package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +0 -1
- package/dist/src/application/models/guards/isVariantInfo.js +0 -28
- package/dist/src/application/models/guards/utils.js +0 -34
- package/dist/src/application/models/index.js +0 -34
- package/dist/src/application/models/utils/snakeToCamelTransformer.js +0 -71
- package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +0 -65
- package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +0 -9
- package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +0 -420
- package/dist/src/application/models/validators/validateGraphQLOrgId.js +0 -6
- package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +0 -9
- package/dist/src/application/models/validators/validateOrgConfigResults.js +0 -44
- package/dist/src/application/models/validators/validateOrganizationConfig.js +0 -34
- package/dist/src/application/models/validators/validateResponse.js +0 -173
- package/dist/src/application/models/validators/validateSuggestion.js +0 -13
- package/dist/src/application/models/validators/validateUserEvent.js +0 -91
- package/dist/src/application/utils/analyticsUtils.js +0 -95
- package/dist/src/application/utils/coreContextToApiContext.js +0 -8
- package/dist/src/application/utils/coreUserEventToApiUserEvent.js +0 -90
- package/dist/src/application/utils/divideArray.js +0 -7
- package/dist/src/application/utils/domObserver.js +0 -85
- package/dist/src/application/utils/elementObserver.js +0 -186
- package/dist/src/application/utils/imageFilter.js +0 -11
- package/dist/src/application/utils/index.js +0 -21
- package/dist/src/application/utils/merchantUtils.js +0 -15
- package/dist/src/application/utils/messageFromFormSubmittedEvent.js +0 -19
- package/dist/src/application/utils/messageFromQueryEvent.js +0 -35
- package/dist/src/application/utils/messageFromResponse.js +0 -123
- package/dist/src/application/utils/messageFromSuggestionEvent.js +0 -27
- package/dist/src/application/utils/mouseEventTypes.js +0 -1
- package/dist/src/application/utils/mutationHelper.js +0 -33
- package/dist/src/application/utils/nextMessageRequestToApiRequest.js +0 -29
- package/dist/src/application/utils/nodeSelector.js +0 -101
- package/dist/src/application/utils/overrides.js +0 -144
- package/dist/src/application/utils/stringUtils.js +0 -47
- package/dist/src/application/utils/supportedEventRequestToApiRequest.js +0 -7
- package/dist/src/application/utils/urlsParser.js +0 -33
- package/dist/src/application/utils/validation.js +0 -5
- package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +0 -4
- package/dist/src/atoms/app/index.js +0 -23
- package/dist/src/atoms/app/variant.js +0 -102
- package/dist/src/atoms/atomStore/atomStore.js +0 -28
- package/dist/src/atoms/atomStore/index.js +0 -1
- package/dist/src/atoms/chat/chatState.js +0 -32
- package/dist/src/atoms/chat/form.js +0 -16
- package/dist/src/atoms/chat/index.js +0 -23
- package/dist/src/atoms/chat/lastMessage.js +0 -10
- package/dist/src/atoms/chat/messageQueue.js +0 -68
- package/dist/src/atoms/chat/performanceMetrics.js +0 -70
- package/dist/src/atoms/chat/renderedWidgetRefs.js +0 -24
- package/dist/src/atoms/chat/replies.js +0 -42
- package/dist/src/atoms/chat/suggestions.js +0 -29
- package/dist/src/atoms/envive/enviveConfig.js +0 -67
- package/dist/src/atoms/globalSearch/globalSearch.js +0 -8
- package/dist/src/atoms/globalSearch/index.js +0 -1
- package/dist/src/atoms/org/customerService.js +0 -6
- package/dist/src/atoms/org/graphqlConfig.js +0 -8
- package/dist/src/atoms/org/index.js +0 -4
- package/dist/src/atoms/org/newOrgConfigAtom.js +0 -2
- package/dist/src/atoms/org/orgAnalyticsConfig.js +0 -8
- package/dist/src/atoms/search/index.js +0 -1
- package/dist/src/atoms/search/productFilters.js +0 -163
- package/dist/src/atoms/search/productRetrievalAPI.js +0 -50
- package/dist/src/atoms/search/productRetrievalAdapter.js +0 -14
- package/dist/src/atoms/search/productSorter.js +0 -13
- package/dist/src/atoms/search/searchAPI.js +0 -140
- package/dist/src/atoms/search/searchServiceAdapter.js +0 -14
- package/dist/src/atoms/search/utils.js +0 -15
- package/dist/src/config/index.js +0 -1
- package/dist/src/config/locators/components/chat/entrypoints.js +0 -10
- package/dist/src/config/locators/components/chat/index.js +0 -21
- package/dist/src/config/locators/components/chat/preview.js +0 -11
- package/dist/src/config/locators/components/chat/variants/index.js +0 -12
- package/dist/src/config/locators/components/common/buttons.js +0 -6
- package/dist/src/config/locators/components/common/cards.js +0 -17
- package/dist/src/config/locators/components/common/index.js +0 -4
- package/dist/src/config/locators/components/common/links.js +0 -1
- package/dist/src/config/locators/components/common/tables.js +0 -1
- package/dist/src/config/locators/components/floating-button.js +0 -2
- package/dist/src/config/locators/components/index.js +0 -3
- package/dist/src/config/locators/components/report-issue.js +0 -13
- package/dist/src/config/locators/components/search/index.js +0 -5
- package/dist/src/config/locators/components/shadow-dom.js +0 -1
- package/dist/src/config/locators/embedded.js +0 -20
- package/dist/src/config/locators/index.js +0 -4
- package/dist/src/contexts/amplitudeContext/amplitudeContext.js +0 -271
- package/dist/src/contexts/amplitudeContext/index.js +0 -1
- package/dist/src/contexts/cdnContext/cdnContext.js +0 -28
- package/dist/src/contexts/cdnContext/index.js +0 -1
- package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +0 -37
- package/dist/src/contexts/enviveConfigContext/index.js +0 -1
- package/dist/src/contexts/enviveCssContext/enviveCssContext.js +0 -31
- package/dist/src/contexts/enviveCssContext/index.js +0 -1
- package/dist/src/contexts/featureFlagContext/featureFlagContext.js +0 -109
- package/dist/src/contexts/featureFlagContext/index.js +0 -1
- package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +0 -47
- package/dist/src/contexts/featureFlagServiceContext/index.js +0 -1
- package/dist/src/contexts/graphqlContext/graphqlContext.js +0 -87
- package/dist/src/contexts/graphqlContext/index.js +0 -1
- package/dist/src/contexts/localStorageContext/index.js +0 -1
- package/dist/src/contexts/localStorageContext/localStorageContext.js +0 -95
- package/dist/src/contexts/newOrgConfigContext/index.js +0 -1
- package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +0 -33
- package/dist/src/contexts/searchContext/index.js +0 -1
- package/dist/src/contexts/searchContext/searchContext.js +0 -131
- package/dist/src/contexts/sessionStorageContext/index.js +0 -1
- package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +0 -43
- package/dist/src/contexts/shopifyUrlContext/index.js +0 -1
- package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +0 -62
- package/dist/src/contexts/systemSettingsContext/index.js +0 -1
- package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +0 -29
- package/dist/src/contexts/userIdentityContext/index.js +0 -1
- package/dist/src/contexts/userIdentityContext/userIdentityContext.js +0 -118
- package/dist/src/events/index.js +0 -51
- package/dist/src/events/registerAnalyticsListeners.js +0 -32
- package/dist/src/exceptions/index.js +0 -2
- package/dist/src/exceptions/sessionExceptions.js +0 -6
- package/dist/src/exceptions/unsupportedProductExceptions.js +0 -6
- package/dist/src/hooks/AmplitudeOperations/index.js +0 -1
- package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +0 -24
- package/dist/src/hooks/AppDetails/index.js +0 -1
- package/dist/src/hooks/AppDetails/useAppDetails.js +0 -26
- package/dist/src/hooks/BlockBackButton/index.js +0 -1
- package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +0 -23
- package/dist/src/hooks/CdnOperations/index.js +0 -1
- package/dist/src/hooks/CdnOperations/useCdnOperations.js +0 -13
- package/dist/src/hooks/ChatToggle/index.js +0 -1
- package/dist/src/hooks/ChatToggle/useChatToggle.js +0 -50
- package/dist/src/hooks/ChatToggleAnalytics/index.js +0 -1
- package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +0 -11
- package/dist/src/hooks/CustomerSupportHandoff/index.js +0 -1
- package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +0 -32
- package/dist/src/hooks/Debounce/index.js +0 -1
- package/dist/src/hooks/Debounce/useDebounce.js +0 -13
- package/dist/src/hooks/ElementObserver/index.js +0 -1
- package/dist/src/hooks/ElementObserver/useElementObserver.js +0 -208
- package/dist/src/hooks/GrabAndScroll/index.js +0 -1
- package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +0 -105
- package/dist/src/hooks/GraphQLConfig/index.js +0 -1
- package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +0 -54
- package/dist/src/hooks/IdentifyUser/index.js +0 -1
- package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +0 -28
- package/dist/src/hooks/ImageResolver/index.js +0 -1
- package/dist/src/hooks/ImageResolver/useImageResolver.js +0 -45
- package/dist/src/hooks/Intersection/index.js +0 -1
- package/dist/src/hooks/Intersection/useIntersection.js +0 -20
- package/dist/src/hooks/IsSmallScreen/index.js +0 -1
- package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +0 -16
- package/dist/src/hooks/LocalStorageOperations/index.js +0 -1
- package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +0 -64
- package/dist/src/hooks/MessageFilter/index.js +0 -1
- package/dist/src/hooks/MessageFilter/useMessageFilter.js +0 -37
- package/dist/src/hooks/MessageScrollObserver/index.js +0 -1
- package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +0 -35
- package/dist/src/hooks/NewOrgConfig/index.js +0 -1
- package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +0 -5
- package/dist/src/hooks/Search/index.js +0 -1
- package/dist/src/hooks/Search/useRecommendedProducts.js +0 -35
- package/dist/src/hooks/Search/useSearch.js +0 -224
- package/dist/src/hooks/Search/useSearchInput.js +0 -192
- package/dist/src/hooks/SearchOperations/index.js +0 -1
- package/dist/src/hooks/SearchOperations/useSearchOperations.js +0 -78
- package/dist/src/hooks/SessionStorageOperations/index.js +0 -1
- package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +0 -20
- package/dist/src/hooks/ShopifyUrlOperations/index.js +0 -1
- package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +0 -34
- package/dist/src/hooks/SnapCalculator/index.js +0 -1
- package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +0 -22
- package/dist/src/hooks/SystemSettingsContext/index.js +0 -1
- package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +0 -9
- package/dist/src/hooks/TrackComponentVisibleEvent/index.js +0 -1
- package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +0 -45
- package/dist/src/hooks/UpdateAnalyticsProps/index.js +0 -1
- package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +0 -43
- package/dist/src/hooks/utils.js +0 -116
- package/dist/src/interceptors/index.js +0 -1
- package/dist/src/interceptors/useMessageInterceptor.js +0 -24
- package/dist/src/types/ApiResponse.js +0 -1
- package/dist/src/types/FilterAttribute.js +0 -3
- package/dist/src/types/Message.js +0 -24
- package/dist/src/types/Suggestion.js +0 -3
- package/dist/src/types/index.js +0 -4
- package/dist/src/util/colorVar.js +0 -3
- package/dist/src/util/configVersion.js +0 -4
- package/dist/src/util/domInsertion.js +0 -16
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { useRef, useState } from 'react';
|
|
2
|
-
const animateHorizontalScroll = ({ element, duration, targetScroll, multiply = 1, direction, callback, offset = 0, }) => {
|
|
3
|
-
const start = element.scrollLeft;
|
|
4
|
-
const distance = (targetScroll - start) * multiply;
|
|
5
|
-
const startTime = performance.now();
|
|
6
|
-
function easeOutSine(x) {
|
|
7
|
-
return Math.sin((x * Math.PI) / 2);
|
|
8
|
-
}
|
|
9
|
-
function scrollStep(currentTime) {
|
|
10
|
-
const timeElapsed = currentTime - startTime;
|
|
11
|
-
const progress = Math.min(timeElapsed / duration, 1);
|
|
12
|
-
const easing = easeOutSine(progress);
|
|
13
|
-
const step = start + distance * easing;
|
|
14
|
-
const canScroll = (direction === 'rt' ? element.scrollLeft < step : element.scrollLeft > step) || !direction;
|
|
15
|
-
if (step > 0 && canScroll) {
|
|
16
|
-
element.scrollTo(step, 0);
|
|
17
|
-
}
|
|
18
|
-
if (timeElapsed < duration) {
|
|
19
|
-
requestAnimationFrame(scrollStep);
|
|
20
|
-
}
|
|
21
|
-
// End of scrolling container
|
|
22
|
-
else if (element.scrollLeft + offset === element.scrollWidth) {
|
|
23
|
-
callback === null || callback === void 0 ? void 0 : callback('rt');
|
|
24
|
-
}
|
|
25
|
-
// Begin of scrolling container
|
|
26
|
-
else if (element.scrollLeft <= 1) {
|
|
27
|
-
callback === null || callback === void 0 ? void 0 : callback('lt');
|
|
28
|
-
}
|
|
29
|
-
// Somewhere in the middle
|
|
30
|
-
else {
|
|
31
|
-
callback === null || callback === void 0 ? void 0 : callback('ct');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
requestAnimationFrame(scrollStep);
|
|
35
|
-
};
|
|
36
|
-
export const useGrabAndScroll = (enabled, chunkWidth, speed = 400, offset = 0) => {
|
|
37
|
-
const containerRef = useRef(null);
|
|
38
|
-
const [leftArrow, setLeftArrow] = useState(false);
|
|
39
|
-
const [rightArrow, setRightArrow] = useState(true);
|
|
40
|
-
const handleArrows = (position) => {
|
|
41
|
-
switch (position) {
|
|
42
|
-
case 'lt':
|
|
43
|
-
setLeftArrow(false);
|
|
44
|
-
setRightArrow(true);
|
|
45
|
-
break;
|
|
46
|
-
case 'rt':
|
|
47
|
-
setLeftArrow(true);
|
|
48
|
-
setRightArrow(false);
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
setLeftArrow(true);
|
|
52
|
-
setRightArrow(true);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const animationTrigger = () => {
|
|
56
|
-
var _a;
|
|
57
|
-
if (enabled && containerRef.current) {
|
|
58
|
-
const dist = (((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) || 0) / chunkWidth;
|
|
59
|
-
const targetScroll = chunkWidth * (Math.floor(dist) + (dist % 1 > 0.5 ? 1 : 0));
|
|
60
|
-
animateHorizontalScroll({
|
|
61
|
-
element: containerRef.current,
|
|
62
|
-
targetScroll,
|
|
63
|
-
duration: speed,
|
|
64
|
-
offset,
|
|
65
|
-
callback: handleArrows,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const onNext = (cardsToSlide) => {
|
|
70
|
-
if (containerRef.current) {
|
|
71
|
-
const targetScroll = containerRef.current.scrollLeft + chunkWidth;
|
|
72
|
-
animateHorizontalScroll({
|
|
73
|
-
element: containerRef.current,
|
|
74
|
-
targetScroll,
|
|
75
|
-
duration: speed,
|
|
76
|
-
direction: 'rt',
|
|
77
|
-
multiply: cardsToSlide,
|
|
78
|
-
offset,
|
|
79
|
-
callback: handleArrows,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const onPrevious = (cardsToSlide) => {
|
|
84
|
-
if (containerRef.current) {
|
|
85
|
-
const targetScroll = containerRef.current.scrollLeft - chunkWidth;
|
|
86
|
-
animateHorizontalScroll({
|
|
87
|
-
element: containerRef.current,
|
|
88
|
-
targetScroll,
|
|
89
|
-
duration: speed,
|
|
90
|
-
direction: 'lt',
|
|
91
|
-
multiply: cardsToSlide,
|
|
92
|
-
offset,
|
|
93
|
-
callback: handleArrows,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
containerRef,
|
|
99
|
-
leftArrow,
|
|
100
|
-
rightArrow,
|
|
101
|
-
animationTrigger,
|
|
102
|
-
onNext,
|
|
103
|
-
onPrevious,
|
|
104
|
-
};
|
|
105
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useGraphQLConfig";
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { useGraphQLClient } from 'src/contexts/graphqlContext/graphqlContext';
|
|
3
|
-
export const useColorsAndFrontendConfig = () => {
|
|
4
|
-
const { getColorsAndFrontendConfig, isReady } = useGraphQLClient();
|
|
5
|
-
const [data, setData] = useState({});
|
|
6
|
-
const [loading, setLoading] = useState(false);
|
|
7
|
-
const [error, setError] = useState(null);
|
|
8
|
-
const fetchConfig = useCallback(async () => {
|
|
9
|
-
if (!isReady)
|
|
10
|
-
return;
|
|
11
|
-
setLoading(true);
|
|
12
|
-
setError(null);
|
|
13
|
-
try {
|
|
14
|
-
const result = await getColorsAndFrontendConfig();
|
|
15
|
-
setData(result);
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
setLoading(false);
|
|
22
|
-
}
|
|
23
|
-
}, [getColorsAndFrontendConfig, isReady]);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
fetchConfig();
|
|
26
|
-
}, [fetchConfig]);
|
|
27
|
-
return { data, loading, error, refetch: fetchConfig };
|
|
28
|
-
};
|
|
29
|
-
export const useOrgId = () => {
|
|
30
|
-
const { getOrgId, isReady } = useGraphQLClient();
|
|
31
|
-
const [orgId, setOrgId] = useState();
|
|
32
|
-
const [loading, setLoading] = useState(false);
|
|
33
|
-
const [error, setError] = useState(null);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!isReady)
|
|
36
|
-
return;
|
|
37
|
-
const fetchOrgId = async () => {
|
|
38
|
-
setLoading(true);
|
|
39
|
-
setError(null);
|
|
40
|
-
try {
|
|
41
|
-
const id = await getOrgId();
|
|
42
|
-
setOrgId(id);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
setError(err instanceof Error ? err : new Error('Unknown error'));
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
setLoading(false);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
fetchOrgId();
|
|
52
|
-
}, [getOrgId, isReady]);
|
|
53
|
-
return { orgId, loading, error };
|
|
54
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useIdentifyUser";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from "react";
|
|
2
|
-
import { useUserIdentity } from "src/contexts/userIdentityContext/userIdentityContext";
|
|
3
|
-
export const useIdentifyUser = () => {
|
|
4
|
-
const { identifyUser, isReady } = useUserIdentity();
|
|
5
|
-
const [loading, setLoading] = useState(false);
|
|
6
|
-
const [error, setError] = useState(null);
|
|
7
|
-
const executeIdentifyUser = useCallback(async () => {
|
|
8
|
-
if (!isReady) {
|
|
9
|
-
setError(new Error("UserIdentityContext not ready."));
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
setLoading(true);
|
|
13
|
-
setError(null);
|
|
14
|
-
try {
|
|
15
|
-
await identifyUser();
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
setError(err instanceof Error
|
|
19
|
-
? err
|
|
20
|
-
: new Error("Unknown error during user identification."));
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
23
|
-
finally {
|
|
24
|
-
setLoading(false);
|
|
25
|
-
}
|
|
26
|
-
}, [identifyUser, isReady]);
|
|
27
|
-
return { loading, error, executeIdentifyUser, isReady };
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useImageResolver";
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import { OrgShortName } from '@envive-ai/types';
|
|
3
|
-
import { useAtomValue } from 'jotai';
|
|
4
|
-
import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
|
|
5
|
-
class ImageResolver {
|
|
6
|
-
}
|
|
7
|
-
class ShopifyImageResolver extends ImageResolver {
|
|
8
|
-
resolve(url, size) {
|
|
9
|
-
const pattern = /_\d+x\.jpg/;
|
|
10
|
-
const urlHasPrefix = pattern.test(url);
|
|
11
|
-
const newSizePrefix = `_${size}x.jpg`;
|
|
12
|
-
if (urlHasPrefix) {
|
|
13
|
-
return url.replace(pattern, newSizePrefix);
|
|
14
|
-
}
|
|
15
|
-
return url.replace('.jpg', newSizePrefix);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export const useImageResolver = () => {
|
|
19
|
-
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
20
|
-
const resolve = (image, size) => {
|
|
21
|
-
var _a;
|
|
22
|
-
if (image && size && orgShortName) {
|
|
23
|
-
const newImagePath = (_a = MerchantImageResolver.get(orgShortName)) === null || _a === void 0 ? void 0 : _a.resolve(image, size);
|
|
24
|
-
return newImagePath || image;
|
|
25
|
-
}
|
|
26
|
-
return image;
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
resolve,
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
class MerchantImageResolver {
|
|
33
|
-
static loadMapping() {
|
|
34
|
-
if (this.imageResolverMap.size === 0) {
|
|
35
|
-
this.imageResolverMap.set(OrgShortName.Spanx, new ShopifyImageResolver());
|
|
36
|
-
this.imageResolverMap.set(OrgShortName.SpanxStaging, new ShopifyImageResolver());
|
|
37
|
-
this.imageResolverMap.set(OrgShortName.UniqueVintage, new ShopifyImageResolver());
|
|
38
|
-
}
|
|
39
|
-
return this.imageResolverMap;
|
|
40
|
-
}
|
|
41
|
-
static get(name) {
|
|
42
|
-
return this.loadMapping().get(name);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
MerchantImageResolver.imageResolverMap = new Map();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useIntersection";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
// https://rasilbaidar.medium.com/trigger-event-when-element-enters-viewport-the-react-way-168509da2e23
|
|
3
|
-
export const useIntersection = (element, rootMargin) => {
|
|
4
|
-
const [isVisible, setIsVisible] = useState(false);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const current = element === null || element === void 0 ? void 0 : element.current;
|
|
7
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
8
|
-
setIsVisible(entry.isIntersecting);
|
|
9
|
-
}, { rootMargin });
|
|
10
|
-
if (current) {
|
|
11
|
-
observer === null || observer === void 0 ? void 0 : observer.observe(current);
|
|
12
|
-
}
|
|
13
|
-
return () => {
|
|
14
|
-
if (current) {
|
|
15
|
-
observer.unobserve(current);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}, []);
|
|
19
|
-
return isVisible;
|
|
20
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useIsSmallScreen";
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
export const useIsSmallScreen = () => {
|
|
3
|
-
const [isSmall, setIsSmall] = useState(false);
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
const mediaQuery = window.matchMedia('(max-width: 479px)');
|
|
6
|
-
// Set initial value
|
|
7
|
-
setIsSmall(mediaQuery.matches);
|
|
8
|
-
// Update state when viewport changes
|
|
9
|
-
const handleResize = (event) => {
|
|
10
|
-
setIsSmall(event.matches);
|
|
11
|
-
};
|
|
12
|
-
mediaQuery.addEventListener('change', handleResize);
|
|
13
|
-
return () => mediaQuery.removeEventListener('change', handleResize);
|
|
14
|
-
}, []);
|
|
15
|
-
return isSmall;
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useLocalStorageOperations";
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { LocalStorageKeys } from '@envive-ai/types';
|
|
2
|
-
import { useState, useEffect, useCallback } from 'react';
|
|
3
|
-
import { useLocalStorage } from 'src/contexts/localStorageContext';
|
|
4
|
-
// Reactive localStorage value hook
|
|
5
|
-
export const useLocalStorageValue = (key) => {
|
|
6
|
-
const { getItem, setItem, attachListener, detachListener } = useLocalStorage();
|
|
7
|
-
const [value, setValue] = useState(() => getItem(key));
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const listener = {
|
|
10
|
-
storageKey: key,
|
|
11
|
-
listener: (event) => {
|
|
12
|
-
setValue(event.newValue);
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
attachListener(listener);
|
|
16
|
-
return () => detachListener(listener);
|
|
17
|
-
}, [key, attachListener, detachListener]);
|
|
18
|
-
const updateValue = useCallback((newValue) => {
|
|
19
|
-
setItem(key, newValue);
|
|
20
|
-
setValue(newValue);
|
|
21
|
-
}, [key, setItem]);
|
|
22
|
-
return { value, setValue: updateValue };
|
|
23
|
-
};
|
|
24
|
-
// Feature flag hook for Spiffy
|
|
25
|
-
export const useSpiffyFeatureFlag = () => {
|
|
26
|
-
const { setSpiffyOnFeatureFlag } = useLocalStorage();
|
|
27
|
-
const { value } = useLocalStorageValue(LocalStorageKeys.SpiffyOnOverride);
|
|
28
|
-
const setFlag = useCallback((flag) => {
|
|
29
|
-
setSpiffyOnFeatureFlag(flag);
|
|
30
|
-
}, [setSpiffyOnFeatureFlag]);
|
|
31
|
-
return {
|
|
32
|
-
value: value === 'true' ? true : value === 'false' ? false : null,
|
|
33
|
-
setFlag,
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
// Feature flag hook for Envive
|
|
37
|
-
export const useEnviveFeatureFlag = () => {
|
|
38
|
-
const { setItem, getItem } = useLocalStorage();
|
|
39
|
-
const { value } = useLocalStorageValue(LocalStorageKeys.EnviveOnOverride);
|
|
40
|
-
const setFlag = useCallback((flag) => {
|
|
41
|
-
if (flag === true) {
|
|
42
|
-
setItem(LocalStorageKeys.EnviveOnOverride, 'true');
|
|
43
|
-
}
|
|
44
|
-
else if (flag === false) {
|
|
45
|
-
setItem(LocalStorageKeys.EnviveOnOverride, 'false');
|
|
46
|
-
}
|
|
47
|
-
}, [setItem]);
|
|
48
|
-
return {
|
|
49
|
-
value: value === 'true' ? true : value === 'false' ? false : null,
|
|
50
|
-
setFlag,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
// Storage listener hook
|
|
54
|
-
export const useLocalStorageListener = (key, callback) => {
|
|
55
|
-
const { attachListener, detachListener } = useLocalStorage();
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
const listener = {
|
|
58
|
-
storageKey: key,
|
|
59
|
-
listener: callback,
|
|
60
|
-
};
|
|
61
|
-
attachListener(listener);
|
|
62
|
-
return () => detachListener(listener);
|
|
63
|
-
}, [key, callback, attachListener, detachListener]);
|
|
64
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useMessageFilter";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { MessageType } from '@envive-ai/types';
|
|
2
|
-
export const useMessageFilter = () => {
|
|
3
|
-
const findMessageIndex = ({ msgs, type, role }) => {
|
|
4
|
-
let lastIndex = -1;
|
|
5
|
-
msgs.forEach((subArray, index) => {
|
|
6
|
-
subArray.forEach((obj) => {
|
|
7
|
-
if (obj.type === type || obj.role === role)
|
|
8
|
-
lastIndex = index;
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
return lastIndex;
|
|
12
|
-
};
|
|
13
|
-
const removePreviousDiscussions = (msgs, index) => {
|
|
14
|
-
if (index > -1) {
|
|
15
|
-
const lastMessages = msgs.slice(index);
|
|
16
|
-
return lastMessages.length > 0 ? lastMessages : msgs;
|
|
17
|
-
}
|
|
18
|
-
return msgs;
|
|
19
|
-
};
|
|
20
|
-
const getFilteredMessages = (msgs, skipFilter) => {
|
|
21
|
-
const messageMap = msgs.reduce((acc, msg) => {
|
|
22
|
-
acc[msg[0].id] = msg;
|
|
23
|
-
return acc;
|
|
24
|
-
}, {});
|
|
25
|
-
const deduplicatedMsgs = Object.values(messageMap);
|
|
26
|
-
if (!skipFilter) {
|
|
27
|
-
const idx = findMessageIndex({ msgs: deduplicatedMsgs, type: MessageType.Separator });
|
|
28
|
-
return removePreviousDiscussions(deduplicatedMsgs, idx);
|
|
29
|
-
}
|
|
30
|
-
return deduplicatedMsgs;
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
findMessageIndex,
|
|
34
|
-
removePreviousDiscussions,
|
|
35
|
-
getFilteredMessages,
|
|
36
|
-
};
|
|
37
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useMessageScrollObserver";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
export const useMessageScrollObserver = (boxRef, scrollRef, onScrollChange) => {
|
|
3
|
-
const calculateScrollHeight = () => {
|
|
4
|
-
var _a, _b;
|
|
5
|
-
const boxHeight = ((_a = boxRef === null || boxRef === void 0 ? void 0 : boxRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
|
|
6
|
-
const scrollHeight = ((_b = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().height) || 0;
|
|
7
|
-
return boxHeight - scrollHeight;
|
|
8
|
-
};
|
|
9
|
-
const updateState = () => {
|
|
10
|
-
const scrollHeight = calculateScrollHeight();
|
|
11
|
-
if (scrollHeight > 0) {
|
|
12
|
-
onScrollChange(scrollHeight);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
let boxRO = null;
|
|
17
|
-
let scrollRO = null;
|
|
18
|
-
if (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) {
|
|
19
|
-
boxRO = new ResizeObserver(updateState);
|
|
20
|
-
boxRO.observe(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current);
|
|
21
|
-
}
|
|
22
|
-
if (boxRef === null || boxRef === void 0 ? void 0 : boxRef.current) {
|
|
23
|
-
scrollRO = new ResizeObserver(updateState);
|
|
24
|
-
scrollRO.observe(boxRef === null || boxRef === void 0 ? void 0 : boxRef.current);
|
|
25
|
-
}
|
|
26
|
-
return () => {
|
|
27
|
-
if ((scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) && boxRO) {
|
|
28
|
-
boxRO.unobserve(scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current);
|
|
29
|
-
}
|
|
30
|
-
if (scrollRO && (boxRef === null || boxRef === void 0 ? void 0 : boxRef.current)) {
|
|
31
|
-
scrollRO === null || scrollRO === void 0 ? void 0 : scrollRO.unobserve(boxRef === null || boxRef === void 0 ? void 0 : boxRef.current);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}, []);
|
|
35
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useNewOrgConfig";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useSearch";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { FeatureGates, } from "@envive-ai/types";
|
|
2
|
-
import { useAtomValue, useSetAtom } from "jotai";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { useFeatureFlagService } from "src/contexts/featureFlagServiceContext/featureFlagServiceContext";
|
|
5
|
-
import { retrievedProductsAtom, performProductRetrievalAtom, productRetrievalAtom, } from "src/atoms/search/productRetrievalAPI";
|
|
6
|
-
import { useNewOrgConfig } from "../NewOrgConfig";
|
|
7
|
-
/**
|
|
8
|
-
* A hook to get recommended products.
|
|
9
|
-
* It checks the `IsRecommendedProductsEnabled` feature gate and triggers fetching if needed.
|
|
10
|
-
* If the gate is enabled, it returns the list of recommended products.
|
|
11
|
-
* If the gate is disabled, it returns an empty array.
|
|
12
|
-
*
|
|
13
|
-
* @returns The list of recommended products or an empty array.
|
|
14
|
-
*/
|
|
15
|
-
export const useRecommendedProducts = () => {
|
|
16
|
-
const featureFlagService = useFeatureFlagService();
|
|
17
|
-
const isEnabled = featureFlagService.isFeatureGateEnabled(FeatureGates.IsRecommendedProductsEnabled);
|
|
18
|
-
const recommendedProducts = useAtomValue(retrievedProductsAtom);
|
|
19
|
-
const performProductRetrieval = useSetAtom(performProductRetrievalAtom);
|
|
20
|
-
const { lastProductIds } = useAtomValue(productRetrievalAtom);
|
|
21
|
-
const orgUIConfig = useNewOrgConfig();
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
const recommendedProductIds = orgUIConfig.searchConfig
|
|
24
|
-
? orgUIConfig.searchConfig.recommendedProducts
|
|
25
|
-
: [];
|
|
26
|
-
// Fetch only if the feature is enabled, there are IDs to fetch, and we haven't already fetched them.
|
|
27
|
-
if (isEnabled &&
|
|
28
|
-
recommendedProductIds &&
|
|
29
|
-
recommendedProductIds.length > 0 &&
|
|
30
|
-
!lastProductIds) {
|
|
31
|
-
performProductRetrieval({ productIds: recommendedProductIds });
|
|
32
|
-
}
|
|
33
|
-
}, [isEnabled, performProductRetrieval, lastProductIds, orgUIConfig]);
|
|
34
|
-
return isEnabled ? recommendedProducts : [];
|
|
35
|
-
};
|