sbuilder-mcp 0.100.0 → 0.100.2
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/CHANGELOG.md +23 -0
- package/CHANGELOG.vi.md +23 -0
- package/dist/domains/site/document.js +7 -3
- package/dist/domains/site/findings.js +4 -0
- package/dist/domains/site/review.js +28 -2
- package/dist/domains/site/writecheck.js +1 -1
- package/dist/tools/live.js +20 -1
- package/dist/tools/page.js +41 -15
- package/dist/tools/store.js +7 -3
- package/dist/transport/pages.js +6 -5
- package/dist/vision/measure.js +25 -4
- package/dist/vision/shoot.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,29 @@ All notable changes to this project are documented in this file.
|
|
|
6
6
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
7
7
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.100.2] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- `sb_look` with a `node_id` inside an overlay such as the cart drawer now measures the overlay's subtree in its open state.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- `sb_look` reports `wider_than_viewport` for fixed, sticky or absolute boxes that overflow the viewport by more than 1px, so a 400px cart drawer on a 390px phone is no longer missed.
|
|
16
|
+
- `sb_review` reports `duplicate_binding_field` when two bindings target the same field, naming the binding that is displayed.
|
|
17
|
+
- `sb_bind` on a field with duplicate bindings replaces the first one and drops the later duplicates.
|
|
18
|
+
|
|
19
|
+
## [0.100.1] - 2026-10-29
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- `sb_outline` collapses only shared headers, footers and overlays, not global custom sections, and a collapsed line carries `collapsed: true`.
|
|
23
|
+
- `sb_duplicate` lists at most 40 nodes in `copies`, and past that it returns the top-level copy plus `copied` and `copies_truncated`.
|
|
24
|
+
- `sb_publish` shows `cascade_note` once per process, on its first appearance in a dry run or a real publish.
|
|
25
|
+
- The error for a missing page source now reads "page <id> not found on site <site> (deleted, or not this site/key)".
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- `sb_store` with `action: "form"` and `node_id` places the form the same way as `sb_add` and checks that the position can be saved first, so a refused position no longer leaves a stray form behind.
|
|
29
|
+
- `sb_review` no longer reports `default_font` when `responsive[bp].style.fontFamily` is already set.
|
|
30
|
+
- `sb_review` no longer counts `background-color` or `border-color` as `color` for `link_colour`.
|
|
31
|
+
|
|
9
32
|
## [0.100.0] - 2026-10-29
|
|
10
33
|
|
|
11
34
|
### Added
|
package/CHANGELOG.vi.md
CHANGED
|
@@ -6,6 +6,29 @@ Mọi thay đổi đáng chú ý của dự án được ghi lại trong file n
|
|
|
6
6
|
Định dạng dựa trên [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
7
7
|
và dự án tuân theo [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
+
## [0.100.2] - 2026-10-29
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- `sb_look` với `node_id` nằm trong overlay như cart drawer nay đo cây con của overlay ở trạng thái đang mở.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- `sb_look` báo `wider_than_viewport` cho hộp fixed, sticky hoặc absolute tràn khung nhìn quá 1px, nên cart drawer 400px trên điện thoại 390px không còn bị bỏ sót.
|
|
16
|
+
- `sb_review` báo `duplicate_binding_field` khi hai binding cùng trỏ vào một field, kèm binding đang được hiển thị.
|
|
17
|
+
- `sb_bind` trên field có binding trùng sẽ thay binding đầu và bỏ các binding trùng phía sau.
|
|
18
|
+
|
|
19
|
+
## [0.100.1] - 2026-10-29
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- `sb_outline` chỉ thu gọn header, footer dùng chung và overlay, không thu gọn global custom section, và dòng thu gọn mang `collapsed: true`.
|
|
23
|
+
- `sb_duplicate` liệt kê tối đa 40 node trong `copies`, quá giới hạn thì trả bản sao cấp trên cùng với `copied` và `copies_truncated`.
|
|
24
|
+
- `sb_publish` chỉ hiện `cascade_note` một lần mỗi process, ở lần xuất hiện đầu tiên khi chạy thử hoặc publish thật.
|
|
25
|
+
- Lỗi khi không tìm thấy nguồn trang nay ghi "page <id> not found on site <site> (deleted, or not this site/key)".
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- `sb_store` với `action: "form"` và `node_id` đặt form giống `sb_add` và kiểm tra vị trí có lưu được trước, nên vị trí bị từ chối không còn để lại form thừa.
|
|
29
|
+
- `sb_review` không còn báo `default_font` khi `responsive[bp].style.fontFamily` đã được đặt.
|
|
30
|
+
- `sb_review` không còn tính `background-color` hay `border-color` là `color` khi xét `link_colour`.
|
|
31
|
+
|
|
9
32
|
## [0.100.0] - 2026-10-29
|
|
10
33
|
|
|
11
34
|
### Added
|
|
@@ -189,8 +189,9 @@ export class PageDoc {
|
|
|
189
189
|
*/
|
|
190
190
|
/**
|
|
191
191
|
* `chrome: false` (the tool's default) stops at a shared header/footer or an
|
|
192
|
-
* overlay: one line each, no kids
|
|
193
|
-
* ~70% of a routine outline (TTG gap #52).
|
|
192
|
+
* overlay: one line each, no kids, marked `collapsed`. They are the same on
|
|
193
|
+
* every page and were ~70% of a routine outline (TTG gap #52). A CUSTOM global
|
|
194
|
+
* is middle-band content the agent designs in, so it stays expanded.
|
|
194
195
|
*/
|
|
195
196
|
outline(opts = {}) {
|
|
196
197
|
const depth = opts.depth ?? 1;
|
|
@@ -213,7 +214,10 @@ export class PageDoc {
|
|
|
213
214
|
out.global = true;
|
|
214
215
|
if (appBlockRoot(this.doc, id) === id)
|
|
215
216
|
out.app = true;
|
|
216
|
-
const
|
|
217
|
+
const kind = n.specials?.globalKind;
|
|
218
|
+
const collapsed = opts.chrome === false && level === 0 && (out.overlay || (out.global && (kind === 'header' || kind === 'footer')));
|
|
219
|
+
if (collapsed && level + 1 < depth && (kidIds.length || satellitesOf(this.doc, id).length))
|
|
220
|
+
out.collapsed = true;
|
|
217
221
|
if (level + 1 < depth && !collapsed) {
|
|
218
222
|
// Satellites come FIRST, and are counted apart from `children`: they are
|
|
219
223
|
// this node's own chrome, not content in it, and mixing the two would
|
|
@@ -80,7 +80,11 @@ export const FIX = {
|
|
|
80
80
|
// "<key>" here is documentation, not a placeholder: this template is never
|
|
81
81
|
// filled with a key, so the reader sees the form a field must take.
|
|
82
82
|
dead_binding_field: 'Rebind with sb_bind and a field of the form "specials.<key>".',
|
|
83
|
+
duplicate_binding_field: 'Keep one: sb_bind id "<id>" field "<key>" with the source you want — it replaces the binding on ' +
|
|
84
|
+
'that field and drops the duplicates.',
|
|
83
85
|
off_canvas: 'Give it a width that can shrink — sb_set id "<id>", namespace style, keys { "maxWidth": "100%" } at this breakpoint.',
|
|
86
|
+
wider_than_viewport: 'Cap it at the screen: sb_set id "<id>", namespace style, keys { "maxWidth": "100%" }, ' +
|
|
87
|
+
'breakpoint "mobile" (and each other width it overhangs at).',
|
|
84
88
|
text_too_small: 'Raise it for this breakpoint: sb_set id "<id>", namespace style, keys { "fontSize": "16px" }.',
|
|
85
89
|
title_bar_stranded: 'Put the action on the right edge: sb_set id "<id>", namespace style, keys ' +
|
|
86
90
|
'{ "justifyContent": "space-between", "alignItems": "center" }, and sb_set id "<cell>", ' +
|
|
@@ -9,7 +9,7 @@ import { ELEMENTS, BINDING_SOURCES, BOUND_SPECIALS, FIRST_CHILD_ONLY, SATELLITE_
|
|
|
9
9
|
import { fill } from './findings.js';
|
|
10
10
|
import { hrefParamProblems, isRecordSource, isSameSitePath, parseRecordRefAxis, readRecordAggregates, recordAggKeyOf, recordAggregateParams, RECORD_FIELD_ID, RECORD_HTML_SOURCE, RECORD_SOURCE, RECORD_TILES, recordScope, } from './record.js';
|
|
11
11
|
import { formFieldFindings, isFormDocument } from './formdoc.js';
|
|
12
|
-
import { deadNavigation, hasPurchaseBinding, liveEventTable, PAYLOAD_NEEDS, soleNavigationClick } from './navhref.js';
|
|
12
|
+
import { deadNavigation, hasPurchaseBinding, liveEventTable, PAYLOAD_NEEDS, PRODUCT_ACTION_BINDING_ID, soleNavigationClick } from './navhref.js';
|
|
13
13
|
import { unknownValueNote, unknownWriteNote, vocabularyFor, vocabularyForWrite } from './vocabulary.js';
|
|
14
14
|
import { iconNote } from './icons.js';
|
|
15
15
|
import { LINK_COLOUR, unstyledLinks } from './writecheck.js';
|
|
@@ -542,7 +542,9 @@ opts = {}) {
|
|
|
542
542
|
// is another family: a deliberate literal is the author's.
|
|
543
543
|
const ff = n.style?.fontFamily;
|
|
544
544
|
const seedFont = meta.defaults.style?.fontFamily;
|
|
545
|
-
|
|
545
|
+
// A family set at any breakpoint is the author's answer too.
|
|
546
|
+
const perBp = Object.values(n.responsive ?? {}).some((r) => r?.style?.fontFamily !== undefined);
|
|
547
|
+
if (opts.bodyFont && !perBp && typeof ff === 'string' && ff === seedFont && !ff.includes('var(') && family(ff) !== family(opts.bodyFont)) {
|
|
546
548
|
out.push({
|
|
547
549
|
code: 'default_font',
|
|
548
550
|
nodeId: id,
|
|
@@ -1535,6 +1537,30 @@ opts = {}) {
|
|
|
1535
1537
|
});
|
|
1536
1538
|
}
|
|
1537
1539
|
}
|
|
1540
|
+
// TWO BINDINGS ON ONE FIELD (TTG gap #62). ApplyBindings
|
|
1541
|
+
// (render/scope/scope.go) walks them IN ORDER and each resolved source
|
|
1542
|
+
// overwrites the special, so the LAST renders and the rest are dead weight
|
|
1543
|
+
// that a reorder silently swaps. The purchase binding is not a field binding.
|
|
1544
|
+
const byField = new Map();
|
|
1545
|
+
for (const b of bindings) {
|
|
1546
|
+
if (!b.field || !b.source || b.id === PRODUCT_ACTION_BINDING_ID)
|
|
1547
|
+
continue;
|
|
1548
|
+
byField.set(b.field, [...(byField.get(b.field) ?? []), b.source]);
|
|
1549
|
+
}
|
|
1550
|
+
for (const [field, sources] of byField) {
|
|
1551
|
+
if (sources.length < 2)
|
|
1552
|
+
continue;
|
|
1553
|
+
const wins = sources[sources.length - 1];
|
|
1554
|
+
out.push({
|
|
1555
|
+
code: 'duplicate_binding_field',
|
|
1556
|
+
nodeId: id,
|
|
1557
|
+
type,
|
|
1558
|
+
key: field,
|
|
1559
|
+
problem: `${sources.length} bindings write ${field} (${sources.join(', ')}); the renderer applies them in ` +
|
|
1560
|
+
`order, so ${wins} renders and the others are dead weight.`,
|
|
1561
|
+
fix: fill('duplicate_binding_field', { id, key: field }),
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1538
1564
|
}
|
|
1539
1565
|
// Tagged in ONE place rather than at eight push sites: whether a node sits
|
|
1540
1566
|
// inside an overlay is a fact about where it is, not about what is wrong with
|
|
@@ -301,7 +301,7 @@ export function writeCheck(type, namespace, keys, opts = {}) {
|
|
|
301
301
|
}
|
|
302
302
|
/** `<a …>` tags in rich text that set no colour of their own. */
|
|
303
303
|
export function unstyledLinks(html) {
|
|
304
|
-
return (html.match(/<a\b[^>]*>/gi) ?? []).filter((tag) => !/style\s*=\s*["'][^"']
|
|
304
|
+
return (html.match(/<a\b[^>]*>/gi) ?? []).filter((tag) => !/style\s*=\s*["'](?:[^"']*[;\s])?color\s*:/i.test(tag)).length;
|
|
305
305
|
}
|
|
306
306
|
export const LINK_COLOUR = {
|
|
307
307
|
problem: "A link in this rich text has no colour of its own, so it renders in the browser's default link blue " +
|
package/dist/tools/live.js
CHANGED
|
@@ -29,6 +29,7 @@ import { LiveSession } from '../live/session.js';
|
|
|
29
29
|
import { refuseAppBlockInterior } from '../domains/site/builder.js';
|
|
30
30
|
import { soft } from '../domains/site/guard.js';
|
|
31
31
|
import { hrefPatches, hasPurchaseBinding, liveEventTable, PAYLOAD_NEEDS, PRODUCT_ACTION_BINDING_ID, } from '../domains/site/navhref.js';
|
|
32
|
+
import { subtreeIds } from '../core/tree.js';
|
|
32
33
|
import { offscreenNodes, offscreenRootOf } from '../domains/site/offscreen.js';
|
|
33
34
|
import { searchStock, SearchUnavailable, NO_SEARCH_NEXT } from '../transport/stock.js';
|
|
34
35
|
import { siteFor } from './context.js';
|
|
@@ -157,12 +158,21 @@ export function bindNode(doc, id, source, field, action, guard) {
|
|
|
157
158
|
const at = node.bindings.findIndex((b) => b?.field === field && b.id !== PRODUCT_ACTION_BINDING_ID);
|
|
158
159
|
if (at >= 0) {
|
|
159
160
|
const prev = node.bindings[at];
|
|
161
|
+
// And drop any LATER binding on the same field (TTG gap #62): the renderer
|
|
162
|
+
// applies them in order and the last one wins, so replacing only the first
|
|
163
|
+
// would leave the old source rendering. Highest index first, so each
|
|
164
|
+
// `remove` addresses the list as it still stands.
|
|
165
|
+
const extra = node.bindings
|
|
166
|
+
.map((b, i) => (i > at && b?.field === field && b.id !== PRODUCT_ACTION_BINDING_ID ? i : -1))
|
|
167
|
+
.filter((i) => i >= 0)
|
|
168
|
+
.reverse();
|
|
160
169
|
return [
|
|
161
170
|
{
|
|
162
171
|
op: 'set',
|
|
163
172
|
path: ['nodes', id, 'bindings', String(at)],
|
|
164
173
|
value: { id: prev.id ?? randomBytes(6).toString('hex'), source, field },
|
|
165
174
|
},
|
|
175
|
+
...extra.map((index) => ({ op: 'remove', path: ['nodes', id, 'bindings'], index })),
|
|
166
176
|
];
|
|
167
177
|
}
|
|
168
178
|
return [
|
|
@@ -431,7 +441,16 @@ export function registerLiveTools(server, ctx, session) {
|
|
|
431
441
|
// and judging its geometry produced thirteen false off-canvas findings
|
|
432
442
|
// per page on a site whose pages were correct.
|
|
433
443
|
const skip = offscreenNodes(doc);
|
|
434
|
-
|
|
444
|
+
// A framed look measures nothing — EXCEPT the overlay it opened, the one
|
|
445
|
+
// surface no whole-page look ever shows open (TTG gap #60: a 400px drawer
|
|
446
|
+
// on a 390px phone reported no layout). Judged alone: the page beneath is
|
|
447
|
+
// what a whole-page look is for.
|
|
448
|
+
const opened = openOverlay ? new Set(subtreeIds(doc, openOverlay)) : undefined;
|
|
449
|
+
const visual = opened
|
|
450
|
+
? measure(shots, new Set([...skip].filter((id) => !opened.has(id))), doc).filter((f) => opened.has(f.nodeId))
|
|
451
|
+
: node_id
|
|
452
|
+
? []
|
|
453
|
+
: measure(shots, skip, doc);
|
|
435
454
|
const layout = compactFindings(visual);
|
|
436
455
|
const layoutNotice = visual.length > 0 ? ctx.notices.once('measure', MEASURE_NOTICE) : undefined;
|
|
437
456
|
// The legend rides with the first look only; the shape does not change after.
|
package/dist/tools/page.js
CHANGED
|
@@ -20,7 +20,7 @@ import { skinLevelNote } from '../domains/site/fieldskin.js';
|
|
|
20
20
|
import { siteTheme } from '../domains/site/theme-fetch.js';
|
|
21
21
|
import { ensureSiteTheme } from './theme.js';
|
|
22
22
|
import { request, redact, watchPageWrites, onPageSourceWrite, onGlobalWrite, onFormDocumentWrite } from '../transport/http.js';
|
|
23
|
-
import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds, ancestors } from '../core/tree.js';
|
|
23
|
+
import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds, ancestors, childrenOf } from '../core/tree.js';
|
|
24
24
|
import { siteToken } from './credentialpick.js';
|
|
25
25
|
import { validateForSave } from '../domains/site/validate.js';
|
|
26
26
|
import { cascadeTail, formDocChecks, hiddenBand, sayChecks, specCheck, writeCheck } from '../domains/site/writecheck.js';
|
|
@@ -75,6 +75,8 @@ export function reviewField(ctx, doc, formTypes, pageType, formDocType, formRedi
|
|
|
75
75
|
*/
|
|
76
76
|
/** How long a save in the live room waits for its ops' acks before leaving `X-WB-Live-Peer` off. */
|
|
77
77
|
const LIVE_ACK_CAP_MS = 2_000;
|
|
78
|
+
/** sb_duplicate's full old → [new, type] map stops here; past it, the top level and a count. */
|
|
79
|
+
const DUPLICATE_COPIES_CAP = 40;
|
|
78
80
|
/**
|
|
79
81
|
* Why `applyAndSave` would refuse this batch on this document, or null — the
|
|
80
82
|
* ONE place that question is answered, so a dry run and the real write cannot
|
|
@@ -99,6 +101,21 @@ export function saveRefusal(d, patches) {
|
|
|
99
101
|
}
|
|
100
102
|
return { before, refusal: null };
|
|
101
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* `addSubtree` with sb_add's placement: ROOT WITH NO INDEX MEANS "ANOTHER
|
|
106
|
+
* SECTION OF THE PAGE" — the end of the middle band, as sb_template_use and
|
|
107
|
+
* sb_duplicate already place one. Appended last it landed after a shared
|
|
108
|
+
* footer, and the band-order check refused the save — on exactly the call
|
|
109
|
+
* empty_page's fix names. Only when a footer is there to land behind: a FORM
|
|
110
|
+
* document's root has none, and addSubtree's own default (above the submit
|
|
111
|
+
* button) is right. Shared with sb_store action:"form" + node_id, which
|
|
112
|
+
* appended after the footer and stored a stray form.
|
|
113
|
+
*/
|
|
114
|
+
export function addPlaced(d, parentId, spec, index, guard) {
|
|
115
|
+
const rootKids = d.doc.nodes[d.doc.root_node_id]?.data.nodes.length ?? 0;
|
|
116
|
+
const mid = parentId === d.doc.root_node_id ? middleEnd(d.doc) : rootKids;
|
|
117
|
+
return addSubtree(d, parentId, spec, index ?? (mid < rootKids ? mid : undefined), guard);
|
|
118
|
+
}
|
|
102
119
|
/** `once` for a real write, `peek` for a dry run — the same notes, spent once. */
|
|
103
120
|
function noticeFor(ctx, dryRun) {
|
|
104
121
|
return dryRun !== false ? (k, b) => ctx.notices.peek(k, b) : (k, b) => ctx.notices.once(k, b);
|
|
@@ -1520,16 +1537,7 @@ export function registerPageTools(server, ctx) {
|
|
|
1520
1537
|
}, async ({ parent_id, spec, index, dry_run, force }) => {
|
|
1521
1538
|
const d = session.current();
|
|
1522
1539
|
const guard = { force, forced: [] };
|
|
1523
|
-
|
|
1524
|
-
// middle band, as sb_template_use and sb_duplicate already place one.
|
|
1525
|
-
// Appended last it landed after a shared footer, and the band-order check
|
|
1526
|
-
// refused the save — on exactly the call empty_page's fix names.
|
|
1527
|
-
// Only when a footer is there to land behind: a FORM document's root has
|
|
1528
|
-
// none, and addSubtree's own default (above the submit button) is right.
|
|
1529
|
-
const rootKids = d.doc.nodes[d.doc.root_node_id]?.data.nodes.length ?? 0;
|
|
1530
|
-
const mid = parent_id === d.doc.root_node_id ? middleEnd(d.doc) : rootKids;
|
|
1531
|
-
const at = index ?? (mid < rootKids ? mid : undefined);
|
|
1532
|
-
const { patches, ids, idOf } = addSubtree(d, parent_id, spec, at, guard);
|
|
1540
|
+
const { patches, ids, idOf } = addPlaced(d, parent_id, spec, index, guard);
|
|
1533
1541
|
const forced = guard.forced.length ? { forced: guard.forced } : {};
|
|
1534
1542
|
// THE SEED COPY IN THE SITE'S LANGUAGE (TTG gap #46): an empty state minted
|
|
1535
1543
|
// here said "No products yet" on a Vietnamese store, while sb_page_create
|
|
@@ -2086,8 +2094,25 @@ export function registerPageTools(server, ctx) {
|
|
|
2086
2094
|
await session.applyAndSave(patches);
|
|
2087
2095
|
// EVERY copy's id, not just the root's: editing the copied row's answer
|
|
2088
2096
|
// used to take a whole sb_outline to find (TTG gap #53).
|
|
2089
|
-
|
|
2090
|
-
|
|
2097
|
+
// CAPPED: the map grows with the subtree, and a 200-node section would
|
|
2098
|
+
// pour 200 pairs into the reader. Past the cap, the copy's top level only.
|
|
2099
|
+
const entry = (from) => [from, [map[from], d.doc.nodes[from]?.data.type ?? '']];
|
|
2100
|
+
const all = Object.keys(map);
|
|
2101
|
+
if (all.length <= DUPLICATE_COPIES_CAP) {
|
|
2102
|
+
return text({ duplicated: id, into: ids[0], copies: Object.fromEntries(all.map(entry)), rev: d.rev, ...forcedOf() });
|
|
2103
|
+
}
|
|
2104
|
+
const top = [id, ...childrenOf(d.doc, id)].filter((k) => k in map).slice(0, DUPLICATE_COPIES_CAP);
|
|
2105
|
+
const how = ctx.notices.once('duplicate-truncated', 'copies holds the copy and its direct children only (copied counts every node); a deeper sb_outline reads the rest.');
|
|
2106
|
+
return text({
|
|
2107
|
+
duplicated: id,
|
|
2108
|
+
into: ids[0],
|
|
2109
|
+
copied: all.length,
|
|
2110
|
+
copies: Object.fromEntries(top.map(entry)),
|
|
2111
|
+
copies_truncated: true,
|
|
2112
|
+
...(how ? { copies_note: how } : {}),
|
|
2113
|
+
rev: d.rev,
|
|
2114
|
+
...forcedOf(),
|
|
2115
|
+
});
|
|
2091
2116
|
}
|
|
2092
2117
|
// ONTO ANOTHER PAGE — the editor's paste (`useCanvasClipboard.ts`).
|
|
2093
2118
|
const from = session.location();
|
|
@@ -2811,8 +2836,9 @@ export function registerPageTools(server, ctx) {
|
|
|
2811
2836
|
// NO CASCADE PREVIEW EXISTS on the platform (page/globalservice.go
|
|
2812
2837
|
// cascadeTargets runs inside publish only), so the dry run says the rule
|
|
2813
2838
|
// rather than a list it cannot know (TTG gap #59); the real answer names
|
|
2814
|
-
// the pages under `cascaded`.
|
|
2815
|
-
|
|
2839
|
+
// the pages under `cascaded`. SPENT on first show, dry or real: a dry
|
|
2840
|
+
// run repeated it on every preview.
|
|
2841
|
+
const cascade = ctx.notices.once('publish-cascade', 'Publishing also republishes, from their LAST PUBLISHED version (never their draft), every live page ' +
|
|
2816
2842
|
'whose shared header/footer, overlay (cart drawer, pop-up) or app block is behind its master. The ' +
|
|
2817
2843
|
'platform offers no preview of that list; the real publish names them under cascaded.');
|
|
2818
2844
|
return text({ dry_run: true, would_post: path, body, ...draftNote(drafts, fresh), ...(cascade ? { cascade_note: cascade } : {}) });
|
package/dist/tools/store.js
CHANGED
|
@@ -42,7 +42,7 @@ import { API_DEFINITIONS } from '../catalog/api.generated.js';
|
|
|
42
42
|
import { siteToken } from './credentialpick.js';
|
|
43
43
|
import { siteFor } from './context.js';
|
|
44
44
|
import { withFreshIds } from '../domains/site/ids.js';
|
|
45
|
-
import { siteChrome, wearChrome } from './page.js';
|
|
45
|
+
import { addPlaced, saveRefusal, siteChrome, wearChrome } from './page.js';
|
|
46
46
|
import { addSubtree } from '../domains/site/builder.js';
|
|
47
47
|
import { attachGlobal, buildChrome, detachGlobal, promoteGlobal, saveTemplate } from './chrome.js';
|
|
48
48
|
import { bindMenu } from './menu.js';
|
|
@@ -398,7 +398,11 @@ async function seedForm(ctx, session, siteId, key, formName, pageName, headline,
|
|
|
398
398
|
throw new Error('sbuilder: action:"form" takes page_name (a new page) or node_id (the open page), not both.');
|
|
399
399
|
if (session.site() !== siteId)
|
|
400
400
|
throw new Error(`sbuilder: the open page is on site ${session.site()}, not ${siteId} — open a page of this site first.`);
|
|
401
|
-
|
|
401
|
+
// sb_add's placement AND the save's own verdict: a page that would refuse
|
|
402
|
+
// the form node must refuse it here, while there is still no form.
|
|
403
|
+
const refusal = saveRefusal(session.current(), addPlaced(session.current(), parentId, { type: 'form', specials: { formId: 'frm_check' } }).patches).refusal;
|
|
404
|
+
if (refusal)
|
|
405
|
+
throw new Error(`sbuilder: ${refusal} — no form was created.`);
|
|
402
406
|
}
|
|
403
407
|
const tpl = FORM_TEMPLATES[key];
|
|
404
408
|
const site = encodeURIComponent(siteId);
|
|
@@ -499,7 +503,7 @@ async function seedForm(ctx, session, siteId, key, formName, pageName, headline,
|
|
|
499
503
|
let placed;
|
|
500
504
|
if (parentId) {
|
|
501
505
|
try {
|
|
502
|
-
const { patches, ids } =
|
|
506
|
+
const { patches, ids } = addPlaced(session.current(), parentId, { type: 'form', specials: { formId: form.id } });
|
|
503
507
|
await session.applyAndSave(patches);
|
|
504
508
|
placed = { id: ids[0], parent: parentId };
|
|
505
509
|
}
|
package/dist/transport/pages.js
CHANGED
|
@@ -16,14 +16,15 @@ export function sourcePath(siteId, pageId) {
|
|
|
16
16
|
* back out on write.
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
|
-
* A 404 on a page's source is a DELETED page
|
|
19
|
+
* A 404 on a page's source is a DELETED page, a wrong site id, or a key scoped to
|
|
20
|
+
* another site — and the session
|
|
20
21
|
* may still be pointing at it: a bare "source not found [http 404]" after an
|
|
21
22
|
* sb_api_call delete told the caller nothing (TTG gap #57). Same status and
|
|
22
23
|
* code, a sentence that says what to do.
|
|
23
24
|
*/
|
|
24
|
-
const gone = (pageId) => (e) => {
|
|
25
|
+
const gone = (siteId, pageId) => (e) => {
|
|
25
26
|
if (e instanceof ApiError && e.status === 404) {
|
|
26
|
-
throw new ApiError(404, e.code, `page ${pageId}
|
|
27
|
+
throw new ApiError(404, e.code, `page ${pageId} not found on site ${siteId} (deleted, or not this site/key) — sb_page_open another page; sb_page_list lists them`, e.details, e.fields);
|
|
27
28
|
}
|
|
28
29
|
throw e;
|
|
29
30
|
};
|
|
@@ -34,7 +35,7 @@ export async function loadSource(ctx, siteId, pageId) {
|
|
|
34
35
|
path: sourcePath(siteId, pageId),
|
|
35
36
|
token: siteToken(ctx),
|
|
36
37
|
fetchImpl: ctx.fetchImpl,
|
|
37
|
-
}).catch(gone(pageId)));
|
|
38
|
+
}).catch(gone(siteId, pageId)));
|
|
38
39
|
return out.source;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
@@ -71,6 +72,6 @@ livePeer) {
|
|
|
71
72
|
body: { document, schemaVersion: document.schema_version ?? 1, ...(baseRev ? { baseRev } : {}) },
|
|
72
73
|
...(livePeer && LIVE_PEER.test(livePeer) ? { headers: { 'X-WB-Live-Peer': livePeer } } : {}),
|
|
73
74
|
fetchImpl: ctx.fetchImpl,
|
|
74
|
-
}).catch(gone(pageId)));
|
|
75
|
+
}).catch(gone(siteId, pageId)));
|
|
75
76
|
return out.source;
|
|
76
77
|
}
|
package/dist/vision/measure.js
CHANGED
|
@@ -33,10 +33,29 @@ export function measureShot(shot, skip = new Set(), doc) {
|
|
|
33
33
|
// that is two dozen false positives long is a list nobody reads.
|
|
34
34
|
if (skip.has(b.id))
|
|
35
35
|
continue;
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
if (b.
|
|
36
|
+
// A box the browser does not show (a CLOSED drawer is `visibility:hidden`
|
|
37
|
+
// and translated off-screen by its own static CSS) is not a visitor's
|
|
38
|
+
// problem; the same drawer OPENED is (TTG gap #60).
|
|
39
|
+
if (b.hidden)
|
|
40
|
+
continue;
|
|
41
|
+
// A FLOATING BOX PAST THE VIEWPORT (TTG gap #60). A fixed drawer 400px wide
|
|
42
|
+
// on a 390px phone overhangs by 10px with no scrollbar to show it — headless
|
|
43
|
+
// has none, and a 24px padding hides most of it in the picture. Out of the
|
|
44
|
+
// flow nothing shrinks it, so the fix is a cap, said with the widths.
|
|
45
|
+
if ((b.position === 'fixed' || b.position === 'sticky' || b.position === 'absolute') &&
|
|
46
|
+
(b.x < -1 || b.x + b.w > shot.width + 1)) {
|
|
47
|
+
out.push({
|
|
48
|
+
code: 'wider_than_viewport',
|
|
49
|
+
nodeId: b.id,
|
|
50
|
+
width: shot.width,
|
|
51
|
+
problem: `${b.position} box ${b.w}px wide on a ${shot.width}px viewport, overhanging it (${b.x} → ${b.x + b.w}).`,
|
|
52
|
+
fix: fill('wider_than_viewport', { id: b.id }),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else if (b.x < -SLOP || b.x + b.w > shot.width + SLOP) {
|
|
56
|
+
// OFF-CANVAS. A negative x, or a right edge past the viewport, is content
|
|
57
|
+
// the visitor cannot reach — and on a phone it also drags a horizontal
|
|
58
|
+
// scrollbar across the whole page.
|
|
40
59
|
out.push({
|
|
41
60
|
code: 'off_canvas',
|
|
42
61
|
nodeId: b.id,
|
|
@@ -74,6 +93,8 @@ export function measureShot(shot, skip = new Set(), doc) {
|
|
|
74
93
|
continue;
|
|
75
94
|
if (a.w === 0 || a.h === 0 || b.w === 0 || b.h === 0)
|
|
76
95
|
continue;
|
|
96
|
+
if (a.hidden || b.hidden)
|
|
97
|
+
continue;
|
|
77
98
|
// AND THE COMMENT ABOVE IS NOW IMPLEMENTED. It has always said that "an
|
|
78
99
|
// absolutely-positioned decoration over a band is a design choice", and
|
|
79
100
|
// nothing checked: `Box` carried no `position`, so the rule could not tell
|
package/dist/vision/shoot.js
CHANGED
|
@@ -364,6 +364,7 @@ async function shootOne(page, url, width, format, opts) {
|
|
|
364
364
|
hasText: own.length > 0,
|
|
365
365
|
position: cs.position,
|
|
366
366
|
...(layer ? { layer } : {}),
|
|
367
|
+
...(cs.visibility !== 'visible' || el.closest('[aria-hidden="true"]') ? { hidden: true } : {}),
|
|
367
368
|
};
|
|
368
369
|
});
|
|
369
370
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sbuilder-mcp",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.2",
|
|
4
4
|
"description": "MCP server that designs and operates a Store Builder site — pages, data, theme and publish — through the platform's own API and live-edit protocol.",
|
|
5
5
|
"mcpName": "io.github.vuluu2k/sbuilder-mcp",
|
|
6
6
|
"type": "module",
|