kenobi-js 0.1.35 → 0.1.37

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/browser/dist.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Kenobi SDK v0.1.33
2
+ * Kenobi SDK v0.1.35
3
3
  * (c) 2025 Kenobi.ai
4
4
  */
5
5
  "use strict";
@@ -1097,7 +1097,7 @@ var KenobiLib = (() => {
1097
1097
  xmlns: "http://www.w3.org/2000/svg",
1098
1098
  children: [
1099
1099
  /* @__PURE__ */ u3("circle", { cx: "446", cy: "450", r: "424", fill: "black" }),
1100
- /* @__PURE__ */ u3("circle", { cx: "450", cy: "450", r: "357", fill: "url(#paint0_linear_1_41)" }),
1100
+ /* @__PURE__ */ u3("circle", { cx: "450", cy: "450", r: "357", fill: "#E8E8E8" }),
1101
1101
  /* @__PURE__ */ u3(
1102
1102
  "ellipse",
1103
1103
  {
@@ -1108,22 +1108,7 @@ var KenobiLib = (() => {
1108
1108
  transform: "rotate(-46.2324 579.85 294.451)",
1109
1109
  fill: "black"
1110
1110
  }
1111
- ),
1112
- /* @__PURE__ */ u3("defs", { children: /* @__PURE__ */ u3(
1113
- "linearGradient",
1114
- {
1115
- id: "paint0_linear_1_41",
1116
- x1: "807",
1117
- y1: "93",
1118
- x2: "93",
1119
- y2: "807",
1120
- gradientUnits: "userSpaceOnUse",
1121
- children: [
1122
- /* @__PURE__ */ u3("stop", { "stop-color": "#FAFAFA" }),
1123
- /* @__PURE__ */ u3("stop", { offset: "1", "stop-color": "#CACACA" })
1124
- ]
1125
- }
1126
- ) })
1111
+ )
1127
1112
  ]
1128
1113
  }
1129
1114
  ), "LogoIcon");
