webcake-storefront-mcp 1.27.0 → 1.28.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.
package/dist/builder/guide.js
CHANGED
|
@@ -237,10 +237,13 @@ create the globals — they embed into each page's source. If you later overwrit
|
|
|
237
237
|
later with update_global_section_element(s) and it updates on every page at once.
|
|
238
238
|
|
|
239
239
|
## Popups (newsletter / promo / age-gate)
|
|
240
|
-
A popup is a GLOBAL SOURCE, not a page section.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
A popup is a GLOBAL SOURCE, not a page section. FAST PATH: \`scaffold_popup({ brand, headline, offer })\`
|
|
241
|
+
builds + saves a designed newsletter popup (heading + text + email form + close button, centred)
|
|
242
|
+
and returns its id. To build one by hand:
|
|
243
|
+
1. Build the popup node: new_element("popup", { children:[…heading,text,form,close button…], style:{ width:480, background:"#fff", borderRadius:"12px" }, config:{ popupHorizontalPosition:"center", popupVerticalPosition:"center" }, specials:{ effect:"fade-in", timeAnim:0.5 } }).
|
|
244
|
+
- SIZE + POSITION live in the popup's runtime style/config (width/height/background + popupHorizontalPosition/popupVerticalPosition), NOT in specials. createPopup seeds a centred-modal default.
|
|
245
|
+
- TRIGGER (auto-open) lives in SPECIALS: \`openPopupAction:"openPopupWithTime"\` + \`timeOpenPopup:<seconds>\` for a delay; \`page_ids:[…]\` to limit which pages it shows on; \`effect\`/\`timeAnim\` for the animation. (There is no exit-intent/only-once flag in the node — those are app settings.)
|
|
246
|
+
- OVERLAY is NOT on the popup node — it's a field on the open_popup EVENT (popup_overlay:true).
|
|
244
247
|
2. Save it: create_global_source({ component:"popup", source:{ sections:[<popupNode>] } }) -> returns its id.
|
|
245
248
|
3. Open/close from any element via events: a button { action:"open_popup", popup_id:"<id>", popup_overlay:true };
|
|
246
249
|
a close button inside { action:"close_popup", popup_id:"<id>" }; a form can auto-close on its
|
package/dist/builder/page.js
CHANGED
|
@@ -192,7 +192,7 @@ export function buildSection(childSpecs = [], sectionOpts = {}) {
|
|
|
192
192
|
};
|
|
193
193
|
return section;
|
|
194
194
|
}
|
|
195
|
-
function buildFromSpec(spec) {
|
|
195
|
+
export function buildFromSpec(spec) {
|
|
196
196
|
if (!spec || !spec.type) {
|
|
197
197
|
throw new Error("Each element spec must have a 'type'.");
|
|
198
198
|
}
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
// Colours use the site theme CSS vars by default (var(--color_02) accent, var(--color_00)
|
|
14
14
|
// text) so a generated site matches whatever palette the theme already defines; callers can
|
|
15
15
|
// override any slot via a Palette object.
|
|
16
|
-
import { buildSection, walk } from "./page.js";
|
|
16
|
+
import { buildSection, buildFromSpec, stackChildren, walk } from "./page.js";
|
|
17
17
|
import { buildElement } from "./catalog.js";
|
|
18
18
|
import { normalizeEvents } from "./events.js";
|
|
19
|
+
const X_ICON_SVG = "<svg xmlns='http://www.w3.org/2000/svg' fill='currentColor' width='100%' height='100%' viewBox='0 0 24 24'><path d='M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z'></path></svg>";
|
|
19
20
|
// Slots map onto the site theme's 5×5 colour matrix, surfaced as CSS vars var(--color_RC)
|
|
20
21
|
// (R=row, C=col). Row 0 is greyscale (00=white … 04=black); row 2 is the BRAND row. Using
|
|
21
22
|
// var(--color_00) for text was a bug — that's WHITE (invisible on the white surface).
|
|
@@ -392,6 +393,48 @@ export function footerSection(opts = {}) {
|
|
|
392
393
|
});
|
|
393
394
|
}
|
|
394
395
|
// ---------------------------------------------------------------------------
|
|
396
|
+
// POPUP (newsletter / promo) — a global SOURCE, not a page section
|
|
397
|
+
// ---------------------------------------------------------------------------
|
|
398
|
+
/**
|
|
399
|
+
* A designed newsletter/promo popup, returned as a ready-to-save global-source source
|
|
400
|
+
* `{ sections: [ <popup node> ] }`. The popup carries an auto-open-after-delay trigger in
|
|
401
|
+
* specials and a centred-modal geometry (seeded by createPopup); the close button references
|
|
402
|
+
* the popup's own id. Save with create_global_source({ component:"popup", source }).
|
|
403
|
+
* Run finalizeForRender(source) BEFORE saving (the tool does this).
|
|
404
|
+
*/
|
|
405
|
+
export function newsletterPopupSource(opts = {}) {
|
|
406
|
+
const p = resolvePalette(opts.palette);
|
|
407
|
+
const heading = {
|
|
408
|
+
type: "text",
|
|
409
|
+
opts: { text: opts.headline || "Nhận ưu đãi 10%", specials: { tag: "h2" }, style: { fontSize: "26px", fontWeight: "800", color: p.text, textAlign: "center", lineHeight: "1.3" } },
|
|
410
|
+
};
|
|
411
|
+
const sub = {
|
|
412
|
+
type: "text",
|
|
413
|
+
opts: { text: opts.subtext || "Đăng ký nhận tin để không bỏ lỡ khuyến mãi mới nhất.", style: { fontSize: "15px", color: p.muted, textAlign: "center", lineHeight: "1.6" } },
|
|
414
|
+
};
|
|
415
|
+
const form = {
|
|
416
|
+
type: "form",
|
|
417
|
+
opts: { specials: { type: "subscribe" }, config: { backgroundInput: p.surface, placeholderColor: p.muted, labelColor: p.text, textPadding: 14, rowGap: 12 } },
|
|
418
|
+
children: [
|
|
419
|
+
{ type: "email", opts: { specials: { field_name: "email", placeholder: "Email của bạn", show_label: false }, config: { backgroundInput: p.surface, textPadding: 14 }, style: { borderColor: p.border, borderRadius: "8px", height: 46 } } },
|
|
420
|
+
{ type: "submit-button", opts: { text: opts.ctaLabel || "Đăng ký ngay", style: { background: p.accent, color: p.onAccent, borderRadius: "8px", height: 46, fontWeight: "600", width: "100%", textAlign: "center" } } },
|
|
421
|
+
],
|
|
422
|
+
};
|
|
423
|
+
// Close button: a small X in the top-right that closes this popup (wired to the popup id below).
|
|
424
|
+
const close = { type: "rectangle", opts: { config: { mask: X_ICON_SVG }, style: { width: 22, height: 22, background: p.muted } } };
|
|
425
|
+
const content = [heading, sub, form, close].map((s) => buildFromSpec(s));
|
|
426
|
+
const popup = buildElement("popup", {
|
|
427
|
+
specials: { effect: "fade-in", timeAnim: 0.5, openPopupAction: "openPopupWithTime", timeOpenPopup: opts.delaySeconds ?? 6 },
|
|
428
|
+
style: { width: 460, background: p.surface, borderRadius: "14px", paddingTop: 40, paddingBottom: 40, paddingLeft: 32, paddingRight: 32 },
|
|
429
|
+
config: { popupHorizontalPosition: "center", popupVerticalPosition: "center" },
|
|
430
|
+
});
|
|
431
|
+
stackChildren(popup, content, { rowGap: 18 });
|
|
432
|
+
// Wire the close button to dismiss THIS popup now that we know its id.
|
|
433
|
+
const closeNode = content[content.length - 1];
|
|
434
|
+
closeNode.events = normalizeEvents([{ action: "close_popup", popup_id: popup.id }], "rectangle");
|
|
435
|
+
return { sections: [popup] };
|
|
436
|
+
}
|
|
437
|
+
// ---------------------------------------------------------------------------
|
|
395
438
|
// registry the scaffolder iterates
|
|
396
439
|
// ---------------------------------------------------------------------------
|
|
397
440
|
/**
|
package/dist/changelog.json
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "1.28.0",
|
|
4
|
+
"d": "26/06/2026",
|
|
5
|
+
"type": "Added",
|
|
6
|
+
"en": "New scaffold_popup tool builds and saves a designed newsletter/promo popup (heading + subtext + email subscribe form + close button, centred modal)…",
|
|
7
|
+
"vi": "Tool mới scaffold_popup xây dựng và lưu một popup newsletter/promo được thiết kế sẵn (tiêu đề + phụ đề + form đăng ký email + nút đóng, dạng modal…"
|
|
8
|
+
},
|
|
2
9
|
{
|
|
3
10
|
"v": "1.27.0",
|
|
4
11
|
"d": "26/06/2026",
|
|
@@ -33,12 +40,5 @@
|
|
|
33
40
|
"type": "Changed",
|
|
34
41
|
"en": "list_elements now documents tabIndex and text_animation_type as shared specials present on every element, covering tab-panel visibility binding and…",
|
|
35
42
|
"vi": "list_elements nay tài liệu hóa tabIndex và text_animation_type là các specials dùng chung có trên mọi phần tử, bao gồm gắn kết hiển thị/ẩn cho…"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"v": "1.23.0",
|
|
39
|
-
"d": "25/06/2026",
|
|
40
|
-
"type": "Added",
|
|
41
|
-
"en": "get_build_guide now includes a category-page filter recipe explaining how sidebar filter widgets (checkbox-group, color-group, tags,…",
|
|
42
|
-
"vi": "get_build_guide nay bổ sung công thức filter trang danh mục, giải thích cách các widget lọc trong sidebar (checkbox-group, color-group, tags,…"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
@@ -2,6 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import { getConfirmMode } from "./context.js";
|
|
3
3
|
import { normalizeEvents } from "../builder/events.js";
|
|
4
4
|
import { normalizeBindings } from "../builder/bindings.js";
|
|
5
|
+
import { newsletterPopupSource, contrastSafePalette } from "../builder/templates.js";
|
|
6
|
+
import { finalizeForRender, validatePage } from "../builder/page.js";
|
|
5
7
|
/**
|
|
6
8
|
* Global Sources tools — manage site-wide components: cart, popup, overview, etc.
|
|
7
9
|
*
|
|
@@ -575,6 +577,35 @@ Same merge rules: style/config/specials = shallow merge, events/bindings = repla
|
|
|
575
577
|
invalidateGsCache();
|
|
576
578
|
return res;
|
|
577
579
|
}));
|
|
580
|
+
server.tool("scaffold_popup", `Build AND save a designed newsletter/promo popup in one call (a 'popup' global source).
|
|
581
|
+
Returns the popup id — open it from any element with an open_popup event { popup_id, popup_overlay:true },
|
|
582
|
+
or set it to auto-open after a delay (built in). Centred modal: heading + subtext + email subscribe
|
|
583
|
+
form + close button, palette-aware (accent derived from the site theme). Use dry_run to preview.`, {
|
|
584
|
+
headline: z.string().optional().describe("Popup heading (default: 'Nhận ưu đãi 10%')"),
|
|
585
|
+
subtext: z.string().optional().describe("Supporting line under the heading"),
|
|
586
|
+
cta_label: z.string().optional().describe("Submit button label (default: 'Đăng ký ngay')"),
|
|
587
|
+
delay_seconds: z.number().optional().describe("Auto-open after N seconds (default 6)"),
|
|
588
|
+
palette: z.record(z.any()).optional().describe("Colour overrides { accent, text, surface, ... }; defaults to the site theme."),
|
|
589
|
+
dry_run: z.boolean().default(true).describe("Preview the popup source (true) or create+save it (false)"),
|
|
590
|
+
}, ({ headline, subtext, cta_label, delay_seconds, palette, dry_run }) => handle(async () => {
|
|
591
|
+
const themePal = await contrastSafePalette(api);
|
|
592
|
+
const source = newsletterPopupSource({
|
|
593
|
+
headline, subtext, ctaLabel: cta_label, delaySeconds: delay_seconds,
|
|
594
|
+
palette: { ...themePal, ...(palette || {}) },
|
|
595
|
+
});
|
|
596
|
+
const validation = validatePage(source);
|
|
597
|
+
finalizeForRender(source);
|
|
598
|
+
const popupId = source.sections[0]?.id || null;
|
|
599
|
+
if (dry_run) {
|
|
600
|
+
return { dry_run: true, valid: validation.valid, popup_id: popupId, ...(validation.errors ? { errors: validation.errors } : {}), hint: "Centred newsletter popup. Call again with dry_run=false to save it, then open it via an open_popup event (popup_id above)." };
|
|
601
|
+
}
|
|
602
|
+
if (!validation.valid)
|
|
603
|
+
return { error: "Popup failed validation — not saving.", validation };
|
|
604
|
+
const res = await api.createGlobalSource({ component: "popup", source, type: "default", site_id: api.siteId });
|
|
605
|
+
invalidateGsCache();
|
|
606
|
+
const id = res?.data?.id || res?.id || popupId;
|
|
607
|
+
return { success: true, global_source_id: id, popup_id: popupId, next_step: "Open it from a button/header with events:[{ action:'open_popup', popup_id, popup_overlay:true }] (or it auto-opens after the delay). publish_site to take it live." };
|
|
608
|
+
}));
|
|
578
609
|
server.tool("update_global_source", `Replace full source of a global source.
|
|
579
610
|
IMPORTANT: Before calling this tool, you MUST:
|
|
580
611
|
1. Read existing source with get_global_source_detail first
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcake-storefront-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"description": "MCP server for the WebCake/StoreCake storefront builder — page CRUD, page authoring, products, orders, and more",
|
|
5
5
|
"mcpName": "io.github.vuluu2k/webcake-storefront-mcp",
|
|
6
6
|
"license": "MIT",
|