veo-sdk 0.5.32 → 0.5.34

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
1
  import { BUILDER_TOKEN_PARAM, BUILDER_PANEL_PATH_PARAM, BUILDER_GUIDE_PARAM, BUILDER_PANEL_PARAM, BUILDER_ORIGIN_PARAM } from './chunk-PTG3BTJE.mjs';
2
- import { computePosition, offset, flip, shift, arrow } from '@floating-ui/dom';
2
+ import { computePosition, offset, flip, shift, arrow, autoUpdate } from '@floating-ui/dom';
3
3
 
4
4
  // src/utils/safe-env.ts
5
5
  function hasWindow() {
@@ -195,6 +195,19 @@ function clearBuilderToken() {
195
195
  }
196
196
  }
197
197
 
198
+ // src/plugins/guides/activation-rules.ts
199
+ function isAutomaticActivation(rules) {
200
+ const trigger = rules?.trigger ?? "immediate";
201
+ if (trigger === "immediate" || trigger === "delayed") return true;
202
+ if (trigger === "on_click" || trigger === "on_hover") return rules?.autoShow === true;
203
+ return false;
204
+ }
205
+ function activationDelayMs(rules) {
206
+ if (!isAutomaticActivation(rules)) return 0;
207
+ const ms = rules?.delayMs ?? 0;
208
+ return Number.isFinite(ms) && ms > 0 ? ms : 0;
209
+ }
210
+
198
211
  // src/plugins/guides/constants.ts
199
212
  var GUIDE_Z_INDEX = 2147483640;
200
213
  var DEFAULT_ANCHOR_WAIT_MS = 5e3;
@@ -2256,6 +2269,188 @@ function buildScale(wrapper, doc, min, max, btnClass, symbol) {
2256
2269
  wrapper.appendChild(row);
2257
2270
  return { wrapper, read: () => selected };
2258
2271
  }
