veo-sdk 0.5.25 → 0.5.28
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/builder-RSWK3RIB.mjs +5 -0
- package/dist/{builder-HDTWSDJR.mjs.map → builder-RSWK3RIB.mjs.map} +1 -1
- package/dist/builder.cjs +154 -12
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.mjs +4 -4
- package/dist/{chunk-ZK4HWKL3.mjs → chunk-CWIUNHWA.mjs} +156 -14
- package/dist/chunk-CWIUNHWA.mjs.map +1 -0
- package/dist/{chunk-5F3DX5VP.mjs → chunk-L5X4AGR7.mjs} +3 -3
- package/dist/{chunk-5F3DX5VP.mjs.map → chunk-L5X4AGR7.mjs.map} +1 -1
- package/dist/{chunk-RDV5GIU7.mjs → chunk-WLW5Y5LU.mjs} +3 -3
- package/dist/{chunk-RDV5GIU7.mjs.map → chunk-WLW5Y5LU.mjs.map} +1 -1
- package/dist/index.cjs +155 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/veo-builder.js +10 -10
- package/dist/veo-builder.js.map +1 -1
- package/dist/veo-guides.js +5 -5
- package/dist/veo-guides.js.map +1 -1
- package/package.json +1 -1
- package/dist/builder-HDTWSDJR.mjs +0 -5
- package/dist/chunk-ZK4HWKL3.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2126,7 +2126,24 @@ var init_custom_frame = __esm({
|
|
|
2126
2126
|
});
|
|
2127
2127
|
|
|
2128
2128
|
// src/plugins/guides/code-block.ts
|
|
2129
|
-
function
|
|
2129
|
+
function insertRawNodes(anchor, nodes, pos) {
|
|
2130
|
+
const parent = anchor.parentNode;
|
|
2131
|
+
if (pos === "prepend") {
|
|
2132
|
+
const first = anchor.firstChild;
|
|
2133
|
+
for (const n of nodes) anchor.insertBefore(n, first);
|
|
2134
|
+
} else if (pos === "append") {
|
|
2135
|
+
for (const n of nodes) anchor.appendChild(n);
|
|
2136
|
+
} else if (pos === "before") {
|
|
2137
|
+
for (const n of nodes) parent?.insertBefore(n, anchor);
|
|
2138
|
+
} else {
|
|
2139
|
+
let ref = anchor;
|
|
2140
|
+
for (const n of nodes) {
|
|
2141
|
+
parent?.insertBefore(n, ref.nextSibling);
|
|
2142
|
+
ref = n;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
function mountCodeBlock(block, doc, context, host, rawInline) {
|
|
2130
2147
|
if (block.sandboxed) {
|
|
2131
2148
|
const step = { html: block.html ?? "", css: block.css, js: block.js };
|
|
2132
2149
|
const { iframe, cleanup } = mountCustomFrame(doc, step, context, { width: "100%" });
|
|
@@ -2145,19 +2162,28 @@ function mountCodeBlock(block, doc, context) {
|
|
|
2145
2162
|
}
|
|
2146
2163
|
let node = null;
|
|
2147
2164
|
if (typeof block.html === "string" && block.html.trim()) {
|
|
2148
|
-
node = doc.createElement("div");
|
|
2149
|
-
node.className = "veo-code-html";
|
|
2150
|
-
const inner = node.attachShadow({ mode: "open" });
|
|
2151
|
-
for (const sheet of Array.from(hostDoc.querySelectorAll('link[rel="stylesheet"], style'))) {
|
|
2152
|
-
inner.appendChild(sheet.cloneNode(true));
|
|
2153
|
-
}
|
|
2154
2165
|
const holder = doc.createElement("div");
|
|
2166
|
+
holder.className = "veo-code-html";
|
|
2155
2167
|
holder.innerHTML = block.html;
|
|
2156
2168
|
for (const old of Array.from(holder.querySelectorAll("script"))) {
|
|
2157
2169
|
injected.push(runScript(old, hostDoc));
|
|
2158
2170
|
old.remove();
|
|
2159
2171
|
}
|
|
2160
|
-
|
|
2172
|
+
if (rawInline) {
|
|
2173
|
+
const rawNodes = Array.from(holder.childNodes);
|
|
2174
|
+
insertRawNodes(rawInline.anchor, rawNodes, rawInline.pos);
|
|
2175
|
+
injected.push(...rawNodes);
|
|
2176
|
+
} else if (host) {
|
|
2177
|
+
const slotName = `veo-code-${++codeSlotSeq}`;
|
|
2178
|
+
holder.slot = slotName;
|
|
2179
|
+
host.appendChild(holder);
|
|
2180
|
+
injected.push(holder);
|
|
2181
|
+
const slot = doc.createElement("slot");
|
|
2182
|
+
slot.setAttribute("name", slotName);
|
|
2183
|
+
node = slot;
|
|
2184
|
+
} else {
|
|
2185
|
+
node = holder;
|
|
2186
|
+
}
|
|
2161
2187
|
}
|
|
2162
2188
|
if (typeof block.js === "string" && block.js.trim()) {
|
|
2163
2189
|
const s = hostDoc.createElement("script");
|
|
@@ -2179,9 +2205,11 @@ function runScript(old, hostDoc) {
|
|
|
2179
2205
|
hostDoc.body.appendChild(s);
|
|
2180
2206
|
return s;
|
|
2181
2207
|
}
|
|
2208
|
+
var codeSlotSeq;
|
|
2182
2209
|
var init_code_block = __esm({
|
|
2183
2210
|
"src/plugins/guides/code-block.ts"() {
|
|
2184
2211
|
init_custom_frame();
|
|
2212
|
+
codeSlotSeq = 0;
|
|
2185
2213
|
}
|
|
2186
2214
|
});
|
|
2187
2215
|
|
|
@@ -2598,12 +2626,25 @@ var init_composite_renderer = __esm({
|
|
|
2598
2626
|
const idx = context.nav?.stepIndex ?? 0;
|
|
2599
2627
|
const step = context.guide.guideSteps[idx];
|
|
2600
2628
|
if (!step) return;
|
|
2601
|
-
const
|
|
2629
|
+
const badgeMode = step.badge?.enabled === true;
|
|
2630
|
+
const anchorSelector = step.position === "relative-to-element" || step.presentation === "inline" || badgeMode ? step.anchorSelector?.trim() || void 0 : void 0;
|
|
2602
2631
|
let anchor = null;
|
|
2603
2632
|
if (anchorSelector) {
|
|
2604
2633
|
anchor = await waitForElement(anchorSelector);
|
|
2605
2634
|
if (!anchor) return;
|
|
2606
2635
|
}
|
|
2636
|
+
const blocks = step.blocks ?? [];
|
|
2637
|
+
const soleCode = blocks.length === 1 && blocks[0]?.type === "code" ? blocks[0] : void 0;
|
|
2638
|
+
if (step.presentation === "inline" && anchor && soleCode && !soleCode.sandboxed) {
|
|
2639
|
+
const rawDoc = anchor.ownerDocument ?? document;
|
|
2640
|
+
const { cleanup } = mountCodeBlock(soleCode, rawDoc, context, void 0, {
|
|
2641
|
+
anchor,
|
|
2642
|
+
pos: inlinePosOf(step.inlinePosition)
|
|
2643
|
+
});
|
|
2644
|
+
this.registerCleanup(cleanup);
|
|
2645
|
+
context.onInteraction({ guideId: context.guide.guideId, stepIndex: idx, action: "shown" });
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2607
2648
|
const { host, root } = this.createHost();
|
|
2608
2649
|
const doc = root.ownerDocument ?? document;
|
|
2609
2650
|
const design = step.design ?? {};
|
|
@@ -2620,11 +2661,16 @@ var init_composite_renderer = __esm({
|
|
|
2620
2661
|
});
|
|
2621
2662
|
};
|
|
2622
2663
|
const readers = [];
|
|
2623
|
-
this.buildContent(card, step.blocks ?? [], doc, context, idx, readers);
|
|
2664
|
+
this.buildContent(card, step.blocks ?? [], doc, context, idx, readers, host);
|
|
2624
2665
|
const lastBlock = card.lastElementChild;
|
|
2625
2666
|
if (lastBlock && !lastBlock.style.marginBottom) lastBlock.style.marginBottom = "0";
|
|
2667
|
+
let closeTooltip = null;
|
|
2626
2668
|
if (design.closeButton !== false) {
|
|
2627
2669
|
const closeBtn = createCloseButton(doc, () => {
|
|
2670
|
+
if (closeTooltip) {
|
|
2671
|
+
closeTooltip();
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2628
2674
|
dismiss("dismissed");
|
|
2629
2675
|
this.closeOrSkip(context);
|
|
2630
2676
|
});
|
|
@@ -2643,6 +2689,21 @@ var init_composite_renderer = __esm({
|
|
|
2643
2689
|
}
|
|
2644
2690
|
card.appendChild(closeBtn);
|
|
2645
2691
|
}
|
|
2692
|
+
if (badgeMode && anchor) {
|
|
2693
|
+
closeTooltip = this.renderBadgeMode(
|
|
2694
|
+
step,
|
|
2695
|
+
card,
|
|
2696
|
+
anchor,
|
|
2697
|
+
anchorSelector,
|
|
2698
|
+
host,
|
|
2699
|
+
root,
|
|
2700
|
+
doc,
|
|
2701
|
+
context,
|
|
2702
|
+
idx,
|
|
2703
|
+
design
|
|
2704
|
+
);
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2646
2707
|
if (step.presentation === "inline" && anchor) {
|
|
2647
2708
|
host.style.display = "block";
|
|
2648
2709
|
const pos = inlinePosOf(step.inlinePosition);
|
|
@@ -2691,7 +2752,7 @@ var init_composite_renderer = __esm({
|
|
|
2691
2752
|
context.onInteraction({ guideId: context.guide.guideId, stepIndex: idx, action: "shown" });
|
|
2692
2753
|
}
|
|
2693
2754
|
/** Recorre los bloques en orden y los pinta en la card. */
|
|
2694
|
-
buildContent(card, blocks, doc, context, idx, readers) {
|
|
2755
|
+
buildContent(card, blocks, doc, context, idx, readers, host) {
|
|
2695
2756
|
const emit = (block) => {
|
|
2696
2757
|
context.onInteraction({
|
|
2697
2758
|
guideId: context.guide.guideId,
|
|
@@ -2725,7 +2786,7 @@ var init_composite_renderer = __esm({
|
|
|
2725
2786
|
continue;
|
|
2726
2787
|
}
|
|
2727
2788
|
if (b.type === "code") {
|
|
2728
|
-
const { node: node2, cleanup } = mountCodeBlock(b, doc, context);
|
|
2789
|
+
const { node: node2, cleanup } = mountCodeBlock(b, doc, context, host);
|
|
2729
2790
|
if (node2) card.appendChild(node2);
|
|
2730
2791
|
this.registerCleanup(cleanup);
|
|
2731
2792
|
i++;
|
|
@@ -2832,6 +2893,88 @@ var init_composite_renderer = __esm({
|
|
|
2832
2893
|
if (context.nav?.callbacks) context.nav.callbacks.onSkip();
|
|
2833
2894
|
else context.onClose();
|
|
2834
2895
|
}
|
|
2896
|
+
/**
|
|
2897
|
+
* Modo BADGE: inserta un MARCADOR permanente (compuesto con `step.badge.blocks`)
|
|
2898
|
+
* junto al ancla, en el flujo del DOM. Al hover/click abre la `card` (los
|
|
2899
|
+
* bloques del paso) como TOOLTIP anclado al marcador. Devuelve una función que
|
|
2900
|
+
* cierra el tooltip (para el ✕). El marcador nunca se descarta.
|
|
2901
|
+
*/
|
|
2902
|
+
renderBadgeMode(step, card, anchor, anchorSelector, host, root, doc, context, idx, design) {
|
|
2903
|
+
const trigger = step.badge?.trigger === "click" ? "click" : "hover";
|
|
2904
|
+
const badge = doc.createElement("div");
|
|
2905
|
+
badge.className = "veo-composite-badge";
|
|
2906
|
+
badge.setAttribute("role", "button");
|
|
2907
|
+
badge.tabIndex = 0;
|
|
2908
|
+
badge.style.cursor = "pointer";
|
|
2909
|
+
badge.style.display = "inline-flex";
|
|
2910
|
+
badge.style.alignItems = "center";
|
|
2911
|
+
this.buildContent(badge, step.badge?.blocks ?? [], doc, context, idx, [], host);
|
|
2912
|
+
root.appendChild(badge);
|
|
2913
|
+
const wrapper = doc.createElement("div");
|
|
2914
|
+
wrapper.className = "veo-composite-anchored";
|
|
2915
|
+
wrapper.style.display = "none";
|
|
2916
|
+
const caretEl = design.caret === false ? null : makeCaret(doc, design);
|
|
2917
|
+
if (caretEl) wrapper.appendChild(caretEl);
|
|
2918
|
+
wrapper.appendChild(card);
|
|
2919
|
+
root.appendChild(wrapper);
|
|
2920
|
+
host.style.display = "inline-block";
|
|
2921
|
+
const pos = inlinePosOf(step.inlinePosition);
|
|
2922
|
+
insertHost(anchor, host, pos);
|
|
2923
|
+
this.registerCleanup(keepHostAttached(host, anchorSelector, pos));
|
|
2924
|
+
let open = false;
|
|
2925
|
+
let stopFloat = null;
|
|
2926
|
+
let closeTimer = null;
|
|
2927
|
+
let shownEmitted = false;
|
|
2928
|
+
const openTip = () => {
|
|
2929
|
+
if (open) return;
|
|
2930
|
+
open = true;
|
|
2931
|
+
wrapper.style.display = "block";
|
|
2932
|
+
void anchorPosition(badge, wrapper, caretEl).then((stop) => {
|
|
2933
|
+
if (open) stopFloat = stop;
|
|
2934
|
+
else stop();
|
|
2935
|
+
});
|
|
2936
|
+
if (!shownEmitted) {
|
|
2937
|
+
shownEmitted = true;
|
|
2938
|
+
context.onInteraction({ guideId: context.guide.guideId, stepIndex: idx, action: "shown" });
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
const closeTip = () => {
|
|
2942
|
+
open = false;
|
|
2943
|
+
wrapper.style.display = "none";
|
|
2944
|
+
stopFloat?.();
|
|
2945
|
+
stopFloat = null;
|
|
2946
|
+
};
|
|
2947
|
+
if (trigger === "hover") {
|
|
2948
|
+
const cancelClose = () => {
|
|
2949
|
+
if (closeTimer !== null) {
|
|
2950
|
+
clearTimeout(closeTimer);
|
|
2951
|
+
closeTimer = null;
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
const scheduleClose = () => {
|
|
2955
|
+
cancelClose();
|
|
2956
|
+
closeTimer = window.setTimeout(closeTip, 150);
|
|
2957
|
+
};
|
|
2958
|
+
badge.addEventListener("mouseenter", () => {
|
|
2959
|
+
cancelClose();
|
|
2960
|
+
openTip();
|
|
2961
|
+
});
|
|
2962
|
+
badge.addEventListener("mouseleave", scheduleClose);
|
|
2963
|
+
badge.addEventListener("focus", openTip);
|
|
2964
|
+
wrapper.addEventListener("mouseenter", cancelClose);
|
|
2965
|
+
wrapper.addEventListener("mouseleave", scheduleClose);
|
|
2966
|
+
} else {
|
|
2967
|
+
badge.addEventListener("click", () => {
|
|
2968
|
+
if (open) closeTip();
|
|
2969
|
+
else openTip();
|
|
2970
|
+
});
|
|
2971
|
+
}
|
|
2972
|
+
this.registerCleanup(() => {
|
|
2973
|
+
stopFloat?.();
|
|
2974
|
+
if (closeTimer !== null) clearTimeout(closeTimer);
|
|
2975
|
+
});
|
|
2976
|
+
return closeTip;
|
|
2977
|
+
}
|
|
2835
2978
|
};
|
|
2836
2979
|
CLOSE_INSET = "10px";
|
|
2837
2980
|
}
|