veo-sdk 0.3.15 → 0.3.16

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/dist/index.cjs CHANGED
@@ -1114,6 +1114,37 @@ var init_base_renderer = __esm({
1114
1114
  this.host = null;
1115
1115
  this.shadow = null;
1116
1116
  this.cleanups = [];
1117
+ // ── Update in-place (preview en vivo del editor) ──
1118
+ // La subclase setea estas piezas en render() para habilitarlo: el contenedor
1119
+ // del contenido, el nodo de contenido actual y cómo reconstruirlo.
1120
+ this.liveContainer = null;
1121
+ this.liveContent = null;
1122
+ this.liveBuild = null;
1123
+ /** Clave de anclaje/estructura fijada en render(); si cambia → remontar. */
1124
+ this.liveKey = "";
1125
+ }
1126
+ /** Clave de anclaje derivada del step (override por subclase). */
1127
+ liveKeyOf(_step) {
1128
+ return "";
1129
+ }
1130
+ /** Hook post-swap (reposicionar tooltip, actualizar clase del banner…). */
1131
+ onLiveUpdate(_step) {
1132
+ }
1133
+ /**
1134
+ * Actualiza el contenido del step SIN remontar el host — así el preview del
1135
+ * editor no parpadea en cada tecla. Devuelve `false` cuando el renderer no
1136
+ * lo soporta o el cambio requiere remontar (cambió el ancla/estructura);
1137
+ * en ese caso el caller hace el re-render completo.
1138
+ */
1139
+ updateStep(step) {
1140
+ if (!this.host || !this.liveContainer || !this.liveContent || !this.liveBuild) return false;
1141
+ if (this.liveKeyOf(step) !== this.liveKey) return false;
1142
+ const next = this.liveBuild(step);
1143
+ this.liveContainer.replaceChild(next, this.liveContent);
1144
+ this.liveContent = next;
1145
+ this.applyDesign(step.style);
1146
+ this.onLiveUpdate(step);
1147
+ return true;
1117
1148
  }
1118
1149
  /**
1119
1150
  * Crea un `<div data-veo-guide>` adjunto a `document.body`, le adjunta
@@ -1204,9 +1235,21 @@ var init_banner_renderer = __esm({
1204
1235
  banner.appendChild(content);
1205
1236
  root.appendChild(banner);
1206
1237
  if (!context.nav) {
1238
+ this.liveContainer = banner;
1239
+ this.liveContent = content;
1240
+ this.liveBuild = (s) => buildStepContent(s, ownerDocument, {
1241
+ onCtaClick: (action, url) => dismiss("cta_clicked", action === "url" ? url : void 0),
1242
+ onDismiss: () => dismiss("dismissed")
1243
+ });
1207
1244
  context.onInteraction({ guideId: context.guide.guideId, stepIndex: 0, action: "shown" });
1208
1245
  }
1209
1246
  }
1247
+ onLiveUpdate(step) {
1248
+ if (this.liveContainer) {
1249
+ const position = step.style?.position === "bottom" ? "bottom" : "top";
1250
+ this.liveContainer.className = `veo-banner veo-banner-${position}`;
1251
+ }
1252
+ }
1210
1253
  };
1211
1254
  }
1212
1255
  });
@@ -1918,8 +1961,18 @@ var init_inline_renderer = __esm({
1918
1961
  });
1919
1962
  card.appendChild(content);
1920
1963
  root.appendChild(card);
1964
+ this.liveContainer = card;
1965
+ this.liveContent = content;
1966
+ this.liveKey = `${selector}|${position}`;
1967
+ this.liveBuild = (s) => buildStepContent(s, ownerDocument, {
1968
+ onCtaClick: (action, url) => dismiss("cta_clicked", action === "url" ? url : void 0),
1969
+ onDismiss: () => dismiss("dismissed")
1970
+ });
1921
1971
  context.onInteraction({ guideId: context.guide.guideId, stepIndex: 0, action: "shown" });
1922
1972
  }
1973
+ liveKeyOf(step) {
1974
+ return `${step.selector ?? ""}|${readInlinePosition(step.style)}`;
1975
+ }
1923
1976
  };
1924
1977
  }
1925
1978
  });
@@ -1965,6 +2018,14 @@ var init_modal_renderer = __esm({
1965
2018
  card.appendChild(content);
1966
2019
  overlay.appendChild(card);
1967
2020
  root.appendChild(overlay);
2021
+ if (!context.nav) {
2022
+ this.liveContainer = card;
2023
+ this.liveContent = content;
2024
+ this.liveBuild = (s) => buildStepContent(s, ownerDocument, {
2025
+ onCtaClick: (action, url) => dismiss("cta_clicked", action === "url" ? url : void 0),
2026
+ onDismiss: () => dismiss("dismissed")
2027
+ });
2028
+ }
1968
2029
  overlay.addEventListener("click", (e) => {
1969
2030
  if (e.target === overlay) onBackdropOrEsc();
1970
2031
  });
@@ -2010,6 +2071,12 @@ var init_tooltip_renderer = __esm({
2010
2071
  init_base_renderer();
2011
2072
  init_floating_arrow();
2012
2073
  TooltipRenderer = class extends BaseRenderer {
2074
+ constructor() {
2075
+ super(...arguments);
2076
+ /** Lado preferido (mutable: el update in-place puede cambiarlo). */
2077
+ this.side = "bottom";
2078
+ this.reposition = null;
2079
+ }
2013
2080
  async render(context) {
2014
2081
  const step = context.guide.guideSteps[0];
2015
2082
  if (!step) return;
@@ -2018,7 +2085,7 @@ var init_tooltip_renderer = __esm({
2018
2085
  const anchor = await waitForElement(selector);
2019
2086
  if (!anchor) return;
2020
2087
  const rawSide = step.style?.tooltipPlacement;
2021
- const side = rawSide === "top" || rawSide === "left" || rawSide === "right" ? rawSide : "bottom";
2088
+ this.side = rawSide === "top" || rawSide === "left" || rawSide === "right" ? rawSide : "bottom";
2022
2089
  const { root } = this.createHost();
2023
2090
  this.applyDesign(step.style);
2024
2091
  const ownerDocument = root.ownerDocument ?? document;
@@ -2046,7 +2113,7 @@ var init_tooltip_renderer = __esm({
2046
2113
  root.appendChild(tooltip);
2047
2114
  const updatePosition = async () => {
2048
2115
  const { x, y, placement, middlewareData } = await dom.computePosition(anchor, tooltip, {
2049
- placement: side,
2116
+ placement: this.side,
2050
2117
  middleware: [dom.offset(10), dom.flip(), dom.shift({ padding: 8 }), dom.arrow({ element: arrowEl })]
2051
2118
  });
2052
2119
  tooltip.style.left = `${x}px`;
@@ -2057,18 +2124,34 @@ var init_tooltip_renderer = __esm({
2057
2124
  const reposition = () => {
2058
2125
  void updatePosition();
2059
2126
  };
2127
+ this.reposition = reposition;
2060
2128
  window.addEventListener("scroll", reposition, true);
2061
2129
  window.addEventListener("resize", reposition);
2062
2130
  this.registerCleanup(() => {
2063
2131
  window.removeEventListener("scroll", reposition, true);
2064
2132
  window.removeEventListener("resize", reposition);
2065
2133
  });
2134
+ this.liveContainer = tooltip;
2135
+ this.liveContent = content;
2136
+ this.liveKey = selector;
2137
+ this.liveBuild = (s) => buildStepContent(s, ownerDocument, {
2138
+ onCtaClick: (action, url) => dismiss("cta_clicked", action === "url" ? url : void 0),
2139
+ onDismiss: () => dismiss("dismissed")
2140
+ });
2066
2141
  context.onInteraction({
2067
2142
  guideId: context.guide.guideId,
2068
2143
  stepIndex: 0,
2069
2144
  action: "shown"
2070
2145
  });
2071
2146
  }
2147
+ liveKeyOf(step) {
2148
+ return step.selector ?? "";
2149
+ }
2150
+ onLiveUpdate(step) {
2151
+ const raw = step.style?.tooltipPlacement;
2152
+ this.side = raw === "top" || raw === "left" || raw === "right" ? raw : "bottom";
2153
+ this.reposition?.();
2154
+ }
2072
2155
  };
2073
2156
  }
2074
2157
  });
@@ -2214,6 +2297,11 @@ var init_guide_preview = __esm({
2214
2297
  this.input = null;
2215
2298
  }
2216
2299
  preview(input) {
2300
+ const nextStep = input.guideSteps[0];
2301
+ if (this.singleStep && this.input && input.guideType === this.input.guideType && input.guideType !== "walkthrough" && nextStep && this.singleStep.updateStep(nextStep)) {
2302
+ this.input = input;
2303
+ return { close: () => this.close(), ready: Promise.resolve({ rendered: true }) };
2304
+ }
2217
2305
  this.close();
2218
2306
  this.input = input;
2219
2307
  const guide = normalize(input);