veo-sdk 0.5.4 → 0.5.6

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,5 +1,5 @@
1
- import { P as PreviewGuideInput } from './guide-preview-B912Y6UY.cjs';
2
- export { a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-B912Y6UY.cjs';
1
+ import { P as PreviewGuideInput } from './guide-preview-XUnTmzUO.cjs';
2
+ export { a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-XUnTmzUO.cjs';
3
3
 
4
4
  /** Dónde soltó el autor un bloque nuevo. */
5
5
  interface BlockDropPayload {
@@ -147,6 +147,13 @@ type BuilderCommand = {
147
147
  type: 'preview';
148
148
  guide: PreviewGuideInput;
149
149
  editable?: boolean;
150
+ } | {
151
+ type: 'block-drag';
152
+ phase: 'move' | 'drop' | 'cancel';
153
+ x: number;
154
+ y: number;
155
+ blockType: string;
156
+ label?: string;
150
157
  } | {
151
158
  type: 'close-preview';
152
159
  } | {
package/dist/builder.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PreviewGuideInput } from './guide-preview-B912Y6UY.js';
2
- export { a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-B912Y6UY.js';
1
+ import { P as PreviewGuideInput } from './guide-preview-XUnTmzUO.js';
2
+ export { a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-XUnTmzUO.js';
3
3
 
4
4
  /** Dónde soltó el autor un bloque nuevo. */
5
5
  interface BlockDropPayload {
@@ -147,6 +147,13 @@ type BuilderCommand = {
147
147
  type: 'preview';
148
148
  guide: PreviewGuideInput;
149
149
  editable?: boolean;
150
+ } | {
151
+ type: 'block-drag';
152
+ phase: 'move' | 'drop' | 'cancel';
153
+ x: number;
154
+ y: number;
155
+ blockType: string;
156
+ label?: string;
150
157
  } | {
151
158
  type: 'close-preview';
152
159
  } | {
package/dist/builder.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import './chunk-GKJW5TOZ.mjs';
2
- import { initBuilderMode } from './chunk-SBNT464M.mjs';
3
- export { createBuilderSession, initBuilderMode, startElementPicker, stopElementPicker } from './chunk-SBNT464M.mjs';
4
- export { closeGuidePreview, previewGuide } from './chunk-JPA46JBS.mjs';
1
+ import './chunk-CPSHNLZG.mjs';
2
+ import { initBuilderMode } from './chunk-A4RHMCCM.mjs';
3
+ export { createBuilderSession, initBuilderMode, startElementPicker, stopElementPicker } from './chunk-A4RHMCCM.mjs';
4
+ export { closeGuidePreview, previewGuide } from './chunk-764FSEHS.mjs';
5
5
  import './chunk-PTG3BTJE.mjs';
6
6
 
7
7
  // src/builder.ts
@@ -436,7 +436,8 @@ function buildButtonBlock(block, doc, callbacks) {
436
436
  btn.textContent = typeof block.text === "string" && block.text ? block.text : "OK";
437
437
  applyBlockStyle(btn, block.style, "button");
438
438
  btn.addEventListener("click", () => {
439
- const action = block.action ?? "dismiss";
439
+ const raw = block.action ?? "dismiss";
440
+ const action = raw === "next" || raw === "url" || raw === "guide" ? raw : "dismiss";
440
441
  const target = action === "url" && typeof block.url === "string" && isSafeUrl(block.url) ? block.url : action === "guide" && typeof block.targetGuideId === "string" && block.targetGuideId ? block.targetGuideId : void 0;
441
442
  const meta = {
442
443
  ...typeof block.id === "string" && block.id ? { buttonId: block.id } : {},
@@ -832,6 +833,35 @@ var GUIDE_STYLES = `
832
833
  animation: veo-fade-in 160ms ease-out;
833
834
  }
834
835
 
836
+ /* \u2500\u2500 Modelo unificado (composite) \u2500\u2500 */
837
+ .veo-composite-overlay {
838
+ position: fixed; inset: 0;
839
+ z-index: ${GUIDE_Z_INDEX};
840
+ pointer-events: none;
841
+ }
842
+ /* Backdrop atenuado (solo centro con backdrop activo). */
843
+ .veo-composite-overlay--dim {
844
+ background: rgba(0, 0, 0, 0.5);
845
+ pointer-events: auto;
846
+ }
847
+ .veo-composite-anchored {
848
+ position: fixed;
849
+ z-index: ${GUIDE_Z_INDEX};
850
+ }
851
+ /* Card gen\xE9rica del modelo unificado. El dise\xF1o (bg/borde/padding/\u2026) lo aplica
852
+ el renderer como estilos inline desde step.design; ac\xE1 van los defaults. */
853
+ .veo-card {
854
+ pointer-events: auto;
855
+ background: var(--veo-bg, #ffffff);
856
+ color: var(--veo-text, #1f2937);
857
+ border-radius: var(--veo-radius, 12px);
858
+ padding: 20px;
859
+ max-width: 90vw;
860
+ box-shadow: var(--veo-shadow, 0 12px 40px rgba(0, 0, 0, 0.18));
861
+ animation: veo-fade-in 160ms ease-out;
862
+ }
863
+ .veo-composite-anchored .veo-card, .veo-composite-overlay .veo-card { position: relative; }
864
+
835
865
  .veo-guide-content {
836
866
  position: relative;
837
867
  display: flex; flex-direction: column;
@@ -1638,6 +1668,182 @@ var BannerRenderer = class extends BaseRenderer {
1638
1668
  function bannerClassOf(position, embedded) {
1639
1669
  return embedded ? "veo-banner veo-banner-embedded" : `veo-banner veo-banner-${position}`;
1640
1670
  }
1671
+ var CompositeRenderer = class extends BaseRenderer {
1672
+ async render(context) {
1673
+ const idx = context.nav?.stepIndex ?? 0;
1674
+ const step = context.guide.guideSteps[idx];
1675
+ if (!step) return;
1676
+ const anchorSelector = step.position === "relative-to-element" || step.presentation === "inline" ? step.anchorSelector?.trim() || void 0 : void 0;
1677
+ let anchor = null;
1678
+ if (anchorSelector) {
1679
+ anchor = await waitForElement(anchorSelector);
1680
+ if (!anchor) return;
1681
+ }
1682
+ const { host, root } = this.createHost();
1683
+ const doc = root.ownerDocument ?? document;
1684
+ const card = doc.createElement("div");
1685
+ card.className = "veo-card";
1686
+ applyCompositeDesign(card, step.design ?? {});
1687
+ const dismiss = (action, meta) => {
1688
+ context.onInteraction({
1689
+ guideId: context.guide.guideId,
1690
+ stepIndex: idx,
1691
+ action,
1692
+ ...meta?.id ? { metadata: { buttonId: meta.id } } : {}
1693
+ });
1694
+ };
1695
+ const synthetic = { blocks: step.blocks ?? [] };
1696
+ for (const node of buildContentNodes(synthetic, doc)) card.appendChild(node);
1697
+ const buttons = (step.blocks ?? []).filter((b) => b.type === "button");
1698
+ if (buttons.length) {
1699
+ const row = doc.createElement("div");
1700
+ row.className = "veo-guide-actions";
1701
+ for (const b of buttons) row.appendChild(this.buildButton(b, doc, context, dismiss));
1702
+ card.appendChild(row);
1703
+ }
1704
+ card.appendChild(
1705
+ createCloseButton(doc, () => {
1706
+ dismiss("dismissed");
1707
+ this.closeOrSkip(context);
1708
+ })
1709
+ );
1710
+ if (step.presentation === "inline" && anchor) {
1711
+ host.style.display = "block";
1712
+ const pos = inlinePosOf(step.inlinePosition);
1713
+ root.appendChild(card);
1714
+ insertHost(anchor, host, pos);
1715
+ this.registerCleanup(keepHostAttached(host, anchorSelector, pos));
1716
+ } else if (step.position === "relative-to-element" && anchor) {
1717
+ const wrapper = doc.createElement("div");
1718
+ wrapper.className = "veo-composite-anchored";
1719
+ wrapper.appendChild(card);
1720
+ root.appendChild(wrapper);
1721
+ this.registerCleanup(await anchorPosition(anchor, wrapper));
1722
+ } else {
1723
+ const overlay = doc.createElement("div");
1724
+ overlay.className = "veo-composite-overlay";
1725
+ if (step.position === "center" && step.design?.backdrop !== false) {
1726
+ overlay.classList.add("veo-composite-overlay--dim");
1727
+ overlay.addEventListener("click", (e) => {
1728
+ if (e.target === overlay) {
1729
+ dismiss("dismissed");
1730
+ this.closeOrSkip(context);
1731
+ }
1732
+ });
1733
+ }
1734
+ applyViewportPosition(card, step.position);
1735
+ overlay.appendChild(card);
1736
+ root.appendChild(overlay);
1737
+ }
1738
+ context.onInteraction({ guideId: context.guide.guideId, stepIndex: idx, action: "shown" });
1739
+ }
1740
+ /** Botón con enrutado de acción (navegación / cierre / url / guía). */
1741
+ buildButton(block, doc, context, emit) {
1742
+ const btn = doc.createElement("button");
1743
+ btn.type = "button";
1744
+ btn.className = "veo-guide-cta";
1745
+ btn.textContent = block.text?.trim() || "OK";
1746
+ btn.addEventListener("click", () => {
1747
+ emit("cta_clicked", block);
1748
+ const nav = context.nav?.callbacks;
1749
+ switch (block.action) {
1750
+ case "next":
1751
+ case "submit-forms":
1752
+ case "submit-forms-advance":
1753
+ if (nav) nav.onNext();
1754
+ else context.onClose();
1755
+ break;
1756
+ case "prev":
1757
+ nav?.onBack();
1758
+ break;
1759
+ case "url":
1760
+ if (typeof block.url === "string" && isSafeUrl(block.url)) {
1761
+ window.open(block.url, "_blank", "noopener,noreferrer");
1762
+ }
1763
+ break;
1764
+ case "guide":
1765
+ if (block.targetGuideId) context.onOpenGuide?.(block.targetGuideId);
1766
+ this.closeOrSkip(context);
1767
+ break;
1768
+ default:
1769
+ this.closeOrSkip(context);
1770
+ }
1771
+ });
1772
+ return btn;
1773
+ }
1774
+ closeOrSkip(context) {
1775
+ if (context.nav?.callbacks) context.nav.callbacks.onSkip();
1776
+ else context.onClose();
1777
+ }
1778
+ };
1779
+ function inlinePosOf(p) {
1780
+ return p === "before" || p === "prepend" || p === "append" ? p : "after";
1781
+ }
1782
+ function applyViewportPosition(card, position) {
1783
+ const s = card.style;
1784
+ s.position = "fixed";
1785
+ const M = "16px";
1786
+ const v = position.includes("top") ? "top" : position.includes("bottom") ? "bottom" : "middle";
1787
+ const h = position.includes("left") ? "left" : position.includes("right") ? "right" : "middle";
1788
+ if (position === "center") {
1789
+ s.top = "50%";
1790
+ s.left = "50%";
1791
+ s.transform = "translate(-50%, -50%)";
1792
+ return;
1793
+ }
1794
+ if (v === "top") s.top = M;
1795
+ else if (v === "bottom") s.bottom = M;
1796
+ else {
1797
+ s.top = "50%";
1798
+ s.transform = "translateY(-50%)";
1799
+ }
1800
+ if (h === "left") s.left = M;
1801
+ else if (h === "right") s.right = M;
1802
+ else {
1803
+ s.left = "50%";
1804
+ s.transform = `${s.transform} translateX(-50%)`.trim();
1805
+ }
1806
+ }
1807
+ async function anchorPosition(anchor, wrapper) {
1808
+ const update = async () => {
1809
+ const { x, y } = await computePosition(anchor, wrapper, {
1810
+ placement: "bottom",
1811
+ strategy: "fixed",
1812
+ middleware: [offset(8), flip(), shift({ padding: 8 })]
1813
+ });
1814
+ wrapper.style.left = `${x}px`;
1815
+ wrapper.style.top = `${y}px`;
1816
+ };
1817
+ await update();
1818
+ const reposition = () => void update();
1819
+ window.addEventListener("scroll", reposition, true);
1820
+ window.addEventListener("resize", reposition);
1821
+ return () => {
1822
+ window.removeEventListener("scroll", reposition, true);
1823
+ window.removeEventListener("resize", reposition);
1824
+ };
1825
+ }
1826
+ function applyCompositeDesign(card, design) {
1827
+ const s = card.style;
1828
+ const px = (v) => typeof v === "number" && Number.isFinite(v) ? `${v}px` : null;
1829
+ const strv = (v) => typeof v === "string" && v ? v : null;
1830
+ if (strv(design.background)) s.background = design.background;
1831
+ if (strv(design.textColor)) s.color = design.textColor;
1832
+ if (px(design.fontSize)) s.fontSize = px(design.fontSize);
1833
+ if (strv(design.fontWeight)) s.fontWeight = design.fontWeight;
1834
+ if (strv(design.align)) s.textAlign = design.align;
1835
+ if (typeof design.lineHeight === "number") s.lineHeight = `${design.lineHeight}%`;
1836
+ if (px(design.radius)) s.borderRadius = px(design.radius);
1837
+ if (px(design.width)) s.width = px(design.width);
1838
+ const bw = px(design.borderWidth);
1839
+ if (bw) s.border = `${bw} solid ${strv(design.borderColor) ?? "#e5e5e5"}`;
1840
+ for (const side of ["Top", "Right", "Bottom", "Left"]) {
1841
+ const p = px(design[`padding${side}`]);
1842
+ if (p) s.setProperty(`padding-${side.toLowerCase()}`, p);
1843
+ const m = px(design[`margin${side}`]);
1844
+ if (m) s.setProperty(`margin-${side.toLowerCase()}`, m);
1845
+ }
1846
+ }
1641
1847
 
1642
1848
  // src/utils/uuid.ts
1643
1849
  function uuidv7() {
@@ -2520,6 +2726,13 @@ var GuidePreviewController = class {
2520
2726
  this.input = input;
2521
2727
  const guide = normalize(input);
2522
2728
  const start = typeof input.startStepIndex === "number" ? input.startStepIndex : 0;
2729
+ if (guide.guideType === "composite") {
2730
+ const s = Math.min(Math.max(0, start), guide.guideSteps.length - 1);
2731
+ const active = guide.guideSteps[s];
2732
+ if (active) guide.guideSteps = [active];
2733
+ const ready2 = this.renderSingleStep(guide);
2734
+ return { close: () => this.close(), ready: ready2, host: () => this.activeHost() };
2735
+ }
2523
2736
  const ready = guide.guideType === "walkthrough" ? this.startWalkthrough(guide, start) : this.renderSingleStep(guide);
2524
2737
  return { close: () => this.close(), ready, host: () => this.activeHost() };
2525
2738
  }
@@ -2699,8 +2912,12 @@ function createSingleStepRenderer(type) {
2699
2912
  return new InlineFormRenderer();
2700
2913
  case "badge":
2701
2914
  return new BadgeRenderer();
2915
+ case "composite":
2916
+ return new CompositeRenderer();
2702
2917
  case "walkthrough":
2703
2918
  return null;
2919
+ default:
2920
+ return null;
2704
2921
  }
2705
2922
  }
2706
2923
  function safeDestroy(renderer) {
@@ -2843,6 +3060,6 @@ function buildSelectorPath(element, maxAncestors = 5) {
2843
3060
  return parts.join(" > ");
2844
3061
  }
2845
3062
 
2846
- export { ALWAYS_BLOCK_SELECTORS, BadgeRenderer, BannerRenderer, 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, InlineCustomRenderer, InlineFormRenderer, InlineRenderer, MAX_ANCESTORS, ModalRenderer, PRIORITY_ATTRIBUTES, SENSITIVE_ATTRIBUTES, TooltipRenderer, WALKTHROUGH_ABANDONMENT_TIMEOUT_MS, WALKTHROUGH_STATE_KEY_PREFIX, WalkthroughRenderer, buildSelectorPath, clearBuilderToken, closeGuidePreview, filterHumanClasses, hasDocument, hasLocalStorage, hasNavigatorSendBeacon, hasWindow, isBuilderMode, previewGuide, resolveBuilderContext, resolveBuilderToken, uuidv7 };
2847
- //# sourceMappingURL=chunk-JPA46JBS.mjs.map
2848
- //# sourceMappingURL=chunk-JPA46JBS.mjs.map
3063
+ 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, InlineCustomRenderer, InlineFormRenderer, InlineRenderer, MAX_ANCESTORS, ModalRenderer, PRIORITY_ATTRIBUTES, SENSITIVE_ATTRIBUTES, TooltipRenderer, WALKTHROUGH_ABANDONMENT_TIMEOUT_MS, WALKTHROUGH_STATE_KEY_PREFIX, WalkthroughRenderer, buildSelectorPath, clearBuilderToken, closeGuidePreview, filterHumanClasses, hasDocument, hasLocalStorage, hasNavigatorSendBeacon, hasWindow, isBuilderMode, previewGuide, resolveBuilderContext, resolveBuilderToken, uuidv7 };
3064
+ //# sourceMappingURL=chunk-764FSEHS.mjs.map
3065
+ //# sourceMappingURL=chunk-764FSEHS.mjs.map