veo-sdk 0.5.24 → 0.5.27

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 { VEO_BLOCK_MIME, attachBlockDropTarget, attachDesignManipulator, createBuilderSession, initBuilderMode, startElementPicker, stopElementPicker } from './chunk-RHYVNG3X.mjs';
2
+ import './chunk-6XZPR7VC.mjs';
3
+ import './chunk-PTG3BTJE.mjs';
4
+ //# sourceMappingURL=builder-5UDF6IHS.mjs.map
5
+ //# sourceMappingURL=builder-5UDF6IHS.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"builder-JSL3OZPL.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"builder-5UDF6IHS.mjs"}
package/dist/builder.cjs CHANGED
@@ -1947,7 +1947,25 @@ function escapeClosing(code, tag) {
1947
1947
  }
1948
1948
 
1949
1949
  // src/plugins/guides/code-block.ts
1950
- function mountCodeBlock(block, doc, context) {
1950
+ function insertRawNodes(anchor, nodes, pos) {
1951
+ const parent = anchor.parentNode;
1952
+ if (pos === "prepend") {
1953
+ const first = anchor.firstChild;
1954
+ for (const n of nodes) anchor.insertBefore(n, first);
1955
+ } else if (pos === "append") {
1956
+ for (const n of nodes) anchor.appendChild(n);
1957
+ } else if (pos === "before") {
1958
+ for (const n of nodes) parent?.insertBefore(n, anchor);
1959
+ } else {
1960
+ let ref = anchor;
1961
+ for (const n of nodes) {
1962
+ parent?.insertBefore(n, ref.nextSibling);
1963
+ ref = n;
1964
+ }
1965
+ }
1966
+ }
1967
+ var codeSlotSeq = 0;
1968
+ function mountCodeBlock(block, doc, context, host, rawInline) {
1951
1969
  if (block.sandboxed) {
1952
1970
  const step = { html: block.html ?? "", css: block.css, js: block.js };
1953
1971
  const { iframe, cleanup } = mountCustomFrame(doc, step, context, { width: "100%" });
@@ -1966,13 +1984,28 @@ function mountCodeBlock(block, doc, context) {
1966
1984
  }
1967
1985
  let node = null;
1968
1986
  if (typeof block.html === "string" && block.html.trim()) {
1969
- node = doc.createElement("div");
1970
- node.className = "veo-code-html";
1971
- node.innerHTML = block.html;
1972
- for (const old of Array.from(node.querySelectorAll("script"))) {
1987
+ const holder = doc.createElement("div");
1988
+ holder.className = "veo-code-html";
1989
+ holder.innerHTML = block.html;
1990
+ for (const old of Array.from(holder.querySelectorAll("script"))) {
1973
1991
  injected.push(runScript(old, hostDoc));
1974
1992
  old.remove();
1975
1993
  }
1994
+ if (rawInline) {
1995
+ const rawNodes = Array.from(holder.childNodes);
1996
+ insertRawNodes(rawInline.anchor, rawNodes, rawInline.pos);
1997
+ injected.push(...rawNodes);
1998
+ } else if (host) {
1999
+ const slotName = `veo-code-${++codeSlotSeq}`;
2000
+ holder.slot = slotName;
2001
+ host.appendChild(holder);
2002
+ injected.push(holder);
2003
+ const slot = doc.createElement("slot");
2004
+ slot.setAttribute("name", slotName);
2005
+ node = slot;
2006
+ } else {
2007
+ node = holder;
2008
+ }
1976
2009
  }
1977
2010
  if (typeof block.js === "string" && block.js.trim()) {
1978
2011
  const s = hostDoc.createElement("script");
@@ -2277,6 +2310,18 @@ var CompositeRenderer = class extends BaseRenderer {
2277
2310
  anchor = await waitForElement(anchorSelector);
2278
2311
  if (!anchor) return;
2279
2312
  }
2313
+ const blocks = step.blocks ?? [];
2314
+ const soleCode = blocks.length === 1 && blocks[0]?.type === "code" ? blocks[0] : void 0;
2315
+ if (step.presentation === "inline" && anchor && soleCode && !soleCode.sandboxed) {
2316
+ const rawDoc = anchor.ownerDocument ?? document;
2317
+ const { cleanup } = mountCodeBlock(soleCode, rawDoc, context, void 0, {
2318
+ anchor,
2319
+ pos: inlinePosOf(step.inlinePosition)
2320
+ });
2321
+ this.registerCleanup(cleanup);
2322
+ context.onInteraction({ guideId: context.guide.guideId, stepIndex: idx, action: "shown" });
2323
+ return;
2324
+ }
2280
2325
  const { host, root } = this.createHost();
2281
2326
  const doc = root.ownerDocument ?? document;
2282
2327
  const design = step.design ?? {};
@@ -2293,7 +2338,7 @@ var CompositeRenderer = class extends BaseRenderer {
2293
2338
  });
2294
2339
  };
2295
2340
  const readers = [];
2296
- this.buildContent(card, step.blocks ?? [], doc, context, idx, readers);
2341
+ this.buildContent(card, step.blocks ?? [], doc, context, idx, readers, host);
2297
2342
  const lastBlock = card.lastElementChild;
2298
2343
  if (lastBlock && !lastBlock.style.marginBottom) lastBlock.style.marginBottom = "0";
2299
2344
  if (design.closeButton !== false) {
@@ -2364,7 +2409,7 @@ var CompositeRenderer = class extends BaseRenderer {
2364
2409
  context.onInteraction({ guideId: context.guide.guideId, stepIndex: idx, action: "shown" });
2365
2410
  }
2366
2411
  /** Recorre los bloques en orden y los pinta en la card. */
2367
- buildContent(card, blocks, doc, context, idx, readers) {
2412
+ buildContent(card, blocks, doc, context, idx, readers, host) {
2368
2413
  const emit = (block) => {
2369
2414
  context.onInteraction({
2370
2415
  guideId: context.guide.guideId,
@@ -2398,7 +2443,7 @@ var CompositeRenderer = class extends BaseRenderer {
2398
2443
  continue;
2399
2444
  }
2400
2445
  if (b.type === "code") {
2401
- const { node: node2, cleanup } = mountCodeBlock(b, doc, context);
2446
+ const { node: node2, cleanup } = mountCodeBlock(b, doc, context, host);
2402
2447
  if (node2) card.appendChild(node2);
2403
2448
  this.registerCleanup(cleanup);
2404
2449
  i++;