@eshal-bot/chat-widget 0.2.49 → 0.2.50

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.
@@ -1 +1 @@
1
- export{S as default}from"./chat-widget-index-BngT4tmp.esm.js";import"react";import"react-dom/client";import"react/jsx-runtime";import"react-dom";
1
+ export{S as default}from"./chat-widget-index-BIUTvn6a.esm.js";import"react";import"react-dom/client";import"react/jsx-runtime";import"react-dom";
@@ -13623,6 +13623,29 @@
13623
13623
  });
13624
13624
  };
13625
13625
 
13626
+ /**
13627
+ * EV-5013: why the widget refuses to render on this page, or null when it
13628
+ * renders. The refusal used to be silent (ChatWidget returned null with no
13629
+ * log), so an install with an empty allow-list looked identical to a broken
13630
+ * embed. The returned sentence names the reason and the host for one
13631
+ * console.warn.
13632
+ * @param {string[]} allowedDomains - Same list isDomainAllowed checks
13633
+ * @returns {string|null}
13634
+ */
13635
+ const domainRefusalReason = (allowedDomains = []) => {
13636
+ if (typeof window === 'undefined') {
13637
+ return null;
13638
+ }
13639
+ if (isDomainAllowed(allowedDomains)) {
13640
+ return null;
13641
+ }
13642
+ const host = window.location.host.toLowerCase();
13643
+ if (!allowedDomains || allowedDomains.length === 0) {
13644
+ return `[Eshal chat widget] Not rendering on ${host}: no allowed domains are configured for this AI assistant. Add the domain under Channels > Website chat.`;
13645
+ }
13646
+ return `[Eshal chat widget] Not rendering on ${host}: this host is not in the allowed domains for this AI assistant. Add it under Channels > Website chat.`;
13647
+ };
13648
+
13626
13649
  // Field order for onboarding form: name → email → phone (then any others)
13627
13650
  // Lower number = earlier in the form. Name first, then email, then phone.
13628
13651
  // Keys are lowercase so getOnboardingFieldOrder(fieldType) works for any casing.
@@ -25254,7 +25277,7 @@
25254
25277
  * value by its own test (that constant sat at 0.1.113 while this package was
25255
25278
  * at 0.2.2 precisely because nothing enforced it - EV-2431).
25256
25279
  */
25257
- const WIDGET_VERSION = '0.2.49';
25280
+ const WIDGET_VERSION = '0.2.50';
25258
25281
 
25259
25282
  /**
25260
25283
  * API utility functions
@@ -25621,6 +25644,23 @@
25621
25644
  return isDomainAllowed(widgetConfig.allowedDomains);
25622
25645
  }, [widgetConfig]);
25623
25646
 
25647
+ // EV-5013: a refused domain used to render nothing with no log at all.
25648
+ // Say why, once per distinct reason, so the operator can see it in the
25649
+ // console instead of guessing at a blank page. Effect, not render: a
25650
+ // render-time warn would repeat on every re-render.
25651
+ const lastRefusalRef = reactExports.useRef(null);
25652
+ reactExports.useEffect(() => {
25653
+ if (!widgetConfig || isAllowed) {
25654
+ lastRefusalRef.current = null;
25655
+ return;
25656
+ }
25657
+ const reason = domainRefusalReason(widgetConfig.allowedDomains);
25658
+ if (reason && reason !== lastRefusalRef.current) {
25659
+ lastRefusalRef.current = reason;
25660
+ console.warn(reason);
25661
+ }
25662
+ }, [widgetConfig, isAllowed]);
25663
+
25624
25664
  // Create default config for useChatState when config is not ready
25625
25665
  const defaultConfig = reactExports.useMemo(() => ({
25626
25666
  welcomeMessage: "Hi! How can we help?",
@@ -25816,6 +25856,8 @@
25816
25856
  console.error("ChatWidget configuration error:", configError);
25817
25857
  return null;
25818
25858
  }
25859
+
25860
+ // The console.warn for this case is the EV-5013 effect above.
25819
25861
  if (!isAllowed) {
25820
25862
  return null;
25821
25863
  }