@envive-ai/react-widgets-v3 0.3.56 → 0.3.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/debug/GenericSelect.cjs +4 -1
  2. package/dist/debug/GenericSelect.js +3 -1
  3. package/dist/debug/chatEmbed.cjs +1 -1
  4. package/dist/debug/chatEmbed.js +1 -1
  5. package/dist/debug/reportIssue.cjs +7 -4
  6. package/dist/debug/reportIssue.js +6 -4
  7. package/dist/hocs/withBaseWidget/withBaseWidget.cjs +46 -4
  8. package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
  9. package/dist/hocs/withBaseWidget/withBaseWidget.js +45 -4
  10. package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
  11. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +6 -6
  12. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
  13. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
  14. package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +6 -6
  15. package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
  16. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +4 -4
  17. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
  18. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
  19. package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +4 -4
  20. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +5 -27
  21. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +2 -2
  22. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +2 -2
  23. package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +6 -28
  24. package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.cjs +1 -1
  25. package/dist/widgets/FloatingChatWidget/hooks/useAutoPopup.js +1 -1
  26. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
  27. package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
  28. package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +3 -3
  29. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
  30. package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
  31. package/dist/widgets/ProductCardWidget/ProductCardWidget.js +3 -3
  32. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +4 -4
  33. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
  34. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
  35. package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +4 -4
  36. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +4 -4
  37. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
  38. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
  39. package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +4 -4
  40. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
  41. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +2 -2
  42. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
  43. package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
  44. package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +6 -6
  45. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
  46. package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
  47. package/dist/widgets/SocialProofWidget/SocialProofWidget.js +6 -6
  48. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +2 -2
  49. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
  50. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
  51. package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +2 -2
  52. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +1 -1
  53. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
  54. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
  55. package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
  56. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +3 -3
  57. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
  58. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
  59. package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +3 -3
  60. package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
  61. package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
  62. package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
  63. package/dist/widgets/utils/functions.cjs +1 -1
  64. package/dist/widgets/utils/functions.js +1 -1
  65. package/package.json +1 -1
  66. package/src/debug/GenericSelect.tsx +4 -1
  67. package/src/debug/reportIssue.tsx +6 -3
  68. package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +235 -4
  69. package/src/hocs/withBaseWidget/withBaseWidget.tsx +71 -1
  70. package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +5 -1
  71. package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +19 -42
  72. package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +1 -1
  73. package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +6 -1
  74. package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +5 -1
  75. package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +3 -1
  76. package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +1 -1
  77. package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +5 -1
  78. package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +1 -1
  79. package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +5 -1
@@ -1,9 +1,12 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  let react = require("react");
3
3
  react = require_rolldown_runtime.__toESM(react);
4
+ let __envive_ai_react_hooks_application_logging = require("@envive-ai/react-hooks/application/logging");
5
+ __envive_ai_react_hooks_application_logging = require_rolldown_runtime.__toESM(__envive_ai_react_hooks_application_logging);
4
6
  let react_jsx_runtime = require("react/jsx-runtime");
5
7
 
6
8
  //#region src/debug/GenericSelect.tsx