2272
+ 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";
2273
+ 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";
2274
+ 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";
2275
+ var CIRCLE = "M21 12a9 9 0 11-18 0 9 9 0 0118 0z";
2276
+ var TARGET_GLYPH = "M7.5 3.75H6A2.25 2.25 0 0 0 3.75 6v1.5M16.5 3.75H18A2.25 2.25 0 0 1 20.25 6v1.5m0 9V18A2.25 2.25 0 0 1 18 20.25h-1.5m-9 0H6A2.25 2.25 0 0 1 3.75 18v-1.5M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z";
2277
+ var BADGE_ICONS = {
2278
+ info: { paths: [CIRCLE, INFO_GLYPH], dots: [[12, 8.25]] },
2279
+ exclamation: { paths: [CIRCLE, "M12 8v4.5"], dots: [[12, 15.75]] },
2280
+ question: { paths: [CIRCLE, QUESTION_GLYPH], dots: [[12, 17.25]] },
2281
+ star: { paths: [STAR_GLYPH] },
2282
+ "info-solid": { paths: [INFO_GLYPH], dots: [[12, 8.25]], solid: true, scale: 0.8 },
2283
+ "exclamation-solid": { paths: ["M12 8v4.5"], dots: [[12, 15.75]], solid: true, scale: 0.8 },
2284
+ "question-solid": { paths: [QUESTION_GLYPH], dots: [[12, 17.25]], solid: true, scale: 0.8 },
2285
+ "star-solid": { paths: [STAR_GLYPH], solid: true, scale: 0.55 },
2286
+ "target-solid": { paths: [TARGET_GLYPH], solid: true, scale: 0.6 },
2287
+ new: { paths: [], text: "New" }
2288
+ };
2289
+ var DEFAULT_MARKER_SIZE = 14;
2290
+ var DEFAULT_MARKER_Z = 19e3;
2291
+ var SIDE_GAP = 8;
2292
+ function num(v, fallback) {
2293
+ return typeof v === "number" && Number.isFinite(v) ? v : fallback;
2294
+ }
2295
+ function iconNode(doc, name, size, color) {
2296
+ const def = BADGE_ICONS[name] ?? BADGE_ICONS.info;
2297
+ if (def.text) {
2298
+ const t = doc.createElement("span");
2299
+ t.textContent = def.text;
2300
+ t.style.font = `700 ${Math.round(size * 0.85)}px/1 system-ui, -apple-system, sans-serif`;
2301
+ t.style.color = color;
2302
+ return t;
2303
+ }
2304
+ const ns = "http://www.w3.org/2000/svg";
2305
+ const svg = doc.createElementNS(ns, "svg");
2306
+ svg.setAttribute("viewBox", "0 0 24 24");
2307
+ svg.setAttribute("width", String(size));
2308
+ svg.setAttribute("height", String(size));
2309
+ svg.setAttribute("fill", "none");
2310
+ svg.setAttribute("aria-hidden", "true");
2311
+ const glyphColor = def.solid ? "#ffffff" : color;
2312
+ if (def.solid) {
2313
+ const bg = doc.createElementNS(ns, "circle");
2314
+ bg.setAttribute("cx", "12");
2315
+ bg.setAttribute("cy", "12");
2316
+ bg.setAttribute("r", "12");
2317
+ bg.setAttribute("fill", color);
2318
+ svg.appendChild(bg);
2319
+ }
2320
+ const g = doc.createElementNS(ns, "g");
2321
+ g.setAttribute("stroke", glyphColor);
2322
+ g.setAttribute("stroke-width", def.solid ? "2" : "1.8");
2323
+ g.setAttribute("stroke-linecap", "round");
2324
+ g.setAttribute("stroke-linejoin", "round");
2325
+ if (def.scale && def.scale !== 1) {
2326
+ const k = def.scale;
2327
+ const t = 12 - 12 * k;
2328
+ g.setAttribute("transform", `translate(${t} ${t}) scale(${k})`);
2329
+ }
2330
+ for (const d of def.paths) {
2331
+ const path = doc.createElementNS(ns, "path");
2332
+ path.setAttribute("d", d);
2333
+ g.appendChild(path);
2334
+ }
2335
+ for (const [cx, cy] of def.dots ?? []) {
2336
+ const dot = doc.createElementNS(ns, "circle");
2337
+ dot.setAttribute("cx", String(cx));
2338
+ dot.setAttribute("cy", String(cy));
2339
+ dot.setAttribute("r", "0.9");
2340
+ dot.setAttribute("fill", glyphColor);
2341
+ dot.setAttribute("stroke", "none");
2342
+ g.appendChild(dot);
2343
+ }
2344
+ svg.appendChild(g);
2345
+ return svg;
2346
+ }
2347
+ function buildMarkerElement(doc, marker) {
2348
+ const size = num(marker.size, DEFAULT_MARKER_SIZE);
2349
+ const color = marker.color || "#000000";
2350
+ const el = doc.createElement("span");
2351
+ el.className = `veo-badge-marker veo-badge-marker-${marker.kind}`;
2352
+ el.style.display = "inline-flex";
2353
+ el.style.alignItems = "center";
2354
+ el.style.justifyContent = "center";
2355
+ el.style.boxSizing = "border-box";
2356
+ el.style.lineHeight = "1";
2357
+ if (marker.kind === "image") {
2358
+ const img = doc.createElement("img");
2359
+ img.alt = "";
2360
+ img.src = marker.imageUrl || "";
2361
+ img.style.width = `${size}px`;
2362
+ img.style.height = `${size}px`;
2363
+ img.style.objectFit = "contain";
2364
+ img.style.display = "block";
2365
+ el.appendChild(img);
2366
+ return el;
2367
+ }
2368
+ if (marker.kind === "icon-text") {
2369
+ el.style.gap = "6px";
2370
+ el.style.color = color;
2371
+ el.style.fontSize = `${size}px`;
2372
+ el.style.fontFamily = "inherit";
2373
+ el.style.fontWeight = "600";
2374
+ el.style.whiteSpace = "nowrap";
2375
+ el.style.background = marker.bgColor || "transparent";
2376
+ const bw = num(marker.borderWidth, 0);
2377
+ if (bw > 0) el.style.border = `${bw}px solid ${marker.borderColor || color}`;
2378
+ el.style.padding = `${num(marker.paddingY, 6)}px ${num(marker.paddingX, 10)}px`;
2379
+ el.style.borderRadius = `${num(marker.radius, 999)}px`;
2380
+ if (marker.showIcon !== false)
2381
+ el.appendChild(iconNode(doc, marker.icon || "star", size, color));
2382
+ const text = doc.createElement("span");
2383
+ text.textContent = marker.text || "";
2384
+ el.appendChild(text);
2385
+ return el;
2386
+ }
2387
+ el.style.width = `${size}px`;
2388
+ el.style.height = `${size}px`;
2389
+ el.appendChild(iconNode(doc, marker.icon || "info", size, color));
2390
+ return el;
2391
+ }
2392
+ function markerOffset(anchor, marker, position, offset6) {
2393
+ const right = anchor.left + anchor.width;
2394
+ const bottom = anchor.top + anchor.height;
2395
+ const midY = anchor.top + anchor.height / 2 - marker.height / 2;
2396
+ const midX = anchor.left + anchor.width / 2 - marker.width / 2;
2397
+ let x;
2398
+ let y;
2399
+ switch (position) {
2400
+ case "top-left":
2401
+ x = anchor.left - marker.width / 2;
2402
+ y = anchor.top - marker.height / 2;
2403
+ break;
2404
+ case "bottom-left":
2405
+ x = anchor.left - marker.width / 2;
2406
+ y = bottom - marker.height / 2;
2407
+ break;
2408
+ case "bottom-right":
2409
+ x = right - marker.width / 2;
2410
+ y = bottom - marker.height / 2;
2411
+ break;
2412
+ case "left":
2413
+ x = anchor.left - marker.width - SIDE_GAP;
2414
+ y = midY;
2415
+ break;
2416
+ case "right":
2417
+ x = right + SIDE_GAP;
2418
+ y = midY;
2419
+ break;
2420
+ case "center":
2421
+ x = midX;
2422
+ y = midY;
2423
+ break;
2424
+ default:
2425
+ x = right - marker.width / 2;
2426
+ y = anchor.top - marker.height / 2;
2427
+ }
2428
+ return { x: x + offset6.x, y: y + offset6.y };
2429
+ }
2430
+ function attachMarker(anchor, host, marker) {
2431
+ host.style.position = "absolute";
2432
+ host.style.zIndex = String(num(marker.zIndex, DEFAULT_MARKER_Z));
2433
+ host.style.margin = "0";
2434
+ const update = () => {
2435
+ const a = anchor.getBoundingClientRect();
2436
+ const m = host.getBoundingClientRect();
2437
+ const { x, y } = markerOffset(
2438
+ {
2439
+ left: a.left + window.scrollX,
2440
+ top: a.top + window.scrollY,
2441
+ width: a.width,
2442
+ height: a.height
2443
+ },
2444
+ { width: m.width, height: m.height },
2445
+ marker.position ?? "top-right",
2446
+ { x: num(marker.offsetX, 0), y: num(marker.offsetY, 0) }
2447
+ );
2448
+ host.style.left = `${Math.round(x)}px`;
2449
+ host.style.top = `${Math.round(y)}px`;
2450
+ };
2451
+ update();
2452
+ return autoUpdate(anchor, host, update);
2453
+ }
2259
2454
 