@@ -1196,6 +1181,14 @@ var KenobiLib = (() => {
1196
1181
  /* Launcher dismiss button */
1197
1182
  .launcher .btn-dismiss.launcher-dismiss { top: -0.375rem; left: -0.375rem; width: 1.25rem; height: 1.25rem; opacity: 0; transition: opacity 0.2s ease-out, background-color 0.3s ease-out, color 0.3s ease-out; }
1198
1183
  .launcher:hover .btn-dismiss.launcher-dismiss { opacity: 1; }
1184
+ /* Launcher logo */
1185
+ .launcher-logo { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
1186
+ .launcher-logo svg { width: 20px; height: 20px; }
1187
+ /* Mobile: hide keyboard hints, show dismiss button */
1188
+ @media (max-width: 768px) {
1189
+ .launcher .kbd-hint { display: none; }
1190
+ .launcher .btn-dismiss.launcher-dismiss { opacity: 1; }
1191
+ }
1199
1192
  `;
1200
1193
  var useEnterExitAnimation = /* @__PURE__ */ __name((ref, isVisible, config) => {
1201
1194
  const hasEnteredRef = A2(false);
@@ -1680,14 +1673,27 @@ var KenobiLib = (() => {
1680
1673
  }, []);
1681
1674
  const clampedProgress = Math.max(0, Math.min(100, config.progressPct ?? 0));
1682
1675
  const displayedProgress = timerEnabled ? timerProgress : clampedProgress;
1676
+ const isContainerVisible = !!config.isVisible && mode === "card" && !isDismissed;
1677
+ const isLauncherVisible = !!config.isVisible && mode === "launcher" && !isDismissed;
1678
+ const isAnythingVisible = isContainerVisible || isLauncherVisible;
1683
1679
  return /* @__PURE__ */ u3(k, { children: [
1684
- /* @__PURE__ */ u3("div", { ref: backdropRef, class: "backdrop" }),
1680
+ /* @__PURE__ */ u3(
1681
+ "div",
1682
+ {
1683
+ ref: backdropRef,
1684
+ class: "backdrop",
1685
+ style: { display: isAnythingVisible ? "block" : "none" }
1686
+ }
1687
+ ),
1685
1688
  /* @__PURE__ */ u3(
1686
1689
  "div",
1687
1690
  {
1688
1691
  ref: containerRef,
1689
1692
  class: `container theme-${config.theme || "glass"} pos-${config.position || "top-center"}`,
1690
- style: getThemeStyles(config.customTheme),
1693
+ style: {
1694
+ ...getThemeStyles(config.customTheme),
1695
+ pointerEvents: isContainerVisible ? "auto" : "none"
1696
+ },
1691
1697
  onClick: () => !isOpen && !isPending && !isSuccess && setIsOpen(true),
1692
1698
  onMouseEnter: () => setIsHovering(true),
1693
1699
  onMouseLeave: () => setIsHovering(false),
@@ -1829,9 +1835,13 @@ var KenobiLib = (() => {
1829
1835
  {
1830
1836
  ref: launcherRef,
1831
1837
  class: `launcher theme-${config.theme || "glass"} pos-${config.position || "top-center"}`,
1832
- style: getThemeStyles(config.customTheme),
1838
+ style: {
1839
+ ...getThemeStyles(config.customTheme),
1840
+ pointerEvents: isLauncherVisible ? "auto" : "none"
1841
+ },
1833
1842
  onClick: (e3) => {
1834
1843
  e3.stopPropagation();
1844
+ setIsDismissed(false);
1835
1845
  setMode("card");
1836
1846
  setIsOpen(true);
1837
1847
  },
@@ -1851,20 +1861,7 @@ var KenobiLib = (() => {
1851
1861
  children: /* @__PURE__ */ u3(XMarkIcon, {})
1852
1862
  }
1853
1863
  ),
1854
- /* @__PURE__ */ u3(
1855
- "div",
1856
- {
1857
- style: {
1858
- display: "flex",
1859
- width: "20px",
1860
- height: "20px",
1861
- overflow: "hidden",
1862
- alignItems: "center",
1863
- justifyContent: "center"
1864
- },
1865
- children: /* @__PURE__ */ u3("div", { style: { transform: "scale(0.6)" }, children: /* @__PURE__ */ u3(LogoIcon, {}) })
1866
- }
1867
- ),
1864
+ /* @__PURE__ */ u3("div", { class: "launcher-logo", children: /* @__PURE__ */ u3(LogoIcon, {}) }),
1868
1865
  config.textOverrides?.launcherLabel || (hasHadSuccessRef.current ? "Personalize again" : "Personalize"),
1869
1866
  config.showKeyboardHints && /* @__PURE__ */ u3("div", { class: "kbd-hint visible", children: /* @__PURE__ */ u3("div", { class: "kbd-group", children: shortcutDisplay.map((k3, i3) => /* @__PURE__ */ u3("div", { class: "kbd", children: k3 }, i3)) }) })
1870
1867
  ]
@@ -2437,6 +2434,7 @@ var KenobiLib = (() => {
2437
2434
  __publicField(this, "currentUrl");
2438
2435
  __publicField(this, "navTicking", false);
2439
2436
  __publicField(this, "transitionDefaults");
2437
+ __publicField(this, "cueCardPaths");
2440
2438
  __publicField(this, "startAutoTransform", /* @__PURE__ */ __name(async () => {
2441
2439
  try {
2442
2440
  this.syncChangeStack();
@@ -2569,6 +2567,23 @@ var KenobiLib = (() => {
2569
2567
  __publicField(this, "getDurationInMilliseconds", /* @__PURE__ */ __name((start, end) => +end - +start, "getDurationInMilliseconds"));
2570
2568
  __publicField(this, "formatThousands", /* @__PURE__ */ __name((number) => new Intl.NumberFormat("en-US").format(number), "formatThousands"));
2571
2569
  __publicField(this, "setDebug", /* @__PURE__ */ __name((value) => this.config.debug = value, "setDebug"));
2570
+ /**
2571
+ * Checks if a path matches a pattern.
2572
+ * Supports exact matches ("/pricing") and wildcard suffixes ("/blog/*").
2573
+ */
2574
+ __publicField(this, "matchesPathPattern", /* @__PURE__ */ __name((path, pattern) => {
2575
+ const normalizedPath = path === "/" ? "/" : path.replace(/\/$/, "");
2576
+ const normalizedPattern = pattern === "/" ? "/" : pattern.replace(/\/$/, "");
2577
+ if (normalizedPattern.endsWith("/*")) {
2578
+ const base = normalizedPattern.slice(0, -2);
2579
+ return normalizedPath === base || normalizedPath.startsWith(base + "/");
2580
+ }
2581
+ return normalizedPath === normalizedPattern;
2582
+ }, "matchesPathPattern"));
2583
+ /**
2584
+ * Checks if the given path matches any of the configured cueCardPaths.
2585
+ */
2586
+ __publicField(this, "isPathAllowedForCueCard", /* @__PURE__ */ __name((path) => this.cueCardPaths.some((pattern) => this.matchesPathPattern(path, pattern)), "isPathAllowedForCueCard"));
2572
2587
  __publicField(this, "isInputElement", /* @__PURE__ */ __name((el) => {
2573
2588
  if (!(el instanceof HTMLInputElement) && !(el instanceof HTMLTextAreaElement) && !(el instanceof HTMLSelectElement))
2574
2589
  return false;
@@ -2678,6 +2693,7 @@ var KenobiLib = (() => {
2678
2693
  this.undoAll();
2679
2694
  void this.startAutoTransform();
2680
2695
  }
2696
+ this.syncCueCardVisibility();
2681
2697
  }
2682
2698
  });
2683
2699
  }, "schedule");
@@ -3051,6 +3067,13 @@ var KenobiLib = (() => {
3051
3067
  this.log("warn", "CueCard already initialized, skipping...");
3052
3068
  return;
3053
3069
  }
3070
+ if (!this.isPathAllowedForCueCard(this.currentPath)) {
3071
+ this.log(
3072
+ "debug",
3073
+ `CueCard not mounted: path "${this.currentPath}" not in allowed paths`
3074
+ );
3075
+ return;
3076
+ }
3054
3077
  this.cueCardInstance = new CueCard({
3055
3078
  theme: "light",
3056
3079
  position: "top-center",
@@ -3083,6 +3106,29 @@ var KenobiLib = (() => {
3083
3106
  this.cueCardInstance.mount();
3084
3107
  this.log("debug", "CueCard mounted successfully");
3085
3108
  }, "initCueCard"));
3109
+ /**
3110
+ * Syncs CueCard visibility based on the current path.
3111
+ * Mounts CueCard if on an allowed path, unmounts if not.
3112
+ * Called after navigation changes.
3113
+ */
3114
+ __publicField(this, "syncCueCardVisibility", /* @__PURE__ */ __name(() => {
3115
+ if (!this.config.publicKey) return;
3116
+ const isAllowed = this.isPathAllowedForCueCard(this.currentPath);
3117
+ if (isAllowed && !this.cueCardInstance) {
3118
+ this.log(
3119
+ "debug",
3120
+ `Navigated to allowed path "${this.currentPath}", mounting CueCard`
3121
+ );
3122
+ this.initCueCard();
3123
+ } else if (!isAllowed && this.cueCardInstance) {
3124
+ this.log(
3125
+ "debug",
3126
+ `Navigated away from allowed paths to "${this.currentPath}", unmounting CueCard`
3127
+ );
3128
+ this.cueCardInstance.unmount();
3129
+ this.cueCardInstance = null;
3130
+ }
3131
+ }, "syncCueCardVisibility"));
3086
3132
  /**
3087
3133
  * Triggers personalization by calling the API with the provided input.
3088
3134
  * Updates CueCard status during the flow and applies transformations.
@@ -3161,6 +3207,7 @@ var KenobiLib = (() => {
3161
3207
  this.config.transitionDefaults
3162
3208
  );
3163
3209
  this.orchestrator = new TransitionOrchestrator();
3210
+ this.cueCardPaths = this.config.cueCardPaths ?? ["/"];
3164
3211
  this.syncVisitorKey();
3165
3212
  this.currentPath = this.getCurrentPath();
3166
3213
  this.currentUrl = this.getCurrentUrl();