9
+ const logger = new __envive_ai_react_hooks_application_logging.default("GenericSelect");
7
10
  const dictionaries = { priority: {
8
11
  p0: { label: "Urgent" },
9
12
  p1: { label: "High" },
@@ -114,7 +117,7 @@ function GenericSelect({ type, selectedKey, onSelect, buttonStyle = {}, menuStyl
114
117
  };
115
118
  }, [isOpen]);
116
119
  if (!dictionary) {
117
- console.error(`Invalid type "${type}".`);
120
+ logger.logError(`Invalid type "${type}".`, void 0);
118
121
  return null;
119
122
  }
120
123
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1,7 +1,9 @@
1
1
  import React, { useRef, useState } from "react";
2
+ import Logger from "@envive-ai/react-hooks/application/logging";
2
3
  import { jsx, jsxs } from "react/jsx-runtime";
3
4
 
4
5
  //#region src/debug/GenericSelect.tsx
6
+ const logger = new Logger("GenericSelect");
5
7
  const dictionaries = { priority: {
6
8
  p0: { label: "Urgent" },
7
9
  p1: { label: "High" },
@@ -112,7 +114,7 @@ function GenericSelect({ type, selectedKey, onSelect, buttonStyle = {}, menuStyl
112
114
  };
113
115
  }, [isOpen]);
114
116
  if (!dictionary) {
115
- console.error(`Invalid type "${type}".`);
117
+ logger.logError(`Invalid type "${type}".`, void 0);
116
118
  return null;
117
119
  }
118
120
  return /* @__PURE__ */ jsxs("div", {
@@ -3,10 +3,10 @@ const require_MessageContent = require('./MessageContent.cjs');
3
3
  let react = require("react");
4
4
  react = require_rolldown_runtime.__toESM(react);
5
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
+ let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
6
7
  let jotai = require("jotai");
7
8
  let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
8
9
  let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
9
- let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
10
10
  let classnames = require("classnames");
11
11
  classnames = require_rolldown_runtime.__toESM(classnames);
12
12
 
@@ -1,10 +1,10 @@
1
1
  import { MessageContent } from "./MessageContent.js";
2
2
  import React from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { chatAtom } from "@envive-ai/react-hooks/atoms/chat";
4
5
  import { useAtomValue } from "jotai";
5
6
  import { MessageType } from "@envive-ai/react-hooks/application/models";
6
7
  import { PromptCarousel, PromptCarouselRows } from "@envive-ai/react-toolkit-v3/PromptCarousel";
7
- import { chatAtom } from "@envive-ai/react-hooks/atoms/chat";
8
8
  import classNames from "classnames";
9
9
 
10
10
  //#region src/debug/chatEmbed.tsx
@@ -4,10 +4,12 @@ const require_IconCloseVariant = require('../packages/icons/dist/IconCloseVarian
4
4
  const require_GenericSelect = require('./GenericSelect.cjs');
5
5
  const require_chatEmbed = require('./chatEmbed.cjs');
6
6
  let react = require("react");
7
+ let __envive_ai_react_hooks_application_logging = require("@envive-ai/react-hooks/application/logging");
8
+ __envive_ai_react_hooks_application_logging = require_rolldown_runtime.__toESM(__envive_ai_react_hooks_application_logging);
7
9
  let react_jsx_runtime = require("react/jsx-runtime");
10
+ let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
8
11
  let jotai = require("jotai");
9
12
  let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
10
- let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
11
13
  let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/app");
12
14
  let classnames = require("classnames");
13
15
  classnames = require_rolldown_runtime.__toESM(classnames);
@@ -18,6 +20,7 @@ let __envive_ai_react_hooks_application_utils = require("@envive-ai/react-hooks/
18
20
 
19
21
  //#region src/debug/reportIssue.tsx
20
22
  var import_dist = require_index.default;
23
+ const logger = new __envive_ai_react_hooks_application_logging.default("reportIssue");
21
24
  const messageContent = (m) => {
22
25
  if (m.type === __envive_ai_react_hooks_application_models.MessageType.Text) return m.metadata.content;
23
26
  if (m.type === __envive_ai_react_hooks_application_models.MessageType.Product) return `PRODUCT ID: ${m.metadata?.id}`;
@@ -39,7 +42,7 @@ const ReportHeader = ({ onClose }) => {
39
42
  try {
40
43
  await navigator.clipboard.writeText(userId);
41
44
  } catch (err) {
42
- console.error("Failed to copy to clipboard:", err);
45
+ logger.logError("Failed to copy to clipboard", err);
43
46
  }
44
47
  }, [userId]);
45
48
  const headerTitleClassnames = (0, classnames.default)({
@@ -431,11 +434,11 @@ const ReportIssue = () => {
431
434
  turn_info: turnInfo,
432
435
  report_type: reportType
433
436
  };
434
- console.info("Submitting report", request);
437
+ logger.logInfo("Submitting report", request);
435
438
  await __envive_ai_react_hooks_application_commerce_api.default.reportSession(request);
436
439
  onClose();
437
440
  } catch (error) {
438
- console.error("Error sending report", error);
441
+ logger.logError("Error sending report", error);
439
442
  setErrorMessage("There was an error sending the report. Please try again or contact Envive Support.");
440
443
  } finally {
441
444
  setIsReporting(false);
@@ -2,10 +2,11 @@ import { IconCloseVariant_default } from "../packages/icons/dist/IconCloseVarian
2
2
  import { GenericSelect } from "./GenericSelect.js";
3
3
  import chatEmbed_default from "./chatEmbed.js";
4
4
  import { useCallback, useEffect, useState } from "react";
5
+ import Logger from "@envive-ai/react-hooks/application/logging";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
6
8
  import { useAtomValue } from "jotai";
7
9
  import { MessageType } from "@envive-ai/react-hooks/application/models";
8
- import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
9
10
  import { userIdAtom } from "@envive-ai/react-hooks/atoms/app";
10
11
  import { ReportSessionRequestReportPriorityEnum, ReportSessionRequestReportTypeEnum } from "@spiffy-ai/commerce-api-client";
11
12
  import classNames from "classnames";
@@ -14,6 +15,7 @@ import { orgShortNameAtom } from "@envive-ai/react-hooks/atoms/envive/enviveConf
14
15
  import { StringUtils, validateEmail } from "@envive-ai/react-hooks/application/utils";
15
16
 
16
17
  //#region src/debug/reportIssue.tsx
18
+ const logger = new Logger("reportIssue");
17
19
  const messageContent = (m) => {
18
20
  if (m.type === MessageType.Text) return m.metadata.content;
19
21
  if (m.type === MessageType.Product) return `PRODUCT ID: ${m.metadata?.id}`;
@@ -35,7 +37,7 @@ const ReportHeader = ({ onClose }) => {
35
37
  try {
36
38
  await navigator.clipboard.writeText(userId);
37
39
  } catch (err) {
38
- console.error("Failed to copy to clipboard:", err);
40
+ logger.logError("Failed to copy to clipboard", err);
39
41
  }
40
42
  }, [userId]);
41
43
  const headerTitleClassnames = classNames({
@@ -427,11 +429,11 @@ const ReportIssue = () => {
427
429
  turn_info: turnInfo,
428
430
  report_type: reportType
429
431
  };
430
- console.info("Submitting report", request);
432
+ logger.logInfo("Submitting report", request);
431
433
  await CommerceApiClient.reportSession(request);
432
434
  onClose();
433
435
  } catch (error) {
434
- console.error("Error sending report", error);
436
+ logger.logError("Error sending report", error);
435
437
  setErrorMessage("There was an error sending the report. Please try again or contact Envive Support.");
436
438
  } finally {
437
439
  setIsReporting(false);
@@ -1,5 +1,7 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
  let react = require("react");
3
+ let __envive_ai_react_hooks_application_logging = require("@envive-ai/react-hooks/application/logging");
4
+ __envive_ai_react_hooks_application_logging = require_rolldown_runtime.__toESM(__envive_ai_react_hooks_application_logging);
3
5
  let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
4
6
  let __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent = require("@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent");
5
7
  let __envive_ai_react_hooks_contexts_hardcopyContext = require("@envive-ai/react-hooks/contexts/hardcopyContext");
@@ -9,6 +11,8 @@ let __envive_ai_react_hooks_contexts_uiConfigContext = require("@envive-ai/react
9
11
  let react_jsx_runtime = require("react/jsx-runtime");
10
12
 
11
13
  //#region src/hocs/withBaseWidget/withBaseWidget.tsx
14
+ const logger = new __envive_ai_react_hooks_application_logging.default("withBaseWidget");
15
+ const WIDGET_LOADING_WATCHDOG_MS = 5e3;
12
16
  function withBaseWidget(Widget, options) {
13
17
  const WrappedWidget = (props) => {
14
18
  const { widgetConfigId, widgetType } = props;
@@ -22,7 +26,11 @@ function withBaseWidget(Widget, options) {
22
26
  const { getWidgetConfig, isLoading: isWidgetConfigLoading } = (0, __envive_ai_react_hooks_contexts_widgetConfigContext.useWidgetConfig)();
23
27
  const [uiConfig, setUiConfig] = (0, react.useState)(void 0);
24
28
  const { getUiConfig, isLoading: isUiConfigLoading } = (0, __envive_ai_react_hooks_contexts_uiConfigContext.useUiConfig)();
25
- const isLoading = isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading;
29
+ const [hardcopySettled, setHardcopySettled] = (0, react.useState)(false);
30
+ const [widgetConfigSettled, setWidgetConfigSettled] = (0, react.useState)(false);
31
+ const [uiConfigSettled, setUiConfigSettled] = (0, react.useState)(false);
32
+ const ownRequestsSettled = hardcopySettled && widgetConfigSettled && uiConfigSettled;
33
+ const isLoading = !ownRequestsSettled && (isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading);
26
34
  const { isVisible } = (0, __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent.useTrackComponentVisibleEvent)(widgetRef, {
27
35
  widget_config_id: widgetConfigId,
28
36
  widget_type: widgetType,
@@ -36,13 +44,43 @@ function withBaseWidget(Widget, options) {
36
44
  widgetConfigId,
37
45
  widgetType
38
46
  ]);
47
+ const settledStateRef = (0, react.useRef)({
48
+ hardcopy: false,
49
+ widgetConfig: false,
50
+ uiConfig: false
51
+ });
52
+ settledStateRef.current = {
53
+ hardcopy: hardcopySettled,
54
+ widgetConfig: widgetConfigSettled,
55
+ uiConfig: uiConfigSettled
56
+ };
57
+ (0, react.useEffect)(() => {
58
+ if (!startLoading || ownRequestsSettled) return;
59
+ const timer = setTimeout(() => {
60
+ const settled = settledStateRef.current;
61
+ logger.logError(`Widget still loading ${WIDGET_LOADING_WATCHDOG_MS}ms after fetches started`, void 0, {
62
+ widget_type: widgetType,
63
+ widget_config_id: widgetConfigId,
64
+ pending_requests: Object.entries(settled).filter(([, isSettled]) => !isSettled).map(([name]) => name),
65
+ connection_type: navigator.connection?.effectiveType
66
+ });
67
+ }, WIDGET_LOADING_WATCHDOG_MS);
68
+ return () => clearTimeout(timer);
69
+ }, [
70
+ startLoading,
71
+ ownRequestsSettled,
72
+ widgetConfigId,
73
+ widgetType
74
+ ]);
39
75
  (0, react.useEffect)(() => {
40
76
  if (!startLoading || hardcopyFetchedRef.current) return;
41
77
  hardcopyFetchedRef.current = true;
42
78
  getHardcopy({
43
79
  widgetType,
44
80
  userEvent
45
- }).then(setHardcopyContent).catch(() => {});
81
+ }).then(setHardcopyContent).catch(() => {}).finally(() => {
82
+ setHardcopySettled(true);
83
+ });
46
84
  }, [
47
85
  startLoading,
48
86
  widgetType,
@@ -52,7 +90,9 @@ function withBaseWidget(Widget, options) {
52
90
  ]);
53
91
  (0, react.useEffect)(() => {
54
92
  if (!startLoading) return;
55
- getUiConfig().then(setUiConfig).catch(() => {});
93
+ getUiConfig().then(setUiConfig).catch(() => {}).finally(() => {
94
+ setUiConfigSettled(true);
95
+ });
56
96
  }, [
57
97
  startLoading,
58
98
  getUiConfig,
@@ -64,7 +104,9 @@ function withBaseWidget(Widget, options) {
64
104
  getWidgetConfig({
65
105
  widgetConfigId,
66
106
  widgetType
67
- }).then(setWidgetConfig).catch(() => {});
107
+ }).then(setWidgetConfig).catch(() => {}).finally(() => {
108
+ setWidgetConfigSettled(true);
109
+ });
68
110
  }, [
69
111
  startLoading,
70
112
  widgetConfigId,
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.cjs";
2
- import * as react_jsx_runtime8 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime6 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/hocs/withBaseWidget/withBaseWidget.d.ts
5
5
  declare function withBaseWidget<P extends BaseWidgetProps>(Widget: React.ComponentType<P>, options?: WithBaseWidgetOptions): {
6
- (props: P): react_jsx_runtime8.JSX.Element;
6
+ (props: P): react_jsx_runtime6.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  //#endregion
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useMemo, useRef, useState } from "react";
2
+ import Logger from "@envive-ai/react-hooks/application/logging";
2
3
  import { useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
3
4
  import { useTrackComponentVisibleEvent } from "@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent";
4
5
  import { useHardcopy } from "@envive-ai/react-hooks/contexts/hardcopyContext";
@@ -8,6 +9,8 @@ import { useUiConfig } from "@envive-ai/react-hooks/contexts/uiConfigContext";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
 
10
11
  //#region src/hocs/withBaseWidget/withBaseWidget.tsx
12
+ const logger = new Logger("withBaseWidget");
13
+ const WIDGET_LOADING_WATCHDOG_MS = 5e3;
11
14
  function withBaseWidget(Widget, options) {
12
15
  const WrappedWidget = (props) => {
13
16
  const { widgetConfigId, widgetType } = props;
@@ -21,7 +24,11 @@ function withBaseWidget(Widget, options) {
21
24
  const { getWidgetConfig, isLoading: isWidgetConfigLoading } = useWidgetConfig();
22
25
  const [uiConfig, setUiConfig] = useState(void 0);
23
26
  const { getUiConfig, isLoading: isUiConfigLoading } = useUiConfig();
24
- const isLoading = isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading;
27
+ const [hardcopySettled, setHardcopySettled] = useState(false);
28
+ const [widgetConfigSettled, setWidgetConfigSettled] = useState(false);
29
+ const [uiConfigSettled, setUiConfigSettled] = useState(false);
30
+ const ownRequestsSettled = hardcopySettled && widgetConfigSettled && uiConfigSettled;
31
+ const isLoading = !ownRequestsSettled && (isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading);
25
32
  const { isVisible } = useTrackComponentVisibleEvent(widgetRef, {
26
33
  widget_config_id: widgetConfigId,
27
34
  widget_type: widgetType,
@@ -35,13 +42,43 @@ function withBaseWidget(Widget, options) {
35
42
  widgetConfigId,
36
43
  widgetType
37
44
  ]);
45
+ const settledStateRef = useRef({
46
+ hardcopy: false,
47
+ widgetConfig: false,
48
+ uiConfig: false
49
+ });
50
+ settledStateRef.current = {
51
+ hardcopy: hardcopySettled,
52
+ widgetConfig: widgetConfigSettled,
53
+ uiConfig: uiConfigSettled
54
+ };
55
+ useEffect(() => {
56
+ if (!startLoading || ownRequestsSettled) return;
57
+ const timer = setTimeout(() => {
58
+ const settled = settledStateRef.current;
59
+ logger.logError(`Widget still loading ${WIDGET_LOADING_WATCHDOG_MS}ms after fetches started`, void 0, {
60
+ widget_type: widgetType,
61
+ widget_config_id: widgetConfigId,
62
+ pending_requests: Object.entries(settled).filter(([, isSettled]) => !isSettled).map(([name]) => name),
63
+ connection_type: navigator.connection?.effectiveType
64
+ });
65
+ }, WIDGET_LOADING_WATCHDOG_MS);
66
+ return () => clearTimeout(timer);
67
+ }, [
68
+ startLoading,
69
+ ownRequestsSettled,
70
+ widgetConfigId,
71
+ widgetType
72
+ ]);
38
73
  useEffect(() => {
39
74
  if (!startLoading || hardcopyFetchedRef.current) return;
40
75
  hardcopyFetchedRef.current = true;
41
76
  getHardcopy({
42
77
  widgetType,
43
78
  userEvent
44
- }).then(setHardcopyContent).catch(() => {});
79
+ }).then(setHardcopyContent).catch(() => {}).finally(() => {
80
+ setHardcopySettled(true);
81
+ });
45
82
  }, [
46
83
  startLoading,
47
84
  widgetType,
@@ -51,7 +88,9 @@ function withBaseWidget(Widget, options) {
51
88
  ]);
52
89
  useEffect(() => {
53
90
  if (!startLoading) return;
54
- getUiConfig().then(setUiConfig).catch(() => {});
91
+ getUiConfig().then(setUiConfig).catch(() => {}).finally(() => {
92
+ setUiConfigSettled(true);
93
+ });
55
94
  }, [
56
95
  startLoading,
57
96
  getUiConfig,
@@ -63,7 +102,9 @@ function withBaseWidget(Widget, options) {
63
102
  getWidgetConfig({
64
103
  widgetConfigId,
65
104
  widgetType
66
- }).then(setWidgetConfig).catch(() => {});
105
+ }).then(setWidgetConfig).catch(() => {}).finally(() => {
106
+ setWidgetConfigSettled(true);
107
+ });
67
108
  }, [
68
109
  startLoading,
69
110
  widgetConfigId,
@@ -1,8 +1,8 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
2
2
 
3
3
  //#region ../widgets/dist/SearchResults/SearchResultsWidget.d.ts
4
4
  //#region src/SearchResults/SearchResultsWidget.d.ts
5
- declare const SearchResultsWidget: () => react_jsx_runtime0.JSX.Element;
5
+ declare const SearchResultsWidget: () => react_jsx_runtime1.JSX.Element;
6
6
  //#endregion
7
7
 
8
8
  //#endregion
@@ -5,19 +5,19 @@ const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/Ch
5
5
  let react = require("react");
6
6
  let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
+ let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
9
+ let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
8
10
  let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
11
+ let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
9
12
  let jotai = require("jotai");
10
13
  let __envive_ai_react_hooks_contexts_featureFlagServiceContext = require("@envive-ai/react-hooks/contexts/featureFlagServiceContext");
11
14
  let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
12
- let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
13
- let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
14
- let __envive_ai_react_hooks_hooks_WidgetInteraction_types = require("@envive-ai/react-hooks/hooks/WidgetInteraction/types");
15
- let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
16
- let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
17
- let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
18
15
  let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/app");
19
16
  let __envive_ai_react_hooks_hooks_WidgetInteraction = require("@envive-ai/react-hooks/hooks/WidgetInteraction");
17
+ let __envive_ai_react_hooks_hooks_WidgetInteraction_types = require("@envive-ai/react-hooks/hooks/WidgetInteraction/types");
20
18
  let __envive_ai_react_toolkit_v3_ChatPreviewComparison = require("@envive-ai/react-toolkit-v3/ChatPreviewComparison");
19
+ let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
20
+ let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
21
21
 
22
22
  //#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
23
23
  const ChatPreviewComparisonWidgetHandler = (props) => {
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime16 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts
5
5
  declare const ChatPreviewComparisonWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime16.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime8.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewComparisonWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewComparisonWidgetProps {
12
12
  declare const ChatPreviewComparisonWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewComparisonWidgetProps): react_jsx_runtime16.JSX.Element;
15
+ }: ChatPreviewComparisonWidgetProps): react_jsx_runtime8.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
2
- import * as react_jsx_runtime11 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime9 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts
5
5
  declare const ChatPreviewComparisonWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime11.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime9.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewComparisonWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewComparisonWidgetProps {
12
12
  declare const ChatPreviewComparisonWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewComparisonWidgetProps): react_jsx_runtime11.JSX.Element;
15
+ }: ChatPreviewComparisonWidgetProps): react_jsx_runtime9.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -4,19 +4,19 @@ import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWid
4
4
  import { useCallback, useMemo } from "react";
5
5
  import { EnviveMetricsEventName } from "@envive-ai/react-hooks/contexts/amplitudeContext";
6
6
  import { jsx } from "react/jsx-runtime";
7
+ import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
8
+ import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
7
9
  import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
10
+ import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
8
11
  import { useAtomValue } from "jotai";
9
12
  import { useFeatureFlagService } from "@envive-ai/react-hooks/contexts/featureFlagServiceContext";
10
13
  import { ChatElementDisplayLocationV3, FeatureGates, VariantTypeEnum } from "@envive-ai/react-hooks/application/models";
11
- import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
12
- import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
13
- import { WidgetInteractionComponent, WidgetInteractionType } from "@envive-ai/react-hooks/hooks/WidgetInteraction/types";
14
- import { usePromptCarouselAnalytics } from "@envive-ai/react-toolkit-v3/PromptCarousel";
15
- import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
16
- import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
17
14
  import { variantInfoAtom } from "@envive-ai/react-hooks/atoms/app";
18
15
  import { useWidgetInteraction } from "@envive-ai/react-hooks/hooks/WidgetInteraction";
16
+ import { WidgetInteractionComponent, WidgetInteractionType } from "@envive-ai/react-hooks/hooks/WidgetInteraction/types";
19
17
  import { ChatPreviewComparison } from "@envive-ai/react-toolkit-v3/ChatPreviewComparison";
18
+ import { usePromptCarouselAnalytics } from "@envive-ai/react-toolkit-v3/PromptCarousel";
19
+ import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
20
20
 
21
21
  //#region src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx
22
22
  const ChatPreviewComparisonWidgetHandler = (props) => {
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime6 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime4 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts
5
5
  declare const ChatPreviewLoadingWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime6.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime4.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewLoadingWidgetProps {
@@ -11,6 +11,6 @@ interface ChatPreviewLoadingWidgetProps {
11
11
  }
12
12
  declare const ChatPreviewLoadingWidget: ({
13
13
  widgetConfigId
14
- }: ChatPreviewLoadingWidgetProps) => react_jsx_runtime6.JSX.Element;
14
+ }: ChatPreviewLoadingWidgetProps) => react_jsx_runtime4.JSX.Element;
15
15
  //#endregion
16
16
  export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetProps, ChatPreviewLoadingWidgetWithBaseWidget };
@@ -5,17 +5,17 @@ const require_ChatPreviewLoadingWidget = require('../ChatPreviewLoadingWidget/Ch
5
5
  let react = require("react");
6
6
  let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
+ let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
9
+ let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
8
10
  let __envive_ai_react_hooks_contexts_typesV3 = require("@envive-ai/react-hooks/contexts/typesV3");
11
+ let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
9
12
  let jotai = require("jotai");
10
13
  let __envive_ai_react_hooks_contexts_featureFlagServiceContext = require("@envive-ai/react-hooks/contexts/featureFlagServiceContext");
11
14
  let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
12
- let __envive_ai_react_hooks_contexts_salesAgentContext = require("@envive-ai/react-hooks/contexts/salesAgentContext");
13
- let __envive_ai_react_hooks_hooks_ChatToggle = require("@envive-ai/react-hooks/hooks/ChatToggle");
15
+ let __envive_ai_react_hooks_hooks_WidgetInteraction = require("@envive-ai/react-hooks/hooks/WidgetInteraction");
14
16
  let __envive_ai_react_hooks_hooks_WidgetInteraction_types = require("@envive-ai/react-hooks/hooks/WidgetInteraction/types");
15
17
  let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
16
18
  let __envive_ai_react_toolkit_v3_Tokens = require("@envive-ai/react-toolkit-v3/Tokens");
17
- let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
18
- let __envive_ai_react_hooks_hooks_WidgetInteraction = require("@envive-ai/react-hooks/hooks/WidgetInteraction");
19
19
  let __envive_ai_react_toolkit_v3_ChatPreview = require("@envive-ai/react-toolkit-v3/ChatPreview");
20
20
 
21
21
  //#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.cjs";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts
5
5
  declare const ChatPreviewWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime0.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime1.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewWidgetProps {
12
12
  declare const ChatPreviewWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewWidgetProps): react_jsx_runtime0.JSX.Element;
15
+ }: ChatPreviewWidgetProps): react_jsx_runtime1.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { BaseWidgetProps } from "../../hocs/withBaseWidget/types.js";
2
- import * as react_jsx_runtime13 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime12 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts
5
5
  declare const ChatPreviewWidgetWithBaseWidget: {
6
- (props: BaseWidgetProps): react_jsx_runtime13.JSX.Element;
6
+ (props: BaseWidgetProps): react_jsx_runtime12.JSX.Element;
7
7
  displayName: string;
8
8
  };
9
9
  interface ChatPreviewWidgetProps {
@@ -12,7 +12,7 @@ interface ChatPreviewWidgetProps {
12
12
  declare const ChatPreviewWidget: {
13
13
  ({
14
14
  widgetConfigId
15
- }: ChatPreviewWidgetProps): react_jsx_runtime13.JSX.Element;
15
+ }: ChatPreviewWidgetProps): react_jsx_runtime12.JSX.Element;
16
16
  displayName: string;
17
17
  };
18
18
  //#endregion
@@ -4,17 +4,17 @@ import { ChatPreviewLoadingWidgetWithBaseWidget } from "../ChatPreviewLoadingWid
4
4
  import { useCallback, useMemo } from "react";
5
5
  import { EnviveMetricsEventName, useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
6
6
  import { jsx } from "react/jsx-runtime";
7
+ import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
8
+ import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
7
9
  import { WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
10
+ import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
8
11
  import { useAtomValue } from "jotai";
9
12
  import { useFeatureFlagService } from "@envive-ai/react-hooks/contexts/featureFlagServiceContext";
10
13
  import { ChatElementDisplayLocationV3, FeatureGates } from "@envive-ai/react-hooks/application/models";
11
- import { useSalesAgent } from "@envive-ai/react-hooks/contexts/salesAgentContext";
12
- import { useChatToggle } from "@envive-ai/react-hooks/hooks/ChatToggle";
14
+ import { useWidgetInteraction } from "@envive-ai/react-hooks/hooks/WidgetInteraction";
13
15
  import { WidgetInteractionComponent, WidgetInteractionType } from "@envive-ai/react-hooks/hooks/WidgetInteraction/types";
14
16
  import { usePromptCarouselAnalytics } from "@envive-ai/react-toolkit-v3/PromptCarousel";
15
17
  import { Theme } from "@envive-ai/react-toolkit-v3/Tokens";
16
- import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
17
- import { useWidgetInteraction } from "@envive-ai/react-hooks/hooks/WidgetInteraction";
18
18
  import { ChatPreview } from "@envive-ai/react-toolkit-v3/ChatPreview";
19
19
 
20
20
  //#region src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx