veo-sdk 0.3.8 → 0.3.10

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.
@@ -0,0 +1,5 @@
1
+ export { createBuilderSession, initBuilderMode, startElementPicker, stopElementPicker } from './chunk-FC5IA6CO.mjs';
2
+ import './chunk-OENKQRLR.mjs';
3
+ import './chunk-PTG3BTJE.mjs';
4
+ //# sourceMappingURL=builder-TIN4M7IH.mjs.map
5
+ //# sourceMappingURL=builder-TIN4M7IH.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"builder-YYMD7MNK.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"builder-TIN4M7IH.mjs"}
package/dist/builder.cjs CHANGED
@@ -792,21 +792,6 @@ var GUIDE_STYLES = `
792
792
  background: transparent;
793
793
  color-scheme: normal;
794
794
  }
795
- /*
796
- * X de cerrar de las gu\xEDas custom: el HTML del cliente vive en un iframe
797
- * sandbox, as\xED que el bot\xF3n lo pone el host POR ENCIMA del iframe. Con fondo
798
- * propio para ser visible sobre cualquier contenido.
799
- */
800
- .veo-custom-close {
801
- position: absolute; top: 6px; right: 6px; z-index: 1;
802
- width: 22px; height: 22px; padding: 0;
803
- display: flex; align-items: center; justify-content: center;
804
- font-size: 16px; line-height: 1; color: #6b7280;
805
- background: rgba(255, 255, 255, 0.92);
806
- border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 50%;
807
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); cursor: pointer;
808
- }
809
- .veo-custom-close:hover { color: #111827; }
810
795
 
811
796
  @keyframes veo-fade-in { from { opacity: 0; } to { opacity: 1; } }
812
797
  @keyframes veo-slide-up {
@@ -980,7 +965,8 @@ function mountCustomFrame(doc, step, context, opts) {
980
965
  const token = uuidv7();
981
966
  const wantsTailwind = step.style?.tailwind === true;
982
967
  iframe.srcdoc = buildSrcdoc(step.html ?? "", step.css ?? "", step.js ?? "", token, {
983
- tokens: collectHostTokens(),
968
+ hostCss: collectHostStyles(),
969
+ htmlAttrs: hostHtmlAttrs(),
984
970
  tailwind: wantsTailwind
985
971
  });
986
972
  const close = () => context.onClose();
@@ -1031,25 +1017,40 @@ function mountCustomFrame(doc, step, context, opts) {
1031
1017
  function toCssSize(value) {
1032
1018
  return typeof value === "number" ? `${value}px` : value;
1033
1019
  }
1034
- function collectHostTokens() {
1035
- if (typeof window === "undefined" || typeof document === "undefined") return "";
1020
+ var MAX_HOST_CSS = 800 * 1024;
1021
+ function collectHostStyles() {
1022
+ if (typeof document === "undefined") return "";
1023
+ let out = "";
1036
1024
  try {
1037
- const rootStyle = getComputedStyle(document.documentElement);
1038
- const decls = [];
1039
- const seen = /* @__PURE__ */ new Set();
1040
- for (let i = 0; i < rootStyle.length && decls.length < 400; i++) {
1041
- const name = rootStyle.item(i);
1042
- if (!name.startsWith("--") || seen.has(name)) continue;
1043
- seen.add(name);
1044
- const value = rootStyle.getPropertyValue(name).trim();
1045
- if (!value || value.length > 200 || /[<>{}]/.test(value)) continue;
1046
- decls.push(`${name}:${value}`);
1025
+ for (const sheet of Array.from(document.styleSheets)) {
1026
+ let rules = null;
1027
+ try {
1028
+ rules = sheet.cssRules;
1029
+ } catch {
1030
+ continue;
1031
+ }
1032
+ if (!rules) continue;
1033
+ for (const rule of Array.from(rules)) {
1034
+ out += `${rule.cssText}
1035
+ `;
1036
+ if (out.length > MAX_HOST_CSS) return out;
1037
+ }
1047
1038
  }
1048
- const bodyFont = getComputedStyle(document.body).fontFamily;
1049
- if (bodyFont && bodyFont.length <= 200 && !/[<>{}]/.test(bodyFont)) {
1050
- decls.push(`--veo-host-font:${bodyFont}`);
1039
+ } catch {
1040
+ return out;
1041
+ }
1042
+ return out;
1043
+ }
1044
+ function hostHtmlAttrs() {
1045
+ if (typeof document === "undefined") return "";
1046
+ try {
1047
+ const el = document.documentElement;
1048
+ const attrs = [];
1049
+ for (const name of ["class", "style", "data-theme", "data-mode", "data-color-mode"]) {
1050
+ const v = el.getAttribute(name);
1051
+ if (v && v.length <= 1e3 && !/["<>]/.test(v)) attrs.push(`${name}="${v}"`);
1051
1052
  }
1052
- return decls.length ? `:root{${decls.join(";")}}` : "";
1053
+ return attrs.join(" ");
1053
1054
  } catch {
1054
1055
  return "";
1055
1056
  }
@@ -1059,9 +1060,20 @@ function isRecord(value) {
1059
1060
  }
1060
1061
  function buildSrcdoc(html, css, js, token, opts) {
1061
1062
  const bridge = `(function(){var T=${JSON.stringify(token)};function P(m){m.__veo=T;parent.postMessage(m,'*');}window.veo={dismiss:function(){P({type:'dismiss'});},cta:function(u){P({type:'cta',url:u});},track:function(n,p){P({type:'track',name:n,props:p||{}});},navigate:function(u){P({type:'navigate',url:u});}};document.addEventListener('click',function(e){var a=e.target&&e.target.closest?e.target.closest('a[href]'):null;if(!a)return;var h=a.getAttribute('href');if(!h||h.charAt(0)==='#'||/^(javascript|mailto|tel):/i.test(h))return;e.preventDefault();if(a.target==='_blank'){P({type:'cta',url:a.href,close:false});}else{P({type:'navigate',url:h});}},true);function H(){P({type:'resize',height:Math.ceil(document.documentElement.scrollHeight)});}window.addEventListener('load',H);try{if(typeof ResizeObserver!=='undefined'){new ResizeObserver(H).observe(document.documentElement);}}catch(e){}})();`;
1062
- const tokensStyle = opts.tokens ? `<style>${escapeClosing(opts.tokens, "style")}</style>` : "";
1063
+ const hostStyle = opts.hostCss ? `<style>${escapeClosing(opts.hostCss, "style")}</style>` : "";
1063
1064
  const tailwind = opts.tailwind ? '<script src="https://cdn.tailwindcss.com"></script>' : "";
1064
- return '<!DOCTYPE html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;font-family:var(--veo-host-font,system-ui,sans-serif);}</style>' + tokensStyle + tailwind + `<style>${escapeClosing(css, "style")}</style></head><body>${html}<script>${bridge}</script>` + (js ? `<script>${escapeClosing(js, "script")}</script>` : "") + "</body></html>";
1065
+ return (
1066
+ // Orden: base → CSS del host (utilidades+clases propias+:root) → reset
1067
+ // flotante (fondo transparente, sin márgenes) → Tailwind → CSS del autor (gana).
1068
+ `<!DOCTYPE html><html ${opts.htmlAttrs}><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;}body{font-family:system-ui,-apple-system,sans-serif;}</style>` + hostStyle + // Reset flotante: el CSS de la app trae reglas de PÁGINA (body{min-height:100vh},
1069
+ // html{height:100%}, fondo del layout…) que en un iframe embebido lo estirarían a
1070
+ // toda la pantalla (caja negra) en vez de ajustarse al contenido. Neutralizamos
1071
+ // tamaño/fondo/overflow (mantenemos color y fuente heredados de la app).
1072
+ "<style>html,body{margin:0!important;padding:0!important;background:transparent!important;height:auto!important;min-height:0!important;max-height:none!important;width:auto!important;min-width:0!important;overflow:visible!important;}</style>" + tailwind + // Inline en <body>: gana incluso sobre reglas `!important` de la app (p. ej.
1073
+ // `.dark body{background:#000!important}`) porque el estilo inline tiene la
1074
+ // mayor especificidad dentro de la capa important-author.
1075
+ `<style>${escapeClosing(css, "style")}</style></head><body style="margin:0!important;background:transparent!important;min-height:0!important;height:auto!important;">` + html + `<script>${bridge}</script>` + (js ? `<script>${escapeClosing(js, "script")}</script>` : "") + "</body></html>"
1076
+ );
1065
1077
  }
