veo-sdk 0.6.3 → 0.6.4

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.
@@ -213,6 +213,7 @@ var GUIDE_Z_INDEX = 2147483640;
213
213
  var DEFAULT_ANCHOR_WAIT_MS = 5e3;
214
214
  var SAFE_URL_PROTOCOLS = ["http:", "https:"];
215
215
  var GUIDE_HOST_ATTR = "data-veo-guide";
216
+ var BADGE_MARKER_HOST_ATTR = "data-veo-badge";
216
217
  var FREQUENCY_CACHE_KEY_PREFIX = "veo:freq:";
217
218
  var DEFAULT_TRACKER_FLUSH_INTERVAL_MS = 3e3;
218
219
  var DEFAULT_TRACKER_BATCH_SIZE = 5;
@@ -1776,6 +1777,25 @@ var BaseRenderer = class {
1776
1777
  this.shadow = shadow;
1777
1778
  return { host, shadow, root };
1778
1779
  }
1780
+ /**
1781
+ * Host SUELTO con los mismos estilos (shadow DOM), sin agregarlo al DOM ni
1782
+ * registrarlo como `this.host`. Para piezas que deben vivir dentro de la app
1783
+ * (el marcador de un badge, junto a su ancla) mientras la tarjeta se queda
1784
+ * en `body`: si la tarjeta viajara dentro del ancla, un ancestro con
1785
+ * `transform`/`overflow` la recortaría y su z-index quedaría atrapado.
1786
+ */
1787
+ createDetachedHost(attr = BADGE_MARKER_HOST_ATTR) {
1788
+ const host = document.createElement("div");
1789
+ host.setAttribute(attr, "");
1790
+ const shadow = host.attachShadow({ mode: "open" });
1791
+ const style = document.createElement("style");
1792
+ style.textContent = GUIDE_STYLES;
1793
+ shadow.appendChild(style);
1794
+ const root = document.createElement("div");
1795
+ shadow.appendChild(root);
1796
+ this.registerCleanup(() => host.remove());
1797
+ return { host, root };
1798
+ }
1779
1799
  /**
1780
1800
  * Aplica la tematización por datos del step (`step.style`) como variables
1781
1801
  * CSS sobre el host. Llamar tras `createHost()`. No-op si no hay host o
@@ -3261,6 +3281,13 @@ function isSnoozed(guideId, now = Date.now()) {
3261
3281
  return false;
3262
3282
  }
3263
3283
  }
3284
+
3285
+ // src/plugins/guides/z-index.ts
3286
+ var MAX_Z_INDEX = 2147483647;
3287
+ function clampZIndex(value, fallback) {
3288
+ if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
3289
+ return Math.max(-MAX_Z_INDEX, Math.min(MAX_Z_INDEX, Math.round(value)));
3290
+ }
3264
3291
  var INFO_GLYPH = "M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021";
3265
3292
  var QUESTION_GLYPH = "M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75";
3266
3293
  var STAR_GLYPH = "M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z";
@@ -3445,7 +3472,7 @@ function canNest(anchor) {
3445
3472
  }
3446
3473
  function attachMarker(anchor, host, marker) {
3447
3474
  host.style.position = "absolute";
3448
- host.style.zIndex = String(num(marker.zIndex, DEFAULT_MARKER_Z));
3475
+ host.style.zIndex = String(clampZIndex(marker.zIndex, DEFAULT_MARKER_Z));
3449
3476
  host.style.margin = "0";
3450
3477
  const position = marker.position ?? "top-right";
3451
3478
  const offset6 = { x: num(marker.offsetX, 0), y: num(marker.offsetY, 0) };
@@ -3583,7 +3610,9 @@ var CompositeRenderer = class extends BaseRenderer {
3583
3610
  const { host, root } = this.createHost();
3584
3611
  const doc = root.ownerDocument ?? document;
3585
3612
  const design = step.design ?? {};
3586
- if (typeof design.zIndex === "number") host.style.zIndex = String(design.zIndex);
3613
+ if (typeof design.zIndex === "number") {
3614
+ host.style.zIndex = String(clampZIndex(design.zIndex, 0));
3615
+ }
3587
3616
  const card = doc.createElement("div");
3588
3617
  card.className = "veo-card";
3589
3618
  const themeMode = themeModeFor(context.guide.theme, design);
@@ -3692,7 +3721,7 @@ var CompositeRenderer = class extends BaseRenderer {
3692
3721
  const bg = doc.createElement("div");
3693
3722
  bg.className = "veo-composite-overlay veo-composite-overlay--dim";
3694
3723
  if (typeof design.backdropColor === "string") bg.style.background = design.backdropColor;
3695
- const bz = typeof design.backdropZIndex === "number" ? design.backdropZIndex : 2e5;
3724
+ const bz = clampZIndex(design.backdropZIndex, 2e5);
3696
3725
  bg.style.zIndex = String(bz);
3697
3726
  root.appendChild(bg);
3698
3727
  this.registerCleanup(lockScroll(doc));
@@ -3714,7 +3743,7 @@ var CompositeRenderer = class extends BaseRenderer {
3714
3743
  overlay.style.background = design.backdropColor;
3715
3744
  }
3716
3745
  if (typeof design.backdropZIndex === "number") {
3717
- overlay.style.zIndex = String(design.backdropZIndex);
3746
+ overlay.style.zIndex = String(clampZIndex(design.backdropZIndex, 0));
3718
3747
  }
3719
3748
  overlay.addEventListener("click", (e) => {
3720
3749
  if (e.target === overlay) {
@@ -4035,6 +4064,7 @@ var CompositeRenderer = class extends BaseRenderer {
4035
4064
  renderBadgeMode(step, card, anchor, anchorSelector, host, root, doc, context, idx, design) {
4036
4065
  const trigger = step.badge?.trigger === "click" ? "click" : "hover";
4037
4066
  const placement = step.badge?.placement === "top" || step.badge?.placement === "left" || step.badge?.placement === "right" ? step.badge.placement : "bottom";
4067
+ const { host: markerHost, root: markerRoot } = this.createDetachedHost();
4038
4068
  const badge = doc.createElement("div");
4039
4069
  badge.className = "veo-composite-badge";
4040
4070
  badge.setAttribute("role", "button");
@@ -4045,7 +4075,8 @@ var CompositeRenderer = class extends BaseRenderer {
4045
4075
  const marker = step.badge?.marker ?? null;
4046
4076
  if (marker) badge.appendChild(buildMarkerElement(doc, marker));
4047
4077
  else this.buildContent(badge, step.badge?.blocks ?? [], doc, context, idx, [], host);
4048
- root.appendChild(badge);
4078
+ markerRoot.appendChild(badge);
4079
+ host.style.display = "block";
4049
4080
  if (design.fullWidth === true) {
4050
4081
  card.style.width = "auto";
4051
4082
  card.style.maxWidth = "320px";
@@ -4060,13 +4091,13 @@ var CompositeRenderer = class extends BaseRenderer {
4060
4091
  wrapper.appendChild(card);
4061
4092
  root.appendChild(wrapper);
4062
4093
  if (marker) {
4063
- host.style.display = "inline-block";
4064
- this.registerCleanup(attachMarker(anchor, host, marker));
4094
+ markerHost.style.display = "inline-block";
4095
+ this.registerCleanup(attachMarker(anchor, markerHost, marker));
4065
4096
  } else {
4066
- host.style.display = "inline-block";
4097
+ markerHost.style.display = "inline-block";
4067
4098
  const pos = inlinePosOf(step.inlinePosition);
4068
- insertHost(anchor, host, pos);
4069
- this.registerCleanup(keepHostAttached(host, anchorSelector, pos));
4099
+ insertHost(anchor, markerHost, pos);
4100
+ this.registerCleanup(keepHostAttached(markerHost, anchorSelector, pos));
4070
4101
  }
4071
4102
  let open = false;
4072
4103
  let stopFloat = null;
@@ -4196,7 +4227,7 @@ function liftTarget(anchor, zIndex) {
4196
4227
  const prevPosition = el.style.position;
4197
4228
  const prevZ = el.style.zIndex;
4198
4229
  if (getComputedStyle(el).position === "static") el.style.position = "relative";
4199
- el.style.zIndex = String(zIndex);
4230
+ el.style.zIndex = String(clampZIndex(zIndex, 0));
4200
4231
  return () => {
4201
4232
  el.style.position = prevPosition;
4202
4233
  el.style.zIndex = prevZ;
@@ -5162,5 +5193,5 @@ function pageRuleMatches(rule, pageUrl) {
5162
5193
  }
5163
5194
 
5164
5195
  export { ALWAYS_BLOCK_SELECTORS, BadgeRenderer, BannerRenderer, CompositeRenderer, CustomRenderer, DEFAULT_AUTOCAPTURE_CONFIG, DEFAULT_TRACKER_BATCH_SIZE, DEFAULT_TRACKER_FLUSH_INTERVAL_MS, DEFAULT_TRACKER_MAX_RETRIES, FREQUENCY_CACHE_KEY_PREFIX, FREQUENCY_CACHE_MAX_ENTRIES, FREQUENCY_CACHE_TTL_MS, FormRenderer, GUIDE_STYLES, InlineCustomRenderer, InlineFormRenderer, InlineRenderer, MAX_ANCESTORS, ModalRenderer, PRIORITY_ATTRIBUTES, RAW_BLOCK_ATTR, SENSITIVE_ATTRIBUTES, TooltipRenderer, WALKTHROUGH_ABANDONMENT_TIMEOUT_MS, WALKTHROUGH_STATE_KEY_PREFIX, WalkthroughRenderer, activationDelayMs, applyBlockStyle, buildContentBlock, buildSelectorPath, clearBuilderToken, clearPreviewToken, closeGuidePreview, filterHumanClasses, getPreviewToken, groupLayout, hasDocument, hasLocalStorage, hasNavigatorSendBeacon, hasWindow, isAutomaticActivation, isBuilderMode, isDeviceAllowed, isSnoozed, previewGuide, resolveBuilderContext, resolveBuilderToken, stepMatchesPage, uuidv7 };
5165
- //# sourceMappingURL=chunk-SZCIXA5X.mjs.map
5166
- //# sourceMappingURL=chunk-SZCIXA5X.mjs.map
5196
+ //# sourceMappingURL=chunk-CMPOHTUM.mjs.map
5197
+ //# sourceMappingURL=chunk-CMPOHTUM.mjs.map