veo-sdk 0.5.19 → 0.5.21

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.
@@ -152,13 +152,6 @@ interface PreviewGuideInput {
152
152
  formSubmit?: (answers: Record<string, unknown>) => Promise<boolean>;
153
153
  /** Nota bajo el "¡Gracias!" cuando hay `formSubmit` propio. */
154
154
  formSubmitNote?: string;
155
- /**
156
- * `true` = la preview corre EN la página del editor (panel in-app). Los
157
- * bloques de código en modo host NO se inyectan (corromperían el editor);
158
- * muestran un placeholder. El link de preview (app real, sin editor) lo deja
159
- * en `false` → el código host sí corre.
160
- */
161
- editorPreview?: boolean;
162
155
  }
163
156
  /** Resultado del primer render de una preview. */
164
157
  interface PreviewResult {
@@ -152,13 +152,6 @@ interface PreviewGuideInput {
152
152
  formSubmit?: (answers: Record<string, unknown>) => Promise<boolean>;
153
153
  /** Nota bajo el "¡Gracias!" cuando hay `formSubmit` propio. */
154
154
  formSubmitNote?: string;
155
- /**
156
- * `true` = la preview corre EN la página del editor (panel in-app). Los
157
- * bloques de código en modo host NO se inyectan (corromperían el editor);
158
- * muestran un placeholder. El link de preview (app real, sin editor) lo deja
159
- * en `false` → el código host sí corre.
160
- */
161
- editorPreview?: boolean;
162
155
  }
163
156
  /** Resultado del primer render de una preview. */
164
157
  interface PreviewResult {
package/dist/index.cjs CHANGED
@@ -2135,10 +2135,6 @@ function mountCodeBlock(block, doc, context) {
2135
2135
  wrapper.appendChild(iframe);
2136
2136
  return { node: wrapper, cleanup };
2137
2137
  }
2138
- if (context.editorPreview) {
2139
- return { node: buildHostPlaceholder(doc), cleanup: () => {
2140
- } };
2141
- }
2142
2138
  const hostDoc = doc;
2143
2139
  const injected = [];
2144
2140
  if (typeof block.css === "string" && block.css.trim()) {
@@ -2170,18 +2166,6 @@ function mountCodeBlock(block, doc, context) {
2170
2166
  }
2171
2167
  };
2172
2168
  }
2173
- function buildHostPlaceholder(doc) {
2174
- const box = doc.createElement("div");
2175
- box.className = "veo-code-placeholder";
2176
- box.style.cssText = "border:1px dashed #cbd5e1;border-radius:8px;padding:12px;text-align:center;font:13px/1.4 system-ui,sans-serif;color:#64748b;background:#f8fafc;";
2177
- const t = doc.createElement("strong");
2178
- t.textContent = "\u27E8 \u27E9 Bloque de c\xF3digo";
2179
- t.style.cssText = "display:block;color:#475569;margin-bottom:2px;";
2180
- const s = doc.createElement("span");
2181
- s.textContent = "Se ejecuta en tu app al publicar (no corre en el editor).";
2182
- box.append(t, s);
2183
- return box;
2184
- }
2185
2169
  function runScript(old, hostDoc) {
2186
2170
  const s = hostDoc.createElement("script");
2187
2171
  for (const attr of Array.from(old.attributes)) s.setAttribute(attr.name, attr.value);
@@ -3515,7 +3499,6 @@ var init_guide_preview = __esm({
3515
3499
  // el caller puede pasar `formSubmit` real (link de preview).
3516
3500
  onFormSubmit: this.input?.formSubmit ?? (() => Promise.resolve(true)),
3517
3501
  isPreview: true,
3518
- editorPreview: this.input?.editorPreview === true,
3519
3502
  ...this.input?.formSubmit && this.input.formSubmitNote !== void 0 ? { previewNote: this.input.formSubmitNote } : {}
3520
3503
  });
3521
3504
  } catch {
@@ -4380,7 +4363,7 @@ function initBuilderMode() {
4380
4363
  dropTarget?.detach();
4381
4364
  dropTarget = null;
4382
4365
  previewStepIndex = cmd.guide.startStepIndex ?? 0;
4383
- const handle = previewGuide({ ...cmd.guide, editorPreview: true });
4366
+ const handle = previewGuide(cmd.guide);
4384
4367
  if (!cmd.editable) return;
4385
4368
  void handle.ready.then((result) => {
4386
4369
  if (!result.rendered) return;
@@ -6192,6 +6175,13 @@ var GuidesController = class {
6192
6175
  * a esa página (tours multi-página estilo Pendo).
6193
6176
  */
6194
6177
  this.pendingComposite = null;
6178
+ /**
6179
+ * Guías composite EN PANTALLA con el paso mostrado, por `guideId`. En una SPA,
6180
+ * al navegar a una página que ya NO matchea la `pageLocation` del paso, hay que
6181
+ * DESTRUIR la guía (si no, queda pegada y "se muestra en todo lado"). Se poda
6182
+ * en cada `checkGuides` con {@link pruneComposite}.
6183
+ */
6184
+ this.activeComposite = /* @__PURE__ */ new Map();
6195
6185
  this.debug = config.debug === true;
6196
6186
  this.apiUrl = config.apiUrl;
6197
6187
  this.apiKey = config.apiKey;
@@ -6238,6 +6228,7 @@ var GuidesController = class {
6238
6228
  if (this.debug) console.log("[veo] guides: skipped, no endUserId yet");
6239
6229
  return;
6240
6230
  }
6231
+ this.pruneComposite(pageUrl);
6241
6232
  if (await this.tryResumeWalkthrough(endUserId, sessionId, pageUrl)) {
6242
6233
  return;
6243
6234
  }
@@ -6370,6 +6361,7 @@ ${pageUrl}`;
6370
6361
  }
6371
6362
  this.activeRenderers.clear();
6372
6363
  this.activeByGuideId.clear();
6364
+ this.activeComposite.clear();
6373
6365
  if (this.activeWalkthroughRenderer) {
6374
6366
  try {
6375
6367
  this.activeWalkthroughRenderer.destroy();
@@ -6406,6 +6398,20 @@ ${pageUrl}`;
6406
6398
  if (start === -1) return;
6407
6399
  this.renderCompositeStep(guide, start, sessionId, pageUrl);
6408
6400
  }
6401
+ /**
6402
+ * Destruye las guías composite en pantalla cuyo paso mostrado ya no matchea la
6403
+ * URL actual (el usuario navegó fuera de su `pageLocation` en una SPA). Sin
6404
+ * esto la guía queda montada en el DOM y aparece en páginas que no debía.
6405
+ */
6406
+ pruneComposite(pageUrl) {
6407
+ for (const entry of this.activeComposite.values()) {
6408
+ const steps = entry.guide.guideSteps;
6409
+ const step = steps[entry.stepIndex];
6410
+ if (!step || !stepMatchesPage(step.pageLocation, pageUrl)) {
6411
+ entry.cleanup();
6412
+ }
6413
+ }
6414
+ }
6409
6415
  /**
6410
6416
  * Resume un tour composite que quedó esperando navegación: si el paso
6411
6417
  * pendiente aplica a la página actual, lo pinta. Devuelve `true` si resumió.
@@ -6440,7 +6446,9 @@ ${pageUrl}`;
6440
6446
  if (this.activeByGuideId.get(guide.guideId) === renderer) {
6441
6447
  this.activeByGuideId.delete(guide.guideId);
6442
6448
  }
6449
+ this.activeComposite.delete(guide.guideId);
6443
6450
  };
6451
+ this.activeComposite.set(guide.guideId, { guide, stepIndex: idx, cleanup });
6444
6452
  const goToStep = (target) => {
6445
6453
  cleanup();
6446
6454
  if (target < 0 || target >= steps.length) return;