webcake-landing-mcp 1.11.0 → 1.13.0

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,4 +1,18 @@
1
1
  [
2
+ {
3
+ "v": "1.13.0",
4
+ "d": "19/11/2026",
5
+ "type": "Added",
6
+ "en": "new_element and the get_element/list_elements skeletons now return the exact node the Webcake editor drops for a type — its default colors, font,…",
7
+ "vi": "new_element và skeleton của get_element/list_elements nay trả về đúng node mà editor Webcake thả ra cho type đó — màu, font, viền, kích thước mặc…"
8
+ },
9
+ {
10
+ "v": "1.12.0",
11
+ "d": "19/11/2026",
12
+ "type": "Added",
13
+ "en": "get_element/list_elements now return keys (one line per specials/config/styles key the published renderer actually reads, with meaning, value type,…",
14
+ "vi": "get_element/list_elements nay trả thêm keys (mỗi dòng là một key specials/config/styles mà renderer thật có đọc, kèm ý nghĩa, kiểu giá trị, enum,…"
15
+ },
2
16
  {
3
17
  "v": "1.11.0",
4
18
  "d": "19/11/2026",
@@ -26,19 +40,5 @@
26
40
  "type": "Added",
27
41
  "en": "The stdio server now detects an expired or backend-rejected WEBCAKE_JWT and automatically reopens the browser Connect page, then retries the failing…",
28
42
  "vi": "Server stdio nay tự phát hiện WEBCAKE_JWT đã hết hạn hoặc bị backend từ chối, tự mở lại trang Connect trên trình duyệt, rồi thử lại tool bị lỗi một…"
29
- },
30
- {
31
- "v": "1.7.0",
32
- "d": "05/11/2026",
33
- "type": "Added",
34
- "en": "install gained a --dev flag that reopens the old step-by-step wizard (choose environment, log in or paste a JWT, pick an organization, pick IDEs)…",
35
- "vi": "install nay có thêm cờ --dev để mở lại wizard từng bước kiểu cũ (chọn environment, đăng nhập hoặc dán JWT, chọn organization, chọn IDE) cho ai vẫn…"
36
- },
37
- {
38
- "v": "1.6.2",
39
- "d": "27/10/2026",
40
- "type": "Fixed",
41
- "en": "expand now syncs a field element's properties.field_default with its specials.field_name, turning it on for the editor's system columns…",
42
- "vi": "expand nay đồng bộ properties.field_default của field element theo specials.field_name: bật cho các cột hệ thống của editor (phone_number,…"
43
43
  }
44
44
  ]
