webcake-storefront-mcp 1.38.0 → 1.40.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/api.js +233 -145
- package/dist/auth/login.js +22 -1
- package/dist/auth/oauth-server.js +19 -2
- package/dist/builder/attributes.js +1 -1
- package/dist/builder/guide.js +11 -5
- package/dist/builder/native-first.js +4 -5
- package/dist/builder/page.js +247 -13
- package/dist/builder/shape.js +174 -0
- package/dist/changelog.json +14 -14
- package/dist/config.js +13 -3
- package/dist/http.js +38 -17
- package/dist/index.js +2 -0
- package/dist/persistence/screenshot-client.js +208 -0
- package/dist/tools/builder-extras.js +172 -4
- package/dist/tools/builder.js +30 -23
- package/dist/tools/global-section-write.js +1 -1
- package/dist/tools/global-sources.js +25 -75
- package/dist/tools/page-draft.js +3 -2
- package/dist/tools/pages.js +32 -70
- package/dist/web-guide-scene.js +10 -4
- package/package.json +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { getConfirmMode } from "./context.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { checkContentPlaceholders, checkElementPatch, checkNativeContent } from "../builder/page.js";
|
|
3
|
+
import { STYLE_DESC, CONFIG_DESC } from "./pages.js";
|
|
4
|
+
import { addedErrors, applyNodeUpdates, computeNodeDiff, checkContentPlaceholders, checkElementPatch, finalizeForRender } from "../builder/page.js";
|
|
6
5
|
/**
|
|
7
6
|
* Global Sources tools — manage site-wide components: cart, popup, overview, etc.
|
|
8
7
|
*
|
|
@@ -115,67 +114,6 @@ export function findNodeById(source, elementId) {
|
|
|
115
114
|
});
|
|
116
115
|
return found;
|
|
117
116
|
}
|
|
118
|
-
/** Deep-diff two nodes — returns only changed fields with before/after.
|
|
119
|
-
* Objects (style, config, specials) are diffed at key-level.
|
|
120
|
-
* Arrays (events, bindings) show full before/after.
|
|
121
|
-
* Responsive breakpoints diffed individually.
|
|
122
|
-
*/
|
|
123
|
-
function computeNodeDiff(beforeNode, afterNode) {
|
|
124
|
-
const diff = {};
|
|
125
|
-
const objFields = ["style", "config", "specials"];
|
|
126
|
-
const arrFields = ["events", "bindings"];
|
|
127
|
-
for (const field of objFields) {
|
|
128
|
-
const b = beforeNode[field] || {};
|
|
129
|
-
const a = afterNode[field] || {};
|
|
130
|
-
if (JSON.stringify(b) === JSON.stringify(a))
|
|
131
|
-
continue;
|
|
132
|
-
const fieldDiff = {};
|
|
133
|
-
for (const k of new Set([...Object.keys(b), ...Object.keys(a)])) {
|
|
134
|
-
if (JSON.stringify(b[k]) !== JSON.stringify(a[k])) {
|
|
135
|
-
fieldDiff[k] = { before: b[k] ?? null, after: a[k] ?? null };
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (Object.keys(fieldDiff).length)
|
|
139
|
-
diff[field] = fieldDiff;
|
|
140
|
-
}
|
|
141
|
-
for (const field of arrFields) {
|
|
142
|
-
if (JSON.stringify(beforeNode[field] || null) !== JSON.stringify(afterNode[field] || null)) {
|
|
143
|
-
diff[field] = { before: beforeNode[field] || null, after: afterNode[field] || null };
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
for (const key of new Set([...Object.keys(beforeNode), ...Object.keys(afterNode)])) {
|
|
147
|
-
if (!/^bp\d+$/.test(key))
|
|
148
|
-
continue;
|
|
149
|
-
if (JSON.stringify(beforeNode[key] || null) !== JSON.stringify(afterNode[key] || null)) {
|
|
150
|
-
if (!diff.responsive)
|
|
151
|
-
diff.responsive = {};
|
|
152
|
-
diff.responsive[key] = { before: beforeNode[key] || null, after: afterNode[key] || null };
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return Object.keys(diff).length ? diff : null;
|
|
156
|
-
}
|
|
157
|
-
function applyNodeUpdates(node, updates) {
|
|
158
|
-
if (updates.style)
|
|
159
|
-
node.style = { ...(node.style || {}), ...updates.style };
|
|
160
|
-
if (updates.config)
|
|
161
|
-
node.config = { ...(node.config || {}), ...updates.config };
|
|
162
|
-
if (updates.specials)
|
|
163
|
-
node.specials = { ...(node.specials || {}), ...updates.specials };
|
|
164
|
-
// Normalize so updated events/bindings get a valid id + eventName (renderer needs it).
|
|
165
|
-
if (updates.events !== undefined)
|
|
166
|
-
node.events = normalizeEvents(updates.events, node.type);
|
|
167
|
-
if (updates.bindings !== undefined)
|
|
168
|
-
node.bindings = normalizeBindings(updates.bindings);
|
|
169
|
-
if (updates.responsive) {
|
|
170
|
-
for (const [bp, val] of Object.entries(updates.responsive)) {
|
|
171
|
-
if (/^bp\d+$/.test(bp)) {
|
|
172
|
-
node[bp] = node[bp]
|
|
173
|
-
? { style: { ...node[bp].style, ...val.style }, config: { ...node[bp].config, ...val.config } }
|
|
174
|
-
: val;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
117
|
export function searchElements(source, filters) {
|
|
180
118
|
const results = [];
|
|
181
119
|
const limit = filters.limit || 50;
|
|
@@ -324,8 +262,8 @@ async function getGsWithSource(api, globalSourceId, componentHint) {
|
|
|
324
262
|
// ── Zod schemas (reused across tools) ──
|
|
325
263
|
const elementUpdateShape = z.object({
|
|
326
264
|
element_id: z.string().describe("Element ID"),
|
|
327
|
-
style: z.record(z.any()).optional(),
|
|
328
|
-
config: z.record(z.any()).optional(),
|
|
265
|
+
style: z.record(z.any()).optional().describe(STYLE_DESC),
|
|
266
|
+
config: z.record(z.any()).optional().describe(CONFIG_DESC),
|
|
329
267
|
specials: z.record(z.any()).optional(),
|
|
330
268
|
events: z.array(z.record(z.any())).optional(),
|
|
331
269
|
bindings: z.array(z.record(z.any())).optional(),
|
|
@@ -449,8 +387,8 @@ events/bindings = REPLACE the whole array — pass the COMPLETE list (read it fi
|
|
|
449
387
|
element_id: z.string().describe("Element ID to update (e.g. 'TEXT-3', 'BUTTON-1')"),
|
|
450
388
|
component: z.string().optional().describe('Component hint for faster lookup'),
|
|
451
389
|
dry_run: z.boolean().optional().describe("Preview only (true) or apply changes (false). Defaults to confirm_mode setting. Use toggle_confirm_mode to change default."),
|
|
452
|
-
style: z.record(z.any()).optional().describe(
|
|
453
|
-
config: z.record(z.any()).optional().describe(
|
|
390
|
+
style: z.record(z.any()).optional().describe(STYLE_DESC),
|
|
391
|
+
config: z.record(z.any()).optional().describe(CONFIG_DESC),
|
|
454
392
|
specials: z.record(z.any()).optional().describe("Specials to merge (text, custom_class, custom_css)"),
|
|
455
393
|
events: z.array(z.record(z.any())).optional().describe("Complete events array (replaces existing)"),
|
|
456
394
|
bindings: z.array(z.record(z.any())).optional().describe("Complete bindings array (replaces existing)"),
|
|
@@ -466,6 +404,7 @@ events/bindings = REPLACE the whole array — pass the COMPLETE list (read it fi
|
|
|
466
404
|
return { error };
|
|
467
405
|
if (!source)
|
|
468
406
|
return { error: "Global source has no source data" };
|
|
407
|
+
const saved0 = structuredClone(source); // before any patch: source may be the cached object itself
|
|
469
408
|
const node = findNodeById(source, element_id);
|
|
470
409
|
if (!node)
|
|
471
410
|
return { error: `Element "${element_id}" not found` };
|
|
@@ -475,6 +414,9 @@ events/bindings = REPLACE the whole array — pass the COMPLETE list (read it fi
|
|
|
475
414
|
const codeErrors = checkElementPatch(asPageShape(source), node, beforeNode, updates.specials);
|
|
476
415
|
if (codeErrors.length)
|
|
477
416
|
return { error: "BLOCKED: not saving.", element_id, errors: codeErrors };
|
|
417
|
+
const shapeErrors = addedErrors(asPageShape(source), asPageShape(saved0));
|
|
418
|
+
if (shapeErrors.length)
|
|
419
|
+
return { error: "BLOCKED: not saving.", element_id, errors: shapeErrors };
|
|
478
420
|
const diff = computeNodeDiff(beforeNode, node);
|
|
479
421
|
if (!diff)
|
|
480
422
|
return { info: "No changes detected", element_id };
|
|
@@ -531,6 +473,7 @@ Same merge rules: style/config/specials = shallow merge, events/bindings = repla
|
|
|
531
473
|
return { error };
|
|
532
474
|
if (!source)
|
|
533
475
|
return { error: "Global source has no source data" };
|
|
476
|
+
const saved0 = structuredClone(source); // before any patch: source may be the cached object itself
|
|
534
477
|
const results = [];
|
|
535
478
|
for (const upd of elementUpdates) {
|
|
536
479
|
const node = findNodeById(source, upd.element_id);
|
|
@@ -547,6 +490,9 @@ Same merge rules: style/config/specials = shallow merge, events/bindings = repla
|
|
|
547
490
|
const diff = computeNodeDiff(beforeNode, node);
|
|
548
491
|
results.push({ element_id, diff: diff || "no changes" });
|
|
549
492
|
}
|
|
493
|
+
const shapeErrors = addedErrors(asPageShape(source), asPageShape(saved0));
|
|
494
|
+
if (shapeErrors.length)
|
|
495
|
+
return { error: "BLOCKED: not saving any of this batch.", errors: shapeErrors };
|
|
550
496
|
if (dry_run) {
|
|
551
497
|
return {
|
|
552
498
|
dry_run: true,
|
|
@@ -584,10 +530,13 @@ Same merge rules: style/config/specials = shallow merge, events/bindings = repla
|
|
|
584
530
|
source: z.any().describe("Source configuration (sections/elements JSON)"),
|
|
585
531
|
type: z.string().default("default").describe('Type variant (default: "default")'),
|
|
586
532
|
}, ({ component, source, type }) => handle(async () => {
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
const
|
|
533
|
+
const obj = typeof source === "string" ? JSON.parse(source) : source;
|
|
534
|
+
// runtime-shaped nodes (new_element output) → per-breakpoint keys, in place (asPageShape keeps node refs)
|
|
535
|
+
finalizeForRender(asPageShape(obj), await api.getSiteBreakpoints(), await api.getSiteDefaultGrid());
|
|
536
|
+
const errors = addedErrors(asPageShape(obj));
|
|
537
|
+
if (errors.length)
|
|
538
|
+
return { error: "BLOCKED: not saving.", errors };
|
|
539
|
+
const params = { component, source: obj, type, site_id: api.siteId };
|
|
591
540
|
const res = component === "cart-droppable"
|
|
592
541
|
? await api.createSourceCart(params)
|
|
593
542
|
: await api.createGlobalSource(params);
|
|
@@ -611,10 +560,11 @@ Safeguarded: blocks if new source is <50% of existing size. For element-level ch
|
|
|
611
560
|
return { error };
|
|
612
561
|
// Ensure source is an object (not string) — backend does Jason.encode! so we must send object
|
|
613
562
|
const newSourceObj = typeof newSourceInput === "string" ? JSON.parse(newSourceInput) : newSourceInput;
|
|
563
|
+
finalizeForRender(asPageShape(newSourceObj), await api.getSiteBreakpoints(), await api.getSiteDefaultGrid());
|
|
614
564
|
const newLen = JSON.stringify(newSourceObj).length;
|
|
615
|
-
const
|
|
616
|
-
if (
|
|
617
|
-
return { error: "BLOCKED: not saving.", errors
|
|
565
|
+
const errors = addedErrors(asPageShape(newSourceObj), existingSource ? asPageShape(existingSource) : undefined);
|
|
566
|
+
if (errors.length)
|
|
567
|
+
return { error: "BLOCKED: not saving.", errors };
|
|
618
568
|
// Safeguard: block if new source is suspiciously smaller
|
|
619
569
|
if (existingSource) {
|
|
620
570
|
const existingLen = JSON.stringify(existingSource).length;
|
package/dist/tools/page-draft.js
CHANGED
|
@@ -134,7 +134,7 @@ RESUMABLE: if a request fails mid-commit, the draft keeps its page_id + committe
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
// Expand runtime -> bp1..bp4 so the saved nodes actually render.
|
|
137
|
-
finalizeForRender(full, await api.getSiteBreakpoints());
|
|
137
|
+
finalizeForRender(full, await api.getSiteBreakpoints(), await api.getSiteDefaultGrid());
|
|
138
138
|
const finalizedSections = full.sections;
|
|
139
139
|
try {
|
|
140
140
|
// Create the page with only the FIRST section (a SMALL first request) if not already created.
|
|
@@ -149,7 +149,8 @@ RESUMABLE: if a request fails mid-commit, the draft keeps its page_id + committe
|
|
|
149
149
|
}
|
|
150
150
|
// Append the remaining sections one at a time, saving progress after each.
|
|
151
151
|
for (let i = draft.committed_count ?? 1; i < finalizedSections.length; i++) {
|
|
152
|
-
|
|
152
|
+
// Rebuild CSS / sync globals once, on the last section (each sync builds the whole page CSS).
|
|
153
|
+
await api.updatePageSource(draft.page_id, { source: { sections: finalizedSections.slice(0, i + 1) } }, { timeout: 120000, sync: i === finalizedSections.length - 1 });
|
|
153
154
|
draft.committed_count = i + 1;
|
|
154
155
|
await setDraft(draft);
|
|
155
156
|
}
|
package/dist/tools/pages.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CUSTOM_CODE_GUIDE } from "../guides.js";
|
|
3
3
|
import { getConfirmMode } from "./context.js";
|
|
4
|
-
import {
|
|
5
|
-
import { normalizeBindings } from "../builder/bindings.js";
|
|
6
|
-
import { checkContentPlaceholders, checkElementPatch, checkNativeContent } from "../builder/page.js";
|
|
4
|
+
import { addedErrors, applyNodeUpdates, computeNodeDiff, checkContentPlaceholders, checkElementPatch, finalizeForRender } from "../builder/page.js";
|
|
7
5
|
import { SITE_CODE_FIELDS, checkSiteCode, codeGuard, codeUsage } from "../builder/native-first.js";
|
|
8
6
|
import { PAGE_TYPE_NUM, PAGE_KINDS, applyPageMeta, normalizeSlug, checkPageCreateConflict } from "./builder.js";
|
|
9
7
|
const pageSeoSchema = z.object({
|
|
@@ -130,65 +128,6 @@ function findNodeById(source, elementId) {
|
|
|
130
128
|
});
|
|
131
129
|
return found;
|
|
132
130
|
}
|
|
133
|
-
/** Deep-diff two nodes — returns only changed fields with before/after */
|
|
134
|
-
function computeNodeDiff(beforeNode, afterNode) {
|
|
135
|
-
const diff = {};
|
|
136
|
-
const objFields = ["style", "config", "specials"];
|
|
137
|
-
const arrFields = ["events", "bindings"];
|
|
138
|
-
for (const field of objFields) {
|
|
139
|
-
const b = beforeNode[field] || {};
|
|
140
|
-
const a = afterNode[field] || {};
|
|
141
|
-
if (JSON.stringify(b) === JSON.stringify(a))
|
|
142
|
-
continue;
|
|
143
|
-
const fieldDiff = {};
|
|
144
|
-
for (const k of new Set([...Object.keys(b), ...Object.keys(a)])) {
|
|
145
|
-
if (JSON.stringify(b[k]) !== JSON.stringify(a[k])) {
|
|
146
|
-
fieldDiff[k] = { before: b[k] ?? null, after: a[k] ?? null };
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (Object.keys(fieldDiff).length)
|
|
150
|
-
diff[field] = fieldDiff;
|
|
151
|
-
}
|
|
152
|
-
for (const field of arrFields) {
|
|
153
|
-
if (JSON.stringify(beforeNode[field] || null) !== JSON.stringify(afterNode[field] || null)) {
|
|
154
|
-
diff[field] = { before: beforeNode[field] || null, after: afterNode[field] || null };
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
for (const key of new Set([...Object.keys(beforeNode), ...Object.keys(afterNode)])) {
|
|
158
|
-
if (!/^bp\d+$/.test(key))
|
|
159
|
-
continue;
|
|
160
|
-
if (JSON.stringify(beforeNode[key] || null) !== JSON.stringify(afterNode[key] || null)) {
|
|
161
|
-
if (!diff.responsive)
|
|
162
|
-
diff.responsive = {};
|
|
163
|
-
diff.responsive[key] = { before: beforeNode[key] || null, after: afterNode[key] || null };
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return Object.keys(diff).length ? diff : null;
|
|
167
|
-
}
|
|
168
|
-
/** Apply updates to a node in-place (shallow merge for objects, replace for arrays) */
|
|
169
|
-
function applyNodeUpdates(node, updates) {
|
|
170
|
-
if (updates.style)
|
|
171
|
-
node.style = { ...(node.style || {}), ...updates.style };
|
|
172
|
-
if (updates.config)
|
|
173
|
-
node.config = { ...(node.config || {}), ...updates.config };
|
|
174
|
-
if (updates.specials)
|
|
175
|
-
node.specials = { ...(node.specials || {}), ...updates.specials };
|
|
176
|
-
// Normalize so updated events/bindings carry a valid id + eventName (and the right
|
|
177
|
-
// element-type default trigger) — the storefront renderer won't dispatch an event with
|
|
178
|
-
// no eventName. Round-trip safe: already-formed entries pass through unchanged.
|
|
179
|
-
if (updates.events !== undefined)
|
|
180
|
-
node.events = normalizeEvents(updates.events, node.type);
|
|
181
|
-
if (updates.bindings !== undefined)
|
|
182
|
-
node.bindings = normalizeBindings(updates.bindings);
|
|
183
|
-
// Responsive breakpoints (bp1, bp2, ...)
|
|
184
|
-
if (updates.responsive) {
|
|
185
|
-
for (const [bp, val] of Object.entries(updates.responsive)) {
|
|
186
|
-
if (/^bp\d+$/.test(bp)) {
|
|
187
|
-
node[bp] = node[bp] ? { style: { ...node[bp].style, ...val.style }, config: { ...node[bp].config, ...val.config } } : val;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
131
|
/** Search/filter elements in source by criteria */
|
|
193
132
|
function searchElements(source, filters) {
|
|
194
133
|
const results = [];
|
|
@@ -268,6 +207,8 @@ async function readSiteCode(api) {
|
|
|
268
207
|
const values = await Promise.all(SITE_CODE_FIELDS.map((f) => api.getSiteSettingField(f)));
|
|
269
208
|
return Object.fromEntries(SITE_CODE_FIELDS.map((f, i) => [f, values[i] || ""]));
|
|
270
209
|
}
|
|
210
|
+
export const STYLE_DESC = "Style to merge, camelCase like the editor (e.g. {color:'#fff', fontSize:'16px'}). Colours, fonts, borders… go to every breakpoint; size/position (width, height, top, left, fontSize…) to desktop (bp1) only. For tablet/mobile use responsive.";
|
|
211
|
+
export const CONFIG_DESC = "Config to merge (layout: widthUnit auto|px|%, constraintX/Y, columnStart…). Same breakpoint rule as style.";
|
|
271
212
|
const ALLOW_SHRINK = z.boolean().optional()
|
|
272
213
|
.describe("Allow the source to shrink by more than half: set it when native elements replaced an oversized embed or custom_css and you have read it first.");
|
|
273
214
|
const NATIVE_GAP = z.string().min(30).optional()
|
|
@@ -469,7 +410,15 @@ For full rewrites, use update_site_custom_code instead.`, {
|
|
|
469
410
|
}, ({ page_id }) => handle(async () => {
|
|
470
411
|
const res = await api.deletePage({ page_id });
|
|
471
412
|
invalidatePageCache();
|
|
472
|
-
|
|
413
|
+
// Like the editor: a deleted page leaves every global section's page list. The page is
|
|
414
|
+
// already gone, so a failure here is a warning, not a failed delete (a retry would 404).
|
|
415
|
+
try {
|
|
416
|
+
const unlinked = await api.unlinkPageFromGlobalSections(page_id);
|
|
417
|
+
return unlinked ? { ...res, global_sections_unlinked: unlinked } : res;
|
|
418
|
+
}
|
|
419
|
+
catch (e) {
|
|
420
|
+
return { ...res, warning: `Page deleted, but removing it from global sections' page lists failed: ${e?.message || e}` };
|
|
421
|
+
}
|
|
473
422
|
}));
|
|
474
423
|
server.tool("get_page_versions", "View version history of a page", {
|
|
475
424
|
page_id: z.string().describe("Page ID"),
|
|
@@ -545,8 +494,8 @@ events/bindings = REPLACE the whole array — pass the COMPLETE list (read it fi
|
|
|
545
494
|
page_id: z.string().describe("Page ID"),
|
|
546
495
|
element_id: z.string().describe("Element ID to update (e.g. 'TEXT-3', 'BUTTON-1')"),
|
|
547
496
|
dry_run: z.boolean().optional().describe("Preview only (true) or apply changes (false). Defaults to confirm_mode setting. Use toggle_confirm_mode to change default."),
|
|
548
|
-
style: z.record(z.any()).optional().describe(
|
|
549
|
-
config: z.record(z.any()).optional().describe(
|
|
497
|
+
style: z.record(z.any()).optional().describe(STYLE_DESC),
|
|
498
|
+
config: z.record(z.any()).optional().describe(CONFIG_DESC),
|
|
550
499
|
specials: z.record(z.any()).optional().describe("Specials to merge (text, custom_class, custom_css, etc.)"),
|
|
551
500
|
events: z.array(z.record(z.any())).optional().describe("Complete events array (replaces existing)"),
|
|
552
501
|
bindings: z.array(z.record(z.any())).optional().describe("Complete bindings array (replaces existing)"),
|
|
@@ -560,6 +509,7 @@ events/bindings = REPLACE the whole array — pass the COMPLETE list (read it fi
|
|
|
560
509
|
return { error };
|
|
561
510
|
if (!source)
|
|
562
511
|
return { error: "Page has no source" };
|
|
512
|
+
const saved0 = structuredClone(source); // before any patch: source may be the cached object itself
|
|
563
513
|
const node = findNodeById(source, element_id);
|
|
564
514
|
if (!node)
|
|
565
515
|
return { error: `Element "${element_id}" not found` };
|
|
@@ -568,6 +518,10 @@ events/bindings = REPLACE the whole array — pass the COMPLETE list (read it fi
|
|
|
568
518
|
const codeErrors = checkElementPatch(source, node, beforeNode, updates.specials);
|
|
569
519
|
if (codeErrors.length)
|
|
570
520
|
return { error: "BLOCKED: not saving.", element_id, errors: codeErrors };
|
|
521
|
+
// A patch can break the renderer too (style value as an object, widthUnit "em"…).
|
|
522
|
+
const shapeErrors = addedErrors(source, saved0);
|
|
523
|
+
if (shapeErrors.length)
|
|
524
|
+
return { error: "BLOCKED: not saving.", element_id, errors: shapeErrors };
|
|
571
525
|
const diff = computeNodeDiff(beforeNode, node);
|
|
572
526
|
if (!diff)
|
|
573
527
|
return { info: "No changes detected", element_id };
|
|
@@ -606,8 +560,8 @@ Same merge rules: style/config/specials = shallow merge, events/bindings = repla
|
|
|
606
560
|
dry_run: z.boolean().optional().describe("Preview only (true) or apply changes (false). Defaults to confirm_mode setting."),
|
|
607
561
|
updates: z.array(z.object({
|
|
608
562
|
element_id: z.string().describe("Element ID"),
|
|
609
|
-
style: z.record(z.any()).optional(),
|
|
610
|
-
config: z.record(z.any()).optional(),
|
|
563
|
+
style: z.record(z.any()).optional().describe(STYLE_DESC),
|
|
564
|
+
config: z.record(z.any()).optional().describe(CONFIG_DESC),
|
|
611
565
|
specials: z.record(z.any()).optional(),
|
|
612
566
|
events: z.array(z.record(z.any())).optional(),
|
|
613
567
|
bindings: z.array(z.record(z.any())).optional(),
|
|
@@ -622,6 +576,7 @@ Same merge rules: style/config/specials = shallow merge, events/bindings = repla
|
|
|
622
576
|
return { error };
|
|
623
577
|
if (!source)
|
|
624
578
|
return { error: "Page has no source" };
|
|
579
|
+
const saved0 = structuredClone(source); // before any patch: source may be the cached object itself
|
|
625
580
|
const results = [];
|
|
626
581
|
for (const upd of elementUpdates) {
|
|
627
582
|
const node = findNodeById(source, upd.element_id);
|
|
@@ -638,6 +593,9 @@ Same merge rules: style/config/specials = shallow merge, events/bindings = repla
|
|
|
638
593
|
const diff = computeNodeDiff(beforeNode, node);
|
|
639
594
|
results.push({ element_id, diff: diff || "no changes" });
|
|
640
595
|
}
|
|
596
|
+
const shapeErrors = addedErrors(source, saved0);
|
|
597
|
+
if (shapeErrors.length)
|
|
598
|
+
return { error: "BLOCKED: not saving any of this batch.", errors: shapeErrors };
|
|
641
599
|
if (dry_run) {
|
|
642
600
|
return {
|
|
643
601
|
dry_run: true,
|
|
@@ -678,6 +636,9 @@ Safeguarded: blocks if new source is <50% of existing size.`, {
|
|
|
678
636
|
if (source != null) {
|
|
679
637
|
// Ensure source is an object — backend does Jason.encode! so we must send object, not string
|
|
680
638
|
body.source = typeof source === "string" ? JSON.parse(source) : source;
|
|
639
|
+
// Nodes still in builder shape (runtime, e.g. straight from new_element) get their
|
|
640
|
+
// per-breakpoint keys like every other writer; nodes already in bp shape are untouched.
|
|
641
|
+
finalizeForRender(body.source, await api.getSiteBreakpoints(), await api.getSiteDefaultGrid());
|
|
681
642
|
}
|
|
682
643
|
if (custom_code != null) {
|
|
683
644
|
invalidatePageCache();
|
|
@@ -692,9 +653,10 @@ Safeguarded: blocks if new source is <50% of existing size.`, {
|
|
|
692
653
|
if (body.source) {
|
|
693
654
|
invalidatePageCache();
|
|
694
655
|
const { source: existingSource, error } = await getPageWithSource(api, page_id);
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
656
|
+
// Full structural + renderer-crash check, refusing only what this save ADDS.
|
|
657
|
+
const added = addedErrors(body.source, existingSource || undefined);
|
|
658
|
+
if (added.length)
|
|
659
|
+
return { error: "BLOCKED: not saving.", errors: added };
|
|
698
660
|
if (!error && existingSource) {
|
|
699
661
|
const existingLen = JSON.stringify(existingSource).length;
|
|
700
662
|
const newLen = JSON.stringify(body.source).length;
|
package/dist/web-guide-scene.js
CHANGED
|
@@ -121,7 +121,7 @@ export function sceneHtml(lang) {
|
|
|
121
121
|
.map((s, i) => `<li${i === 0 ? ' class="cur"' : ""}><button type="button" class="sc-step"><span class="sc-n">${i + 1}</span><span>${s.t}</span></button><div class="sc-dw"><p>${s.d}</p></div></li>`)
|
|
122
122
|
.join("\n ")}
|
|
123
123
|
</ol>
|
|
124
|
-
<button type="button" class="sc-ctl" hidden
|
|
124
|
+
<button type="button" class="sc-ctl" hidden>${c.pause}</button>
|
|
125
125
|
</div>
|
|
126
126
|
</section>`;
|
|
127
127
|
}
|
|
@@ -171,10 +171,13 @@ export const GLASS_CSS = `
|
|
|
171
171
|
.sc{position:relative;width:min(1180px,calc(100vw - 32px));margin-left:calc(50% - min(590px,calc(50vw - 16px)))}
|
|
172
172
|
.sc-stage{display:none;position:relative;overflow:hidden;height:clamp(440px,46vw,600px)}
|
|
173
173
|
.js .sc.on .sc-stage{display:block}
|
|
174
|
-
.sc-stage canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
|
|
174
|
+
.sc-stage canvas{position:absolute;inset:0;width:100%;height:100%;display:block;opacity:0;transition:opacity .45s ease}
|
|
175
|
+
/* Canvas + labels wait for the first drawn frame, so the labels never flash stacked at 0,0. */
|
|
176
|
+
.sc-tag{opacity:0}
|
|
177
|
+
.sc.ready .sc-stage canvas,.sc.ready .sc-tag{opacity:1}
|
|
175
178
|
.sc-tag{position:absolute;left:0;top:0;padding:5px 13px 6px;border-radius:14px;text-align:center;white-space:nowrap;line-height:1.25;
|
|
176
179
|
color:var(--ink);background:var(--glass-strong);box-shadow:inset 0 1px 0 var(--rim),0 8px 18px -12px rgba(0,0,0,.5);
|
|
177
|
-
-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);pointer-events:none;will-change:transform;transition:color .25s ease}
|
|
180
|
+
-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);pointer-events:none;will-change:transform;transition:color .25s ease,opacity .45s ease}
|
|
178
181
|
.sc-tag b{display:block;font-size:.84rem}
|
|
179
182
|
.sc-tag small{display:block;font-size:.72rem;font-weight:500;color:var(--mut)}
|
|
180
183
|
.sc-tag.on b{color:var(--g7)}
|
|
@@ -199,8 +202,10 @@ export const GLASS_CSS = `
|
|
|
199
202
|
color:var(--g7);font:inherit;font-size:.84rem;font-weight:700}
|
|
200
203
|
.sc-ctl:hover{background:rgba(127,160,140,.14)}
|
|
201
204
|
.sc-ctl[hidden]{display:none}
|
|
205
|
+
/* Reserve the play/pause row before three.js arrives so the panel doesn't grow. */
|
|
206
|
+
@media(prefers-reduced-motion:no-preference){.js .sc.on .sc-ctl[hidden]{display:block;visibility:hidden}}
|
|
202
207
|
@media(max-width:639px){.sc-stage{height:520px}.sc-tag small{font-size:.68rem}.nav{margin-left:0;margin-right:0}}
|
|
203
|
-
@media(prefers-reduced-motion:reduce){.sc-dw,.sc-step,.sc-n,.sc-tag{transition:none}}
|
|
208
|
+
@media(prefers-reduced-motion:reduce){.sc-dw,.sc-step,.sc-n,.sc-tag,.sc-stage canvas{transition:none}}
|
|
204
209
|
@media(prefers-reduced-transparency:reduce){
|
|
205
210
|
.glass,.iconbtn,.langsw,.btn.ghost,.btn.ghost:hover,.nav,.tip,.sc-tag{background-color:var(--card);background-image:none;
|
|
206
211
|
-webkit-backdrop-filter:none;backdrop-filter:none}
|
|
@@ -545,6 +550,7 @@ export const SCENE_JS = String.raw `
|
|
|
545
550
|
}
|
|
546
551
|
syncCtl();
|
|
547
552
|
renderer.render(scene,camera);
|
|
553
|
+
root.classList.add('ready');
|
|
548
554
|
}
|
|
549
555
|
function syncCtl(){
|
|
550
556
|
if(reduced)return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcake-storefront-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.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",
|