1066
1078
  function escapeClosing(code, tag) {
1067
1079
  const rx = tag === "script" ? /<\/script/gi : /<\/style/gi;
@@ -1094,20 +1106,6 @@ var CustomRenderer = class extends BaseRenderer {
1094
1106
  });
1095
1107
  this.registerCleanup(cleanup);
1096
1108
  wrapper.appendChild(iframe);
1097
- wrapper.appendChild(
1098
- createCloseButton(
1099
- doc,
1100
- () => {
1101
- context.onInteraction({
1102
- guideId: context.guide.guideId,
1103
- stepIndex: 0,
1104
- action: "dismissed"
1105
- });
1106
- context.onClose();
1107
- },
1108
- "veo-custom-close"
1109
- )
1110
- );
1111
1109
  root.appendChild(wrapper);
1112
1110
  if (placement.mode === "floating") {
1113
1111
  applyFloatingPosition(wrapper, placement);
@@ -1509,20 +1507,6 @@ var InlineCustomRenderer = class extends BaseRenderer {
1509
1507
  const { iframe, cleanup } = mountCustomFrame(doc, step, context, { width: "100%" });
1510
1508
  this.registerCleanup(cleanup);
1511
1509
  wrapper.appendChild(iframe);
1512
- wrapper.appendChild(
1513
- createCloseButton(
1514
- doc,
1515
- () => {
1516
- context.onInteraction({
1517
- guideId: context.guide.guideId,
1518
- stepIndex: 0,
1519
- action: "dismissed"
1520
- });
1521
- context.onClose();
1522
- },
1523
- "veo-custom-close"
1524
- )
1525
- );
1526
1510
  root.appendChild(wrapper);
1527
1511
  context.onInteraction({ guideId: context.guide.guideId, stepIndex: 0, action: "shown" });
1528
1512
  }