2260
2455
  // src/plugins/guides/renderers/composite-renderer.ts
2261
2456
  var ROW_ALIGN = {
@@ -2551,7 +2746,9 @@ var CompositeRenderer = class extends BaseRenderer {
2551
2746
  badge.style.cursor = "pointer";
2552
2747
  badge.style.display = "inline-flex";
2553
2748
  badge.style.alignItems = "center";
2554
- this.buildContent(badge, step.badge?.blocks ?? [], doc, context, idx, [], host);
2749
+ const marker = step.badge?.marker ?? null;
2750
+ if (marker) badge.appendChild(buildMarkerElement(doc, marker));
2751
+ else this.buildContent(badge, step.badge?.blocks ?? [], doc, context, idx, [], host);
2555
2752
  root.appendChild(badge);
2556
2753
  if (design.fullWidth === true) {
2557
2754
  card.style.width = "auto";
@@ -2566,10 +2763,17 @@ var CompositeRenderer = class extends BaseRenderer {
2566
2763
  if (caretEl) wrapper.appendChild(caretEl);
2567
2764
  wrapper.appendChild(card);
2568
2765
  root.appendChild(wrapper);
2569
- host.style.display = "inline-block";
2570
- const pos = inlinePosOf(step.inlinePosition);
2571
- insertHost(anchor, host, pos);
2572
- this.registerCleanup(keepHostAttached(host, anchorSelector, pos));
2766
+ if (marker) {
2767
+ host.style.display = "inline-block";
2768
+ (anchor.ownerDocument ?? document).body.appendChild(host);
2769
+ this.registerCleanup(attachMarker(anchor, host, marker));
2770
+ this.registerCleanup(() => host.remove());
2771
+ } else {
2772
+ host.style.display = "inline-block";
2773
+ const pos = inlinePosOf(step.inlinePosition);
2774
+ insertHost(anchor, host, pos);
2775
+ this.registerCleanup(keepHostAttached(host, anchorSelector, pos));
2776
+ }
2573
2777
  let open = false;
2574
2778
  let stopFloat = null;
2575
2779
  let closeTimer = null;
@@ -2622,6 +2826,7 @@ var CompositeRenderer = class extends BaseRenderer {
2622
2826
  stopFloat?.();
2623
2827
  if (closeTimer !== null) clearTimeout(closeTimer);
2624
2828
  });
2829
+ if (context.badgeOpen) openTip();
2625
2830
  return closeTip;
2626
2831
  }
2627
2832
  };
@@ -3198,7 +3403,8 @@ var GuidePreviewController = class {
3198
3403
  }
3199
3404
  preview(input) {
3200
3405
  const nextStep = input.guideSteps[0];
3201
- if (this.singleStep && this.input && input.guideType === this.input.guideType && input.guideType !== "walkthrough" && nextStep && this.singleStep.updateStep(nextStep)) {
3406
+ if (this.singleStep && this.input && input.guideType === this.input.guideType && input.guideType !== "walkthrough" && // Abrir/cerrar el tooltip del badge requiere remontar.
3407
+ input.badgeOpen === true === (this.input.badgeOpen === true) && nextStep && this.singleStep.updateStep(nextStep)) {
3202
3408
  this.input = input;
3203
3409
  return {
3204
3410
  close: () => this.close(),
@@ -3228,7 +3434,8 @@ var GuidePreviewController = class {
3228
3434
  }
3229
3435
  return null;
3230
3436
  }
3231
- close() {
3437
+ close(byUser = false) {
3438
+ const onClosed = byUser ? this.input?.onClosed : void 0;
3232
3439
  if (this.singleStep) {
3233
3440
  safeDestroy(this.singleStep);
3234
3441
  this.singleStep = null;
@@ -3240,6 +3447,7 @@ var GuidePreviewController = class {
3240
3447
  this.walkthroughGuide = null;
3241
3448
  this.walkthroughIndex = 0;
3242
3449
  this.input = null;
3450
+ onClosed?.();
3243
3451
  }
3244
3452
  async renderSingleStep(guide) {
3245
3453
  const renderer = createSingleStepRenderer(guide.guideType);
@@ -3252,7 +3460,10 @@ var GuidePreviewController = class {
3252
3460
  onInteraction: (event) => {
3253
3461
  if (event.action === "shown") shown = true;
3254
3462
  },
3255
- onClose: () => this.close(),
3463
+ onClose: () => this.close(true),
3464
+ // Sin indicación explícita, el badge se abre solo si la guía arranca
3465
+ // sola (como en el runtime); `manual` lo deja cerrado.
3466
+ badgeOpen: this.input?.badgeOpen ?? isAutomaticActivation(this.input?.activationRules),
3256
3467
  onTrack: () => {
3257
3468
  },
3258
3469
  // Encadenado en preview: no-op — el editor no puede montar otra guía
@@ -3318,7 +3529,7 @@ var GuidePreviewController = class {
3318
3529
  guide,
3319
3530
  onInteraction: () => {
3320
3531
  },
3321
- onClose: () => this.close(),
3532
+ onClose: () => this.close(true),
3322
3533
  nav: { stepIndex: index, totalSteps: guide.guideSteps.length, callbacks }
3323
3534
  });
3324
3535
  } catch {
@@ -3411,16 +3622,36 @@ function safeDestroy(renderer) {
3411
3622
  }
3412
3623
  }
3413
3624
 
3625
+ // src/plugins/guides/activation-devices.ts
3626
+ var MOBILE_MAX_WIDTH = 767;
3627
+ function isDeviceAllowed(devices, viewportWidth = typeof window === "undefined" ? 1024 : window.innerWidth) {
3628
+ if (!devices || devices === "all") return true;
3629
+ const mobile = viewportWidth <= MOBILE_MAX_WIDTH;
3630
+ return devices === "mobile" ? mobile : !mobile;
3631
+ }
3632
+
3414
3633
  // src/plugins/guides/url-match.ts
3634
+ function urlCandidates(pageUrl) {
3635
+ const out = [pageUrl];
3636
+ try {
3637
+ const u = new URL(pageUrl);
3638
+ out.push(`${u.pathname}${u.search}${u.hash}`);
3639
+ if (u.hash.startsWith("#/")) out.push(u.hash.slice(1));
3640
+ } catch {
3641
+ }
3642
+ return out;
3643
+ }
3415
3644
  function matchesUrl(matcher, pageUrl) {
3645
+ const candidates = urlCandidates(pageUrl);
3416
3646
  switch (matcher.type) {
3417
3647
  case "exact":
3418
- return matcher.pattern === pageUrl;
3648
+ return candidates.some((c) => c === matcher.pattern);
3419
3649
  case "prefix":
3420
- return pageUrl.startsWith(matcher.pattern);
3650
+ return candidates.some((c) => c.startsWith(matcher.pattern));
3421
3651
  case "regex":
3422
3652
  try {
3423
- return new RegExp(matcher.pattern).test(pageUrl);
3653
+ const re = new RegExp(matcher.pattern);
3654
+ return candidates.some((c) => re.test(c));
3424
3655
  } catch {
3425
3656
  return false;
3426
3657
  }
@@ -3564,6 +3795,6 @@ function buildSelectorPath(element, maxAncestors = 5) {
3564
3795
  return parts.join(" > ");
3565
3796
  }
3566
3797
 
3567
- 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, clearPreviewToken, closeGuidePreview, filterHumanClasses, getPreviewToken, hasDocument, hasLocalStorage, hasNavigatorSendBeacon, hasWindow, isBuilderMode, previewGuide, resolveBuilderContext, resolveBuilderToken, stepMatchesPage, uuidv7 };
3568
- //# sourceMappingURL=chunk-X27GD7IT.mjs.map
3569
- //# sourceMappingURL=chunk-X27GD7IT.mjs.map
3798
+ 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, activationDelayMs, buildSelectorPath, clearBuilderToken, clearPreviewToken, closeGuidePreview, filterHumanClasses, getPreviewToken, hasDocument, hasLocalStorage, hasNavigatorSendBeacon, hasWindow, isAutomaticActivation, isBuilderMode, isDeviceAllowed, previewGuide, resolveBuilderContext, resolveBuilderToken, stepMatchesPage, uuidv7 };
3799
+ //# sourceMappingURL=chunk-W4R4XCWL.mjs.map
3800
+ //# sourceMappingURL=chunk-W4R4XCWL.mjs.map