@envive-ai/react-hooks 0.2.6-alpha-5 → 0.2.6-alpha-7
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-CNFlPr53.cjs → AmplitudeOperations-DbUiR0N_.cjs} +3 -3
- package/dist/{AmplitudeOperations-cmAprPCA.js → AmplitudeOperations-DjqOM3uE.js} +2 -2
- package/dist/{NewOrgConfig-Bicbf8I7.js → NewOrgConfig-C_1T1iOt.js} +2 -2
- package/dist/{NewOrgConfig-6dFyYjJG.cjs → NewOrgConfig-D2Kvqa1z.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-BebTjNtS.js → TrackComponentVisibleEvent-BxOhr9Da.js} +4 -4
- package/dist/{TrackComponentVisibleEvent-COwxsJRE.cjs → TrackComponentVisibleEvent-CDbecFPM.cjs} +5 -5
- package/dist/amplitudeContext-BWmXliMI.cjs +243 -0
- package/dist/amplitudeContext-BjMlg5RV.js +227 -0
- package/dist/amplitudeTrackEventAtom-D66l5oFp.js +8 -0
- package/dist/amplitudeTrackEventAtom-f22P2U0u.cjs +15 -0
- package/dist/app-Bs2KxG_8.js +515 -0
- package/dist/app-DSnDDqcW.cjs +570 -0
- package/dist/application/models/graphql/index.d.ts +1 -1
- package/dist/application/models/guards/api/index.d.ts +2 -2
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/index.cjs +2 -2
- package/dist/application/models/index.d.ts +4 -4
- package/dist/application/models/index.js +2 -2
- package/dist/application/utils/index.cjs +5 -14
- package/dist/application/utils/index.d.cts +7 -8
- package/dist/application/utils/index.d.ts +8 -9
- package/dist/application/utils/index.js +5 -14
- package/dist/{atomStore-CZKe3itM.cjs → atomStore-BQVO5haU.cjs} +1 -1
- package/dist/{atomStore-BuopbV9k.js → atomStore-CfzCqWB9.js} +1 -1
- package/dist/atoms/app/index.cjs +17 -19
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/index.d.ts +7 -7
- package/dist/atoms/app/index.js +12 -14
- 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 +15 -17
- package/dist/atoms/chat/index.d.cts +33 -34
- package/dist/atoms/chat/index.d.ts +34 -35
- package/dist/atoms/chat/index.js +15 -17
- 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 +17 -17
- package/dist/atoms/org/index.d.ts +17 -17
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/search/index.cjs +6 -6
- package/dist/atoms/search/index.d.cts +15 -15
- package/dist/atoms/search/index.d.ts +14 -14
- package/dist/atoms/search/index.js +6 -6
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/{cdnContext-CuZwc-PI.js → cdnContext-CJ2BNLAD.js} +2 -2
- package/dist/{cdnContext-ClAEcKhO.cjs → cdnContext-lkC-AE6A.cjs} +2 -2
- package/dist/chat-C5afTKUY.js +226 -0
- package/dist/{chat-BJL3nXR7.cjs → chat-CCjM6fS_.cjs} +6 -7
- package/dist/{chat-DCGriB7h.cjs → chat-CJ9D8n7g.cjs} +1 -1
- package/dist/{chat-ClvJ9xEj.js → chat-EJbfGWRr.js} +1 -1
- package/dist/chatState-BbI93m6r.js +33 -0
- package/dist/chatState-DlJpHAsW.cjs +119 -0
- package/dist/{common-DQPvV_S_.cjs → common-CuwWqIJ1.cjs} +1 -1
- package/dist/{common-c_4eX0qn.js → common-Df2bwzd2.js} +1 -1
- package/dist/{components-DKwVHIjq.cjs → components-BCfFLf9X.cjs} +1 -1
- package/dist/{components-CDpaMUjK.js → components-QGCWJ26c.js} +1 -1
- package/dist/config/index.cjs +4 -4
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +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.d.cts +1 -1
- package/dist/config/locators/components/chat/index.d.ts +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.d.cts +1 -1
- package/dist/config/locators/components/common/index.d.ts +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.d.cts +1 -1
- package/dist/config/locators/components/index.d.ts +1 -1
- package/dist/config/locators/components/index.js +1 -1
- package/dist/config/locators/index.cjs +4 -4
- package/dist/config/locators/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/config/locators/index.js +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +18 -17
- package/dist/contexts/amplitudeContext/index.d.cts +11 -2
- package/dist/contexts/amplitudeContext/index.d.ts +11 -2
- package/dist/contexts/amplitudeContext/index.js +17 -15
- package/dist/contexts/cdnContext/index.cjs +3 -3
- package/dist/contexts/cdnContext/index.d.cts +1 -1
- package/dist/contexts/cdnContext/index.js +3 -3
- package/dist/contexts/enviveConfigContext/index.cjs +3 -3
- package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
- package/dist/contexts/enviveConfigContext/index.js +3 -3
- package/dist/contexts/enviveCssContext/index.cjs +10 -10
- package/dist/contexts/enviveCssContext/index.js +10 -10
- package/dist/contexts/featureFlagContext/index.cjs +4 -4
- package/dist/contexts/featureFlagContext/index.js +4 -4
- package/dist/contexts/featureFlagServiceContext/index.cjs +3 -3
- package/dist/contexts/featureFlagServiceContext/index.d.cts +1 -1
- package/dist/contexts/featureFlagServiceContext/index.d.ts +1 -1
- package/dist/contexts/featureFlagServiceContext/index.js +3 -3
- package/dist/contexts/graphqlContext/index.cjs +4 -4
- package/dist/contexts/graphqlContext/index.js +4 -4
- package/dist/contexts/localStorageContext/index.cjs +2 -2
- package/dist/contexts/localStorageContext/index.d.cts +1 -1
- package/dist/contexts/localStorageContext/index.js +2 -2
- package/dist/contexts/newOrgConfigContext/index.cjs +9 -9
- package/dist/contexts/newOrgConfigContext/index.js +9 -9
- package/dist/contexts/searchContext/index.cjs +18 -19
- package/dist/contexts/searchContext/index.js +18 -19
- package/dist/contexts/sessionStorageContext/index.cjs +1 -1
- package/dist/contexts/sessionStorageContext/index.js +1 -1
- 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 +3 -3
- package/dist/contexts/systemSettingsContext/index.d.cts +2 -2
- package/dist/contexts/systemSettingsContext/index.js +3 -3
- package/dist/contexts/userIdentityContext/index.cjs +14 -16
- package/dist/contexts/userIdentityContext/index.js +12 -14
- package/dist/{dist-CIM4YRqp.js → dist-C38adNK1.js} +1 -1
- package/dist/{dist-BZX_Mgfn.cjs → dist-VxRI6eQv.cjs} +1 -1
- package/dist/{domObserver-CwieVNgj.cjs → domObserver-C2oQO8vi.cjs} +1 -1
- package/dist/{domObserver-B19-69gW.js → domObserver-DNeeSh1F.js} +1 -1
- package/dist/{enviveConfig-CBnoutoK.js → enviveConfig-Ciq4ASoV.js} +2 -2
- package/dist/{enviveConfig-BwIaVAAm.cjs → enviveConfig-Dp80h9yu.cjs} +2 -2
- package/dist/{enviveConfigContext-B4nejwV9.js → enviveConfigContext-CCjJUmwp.js} +2 -2
- package/dist/{enviveConfigContext-DgewMgYS.cjs → enviveConfigContext-DoYP8KSw.cjs} +2 -2
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/{events-BHBRLPWS.js → events-CXiS1aTc.js} +1 -1
- package/dist/{events-C8LA-0Tp.cjs → events-DBin1Z7o.cjs} +1 -1
- package/dist/exceptions/index.cjs +1 -1
- package/dist/exceptions/index.d.ts +1 -1
- package/dist/exceptions/index.js +1 -1
- package/dist/{exceptions-BBXmiU8P.cjs → exceptions-BjDgLzGi.cjs} +1 -1
- package/dist/{exceptions--fSXOzkB.js → exceptions-CUGY31Ua.js} +1 -1
- package/dist/{featureFlagServiceContext-B7je7VZV.d.cts → featureFlagServiceContext-ClnlCJV5.d.cts} +1 -1
- package/dist/{featureFlagServiceContext-CZj3qPX7.js → featureFlagServiceContext-Cvp7NlpC.js} +2 -2
- package/dist/{featureFlagServiceContext-DiYIv0jI.d.ts → featureFlagServiceContext-CyPGEe2d.d.ts} +1 -1
- package/dist/{featureFlagServiceContext-BkamHViU.cjs → featureFlagServiceContext-DHtkQAtq.cjs} +2 -2
- package/dist/{globalSearch-C94-vEVh.cjs → globalSearch-Cpc8egsM.cjs} +1 -1
- package/dist/{globalSearch-Dlbnfasm.js → globalSearch-nmrfGLOn.js} +1 -1
- package/dist/{graphqlContext-Capum8x6.js → graphqlContext-0cg9fEUw.js} +3 -3
- package/dist/{graphqlContext-C3HXFiHx.cjs → graphqlContext-ChXlE8Ul.cjs} +3 -3
- package/dist/hooks/AmplitudeOperations/index.cjs +17 -15
- package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/index.js +17 -15
- package/dist/hooks/AppDetails/index.cjs +15 -17
- package/dist/hooks/AppDetails/index.js +15 -17
- package/dist/hooks/BlockBackButton/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.cjs +3 -3
- package/dist/hooks/CdnOperations/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.d.ts +1 -1
- package/dist/hooks/CdnOperations/index.js +3 -3
- package/dist/hooks/ChatToggle/index.cjs +21 -19
- package/dist/hooks/ChatToggle/index.d.cts +1 -1
- package/dist/hooks/ChatToggle/index.js +20 -18
- package/dist/hooks/ChatToggleAnalytics/index.cjs +19 -17
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.js +19 -17
- package/dist/hooks/Debounce/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.d.ts +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GraphQLConfig/index.cjs +5 -5
- package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
- package/dist/hooks/GraphQLConfig/index.js +5 -5
- package/dist/hooks/IdentifyUser/index.cjs +14 -16
- package/dist/hooks/IdentifyUser/index.d.cts +1 -1
- package/dist/hooks/IdentifyUser/index.js +13 -15
- package/dist/hooks/ImageResolver/index.cjs +2 -2
- package/dist/hooks/ImageResolver/index.d.cts +1 -1
- package/dist/hooks/ImageResolver/index.js +2 -2
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/IsSmallScreen/index.d.cts +1 -1
- package/dist/hooks/LocalStorageOperations/index.cjs +2 -2
- package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
- package/dist/hooks/LocalStorageOperations/index.js +2 -2
- package/dist/hooks/MessageFilter/index.cjs +1 -1
- package/dist/hooks/MessageFilter/index.d.cts +1 -1
- package/dist/hooks/MessageFilter/index.js +1 -1
- package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
- package/dist/hooks/NewOrgConfig/index.cjs +10 -10
- package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
- package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
- package/dist/hooks/NewOrgConfig/index.js +10 -10
- package/dist/hooks/Search/index.cjs +25 -23
- package/dist/hooks/Search/index.js +25 -23
- package/dist/hooks/SearchOperations/index.cjs +19 -20
- package/dist/hooks/SearchOperations/index.js +19 -20
- package/dist/hooks/SessionStorageOperations/index.cjs +1 -1
- package/dist/hooks/SessionStorageOperations/index.js +1 -1
- package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
- package/dist/hooks/SystemSettingsContext/index.cjs +3 -3
- package/dist/hooks/SystemSettingsContext/index.d.cts +4 -4
- package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
- package/dist/hooks/SystemSettingsContext/index.js +3 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +18 -16
- package/dist/hooks/TrackComponentVisibleEvent/index.js +18 -16
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +20 -18
- package/dist/hooks/UpdateAnalyticsProps/index.js +17 -15
- 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-CAhGZxMI.d.ts → index-5li6ZMDu.d.ts} +1 -1
- package/dist/{index-ca7Qn8o0.d.cts → index-BbqT4BQv.d.cts} +1 -1
- package/dist/{index-w64il54a.d.cts → index-CAJq_8bO.d.cts} +1 -1
- package/dist/index-CMZcE7pk.d.cts +1 -1
- package/dist/{index-BQpWG3Jm.d.cts → index-ChiZg0yw.d.cts} +1 -1
- package/dist/{index-DNccxbJi.d.ts → index-CsmO1rDH.d.ts} +1 -1
- package/dist/{index-Dgu085Lu.d.ts → index-CuihhoIF.d.ts} +2 -2
- package/dist/{index-BR1G8yyg.d.ts → index-DtzPIcQp.d.ts} +1 -1
- package/dist/{index-ZQMda2Iu.d.ts → index-bEjLKG_Q.d.ts} +1 -1
- package/dist/{index-DiIHuPq2.d.ts → index-jFQefHda.d.ts} +1 -1
- package/dist/{index-BO-ZLYtR.d.ts → index-mv7KvWDq.d.ts} +1 -1
- package/dist/{index-ClVBVK15.d.cts → index-npqPeJ1g.d.cts} +1 -1
- package/dist/interceptors/index.cjs +1 -1
- package/dist/interceptors/index.d.cts +1 -1
- package/dist/interceptors/index.d.ts +1 -1
- package/dist/interceptors/index.js +1 -1
- package/dist/{localStorageContext-p_4U0RPI.js → localStorageContext-BFwvuEcf.js} +2 -2
- package/dist/{localStorageContext-CPrkpt8i.cjs → localStorageContext-CWc5xJ6U.cjs} +2 -2
- package/dist/{locators-BMQGmGLq.js → locators-C2fWd-74.js} +1 -1
- package/dist/{locators-DxYdak1F.cjs → locators-Cx3q6Z_h.cjs} +1 -1
- package/dist/{models-L2w8FYCa.js → models-Cw0QcbQv.js} +2 -2
- package/dist/{models-OyYkll03.cjs → models-Dl0_Ujgj.cjs} +2 -2
- package/dist/{newOrgConfigAtom-Dsk0fJNR.js → newOrgConfigAtom-BuQE_zPK.js} +1 -1
- package/dist/{newOrgConfigAtom-hs5A1pbZ.cjs → newOrgConfigAtom-rrYHmp1b.cjs} +1 -1
- package/dist/{newOrgConfigContext-BuqDUkPz.js → newOrgConfigContext-D-gU5ppl.js} +5 -5
- package/dist/{newOrgConfigContext-N4CQzvlH.cjs → newOrgConfigContext-d3RHl430.cjs} +5 -5
- package/dist/{nodeSelector-0gJ8Xayf.d.ts → nodeSelector-BAKg1h_y.d.ts} +1 -1
- package/dist/{nodeSelector-Cj-Xl1LP.d.cts → nodeSelector-BYEAyrsj.d.cts} +1 -1
- package/dist/org-15F128Ah.js +32 -0
- package/dist/org-CIFgIcO4.cjs +111 -0
- package/dist/{search-C_N_oRVZ.js → search--80x6CfL.js} +5 -5
- package/dist/{search-8bPfo07V.cjs → search-Ch6LKNh4.cjs} +5 -5
- package/dist/{searchContext-DdJbpDsU.cjs → searchContext-B0qEUoKb.cjs} +6 -6
- package/dist/{searchContext-BohH5i8s.js → searchContext-BkPoTq1o.js} +6 -6
- package/dist/{searchServiceAdapter-BSPZOg1r.js → searchServiceAdapter-B0h7psvh.js} +1 -1
- package/dist/{searchServiceAdapter-DrjFCiw8.cjs → searchServiceAdapter-BclWy4fE.cjs} +1 -1
- package/dist/{sessionStorageContext-CH37Dkb-.cjs → sessionStorageContext-BuWrJQwc.cjs} +1 -1
- package/dist/{sessionStorageContext-CqrutoVq.js → sessionStorageContext-DvFHbk81.js} +1 -1
- package/dist/{shopifyUrlContext-Ba6MQdNV.cjs → shopifyUrlContext-Bw1kAZ2P.cjs} +2 -2
- package/dist/{shopifyUrlContext-BI3fVtA5.js → shopifyUrlContext-DnJiUmMA.js} +2 -2
- package/dist/src/application/commerce-api.js +408 -0
- package/dist/src/application/logging/logger.js +16 -0
- package/dist/src/application/models/graphql/index.js +3 -0
- package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +13 -0
- package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +13 -0
- package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +10 -0
- package/dist/src/application/models/guards/api/index.js +12 -0
- package/dist/src/application/models/guards/api/isApiFormResponse.js +59 -0
- package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +22 -0
- package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +91 -0
- package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +188 -0
- package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +115 -0
- package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +16 -0
- package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +26 -0
- package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +15 -0
- package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +65 -0
- package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +15 -0
- package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +10 -0
- package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +4 -0
- package/dist/src/application/models/guards/api/isApiResponse.js +33 -0
- package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +22 -0
- package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +23 -0
- package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +20 -0
- package/dist/src/application/models/guards/api/isApiSuggestion.js +24 -0
- package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +4 -0
- package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +4 -0
- package/dist/src/application/models/guards/api/isApiUserEvent.js +18 -0
- package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +41 -0
- package/dist/src/application/models/guards/isBaseEcommerceEvent.js +14 -0
- package/dist/src/application/models/guards/isGA4EcommerceEvent.js +14 -0
- package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +14 -0
- package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +4 -0
- package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +1 -0
- package/dist/src/application/models/guards/isVariantInfo.js +28 -0
- package/dist/src/application/models/guards/utils.js +34 -0
- package/dist/src/application/models/index.js +34 -0
- package/dist/src/application/models/utils/snakeToCamelTransformer.js +71 -0
- package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +65 -0
- package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +9 -0
- package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +420 -0
- package/dist/src/application/models/validators/validateGraphQLOrgId.js +6 -0
- package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +9 -0
- package/dist/src/application/models/validators/validateOrgConfigResults.js +44 -0
- package/dist/src/application/models/validators/validateOrganizationConfig.js +34 -0
- package/dist/src/application/models/validators/validateResponse.js +173 -0
- package/dist/src/application/models/validators/validateSuggestion.js +13 -0
- package/dist/src/application/models/validators/validateUserEvent.js +91 -0
- package/dist/src/application/utils/analyticsUtils.js +95 -0
- package/dist/src/application/utils/coreContextToApiContext.js +8 -0
- package/dist/src/application/utils/coreUserEventToApiUserEvent.js +90 -0
- package/dist/src/application/utils/divideArray.js +7 -0
- package/dist/src/application/utils/domObserver.js +85 -0
- package/dist/src/application/utils/elementObserver.js +186 -0
- package/dist/src/application/utils/imageFilter.js +11 -0
- package/dist/src/application/utils/index.js +21 -0
- package/dist/src/application/utils/merchantUtils.js +15 -0
- package/dist/src/application/utils/messageFromFormSubmittedEvent.js +19 -0
- package/dist/src/application/utils/messageFromQueryEvent.js +35 -0
- package/dist/src/application/utils/messageFromResponse.js +123 -0
- package/dist/src/application/utils/messageFromSuggestionEvent.js +27 -0
- package/dist/src/application/utils/mouseEventTypes.js +1 -0
- package/dist/src/application/utils/mutationHelper.js +33 -0
- package/dist/src/application/utils/nextMessageRequestToApiRequest.js +29 -0
- package/dist/src/application/utils/nodeSelector.js +101 -0
- package/dist/src/application/utils/overrides.js +144 -0
- package/dist/src/application/utils/stringUtils.js +47 -0
- package/dist/src/application/utils/supportedEventRequestToApiRequest.js +7 -0
- package/dist/src/application/utils/urlsParser.js +33 -0
- package/dist/src/application/utils/validation.js +5 -0
- package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +4 -0
- package/dist/src/atoms/app/index.js +23 -0
- package/dist/src/atoms/app/variant.js +102 -0
- package/dist/src/atoms/atomStore/atomStore.js +28 -0
- package/dist/src/atoms/atomStore/index.js +1 -0
- package/dist/src/atoms/chat/chatState.js +32 -0
- package/dist/src/atoms/chat/form.js +16 -0
- package/dist/src/atoms/chat/index.js +23 -0
- package/dist/src/atoms/chat/lastMessage.js +10 -0
- package/dist/src/atoms/chat/messageQueue.js +68 -0
- package/dist/src/atoms/chat/performanceMetrics.js +70 -0
- package/dist/src/atoms/chat/renderedWidgetRefs.js +24 -0
- package/dist/src/atoms/chat/replies.js +42 -0
- package/dist/src/atoms/chat/suggestions.js +29 -0
- package/dist/src/atoms/envive/enviveConfig.js +67 -0
- package/dist/src/atoms/globalSearch/globalSearch.js +8 -0
- package/dist/src/atoms/globalSearch/index.js +1 -0
- package/dist/src/atoms/org/customerService.js +6 -0
- package/dist/src/atoms/org/graphqlConfig.js +8 -0
- package/dist/src/atoms/org/index.js +4 -0
- package/dist/src/atoms/org/newOrgConfigAtom.js +2 -0
- package/dist/src/atoms/org/orgAnalyticsConfig.js +8 -0
- package/dist/src/atoms/search/index.js +1 -0
- package/dist/src/atoms/search/productFilters.js +163 -0
- package/dist/src/atoms/search/productRetrievalAPI.js +50 -0
- package/dist/src/atoms/search/productRetrievalAdapter.js +14 -0
- package/dist/src/atoms/search/productSorter.js +13 -0
- package/dist/src/atoms/search/searchAPI.js +140 -0
- package/dist/src/atoms/search/searchServiceAdapter.js +14 -0
- package/dist/src/atoms/search/utils.js +15 -0
- package/dist/src/config/index.js +1 -0
- package/dist/src/config/locators/components/chat/entrypoints.js +10 -0
- package/dist/src/config/locators/components/chat/index.js +21 -0
- package/dist/src/config/locators/components/chat/preview.js +11 -0
- package/dist/src/config/locators/components/chat/variants/index.js +12 -0
- package/dist/src/config/locators/components/common/buttons.js +6 -0
- package/dist/src/config/locators/components/common/cards.js +17 -0
- package/dist/src/config/locators/components/common/index.js +4 -0
- package/dist/src/config/locators/components/common/links.js +1 -0
- package/dist/src/config/locators/components/common/tables.js +1 -0
- package/dist/src/config/locators/components/floating-button.js +2 -0
- package/dist/src/config/locators/components/index.js +3 -0
- package/dist/src/config/locators/components/report-issue.js +13 -0
- package/dist/src/config/locators/components/search/index.js +5 -0
- package/dist/src/config/locators/components/shadow-dom.js +1 -0
- package/dist/src/config/locators/embedded.js +20 -0
- package/dist/src/config/locators/index.js +4 -0
- package/dist/src/contexts/amplitudeContext/amplitudeContext.js +271 -0
- package/dist/src/contexts/amplitudeContext/index.js +1 -0
- package/dist/src/contexts/cdnContext/cdnContext.js +28 -0
- package/dist/src/contexts/cdnContext/index.js +1 -0
- package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +37 -0
- package/dist/src/contexts/enviveConfigContext/index.js +1 -0
- package/dist/src/contexts/enviveCssContext/enviveCssContext.js +31 -0
- package/dist/src/contexts/enviveCssContext/index.js +1 -0
- package/dist/src/contexts/featureFlagContext/featureFlagContext.js +109 -0
- package/dist/src/contexts/featureFlagContext/index.js +1 -0
- package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +47 -0
- package/dist/src/contexts/featureFlagServiceContext/index.js +1 -0
- package/dist/src/contexts/graphqlContext/graphqlContext.js +87 -0
- package/dist/src/contexts/graphqlContext/index.js +1 -0
- package/dist/src/contexts/localStorageContext/index.js +1 -0
- package/dist/src/contexts/localStorageContext/localStorageContext.js +95 -0
- package/dist/src/contexts/newOrgConfigContext/index.js +1 -0
- package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +33 -0
- package/dist/src/contexts/searchContext/index.js +1 -0
- package/dist/src/contexts/searchContext/searchContext.js +131 -0
- package/dist/src/contexts/sessionStorageContext/index.js +1 -0
- package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +43 -0
- package/dist/src/contexts/shopifyUrlContext/index.js +1 -0
- package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +62 -0
- package/dist/src/contexts/systemSettingsContext/index.js +1 -0
- package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +29 -0
- package/dist/src/contexts/userIdentityContext/index.js +1 -0
- package/dist/src/contexts/userIdentityContext/userIdentityContext.js +118 -0
- package/dist/src/events/index.js +51 -0
- package/dist/src/events/registerAnalyticsListeners.js +32 -0
- package/dist/src/exceptions/index.js +2 -0
- package/dist/src/exceptions/sessionExceptions.js +6 -0
- package/dist/src/exceptions/unsupportedProductExceptions.js +6 -0
- package/dist/src/hooks/AmplitudeOperations/index.js +1 -0
- package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +24 -0
- package/dist/src/hooks/AppDetails/index.js +1 -0
- package/dist/src/hooks/AppDetails/useAppDetails.js +26 -0
- package/dist/src/hooks/BlockBackButton/index.js +1 -0
- package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +23 -0
- package/dist/src/hooks/CdnOperations/index.js +1 -0
- package/dist/src/hooks/CdnOperations/useCdnOperations.js +13 -0
- package/dist/src/hooks/ChatToggle/index.js +1 -0
- package/dist/src/hooks/ChatToggle/useChatToggle.js +50 -0
- package/dist/src/hooks/ChatToggleAnalytics/index.js +1 -0
- package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +11 -0
- package/dist/src/hooks/CustomerSupportHandoff/index.js +1 -0
- package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +32 -0
- package/dist/src/hooks/Debounce/index.js +1 -0
- package/dist/src/hooks/Debounce/useDebounce.js +13 -0
- package/dist/src/hooks/ElementObserver/index.js +1 -0
- package/dist/src/hooks/ElementObserver/useElementObserver.js +208 -0
- package/dist/src/hooks/GrabAndScroll/index.js +1 -0
- package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +105 -0
- package/dist/src/hooks/GraphQLConfig/index.js +1 -0
- package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +54 -0
- package/dist/src/hooks/IdentifyUser/index.js +1 -0
- package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +28 -0
- package/dist/src/hooks/ImageResolver/index.js +1 -0
- package/dist/src/hooks/ImageResolver/useImageResolver.js +45 -0
- package/dist/src/hooks/Intersection/index.js +1 -0
- package/dist/src/hooks/Intersection/useIntersection.js +20 -0
- package/dist/src/hooks/IsSmallScreen/index.js +1 -0
- package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +16 -0
- package/dist/src/hooks/LocalStorageOperations/index.js +1 -0
- package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +64 -0
- package/dist/src/hooks/MessageFilter/index.js +1 -0
- package/dist/src/hooks/MessageFilter/useMessageFilter.js +37 -0
- package/dist/src/hooks/MessageScrollObserver/index.js +1 -0
- package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +35 -0
- package/dist/src/hooks/NewOrgConfig/index.js +1 -0
- package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +5 -0
- package/dist/src/hooks/Search/index.js +1 -0
- package/dist/src/hooks/Search/useRecommendedProducts.js +35 -0
- package/dist/src/hooks/Search/useSearch.js +224 -0
- package/dist/src/hooks/Search/useSearchInput.js +192 -0
- package/dist/src/hooks/SearchOperations/index.js +1 -0
- package/dist/src/hooks/SearchOperations/useSearchOperations.js +78 -0
- package/dist/src/hooks/SessionStorageOperations/index.js +1 -0
- package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +20 -0
- package/dist/src/hooks/ShopifyUrlOperations/index.js +1 -0
- package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +34 -0
- package/dist/src/hooks/SnapCalculator/index.js +1 -0
- package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +22 -0
- package/dist/src/hooks/SystemSettingsContext/index.js +1 -0
- package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +9 -0
- package/dist/src/hooks/TrackComponentVisibleEvent/index.js +1 -0
- package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +45 -0
- package/dist/src/hooks/UpdateAnalyticsProps/index.js +1 -0
- package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +43 -0
- package/dist/src/hooks/utils.js +116 -0
- package/dist/src/interceptors/index.js +1 -0
- package/dist/src/interceptors/useMessageInterceptor.js +24 -0
- package/dist/src/types/ApiResponse.js +1 -0
- package/dist/src/types/FilterAttribute.js +3 -0
- package/dist/src/types/Message.js +24 -0
- package/dist/src/types/Suggestion.js +3 -0
- package/dist/src/types/index.js +4 -0
- package/dist/src/util/colorVar.js +3 -0
- package/dist/src/util/configVersion.js +4 -0
- package/dist/src/util/domInsertion.js +16 -0
- package/dist/{systemSettingsContext-CYce8iqH.cjs → systemSettingsContext-068vQuP2.cjs} +2 -2
- package/dist/{systemSettingsContext-D9BZ9EwQ.js → systemSettingsContext-DPdDfVhj.js} +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/{urlsParser-C-Vzs--G.cjs → urlsParser-bb8ciRFg.cjs} +1 -1
- package/dist/{urlsParser-G7Ocwg0M.js → urlsParser-v_1DKvyf.js} +1 -1
- package/dist/{useAppDetails-CSpw8teP.js → useAppDetails-BPXln8UE.js} +4 -4
- package/dist/{useAppDetails-DNG_-DI9.cjs → useAppDetails-eP2hBuid.cjs} +7 -7
- package/dist/{useGraphQLConfig-D1REGfFB.js → useGraphQLConfig-Btszi6cG.js} +2 -2
- package/dist/{useGraphQLConfig-CKtaLlQ-.cjs → useGraphQLConfig-v9veUbvJ.cjs} +2 -2
- package/dist/{useIntersection-BQMfiS4x.cjs → useIntersection-BcBCa890.cjs} +1 -1
- package/dist/{useIntersection-D-ol9eH8.js → useIntersection-BkMkuJcZ.js} +1 -1
- package/dist/{utils-sosM0bEk.d.ts → utils-BitIIghf.d.ts} +1 -1
- package/dist/{utils-hYTjy7hJ.cjs → utils-CJk5iwQI.cjs} +1 -1
- package/dist/utils-CWzuvlOR.js +607 -0
- package/dist/{utils-BBICrPjW.cjs → utils-CqVRbvfN.cjs} +1 -1
- package/dist/{utils-w4-xONRA.js → utils-DQhbbAnt.js} +1 -1
- package/dist/{utils-D_kATUj6.js → utils-D_nGHczN.js} +1 -1
- package/dist/utils-SjlIHajO.cjs +716 -0
- package/package.json +1 -1
- package/src/application/commerce-api.ts +2 -0
- package/src/application/utils/analyticsUtils.ts +31 -16
- package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -1
- package/src/atoms/chat/chatState.ts +12 -7
- package/src/atoms/chat/replies.ts +42 -40
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +116 -130
- package/dist/amplitudeContext-CMTvCsJC.d.ts +0 -52
- package/dist/amplitudeContext-ZkerrMUa.d.cts +0 -52
- package/dist/amplitudeTrackEventAtom-D9vs8dpE.cjs +0 -15
- package/dist/amplitudeTrackEventAtom-iEIu11Om.js +0 -8
- package/dist/chat-ChCtIEwh.js +0 -227
- package/dist/chatState-BYB77nbx.cjs +0 -120
- package/dist/chatState-CzH7APPP.js +0 -34
- package/dist/org-C2kLSSe9.cjs +0 -111
- package/dist/org-CIczyLRP.js +0 -32
- package/dist/utils-DGpMn2pp.js +0 -1364
- package/dist/utils-DqxtxrFe.cjs +0 -1546
- /package/dist/{featureFlagServiceContext-DgoR6euC.js → featureFlagServiceContext-CISyb90N.js} +0 -0
- /package/dist/{featureFlagServiceContext-b-rYgf0u.cjs → featureFlagServiceContext-Csgo-MUv.cjs} +0 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { createPortal } from 'react-dom';
|
|
2
|
+
import { MutationHelper } from './mutationHelper';
|
|
3
|
+
/**
|
|
4
|
+
* The `ElementObserver` class monitors all changes related to the specific element it is responsible for.
|
|
5
|
+
* It is automatically instantiated by the `useElementObserver` hook, which manages all instances of this class.
|
|
6
|
+
*
|
|
7
|
+
* How it works:
|
|
8
|
+
*
|
|
9
|
+
* Each instance of `ElementObserver` holds several pieces of information related to the node it is monitoring,
|
|
10
|
+
* such as the node's selector and its `MutationObserver`. This class is responsible for translating raw node
|
|
11
|
+
* changes into a more user-friendly format. For example, when the node is added to the DOM, the `ElementObserver`
|
|
12
|
+
* is notified by the `DOMObserver`, which triggers the `onAdd` callback function on the respective `useElementObserver`
|
|
13
|
+
* instance.
|
|
14
|
+
*
|
|
15
|
+
* Instances of `ElementObserver` are fully managed by the `useElementObserver` hook, requiring no additional configuration.
|
|
16
|
+
* When the hook is destroyed, its corresponding `ElementObserver` instance is automatically removed.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export class ElementObserver {
|
|
20
|
+
constructor(selector) {
|
|
21
|
+
this.selector = selector;
|
|
22
|
+
this.mutation = null;
|
|
23
|
+
this.node = null;
|
|
24
|
+
this.eventListeners = new Map();
|
|
25
|
+
this.classAdded = new Map();
|
|
26
|
+
this.classRemoved = new Map();
|
|
27
|
+
this.nodeDisplay = 'block';
|
|
28
|
+
this.addFn = () => { };
|
|
29
|
+
this.removeFn = () => { };
|
|
30
|
+
this.changeFn = () => { };
|
|
31
|
+
this.classChangeFn = () => { };
|
|
32
|
+
this.addChildFn = undefined;
|
|
33
|
+
this.removeChildFn = undefined;
|
|
34
|
+
this.resetFn = () => { };
|
|
35
|
+
}
|
|
36
|
+
handleAttributes(mutationRecord) {
|
|
37
|
+
mutationRecord.filter(MutationHelper.isClass).forEach((mutation) => {
|
|
38
|
+
MutationHelper.fireClassChange(mutation, this.node, this.classChangeFn);
|
|
39
|
+
MutationHelper.fireClassAdded(mutation, this.node, this.classAdded);
|
|
40
|
+
MutationHelper.fireClassRemoved(mutation, this.node, this.classRemoved);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
handleChildList(mutationRecord) {
|
|
44
|
+
if (!this.addChildFn && !this.removeChildFn) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
mutationRecord.filter(MutationHelper.isChildList).forEach((mutation) => {
|
|
48
|
+
MutationHelper.fireSubtreeChange(mutation.addedNodes, this.addChildFn);
|
|
49
|
+
MutationHelper.fireSubtreeChange(mutation.removedNodes, this.removeChildFn);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
addInitialListeners() {
|
|
53
|
+
this.eventListeners.forEach((v, k) => { var _a; return (_a = this.node) === null || _a === void 0 ? void 0 : _a.addEventListener(k, v); });
|
|
54
|
+
}
|
|
55
|
+
clearEventListeners() {
|
|
56
|
+
this.eventListeners.forEach((v, k) => { var _a; return (_a = this.node) === null || _a === void 0 ? void 0 : _a.removeEventListener(k, v); });
|
|
57
|
+
this.eventListeners.clear();
|
|
58
|
+
}
|
|
59
|
+
renew(newNode) {
|
|
60
|
+
if (newNode) {
|
|
61
|
+
this.destroy();
|
|
62
|
+
this.watch(newNode);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
getSelector() {
|
|
66
|
+
return this.selector;
|
|
67
|
+
}
|
|
68
|
+
getNode() {
|
|
69
|
+
return this.node;
|
|
70
|
+
}
|
|
71
|
+
synchronize() {
|
|
72
|
+
const parsedNode = this.getSelector().parse();
|
|
73
|
+
if (this.getNode() !== parsedNode) {
|
|
74
|
+
this.renew(parsedNode);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!this.getNode() && parsedNode) {
|
|
78
|
+
this.watch(parsedNode);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (this.getNode() && !parsedNode) {
|
|
82
|
+
this.destroy();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
init() {
|
|
86
|
+
const node = this.getSelector().parse();
|
|
87
|
+
if (node) {
|
|
88
|
+
this.watch(node);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
watch(node) {
|
|
92
|
+
if (!this.mutation) {
|
|
93
|
+
this.mutation = new MutationObserver((mutationRecord) => {
|
|
94
|
+
this.handleAttributes(mutationRecord);
|
|
95
|
+
this.handleChildList(mutationRecord);
|
|
96
|
+
this.changeFn(this.node);
|
|
97
|
+
});
|
|
98
|
+
this.mutation.observe(node, {
|
|
99
|
+
childList: true,
|
|
100
|
+
subtree: true,
|
|
101
|
+
attributes: true,
|
|
102
|
+
attributeOldValue: true,
|
|
103
|
+
});
|
|
104
|
+
this.node = node;
|
|
105
|
+
this.addFn(this.node);
|
|
106
|
+
this.addInitialListeners();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
destroy() {
|
|
110
|
+
var _a;
|
|
111
|
+
this.resetFn();
|
|
112
|
+
this.removeFn(this.node);
|
|
113
|
+
(_a = this.mutation) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
114
|
+
this.clearEventListeners();
|
|
115
|
+
this.classAdded.clear();
|
|
116
|
+
this.classRemoved.clear();
|
|
117
|
+
this.mutation = null;
|
|
118
|
+
this.node = null;
|
|
119
|
+
}
|
|
120
|
+
render(fn) {
|
|
121
|
+
if (this.node) {
|
|
122
|
+
return createPortal(fn(), this.node);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
fire(event) {
|
|
126
|
+
if (this.node) {
|
|
127
|
+
this.node.dispatchEvent(new MouseEvent(event, {
|
|
128
|
+
bubbles: true,
|
|
129
|
+
cancelable: true,
|
|
130
|
+
view: window,
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
show() {
|
|
135
|
+
var _a;
|
|
136
|
+
const display = (_a = this.node) === null || _a === void 0 ? void 0 : _a.style.display;
|
|
137
|
+
if (this.node && display === 'none') {
|
|
138
|
+
this.node.style.display = this.nodeDisplay || 'block';
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
hide() {
|
|
142
|
+
var _a;
|
|
143
|
+
const display = (_a = this.node) === null || _a === void 0 ? void 0 : _a.style.display;
|
|
144
|
+
if (this.node && display !== 'none') {
|
|
145
|
+
this.nodeDisplay = display || 'block';
|
|
146
|
+
this.node.style.display = 'none';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
registerEvent(event, fn) {
|
|
150
|
+
if (this.node) {
|
|
151
|
+
const previousFn = this.eventListeners.get(event);
|
|
152
|
+
if (previousFn) {
|
|
153
|
+
this.node.removeEventListener(event, previousFn);
|
|
154
|
+
}
|
|
155
|
+
this.node.addEventListener(event, fn);
|
|
156
|
+
}
|
|
157
|
+
this.eventListeners.set(event, fn);
|
|
158
|
+
}
|
|
159
|
+
registerOnReset(fn) {
|
|
160
|
+
this.resetFn = fn;
|
|
161
|
+
}
|
|
162
|
+
registerOnChange(fn) {
|
|
163
|
+
this.changeFn = fn;
|
|
164
|
+
}
|
|
165
|
+
registerOnAdd(fn) {
|
|
166
|
+
this.addFn = fn;
|
|
167
|
+
}
|
|
168
|
+
registerOnRemove(fn) {
|
|
169
|
+
this.removeFn = fn;
|
|
170
|
+
}
|
|
171
|
+
registerOnclassChange(fn) {
|
|
172
|
+
this.classChangeFn = fn;
|
|
173
|
+
}
|
|
174
|
+
registerOnAddChild(fn) {
|
|
175
|
+
this.addChildFn = fn;
|
|
176
|
+
}
|
|
177
|
+
registerOnRemoveChild(fn) {
|
|
178
|
+
this.removeChildFn = fn;
|
|
179
|
+
}
|
|
180
|
+
registerOnClassAdded(className, fn) {
|
|
181
|
+
this.classAdded.set(className, fn);
|
|
182
|
+
}
|
|
183
|
+
registerOnClassRemoved(className, fn) {
|
|
184
|
+
this.classRemoved.set(className, fn);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MessageType } from '@envive-ai/types';
|
|
2
|
+
export const getRecentProductImageUrls = (lastMessages, currentProductId) => {
|
|
3
|
+
const productMessages = lastMessages
|
|
4
|
+
.filter((message) => { var _a; return message.type === MessageType.Product && ((_a = message.metadata) === null || _a === void 0 ? void 0 : _a.imageUrl); })
|
|
5
|
+
.map((m) => m);
|
|
6
|
+
// put added product image at the top of the list
|
|
7
|
+
return [
|
|
8
|
+
...productMessages.filter((m) => { var _a; return ((_a = m.metadata) === null || _a === void 0 ? void 0 : _a.id) === currentProductId; }),
|
|
9
|
+
...productMessages.filter((m) => { var _a; return ((_a = m.metadata) === null || _a === void 0 ? void 0 : _a.id) !== currentProductId; }),
|
|
10
|
+
].map((m) => m.metadata.imageUrl);
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// utils
|
|
2
|
+
export * from './analyticsUtils';
|
|
3
|
+
export * from './coreContextToApiContext';
|
|
4
|
+
export * from './coreUserEventToApiUserEvent';
|
|
5
|
+
export * from './divideArray';
|
|
6
|
+
export * from './domObserver';
|
|
7
|
+
export * from './elementObserver';
|
|
8
|
+
export * from './imageFilter';
|
|
9
|
+
export * from './merchantUtils';
|
|
10
|
+
export * from './messageFromFormSubmittedEvent';
|
|
11
|
+
export * from './messageFromQueryEvent';
|
|
12
|
+
export * from './messageFromResponse';
|
|
13
|
+
export * from './messageFromSuggestionEvent';
|
|
14
|
+
export * from './mutationHelper';
|
|
15
|
+
export * from './nextMessageRequestToApiRequest';
|
|
16
|
+
export * from './nodeSelector';
|
|
17
|
+
export * from './overrides';
|
|
18
|
+
export * from './stringUtils';
|
|
19
|
+
export * from './supportedEventRequestToApiRequest';
|
|
20
|
+
export * from './urlsParser';
|
|
21
|
+
export * from './validation';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const prepareMerchantPage = () => {
|
|
2
|
+
let metaViewport = document.querySelector("meta[name='viewport']");
|
|
3
|
+
if (metaViewport) {
|
|
4
|
+
const content = metaViewport.getAttribute("content");
|
|
5
|
+
const hasMaximumScale = content === null || content === void 0 ? void 0 : content.includes("maximum-scale=1");
|
|
6
|
+
if (!hasMaximumScale) {
|
|
7
|
+
metaViewport.setAttribute("content", `${content}, maximum-scale=1`);
|
|
8
|
+
}
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
metaViewport = document.createElement("meta");
|
|
12
|
+
metaViewport.setAttribute("name", "viewport");
|
|
13
|
+
metaViewport.setAttribute("content", "width=device-width, initial-scale=1, maximum-scale=1");
|
|
14
|
+
document.head.appendChild(metaViewport);
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
2
|
+
import { MessageRole, MessageType, } from '@envive-ai/types';
|
|
3
|
+
export const messageFromFormSubmittedEvent = (event, formResponseAttributes) => {
|
|
4
|
+
if (event.category !== UserEventCategory.FormSubmitted) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const formStringContents = Object.entries(formResponseAttributes.schema.properties)
|
|
8
|
+
.map(([key, value]) => `${value.title}: ${event.attributes.filledSchema[key]}`)
|
|
9
|
+
.join('\n');
|
|
10
|
+
return {
|
|
11
|
+
id: event.eventId,
|
|
12
|
+
role: MessageRole.User,
|
|
13
|
+
type: MessageType.QueryTyped,
|
|
14
|
+
createdAt: event.createdAt,
|
|
15
|
+
metadata: {
|
|
16
|
+
content: formStringContents,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MessageRole, MessageType } from '@envive-ai/types';
|
|
2
|
+
import { UserEventCategory } from '@spiffy-ai/commerce-api-client';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a query UserEvent object into a Message object for presentation.
|
|
5
|
+
*
|
|
6
|
+
* @param event The user event object received from the server
|
|
7
|
+
*
|
|
8
|
+
* @returns A Message if the event is a query event, otherwise undefined
|
|
9
|
+
*/
|
|
10
|
+
export const messageFromQueryEvent = (event) => {
|
|
11
|
+
if (event.category === UserEventCategory.QueryTyped) {
|
|
12
|
+
return {
|
|
13
|
+
id: event.eventId,
|
|
14
|
+
role: MessageRole.User,
|
|
15
|
+
type: MessageType.QueryTyped,
|
|
16
|
+
createdAt: event.createdAt,
|
|
17
|
+
metadata: {
|
|
18
|
+
content: event.attributes.query,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (event.category === UserEventCategory.Search) {
|
|
23
|
+
return {
|
|
24
|
+
id: event.eventId,
|
|
25
|
+
role: MessageRole.User,
|
|
26
|
+
type: MessageType.Search,
|
|
27
|
+
createdAt: event.createdAt,
|
|
28
|
+
metadata: {
|
|
29
|
+
searchTerm: event.attributes.searchTerm || '',
|
|
30
|
+
selectedFilters: event.attributes.selectedFilters || [],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { MessageType, MessageRole } from "src/types";
|
|
2
|
+
import { ResponseCategory } from "@spiffy-ai/commerce-api-client";
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a server Response object into a Message object for presentation.
|
|
5
|
+
*
|
|
6
|
+
* @param response The response object received from the server containing model generated content
|
|
7
|
+
*
|
|
8
|
+
* @returns A Message if the response contains known attributes, undefined otherwise
|
|
9
|
+
*/
|
|
10
|
+
export const messageFromResponse = (response) => {
|
|
11
|
+
var _a;
|
|
12
|
+
if (response == null) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
if (response.category === ResponseCategory.Text) {
|
|
16
|
+
return {
|
|
17
|
+
id: response.id,
|
|
18
|
+
createdAt: response.createdAt,
|
|
19
|
+
type: MessageType.Text,
|
|
20
|
+
role: MessageRole.Assistant,
|
|
21
|
+
metadata: {
|
|
22
|
+
content: response.attributes.content,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (response.category === ResponseCategory.Product) {
|
|
27
|
+
return {
|
|
28
|
+
id: response.id,
|
|
29
|
+
createdAt: response.createdAt,
|
|
30
|
+
role: MessageRole.Assistant,
|
|
31
|
+
type: MessageType.Product,
|
|
32
|
+
metadata: {
|
|
33
|
+
...response.attributes,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (response.category === ResponseCategory.Review) {
|
|
38
|
+
return {
|
|
39
|
+
id: response.id,
|
|
40
|
+
createdAt: response.createdAt,
|
|
41
|
+
type: MessageType.Review,
|
|
42
|
+
role: MessageRole.Assistant,
|
|
43
|
+
metadata: {
|
|
44
|
+
review: response.attributes.review,
|
|
45
|
+
reviewer: response.attributes.reviewer,
|
|
46
|
+
stars: response.attributes.stars,
|
|
47
|
+
title: response.attributes.title,
|
|
48
|
+
richInformation: response.attributes.richInformation,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (response.category === ResponseCategory.Separator) {
|
|
53
|
+
return {
|
|
54
|
+
id: response.id,
|
|
55
|
+
createdAt: response.createdAt,
|
|
56
|
+
type: MessageType.Separator,
|
|
57
|
+
role: MessageRole.Assistant,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (response.category === ResponseCategory.Page) {
|
|
61
|
+
return {
|
|
62
|
+
id: response.id,
|
|
63
|
+
createdAt: response.createdAt,
|
|
64
|
+
role: MessageRole.Assistant,
|
|
65
|
+
type: MessageType.Page,
|
|
66
|
+
metadata: {
|
|
67
|
+
...response.attributes,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (response.category === ResponseCategory.ProductSearch) {
|
|
72
|
+
return {
|
|
73
|
+
id: response.id,
|
|
74
|
+
createdAt: response.createdAt,
|
|
75
|
+
role: MessageRole.Assistant,
|
|
76
|
+
type: MessageType.ProductSearch,
|
|
77
|
+
metadata: {
|
|
78
|
+
...response.attributes,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (response.category === ResponseCategory.ProductSearchFilter) {
|
|
83
|
+
return {
|
|
84
|
+
id: response.id,
|
|
85
|
+
createdAt: response.createdAt,
|
|
86
|
+
role: MessageRole.Assistant,
|
|
87
|
+
type: MessageType.ProductSearchFilter,
|
|
88
|
+
metadata: {
|
|
89
|
+
...response.attributes,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (response.category === ResponseCategory.Form) {
|
|
94
|
+
return {
|
|
95
|
+
id: response.id,
|
|
96
|
+
createdAt: response.createdAt,
|
|
97
|
+
role: MessageRole.Assistant,
|
|
98
|
+
type: MessageType.Form,
|
|
99
|
+
metadata: {
|
|
100
|
+
formType: (_a = response.attributes.formCategory) === null || _a === void 0 ? void 0 : _a.formType,
|
|
101
|
+
fields: Object.entries(response.attributes.schema.properties).map(([key, value]) => ({
|
|
102
|
+
key,
|
|
103
|
+
title: value.title,
|
|
104
|
+
type: value.type,
|
|
105
|
+
format: value.format,
|
|
106
|
+
required: response.attributes.schema.required.includes(key),
|
|
107
|
+
})),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (response.category === ResponseCategory.Order) {
|
|
112
|
+
return {
|
|
113
|
+
id: response.id,
|
|
114
|
+
createdAt: response.createdAt,
|
|
115
|
+
role: MessageRole.Assistant,
|
|
116
|
+
type: MessageType.Order,
|
|
117
|
+
metadata: {
|
|
118
|
+
...response.attributes,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MessageRole, MessageType } from "src/types";
|
|
2
|
+
import { UserEventCategory } from "@spiffy-ai/commerce-api-client";
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a UserEvent object into a Message object for presentation.
|
|
5
|
+
*
|
|
6
|
+
* @param event The UserEvent object received from the server
|
|
7
|
+
* @param suggestions A list of generated suggestions to match the event to
|
|
8
|
+
*
|
|
9
|
+
* @returns A Message if the event is a suggestion click event, undefined otherwise
|
|
10
|
+
*/
|
|
11
|
+
export const messageFromSuggestionEvent = (event, suggestions) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
if (event.category === UserEventCategory.SuggestionClicked) {
|
|
14
|
+
const { suggestionId } = event.attributes;
|
|
15
|
+
return {
|
|
16
|
+
id: event.eventId,
|
|
17
|
+
role: MessageRole.User,
|
|
18
|
+
type: MessageType.SuggestionClicked,
|
|
19
|
+
createdAt: event.createdAt,
|
|
20
|
+
metadata: {
|
|
21
|
+
suggestionId,
|
|
22
|
+
suggestionContent: (_b = (_a = suggestions.find((s) => s.id === suggestionId)) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : "",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const compareTokens = (original, comparison) => {
|
|
2
|
+
const originalTokens = new Set(original.split(' '));
|
|
3
|
+
const comparisonTokens = new Set(comparison.split(' '));
|
|
4
|
+
return [...originalTokens].filter((token) => !comparisonTokens.has(token));
|
|
5
|
+
};
|
|
6
|
+
export class MutationHelper {
|
|
7
|
+
static fireClassChange(record, node, fn) {
|
|
8
|
+
if (node && record.oldValue !== (node === null || node === void 0 ? void 0 : node.classList.value)) {
|
|
9
|
+
fn(node === null || node === void 0 ? void 0 : node.classList);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
static fireClassAdded(record, node, classMap) {
|
|
13
|
+
if (node && record.oldValue) {
|
|
14
|
+
const tokens = compareTokens(node === null || node === void 0 ? void 0 : node.classList.value, record.oldValue);
|
|
15
|
+
tokens.forEach((className) => { var _a; return (_a = classMap.get(className)) === null || _a === void 0 ? void 0 : _a(); });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
static fireClassRemoved(record, node, classMap) {
|
|
19
|
+
if (node && record.oldValue) {
|
|
20
|
+
const tokens = compareTokens(record.oldValue, node === null || node === void 0 ? void 0 : node.classList.value);
|
|
21
|
+
tokens.forEach((className) => { var _a; return (_a = classMap.get(className)) === null || _a === void 0 ? void 0 : _a(); });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
static fireSubtreeChange(nodes, fn) {
|
|
25
|
+
nodes.length && (fn === null || fn === void 0 ? void 0 : fn(nodes));
|
|
26
|
+
}
|
|
27
|
+
static isClass(mutation) {
|
|
28
|
+
return mutation.type === 'attributes' && mutation.attributeName === 'class';
|
|
29
|
+
}
|
|
30
|
+
static isChildList(mutation) {
|
|
31
|
+
return mutation.type === 'childList';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { coreUserEventToApiUserEvent } from './coreUserEventToApiUserEvent';
|
|
2
|
+
export const messageRequestToCommerceMessageRequest = (data) => {
|
|
3
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
4
|
+
return ({
|
|
5
|
+
context: {
|
|
6
|
+
chat_id: data.context.chatId,
|
|
7
|
+
org_id: data.context.orgId,
|
|
8
|
+
org_short_name: data.context.orgShortName,
|
|
9
|
+
user_id: data.context.userId,
|
|
10
|
+
source: data.context.source,
|
|
11
|
+
env: data.context.env,
|
|
12
|
+
},
|
|
13
|
+
id: data.id,
|
|
14
|
+
feature_flags: data.featureFlags,
|
|
15
|
+
user_events: (_a = data.userEvents) === null || _a === void 0 ? void 0 : _a.map((userEvent) => coreUserEventToApiUserEvent(userEvent)),
|
|
16
|
+
generation_params: {
|
|
17
|
+
model: (_b = data.generationParams) === null || _b === void 0 ? void 0 : _b.model,
|
|
18
|
+
max_tokens: (_c = data.generationParams) === null || _c === void 0 ? void 0 : _c.maxTokens,
|
|
19
|
+
stop: (_d = data.generationParams) === null || _d === void 0 ? void 0 : _d.stop,
|
|
20
|
+
stream: (_e = data.generationParams) === null || _e === void 0 ? void 0 : _e.stream,
|
|
21
|
+
temperature: (_f = data.generationParams) === null || _f === void 0 ? void 0 : _f.temperature,
|
|
22
|
+
top_p: (_g = data.generationParams) === null || _g === void 0 ? void 0 : _g.topP,
|
|
23
|
+
num_suggestions: (_h = data.generationParams) === null || _h === void 0 ? void 0 : _h.numSuggestions,
|
|
24
|
+
response_system_prompt: (_j = data.generationParams) === null || _j === void 0 ? void 0 : _j.responseSystemPrompt,
|
|
25
|
+
suggestion_system_prompt: (_k = data.generationParams) === null || _k === void 0 ? void 0 : _k.suggestionSystemPrompt,
|
|
26
|
+
response_caching: (_l = data.generationParams) === null || _l === void 0 ? void 0 : _l.responseCaching,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export class NodeSelector {
|
|
2
|
+
constructor(pattern) {
|
|
3
|
+
this.pattern = pattern;
|
|
4
|
+
this.root = document;
|
|
5
|
+
}
|
|
6
|
+
getPattern() {
|
|
7
|
+
return this.pattern;
|
|
8
|
+
}
|
|
9
|
+
setRoot(root) {
|
|
10
|
+
this.root = root;
|
|
11
|
+
}
|
|
12
|
+
getRoot() {
|
|
13
|
+
return this.root;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class QuerySelector extends NodeSelector {
|
|
17
|
+
parse() {
|
|
18
|
+
return this.getRoot().querySelector(this.getPattern());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class IDSelector extends NodeSelector {
|
|
22
|
+
parse() {
|
|
23
|
+
return this.getRoot().getElementById(this.getPattern());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class XpathSelector extends NodeSelector {
|
|
27
|
+
parse() {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
return (_b = (_a = this.getRoot()) === null || _a === void 0 ? void 0 : _a.evaluate(this.getPattern(), this.getRoot(), null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)) === null || _b === void 0 ? void 0 : _b.singleNodeValue;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class ChainSelector extends NodeSelector {
|
|
33
|
+
parse() {
|
|
34
|
+
let selectorIndex = 0;
|
|
35
|
+
const selectors = this.getPattern().split('@');
|
|
36
|
+
const lastIndex = selectors.length - 1;
|
|
37
|
+
const parseChain = (pattern, prevNode) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const selector = SelectorFactory.parse(pattern);
|
|
40
|
+
if (prevNode) {
|
|
41
|
+
selector.setRoot(prevNode);
|
|
42
|
+
}
|
|
43
|
+
const currentNode = selector.parse();
|
|
44
|
+
if (selectorIndex === lastIndex) {
|
|
45
|
+
return currentNode;
|
|
46
|
+
}
|
|
47
|
+
let node = currentNode || document;
|
|
48
|
+
if (currentNode === null || currentNode === void 0 ? void 0 : currentNode.shadowRoot) {
|
|
49
|
+
node = currentNode.shadowRoot;
|
|
50
|
+
}
|
|
51
|
+
if (currentNode === null || currentNode === void 0 ? void 0 : currentNode.contentWindow) {
|
|
52
|
+
node = (_a = currentNode.contentWindow) === null || _a === void 0 ? void 0 : _a.document;
|
|
53
|
+
}
|
|
54
|
+
return parseChain(selectors[++selectorIndex].trim(), node);
|
|
55
|
+
};
|
|
56
|
+
return parseChain(selectors[selectorIndex].trim());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class Empty extends NodeSelector {
|
|
60
|
+
constructor() {
|
|
61
|
+
super('');
|
|
62
|
+
}
|
|
63
|
+
parse() {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class SelectorFactory {
|
|
68
|
+
static parse(composedSelector) {
|
|
69
|
+
if (!composedSelector) {
|
|
70
|
+
return new Empty();
|
|
71
|
+
}
|
|
72
|
+
const split = composedSelector.split('|');
|
|
73
|
+
const type = split[0];
|
|
74
|
+
const selector = split[1];
|
|
75
|
+
switch (type) {
|
|
76
|
+
case 'id':
|
|
77
|
+
return this.id(selector);
|
|
78
|
+
case 'query':
|
|
79
|
+
return this.query(selector);
|
|
80
|
+
case 'xpath':
|
|
81
|
+
return this.xpath(selector);
|
|
82
|
+
default:
|
|
83
|
+
return new Empty();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
static check(selector) {
|
|
87
|
+
return selector !== null && selector !== void 0 ? selector : new Empty();
|
|
88
|
+
}
|
|
89
|
+
static chain(pattern) {
|
|
90
|
+
return pattern ? new ChainSelector(pattern) : new Empty();
|
|
91
|
+
}
|
|
92
|
+
static id(pattern) {
|
|
93
|
+
return pattern ? new IDSelector(pattern) : new Empty();
|
|
94
|
+
}
|
|
95
|
+
static query(pattern) {
|
|
96
|
+
return pattern ? new QuerySelector(pattern) : new Empty();
|
|
97
|
+
}
|
|
98
|
+
static xpath(pattern) {
|
|
99
|
+
return pattern ? new XpathSelector(pattern) : new Empty();
|
|
100
|
+
}
|
|
101
|
+
}
|