@@ -116,6 +116,10 @@ function reflowChildren(kids, effH, origH, bp, fixes) {
116
116
  // declared b inside a's declared box → leave it alone.
117
117
  if (b.origTop < a.origTop + a.declaredH - TOL)
118
118
  continue;
119
+ // only a sibling that GREW (wrapped text) or was itself pushed can push b — tight gaps the
120
+ // author (or the measured source) chose are kept.
121
+ if (a.eff <= a.declaredH + TOL && a.cur === a.origTop)
122
+ continue;
119
123
  // only a sibling in the same horizontal column can be hit by the spill.
120
124
  const intersects = a.left < b.left + b.w - TOL && b.left < a.left + a.w - TOL;
121
125
  if (!intersects)
@@ -139,21 +143,34 @@ function reflowChildren(kids, effH, origH, bp, fixes) {
139
143
  function processNode(node, bp, canvasW, pageFont, fixes) {
140
144
  if (!node || typeof node !== "object")
141
145
  return 0;
146
+ // hidden on this breakpoint (config.hide): it takes no room there — no estimate, no push, no growth
147
+ if (node?.responsive?.[bp]?.config?.hide === true)
148
+ return 0;
142
149
  const styles = node?.responsive?.[bp]?.styles ?? {};
143
150
  const ownW = num(styles.width) ?? canvasW;
144
151
  const ownH = num(styles.height);
145
- const kids = Array.isArray(node.children) ? node.children.filter((k) => k && typeof k === "object") : [];
152
+ const kids = Array.isArray(node.children) ? node.children.filter((k) => k && typeof k === "object" && k?.responsive?.[bp]?.config?.hide !== true) : [];
146
153
  if (kids.length === 0) {
147
154
  // Leaf: a text-block renders at its measured height regardless of declared
148
155
  // height. Resize the declared box to match (clears the own-box warning) and
149
156
  // report it as the effective height the parent reflows against.
157
+ // A text whose height was MEASURED (config.virtualHeight = its rendered height — written by the editor
158
+ // and by clone_page) is trusted: re-estimating it with font metrics only adds error.
159
+ const vh = num(node?.responsive?.[bp]?.config?.virtualHeight);
150
160
  if (node.type === "text-block" && !isIconGlyph(node.specials?.text)) {
151
161
  const est = estTextHeightPx(node.specials?.text, styles, pageFont);
162
+ // (a measure made stale by an edit is dropped where the edit happens — patch_page / update_page,
163
+ // dropStaleMeasure — not guessed here: font metrics err by 2–3× on some fonts)
164
+ if (vh != null && ownH != null && vh >= ownH - 2)
165
+ return ownH;
152
166
  if (est != null) {
153
167
  const h = num(styles.height);
154
168
  const fs = num(styles.fontSize) ?? 16;
155
169
  if (h != null && est > h + Math.min(fs * 1.4, 24)) {
156
170
  styles.height = est;
171
+ // the live page sizes a text-block by virtualHeight: keep it in step, or the text is clipped
172
+ if (vh != null)
173
+ node.responsive[bp].config.virtualHeight = est;
157
174
  pushFix(fixes, `"${idOf(node)}" [${bp}]: resized height ${h}→${est} to fit wrapped text (real font metrics).`);
158
175
  }
159
176
  return est;
@@ -165,8 +182,11 @@ function processNode(node, bp, canvasW, pageFont, fixes) {
165
182
  // get resized to their measured height) — the reflow's layering test needs the
166
183
  // author's intended box, not the corrected one.
167
184
  const origH = new Map();
168
- for (const k of kids)
185
+ const origTop = new Map();
186
+ for (const k of kids) {
169
187
  origH.set(k, num(k?.responsive?.[bp]?.styles?.height));
188
+ origTop.set(k, num(k?.responsive?.[bp]?.styles?.top));
189
+ }
170
190
  // 1) post-order: settle each child's effective height first.
171
191
  const eff = new Map();
172
192
  for (const k of kids) {
@@ -180,14 +200,21 @@ function processNode(node, bp, canvasW, pageFont, fixes) {
180
200
  for (const k of kids)
181
201
  clampChild(k, bp, ownW, fixes);
182
202
  reflowChildren(kids, eff, origH, bp, fixes);
183
- // 4) grow this container to contain its (reflowed) children.
203
+ // 4) grow this container by what the corrections ADDED (wrapped text, pushed siblings) — a child the
204
+ // author / the measured source placed hanging over the edge (decor, a tilted picture) is intended,
205
+ // and is not a reason to grow.
206
+ // per child: each one is excused only for its OWN declared overhang
184
207
  let maxBottom = 0;
208
+ let spill = 0;
185
209
  for (const k of kids) {
186
210
  const t = num(k?.responsive?.[bp]?.styles?.top) ?? 0;
187
- maxBottom = Math.max(maxBottom, t + (eff.get(k) ?? 0));
211
+ const bottom = t + (eff.get(k) ?? 0);
212
+ maxBottom = Math.max(maxBottom, bottom);
213
+ const declared = (origTop.get(k) ?? t) + (origH.get(k) ?? 0);
214
+ spill = Math.max(spill, Math.ceil(bottom) - Math.max(ownH ?? 0, Math.ceil(declared)));
188
215
  }
189
- if (ownH != null && Math.ceil(maxBottom) > ownH + TOL) {
190
- const grown = Math.ceil(maxBottom);
216
+ if (ownH != null && Math.ceil(maxBottom) > ownH + TOL && spill > TOL) {
217
+ const grown = ownH + spill;
191
218
  node.responsive[bp].styles.height = grown;
192
219
  pushFix(fixes, `"${idOf(node)}" [${bp}]: grew height ${ownH}→${grown} to contain its content.`);
193
220
  return grown;
@@ -317,6 +317,7 @@ function convertElement(ctx, e, sectionH) {
317
317
  ctx.css.push(hoverCss(node, e.hover, e.transition));
318
318
  return node;
319
319
  }
320
+ const ICON_CDN = /^https:\/\/(cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net|unpkg\.com|fonts\.googleapis\.com|use\.fontawesome\.com|maxcdn\.bootstrapcdn\.com|stackpath\.bootstrapcdn\.com|code\.ionicframework\.com|unicons\.iconscout\.com|cdn\.lineicons\.com|site-assets\.fontawesome\.com)\//;
320
321
  /** The inner box each type paints into (render/build/index.js): hover colours go there, motion on #w-<id>. */
321
322
  const INNER_CLASS = { button: "button-css", rectangle: "rectangle-css", "text-block": "text-block-css", "image-block": "image-block-css" };
322
323
  const WRAPPER_PROPS = /^(transform|translate|scale|rotate|opacity|filter|z-index)$/;
@@ -332,6 +333,9 @@ function hoverCss(node, hover, transition) {
332
333
  const wrap = [];
333
334
  const paint = [];
334
335
  for (const d of (hover ?? "").split(";").map((x) => x.trim()).filter(Boolean)) {
336
+ // the source page's CSS lands in raw <style>: nothing that could close the tag / open a rule
337
+ if (/[<>{}\\]/.test(d))
338
+ continue;
335
339
  const prop = d.slice(0, d.indexOf(":")).trim().toLowerCase();
336
340
  if (!prop || /^(position|top|left|right|bottom|width|height|display|margin|padding)/.test(prop))
337
341
  continue; // geometry belongs to the canvas
@@ -341,7 +345,7 @@ function hoverCss(node, hover, transition) {
341
345
  paint.push(d);
342
346
  }
343
347
  let css = "";
344
- if (transition)
348
+ if (transition && !/[<>{}\\;]/.test(transition))
345
349
  css += `${id}${inner ? `,${id}${inner}` : ""}{transition:${transition}}`;
346
350
  if (wrap.length)
347
351
  css += `${id}:hover{${wrap.join(";")}}`;
@@ -366,6 +370,14 @@ function convertElementInner(ctx, e, sectionH) {
366
370
  responsive: responsiveOf(ctx, e.box, mapStyles(style, "text-block"), sectionH),
367
371
  specials: { text: e.text ?? "", tag: e.tag && /^(h[1-6]|p)$/.test(e.tag) ? e.tag : t === "paragraph" ? "p" : "h3" },
368
372
  };
373
+ // measured in a browser: the rendered height is known — record it the way the editor does
374
+ if (ctx.measured) {
375
+ for (const bp of ["desktop", "mobile"]) {
376
+ const h = node.responsive[bp].styles.height;
377
+ if (typeof h === "number")
378
+ node.responsive[bp].config = { ...(node.responsive[bp].config ?? {}), virtualHeight: h };
379
+ }
380
+ }
369
381
  const ev = mapEvents(ctx, e);
370
382
  if (ev)
371
383
  node.events = ev;
@@ -383,6 +395,18 @@ function convertElementInner(ctx, e, sectionH) {
383
395
  setBothConfigs(node, { iconSize: 12, iconTop: 5, linePaddingLeft: 23, linePaddingBottom: 10 });
384
396
  return node;
385
397
  }
398
+ // Native video player for what the landing video element plays (youtube / vimeo / a file); other
399
+ // iframes stay html-box embeds.
400
+ const yt = /(?:youtube(?:-nocookie)?\.com\/(?:embed\/|watch\?v=|shorts\/)|youtu\.be\/)([\w-]{11})/.exec(e.src ?? "");
401
+ const vimeo = /player\.vimeo\.com\/video\/(\d+)|vimeo\.com\/(\d+)/.exec(e.src ?? "");
402
+ if ((t === "html_code" && (yt || vimeo)) || (t === "video" && e.video)) {
403
+ const specials = yt
404
+ ? { typeVideo: "youtube", id: yt[1], img: `https://i.ytimg.com/vi/${yt[1]}/hqdefault.jpg` }
405
+ : vimeo
406
+ ? { typeVideo: "vimeo", video: `https://vimeo.com/${vimeo[1] ?? vimeo[2]}` }
407
+ : { typeVideo: "webcake", video: e.video, ...(e.src ? { img: e.src } : {}) };
408
+ return { id: uniqueId(ctx, e.id), type: "video", responsive: responsiveOf(ctx, e.box, {}, sectionH), specials };
409
+ }
386
410
  if (t === "image" || t === "video") {
387
411
  if (!e.src && t === "video") {
388
412
  ctx.notes.push(`${e.id}: video without a recoverable source skipped.`);
@@ -406,6 +430,16 @@ function convertElementInner(ctx, e, sectionH) {
406
430
  crop.leftBgImage = e.crop.left;
407
431
  if (Object.keys(crop).length)
408
432
  setBothConfigs(node, crop);
433
+ // measured mobile layout: its own crop, or none (the image fits its mobile box)
434
+ if (ctx.measured && e.mobile !== undefined) {
435
+ const mc = e.mobile?.crop;
436
+ const mcfg = { ...(node.responsive.mobile.config ?? {}) };
437
+ for (const k of ["widthBgImage", "heightBgImage", "topBgImage", "leftBgImage"])
438
+ delete mcfg[k];
439
+ if (mc)
440
+ Object.assign(mcfg, { widthBgImage: mc.width, heightBgImage: mc.height, topBgImage: mc.top, leftBgImage: mc.left });
441
+ node.responsive.mobile.config = mcfg;
442
+ }
409
443
  }
410
444
  const ev = mapEvents(ctx, e);
411
445
  if (ev)
@@ -573,6 +607,41 @@ function convertElementInner(ctx, e, sectionH) {
573
607
  applyAnimation(node, e, "countdown");
574
608
  return node;
575
609
  }
610
+ // browser capture: a slider → the native carousel (slideWidth × slideToShow), each slide with its content
611
+ if (t === "slider") {
612
+ const slides = (e.children ?? []).filter((c) => c.type === "slide");
613
+ if (!slides.length)
614
+ return null;
615
+ const sw = (slides[0].box?.width || 0) > 0 ? slides[0].box.width : Math.round((e.box?.width ?? 0) / slides.length);
616
+ if (!(sw > 0)) {
617
+ ctx.notes.push(`${e.id}: slider with no measurable slide width — skipped.`);
618
+ return null;
619
+ }
620
+ const show = Math.max(1, Math.round((e.box?.width ?? sw) / sw));
621
+ const node = {
622
+ id: uniqueId(ctx, e.id),
623
+ type: "carousel",
624
+ responsive: responsiveOf(ctx, e.box, {}, sectionH),
625
+ specials: {},
626
+ children: slides.map((s) => ({
627
+ id: uniqueId(ctx, s.id),
628
+ type: "slide",
629
+ responsive: responsiveOf(ctx, s.box, {}, sectionH),
630
+ specials: {},
631
+ children: convertChildren(ctx, s, sectionH),
632
+ })),
633
+ };
634
+ const m = e.mobile ? e.mobile.box : null;
635
+ const msw = slides[0].mobile && slides[0].mobile.box.width > 0 ? slides[0].mobile.box.width : Math.max(1, Math.round(sw * (MOBILE_W / DESKTOP_W)));
636
+ const mshow = m ? Math.max(1, Math.round(m.width / msw)) : show;
637
+ node.responsive.desktop.styles.width = show * sw;
638
+ node.responsive.mobile.styles.width = mshow * msw;
639
+ const base = { showNavigation: !!e.config?.["nav"], autoplayMode: "repeat", delayTimeMs: 5000, infinity: true };
640
+ node.responsive.desktop.config = { ...(node.responsive.desktop.config ?? {}), ...base, slideWidth: sw, slideToShow: show };
641
+ node.responsive.mobile.config = { ...(node.responsive.mobile.config ?? {}), ...base, slideWidth: msw, slideToShow: mshow };
642
+ ctx.notes.push(`${e.id}: slider → native carousel (${slides.length} slides, ${show} visible on desktop, ${mshow} on mobile)`);
643
+ return node;
644
+ }
576
645
  if (t === "carousel" || t === "gallery") {
577
646
  const media = (e.children ?? [])
578
647
  .filter((c) => c.type === "image" && c.src)
@@ -727,7 +796,7 @@ function convertPopup(ctx, p) {
727
796
  * lossy approximation the caller should review/patch.
728
797
  */
729
798
  export function canvasToPageSource(canvas, meta = {}) {
730
- const ctx = { mobileOnly: !!canvas.mobile_only, notes: [], usedIds: new Set(), mobileByBox: new WeakMap(), css: [] };
799
+ const ctx = { mobileOnly: !!canvas.mobile_only, notes: [], usedIds: new Set(), mobileByBox: new WeakMap(), css: [], measured: canvas.builder === "browser" };
731
800
  const index = (e) => {
732
801
  if (e.box && e.mobile !== undefined)
733
802
  ctx.mobileByBox.set(e.box, e.mobile);
@@ -751,9 +820,12 @@ export function canvasToPageSource(canvas, meta = {}) {
751
820
  source.settings.extra_css = css;
752
821
  ctx.notes.push(`hover effects of ${ctx.css.filter(Boolean).length} element(s) → settings.extra_css (scoped to #w-<id>)`);
753
822
  }
754
- if (canvas.head_links?.length) {
755
- source.settings.bhet = canvas.head_links.map((h) => `<link rel="stylesheet" href="${h.replace(/"/g, "%22")}">`).join("");
756
- ctx.notes.push(`icon font stylesheet(s) → settings.bhet: ${canvas.head_links.join(", ")}`);
823
+ // icon-font stylesheets only from the public CDNs that serve them (a cloned page must not get an
824
+ // arbitrary third-party stylesheet on the user's domain)
825
+ const links = (canvas.head_links ?? []).filter((h) => ICON_CDN.test(h));
826
+ if (links.length) {
827
+ source.settings.bhet = links.map((h) => `<link rel="stylesheet" href="${h.replace(/["<>]/g, encodeURIComponent)}">`).join("");
828
+ ctx.notes.push(`icon font stylesheet(s) → settings.bhet: ${links.join(", ")}`);
757
829
  }
758
830
  if (canvas.truncated) {
759
831
  ctx.notes.push("the canvas payload was truncated (styles pruned) — for full typography re-ingest per section (sections:[id]) and patch the affected elements.");