sbuilder-mcp 0.100.5 → 0.100.6

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 CHANGED
@@ -6,6 +6,20 @@ 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.6] - 2026-10-29
10
+
11
+ ### Added
12
+ - `sb_traits_for` and `sb_set` expose page-level controls on ROOT: `font_family`, `bg_color`, `bg_image`, `padding` and `class_css`.
13
+ - `sb_import_site` reports `links_unread` for pages whose links could not be read.
14
+
15
+ ### Changed
16
+ - The catalog is regenerated from the latest platform, so the starter theme text styles no longer carry a `fontFamily` of "Inter".
17
+
18
+ ### Fixed
19
+ - A theme text style with no font family now resolves to `inherit`, so elements take the page or site font instead of "Inter", and `default_font` no longer crashes or warns when a theme names no family.
20
+ - `sb_look` and `sb_import` no longer leak a Chrome that finishes launching after its deadline, and every page evaluation, settle and tab close now has a time limit.
21
+ - `sb_import` and `sb_import_site` replace a Chrome that hangs mid-capture once and re-read that page, and report the remaining pages as errors straight away if it hangs again.
22
+
9
23
  ## [0.100.5] - 2026-10-29
10
24
 
11
25
  ### Changed
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,20 @@ 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.6] - 2026-10-29
10
+
11
+ ### Added
12
+ - `sb_traits_for` và `sb_set` cung cấp các control cấp trang trên ROOT: `font_family`, `bg_color`, `bg_image`, `padding` và `class_css`.
13
+ - `sb_import_site` báo `links_unread` cho các trang không đọc được liên kết.
14
+
15
+ ### Changed
16
+ - Catalog được tái sinh theo platform mới nhất, nên text style của theme khởi đầu không còn `fontFamily` là "Inter".
17
+
18
+ ### Fixed
19
+ - Text style của theme không có font family nay được đọc là `inherit`, nên element kế thừa font của trang hoặc site thay vì "Inter", và `default_font` không còn crash hay báo nhầm khi theme không nêu family.
20
+ - `sb_look` và `sb_import` không còn để mồ côi một Chrome khởi động xong sau hạn, và mọi bước evaluate, settle và đóng tab của trang đều có hạn thời gian.
21
+ - `sb_import` và `sb_import_site` thay một lần Chrome bị treo giữa chừng khi chụp rồi đọc lại trang đó, và nếu treo lần nữa thì báo lỗi ngay cho các trang còn lại.
22
+
9
23
  ## [0.100.5] - 2026-10-29
10
24
 
11
25
  ### Changed
@@ -1,6 +1,6 @@
1
1
  export const DEAD_KEY_SOURCE = {
2
- "files": 6043,
3
- "identifiers": 111049,
2
+ "files": 6051,
3
+ "identifiers": 111271,
4
4
  "seededKeys": 460,
5
5
  "dead": 0
6
6
  };
@@ -13,8 +13,54 @@ export const ELEMENTS = {
13
13
  "hideInLayer": false,
14
14
  "childAllows": [],
15
15
  "defaults": {},
16
- "inspector": [],
17
- "controls": [],
16
+ "inspector": [
17
+ {
18
+ "tab": "general",
19
+ "groups": [
20
+ {
21
+ "key": "typography",
22
+ "label": "Typography",
23
+ "controls": [
24
+ "font_family"
25
+ ]
26
+ },
27
+ {
28
+ "key": "background",
29
+ "label": "Background",
30
+ "controls": [
31
+ "bg_color",
32
+ "bg_image"
33
+ ]
34
+ }
35
+ ]
36
+ },
37
+ {
38
+ "tab": "advanced",
39
+ "groups": [
40
+ {
41
+ "key": "spacing",
42
+ "label": "Spacing",
43
+ "controls": [
44
+ "padding"
45
+ ]
46
+ },
47
+ {
48
+ "key": "class_css",
49
+ "label": "Class",
50
+ "controls": [
51
+ "class_css"
52
+ ]
53
+ }
54
+ ]
55
+ }
56
+ ],
57
+ "controls": [
58
+ "font_family",
59
+ "bg_color",
60
+ "bg_image",
61
+ "padding",
62
+ "class_css"
63
+ ],
18
64
  "description": "The invisible page root that wraps all top-level sections.",
19
65
  "useWhen": [
20
66
  "Always present as the single root of every page document"
@@ -36421,6 +36467,7 @@ export const PRESENT_ONLY_SOURCES = [
36421
36467
  "site.facebook",
36422
36468
  "site.instagram",
36423
36469
  "site.localeSwitch",
36470
+ "site.money",
36424
36471
  "site.moneySwitch",
36425
36472
  "site.postalCode",
36426
36473
  "site.privacyPolicy",
@@ -36430,6 +36477,7 @@ export const PRESENT_ONLY_SOURCES = [
36430
36477
  "site.supportEmail",
36431
36478
  "site.supportPhone",
36432
36479
  "site.tiktok",
36480
+ "site.timezone",
36433
36481
  "site.youtube"
36434
36482
  ];
36435
36483
  export const BOUND_SPECIALS = {
@@ -4,7 +4,7 @@ export const SHAPE_SOURCE = {
4
4
  "fromHandlers": 334,
5
5
  "fromSwaggerOnly": 10,
6
6
  "withReadOnly": 29,
7
- "structsRead": 3470
7
+ "structsRead": 3482
8
8
  };
9
9
  export const REQUEST_SHAPES = {
10
10
  "post:/api/sites/{id}/ai-credits/purchase": {
@@ -1,7 +1,7 @@
1
1
  // GENERATED by scripts/gen-catalog.ts — do not edit by hand.
2
2
  // The platform commit every other generated file here describes.
3
3
  export const PLATFORM_SOURCE = {
4
- "commit": "ae1e972c66244b299ac4b5460be740a680f63844",
5
- "committedAt": "2026-10-29T19:22:08+07:00",
4
+ "commit": "8243d518032505f7f494c89313bc82ae35e513ea",
5
+ "committedAt": "2026-10-29T22:22:20+07:00",
6
6
  "dirty": false
7
7
  };
@@ -74,7 +74,6 @@ export const STARTER_THEME = {
74
74
  "slug": "heading-1",
75
75
  "name": "Heading 1",
76
76
  "base": {
77
- "fontFamily": "Inter",
78
77
  "fontSize": "48px",
79
78
  "fontWeight": "700",
80
79
  "fontStyle": "normal",
@@ -94,7 +93,6 @@ export const STARTER_THEME = {
94
93
  "slug": "heading-2",
95
94
  "name": "Heading 2",
96
95
  "base": {
97
- "fontFamily": "Inter",
98
96
  "fontSize": "36px",
99
97
  "fontWeight": "700",
100
98
  "fontStyle": "normal",
@@ -114,7 +112,6 @@ export const STARTER_THEME = {
114
112
  "slug": "heading-3",
115
113
  "name": "Heading 3",
116
114
  "base": {
117
- "fontFamily": "Inter",
118
115
  "fontSize": "28px",
119
116
  "fontWeight": "600",
120
117
  "fontStyle": "normal",
@@ -134,7 +131,6 @@ export const STARTER_THEME = {
134
131
  "slug": "heading-4",
135
132
  "name": "Heading 4",
136
133
  "base": {
137
- "fontFamily": "Inter",
138
134
  "fontSize": "22px",
139
135
  "fontWeight": "600",
140
136
  "fontStyle": "normal",
@@ -149,7 +145,6 @@ export const STARTER_THEME = {
149
145
  "slug": "heading-5",
150
146
  "name": "Heading 5",
151
147
  "base": {
152
- "fontFamily": "Inter",
153
148
  "fontSize": "18px",
154
149
  "fontWeight": "600",
155
150
  "fontStyle": "normal",
@@ -164,7 +159,6 @@ export const STARTER_THEME = {
164
159
  "slug": "heading-6",
165
160
  "name": "Heading 6",
166
161
  "base": {
167
- "fontFamily": "Inter",
168
162
  "fontSize": "16px",
169
163
  "fontWeight": "600",
170
164
  "fontStyle": "normal",
@@ -179,7 +173,6 @@ export const STARTER_THEME = {
179
173
  "slug": "text-1",
180
174
  "name": "Text 1",
181
175
  "base": {
182
- "fontFamily": "Inter",
183
176
  "fontSize": "16px",
184
177
  "fontWeight": "400",
185
178
  "fontStyle": "normal",
@@ -194,7 +187,6 @@ export const STARTER_THEME = {
194
187
  "slug": "text-2",
195
188
  "name": "Text 2",
196
189
  "base": {
197
- "fontFamily": "Inter",
198
190
  "fontSize": "14px",
199
191
  "fontWeight": "400",
200
192
  "fontStyle": "normal",
@@ -209,7 +201,6 @@ export const STARTER_THEME = {
209
201
  "slug": "text-3",
210
202
  "name": "Text 3",
211
203
  "base": {
212
- "fontFamily": "Inter",
213
204
  "fontSize": "12px",
214
205
  "fontWeight": "400",
215
206
  "fontStyle": "normal",
@@ -31,6 +31,16 @@ export function findPreset(theme, id) {
31
31
  * was deleted, or the theme is older than the preset) and inventing a colour for
32
32
  * it would be the exact failure this module exists to prevent.
33
33
  */
34
+ /** `--wb-ts-<slug>-<suffix>` → the text-style prop it carries (schema theme.ts textStyleDecls). */
35
+ const TS_PROP = {
36
+ family: 'fontFamily',
37
+ size: 'fontSize',
38
+ weight: 'fontWeight',
39
+ style: 'fontStyle',
40
+ 'line-height': 'lineHeight',
41
+ 'letter-spacing': 'letterSpacing',
42
+ transform: 'textTransform',
43
+ };
34
44
  export function resolveVars(theme, value, depth = 0) {
35
45
  if (depth > 6 || !value.includes('var('))
36
46
  return value;
@@ -40,6 +50,21 @@ export function resolveVars(theme, value, depth = 0) {
40
50
  const [, name, fallback] = m;
41
51
  const scheme = theme.schemes.find((s) => s.id === theme.lightSchemeId) ?? theme.schemes[0] ?? null;
42
52
  let next;
53
+ if (name.startsWith('--wb-ts-')) {
54
+ // A text style DECLARES every prop, empty when unset (schema theme.ts
55
+ // textStyleDecls), so for a slug the theme carries the fallback never applies:
56
+ // an empty var is invalid at computed time and the element INHERITS. The
57
+ // starter's styles name no family since web_builder 81d036721 — reporting the
58
+ // `Inter` fallback there would tell an agent to write the very literal that
59
+ // commit removed. `color` is composed (role/ref) and keeps the old reading.
60
+ const rest = name.slice('--wb-ts-'.length);
61
+ const ts = theme.textStyles.find((t) => rest.startsWith(`${t.slug}-`));
62
+ const key = ts && TS_PROP[rest.slice(ts.slug.length + 1)];
63
+ if (ts && key) {
64
+ const v = ts.base?.[key];
65
+ return typeof v === 'string' && v ? resolveVars(theme, v, depth + 1) : 'inherit';
66
+ }
67
+ }
43
68
  if (name.startsWith('--wb-sc-'))
44
69
  next = scheme?.roles?.[name.slice('--wb-sc-'.length)];
45
70
  else if (name.startsWith('--wb-color-')) {
@@ -169,7 +169,15 @@ async function discoverSite(ctx, entry, opts) {
169
169
  seen.add(real);
170
170
  urls.push({ url: real, from: real === entry ? 'entry' : 'links' });
171
171
  }
172
- return { source: 'links', urls, titles: crawled.titles, visited: crawled.visited, robots, aliases };
172
+ return {
173
+ source: 'links',
174
+ urls,
175
+ titles: crawled.titles,
176
+ visited: crawled.visited,
177
+ robots,
178
+ aliases,
179
+ ...(crawled.unread.length ? { unread: crawled.unread } : {}),
180
+ };
173
181
  }
174
182
  /**
175
183
  * A built subtree as the document a GLOBAL SECTION stores.
@@ -489,6 +497,7 @@ export function registerImportTools(server, ctx, session) {
489
497
  entry,
490
498
  discovered_by: found.source,
491
499
  ...(found.visited ? { pages_read_to_find_them: found.visited } : {}),
500
+ ...(found.unread ? { links_unread: found.unread } : {}),
492
501
  pages: plan.pages.map((p) => ({ url: p.url, slug: p.slug, name: p.name, ...lands(p) })),
493
502
  ...(Object.keys(plan.skipped).length || found.aliases
494
503
  ? { skipped: { ...plan.skipped, ...(found.aliases ? { 'canonical-alias': found.aliases } : {}) } }
@@ -2041,8 +2041,10 @@ export function registerPageTools(server, ctx) {
2041
2041
  catch {
2042
2042
  // Readiness is additional information, never the reason a review fails.
2043
2043
  }
2044
- // The site's font per text style, for `default_font` — a SITE theme only: the
2045
- // starter is set in Inter, so it can never disagree with an old literal Inter.
2044
+ // The site's font per text style, for `default_font` — a SITE theme only, and
2045
+ // only a style that NAMES a family. Since web_builder 81d036721 the starter's
2046
+ // styles name none (they inherit the page/site font), and an inherited family
2047
+ // is not known here, so such a slug is left out and the rule stays silent.
2046
2048
  const fonts = {};
2047
2049
  try {
2048
2050
  const { theme, from } = await siteTheme(ctx, session.site());
@@ -1446,10 +1446,13 @@ async function readPage(browser, url, width, work, navMs = NAV_TIMEOUT_MS, settl
1446
1446
  // question actually being asked (has the page stopped changing) and answers
1447
1447
  // when it becomes true, bounded so a page that never settles is still read.
1448
1448
  await settleDom(page, settleMs);
1449
- return await work(page);
1449
+ // Bounded by the page's own budget: a dense page reads in seconds, and an
1450
+ // evaluate on a Chrome wedged after the tab opened never answers at all.
1451
+ return await deadline(work(page), 'read the page', navMs);
1450
1452
  }
1451
1453
  finally {
1452
- await page?.close().catch(() => undefined);
1454
+ if (page)
1455
+ await deadline(page.close(), 'close a tab').catch(() => undefined);
1453
1456
  }
1454
1457
  }
1455
1458
  function limitsFrom(opts) {
@@ -1515,22 +1518,39 @@ export async function capture(url, opts = {}) {
1515
1518
  */
1516
1519
  export async function captureMany(urls, opts = {}) {
1517
1520
  const limits = limitsFrom(opts);
1518
- return withBrowser(async (browser) => {
1519
- const out = [];
1520
- for (const url of urls) {
1521
- try {
1522
- const result = (await readPage(browser, url, opts.width ?? 1440, (page) => page.evaluate(capturePage, limits), opts.navTimeoutMs, opts.settleMs));
1523
- out.push({ url, ok: true, result });
1524
- }
1525
- catch (e) {
1526
- // ponytail: a wedged Chrome (`ChromeStalled`) fails this page AND each later
1527
- // one after its own 15s deadline, rather than hanging the run; relaunch
1528
- // mid-loop if a site import is ever seen doing that.
1529
- out.push({ url, ok: false, why: readFailure(e) });
1530
- }
1521
+ const out = [];
1522
+ let i = 0;
1523
+ // A WEDGED CHROME IS REPLACED ONCE, MID-RUN, and the page it wedged on is read
1524
+ // again on the fresh one. If that one wedges too the machine is the problem,
1525
+ // and every remaining page fails AT ONCE with the reason — not after a
1526
+ // deadline each, which on a twelve-page import was three silent minutes.
1527
+ for (let attempt = 0; i < urls.length; attempt++) {
1528
+ try {
1529
+ await withBrowser(async (browser) => {
1530
+ for (; i < urls.length; i++) {
1531
+ try {
1532
+ const result = (await readPage(browser, urls[i], opts.width ?? 1440, (page) => page.evaluate(capturePage, limits), opts.navTimeoutMs, opts.settleMs));
1533
+ out.push({ url: urls[i], ok: true, result });
1534
+ }
1535
+ catch (e) {
1536
+ if (e instanceof ChromeStalled)
1537
+ throw e;
1538
+ out.push({ url: urls[i], ok: false, why: readFailure(e) });
1539
+ }
1540
+ }
1541
+ });
1531
1542
  }
1532
- return out;
1533
- });
1543
+ catch (e) {
1544
+ // The first browser not starting at all is no run to report on.
1545
+ if (attempt === 0 && !(e instanceof ChromeStalled))
1546
+ throw e;
1547
+ if (attempt === 0)
1548
+ continue;
1549
+ for (; i < urls.length; i++)
1550
+ out.push({ url: urls[i], ok: false, why: readFailure(e) });
1551
+ }
1552
+ }
1553
+ return out;
1534
1554
  }
1535
1555
  /**
1536
1556
  * Every link on a page, absolute.
@@ -1591,6 +1611,7 @@ export async function crawlLinks(entry, opts) {
1591
1611
  const titles = new Map();
1592
1612
  const canonical = new Map();
1593
1613
  let visited = 0;
1614
+ const unread = [];
1594
1615
  await withBrowser(async (browser) => {
1595
1616
  let frontier = [entry];
1596
1617
  // NAVIGATE ONLY WHILE THE LINKS CAN STILL BE USED. `depth` is how far from
@@ -1626,12 +1647,14 @@ export async function crawlLinks(entry, opts) {
1626
1647
  next.push(url2);
1627
1648
  }
1628
1649
  }
1629
- catch {
1630
- // A page that will not open contributes nothing and ends nothing.
1650
+ catch (e) {
1651
+ // A page that will not open ends nothing, but it is SAID: its links
1652
+ // were never followed, so a thin plan has a reason a caller can read.
1653
+ unread.push({ url, why: readFailure(e) });
1631
1654
  }
1632
1655
  }
1633
1656
  frontier = next;
1634
1657
  }
1635
1658
  });
1636
- return { urls: [...found], titles, canonical, visited };
1659
+ return { urls: [...found], titles, canonical, visited, unread };
1637
1660
  }
@@ -1,5 +1,4 @@
1
- import { chromium } from 'playwright-core';
2
- import { release } from './shoot.js';
1
+ import { launchChrome, release } from './shoot.js';
3
2
  /**
4
3
  * ITS OWN BROWSER, not `shoot.ts`'s pooled one.
5
4
  *
@@ -11,8 +10,10 @@ import { release } from './shoot.js';
11
10
  */
12
11
  let shared = null;
13
12
  async function browser() {
13
+ // Through shoot's launcher: no Playwright signal handlers (src/index.ts owns
14
+ // them), a launch deadline, and a pid noted so `release` can kill a stuck close.
14
15
  if (!shared)
15
- shared = await chromium.launch({ channel: 'chrome' });
16
+ shared = await launchChrome();
16
17
  return shared;
17
18
  }
18
19
  /** MUST be called by any script that diffs, or the process never exits. */
@@ -59,9 +59,19 @@ export function setLauncherForTest(fn) {
59
59
  * one test seam) serves both, while each keeps a browser of its own.
60
60
  */
61
61
  export async function launchChrome() {
62
- const b = await deadline(launcher(), 'start');
63
- void pidOf(b);
64
- return b;
62
+ const launching = launcher();
63
+ try {
64
+ const b = await deadline(launching, 'start', stallMs * 2);
65
+ void pidOf(b);
66
+ return b;
67
+ }
68
+ catch (e) {
69
+ // The deadline lost the race, not the launch: a Chrome that answers late is
70
+ // still a process nobody holds. Release it when it arrives (review of v0.100.5).
71
+ if (e instanceof ChromeStalled)
72
+ void launching.then((late) => release(late), () => { });
73
+ throw e;
74
+ }
65
75
  }
66
76
  /**
67
77
  * A CHROME STEP THAT NEVER ANSWERS MEANS A WEDGED CHROME, and nothing else bounds it.
@@ -74,6 +84,12 @@ export async function launchChrome() {
74
84
  * handle, and in the server every later tool call, because calls run one at a
75
85
  * time. Healthy, the same steps took ≤3.7s at a load average of 47; the deadline
76
86
  * is four times that, and missing it costs a relaunch, not a failure.
87
+ *
88
+ * A LAUNCH GETS TWICE THAT (30s). It is the heaviest step under CPU contention
89
+ * (process spawn, profile, CDP handshake) and the review of v0.100.5 saw 15s
90
+ * expire on a launch that was merely slow — and a missed launch deadline spends
91
+ * a SECOND launch on the same overloaded machine, the opposite of relief. A tab
92
+ * or an evaluate is cheap, so it keeps 15s: there a miss really means a wedge.
77
93
  */
78
94
  let stallMs = 15_000;
79
95
  /** Tests only: shorten the stall deadline. Pass nothing to restore it. */
@@ -93,6 +109,19 @@ export function deadline(step, what, ms = stallMs) {
93
109
  }),
94
110
  ]);
95
111
  }
112
+ /**
113
+ * A BEST-EFFORT page step: its own failure is swallowed (a page that refuses a
114
+ * stylesheet is still worth photographing), a STALL is not — a wedged Chrome
115
+ * answers no later step either, and swallowing it here would only move the
116
+ * hang to the next unbounded call.
117
+ */
118
+ function soft(step, what, fallback, ms) {
119
+ return deadline(step, what, ms).catch((e) => {
120
+ if (e instanceof ChromeStalled)
121
+ throw e;
122
+ return fallback;
123
+ });
124
+ }
96
125
  /**
97
126
  * ONE Chrome per process, launched on first use and kept.
98
127
  *
@@ -175,7 +204,9 @@ export async function release(b, graceMs = 3_000) {
175
204
  const closing = b.close().catch(() => { });
176
205
  const stalled = await Promise.race([closing.then(() => false), sleep(graceMs, true, { ref: false })]);
177
206
  // No pid, no kill: Chrome's own watchdog still ends it, just not on our clock.
178
- if (!stalled || !pid)
207
+ // `pid > 1` before `kill(-pid)`: -1 is EVERY process this user may signal.
208
+ // CDP only ever answers a real pid; this guards the day it does not.
209
+ if (!stalled || !pid || pid <= 1)
179
210
  return;
180
211
  for (const target of [-pid, pid]) {
181
212
  try {
@@ -234,6 +265,10 @@ export async function shoot(url, opts = {}) {
234
265
  if (!(e instanceof ChromeStalled))
235
266
  throw e;
236
267
  // The pool would hand every later call this same wedged handle: replace it, once.
268
+ // CAVEAT: this closes the SHARED Chrome, so a second shoot() running at the same
269
+ // moment loses its tabs mid-shot. In the server sb_look is the only caller and
270
+ // runs on the serial queue (src/mcp/serial.ts — it is not in SESSION_FREE), so
271
+ // two shots never overlap; a script calling shoot() in parallel owns that risk.
237
272
  await closeBrowser();
238
273
  return shootWith(await browser(), url, opts);
239
274
  }
@@ -251,7 +286,10 @@ async function shootWith(b, url, opts) {
251
286
  return await shootOne(page, url, width, format, opts);
252
287
  }
253
288
  finally {
254
- await page.close().catch(() => { });
289
+ // Bounded: a wedged Chrome does not answer a close either, and an
290
+ // unbounded one here would hang the stall it is unwinding from. Swallowed
291
+ // whole, so the error that brought us here is the one reported.
292
+ await deadline(page.close(), 'close a tab').catch(() => undefined);
255
293
  }
256
294
  }));
257
295
  }
@@ -279,8 +317,7 @@ async function shootWith(b, url, opts) {
279
317
  * photographed anyway — a late picture beats none.
280
318
  */
281
319
  export async function settleDom(page, capMs = 2_000) {
282
- await page
283
- .evaluate(({ quiet, cap }) => new Promise((resolve) => {
320
+ await soft(page.evaluate(({ quiet, cap }) => new Promise((resolve) => {
284
321
  const start = Date.now();
285
322
  let last = Date.now();
286
323
  const mo = new MutationObserver(() => {
@@ -307,8 +344,10 @@ export async function settleDom(page, capMs = 2_000) {
307
344
  // a page that holds 2,396 — 4.8% — and reported NO error, because
308
345
  // settling is not failing. A silent thin import is worse than a refused
309
346
  // one, and the shoot path keeps the default it was tuned for.
310
- { quiet: 250, cap: capMs })
311
- .catch(() => { });
347
+ { quiet: 250, cap: capMs }), 'settle', undefined,
348
+ // The in-page cap bounds a page that keeps changing; this bounds a Chrome
349
+ // that stopped answering altogether.
350
+ capMs + stallMs);
312
351
  }
313
352
  /**
314
353
  * WALK THE PAGE so its lazy images load, then come back to the top.
@@ -330,13 +369,10 @@ async function settleLazyImages(page) {
330
369
  // A page with nothing lazy has nothing to walk for, and the walk is 60 ms a
331
370
  // screen. Checked rather than assumed: the renderer marks images below the
332
371
  // first screen lazy, so a short page legitimately has none.
333
- const lazy = await page
334
- .evaluate(() => document.querySelectorAll('img[loading="lazy"]').length)
335
- .catch(() => 1);
372
+ const lazy = await soft(page.evaluate(() => document.querySelectorAll('img[loading="lazy"]').length), 'count images', 1);
336
373
  if (!lazy)
337
374
  return;
338
- await page
339
- .evaluate(async () => {
375
+ await soft(page.evaluate(async () => {
340
376
  const step = window.innerHeight || 900;
341
377
  const end = document.body.scrollHeight;
342
378
  // A very long page is walked in bigger strides rather than not at all.
@@ -346,15 +382,12 @@ async function settleLazyImages(page) {
346
382
  await new Promise((r) => setTimeout(() => r(undefined), 60));
347
383
  }
348
384
  window.scrollTo(0, 0);
349
- })
350
- .catch(() => { });
385
+ }), 'walk the page', undefined);
351
386
  // Give what the walk started a chance to arrive. `complete` is false while a
352
387
  // fetch is in flight; a decoded-but-broken image reports complete with a zero
353
388
  // natural width, and that is a REAL defect the shot should show, so it is not
354
389
  // waited on.
355
- await page
356
- .waitForFunction(() => [...document.querySelectorAll('img')].every((i) => i.complete === true), undefined, { timeout: 3_000 })
357
- .catch(() => { });
390
+ await soft(page.waitForFunction(() => [...document.querySelectorAll('img')].every((i) => i.complete === true), undefined, { timeout: 3_000 }), 'load images', undefined);
358
391
  }
359
392
  /**
360
393
  * SETTLE EVERY ENTRANCE ANIMATION, or photograph a band that is not there.
@@ -388,12 +421,13 @@ async function settleLazyImages(page) {
388
421
  * Best-effort: a page that refuses a stylesheet is still worth photographing.
389
422
  */
390
423
  async function settleAnimations(page) {
391
- await page
392
- // TRANSITION TOO: an overlay opened just before measuring slides in under
393
- // its own transition (cart drawer `transform .25s`), and a shot mid-slide
394
- // measures a box that is not where it ends. `none` jumps to the end value.
395
- .addStyleTag({ content: '*,*::before,*::after{animation:none !important;transition:none !important}' })
396
- .catch(() => { });
424
+ // TRANSITION TOO: an overlay opened just before measuring slides in under
425
+ // its own transition (cart drawer `transform .25s`), and a shot mid-slide
426
+ // measures a box that is not where it ends. `none` jumps to the end value.
427
+ // KNOWN GAP: a reveal chained to ANOTHER element's `transitionend` stays at its
428
+ // start — with no transition, `transitioncancel` fires instead. web_builder's
429
+ // own runtime never listens for `transitionend`; hand-written custom-code can.
430
+ await soft(page.addStyleTag({ content: '*,*::before,*::after{animation:none !important;transition:none !important}' }), 'settle animations', undefined);
397
431
  }
398
432
  async function shootOne(page, url, width, format, opts) {
399
433
  // LOAD, then a BOUNDED settle — never `networkidle` alone.
@@ -420,7 +454,7 @@ async function shootOne(page, url, width, format, opts) {
420
454
  // plus `visibility:visible`. The scrim takes it too, so the shot matches what
421
455
  // a shopper sees rather than a panel floating over bare page.
422
456
  if (opts.open) {
423
- await page.evaluate((id) => {
457
+ await deadline(page.evaluate((id) => {
424
458
  // The narrow `document` shim this file declares is for the MEASUREMENT
425
459
  // pass; here the real DOM is what runs, so reach it through the cast
426
460
  // rather than widening a shim that exists to keep that pass honest.
@@ -428,7 +462,7 @@ async function shootOne(page, url, width, format, opts) {
428
462
  d.getElementById(id)?.classList.add('is-open');
429
463
  for (const s of d.querySelectorAll('.wb-cart-scrim'))
430
464
  s.classList.add('is-open');
431
- }, opts.open);
465
+ }, opts.open), 'open the overlay');
432
466
  }
433
467
  await settleDom(page);
434
468
  await settleLazyImages(page);
@@ -445,7 +479,7 @@ async function shootOne(page, url, width, format, opts) {
445
479
  // node. `type` is read off the leading `wb-` class, which is the only type
446
480
  // signal the render emits; the caller already knows the real types from
447
481
  // sb_outline, so this is a convenience, not a contract.
448
- const boxes = (await page.evaluate(() => {
482
+ const boxes = (await deadline(page.evaluate(() => {
449
483
  // No named inner function: a transpiler's `__name` wrapper would not exist
450
484
  // in the page (the vision skill's evaluate trap).
451
485
  const anon = new Map();
@@ -484,7 +518,7 @@ async function shootOne(page, url, width, format, opts) {
484
518
  ...(inFixed ? { inFixed: true } : {}),
485
519
  };
486
520
  });
487
- }));
521
+ }), 'measure the page'));
488
522
  // ZOOM. A designer does not judge a card by looking at the whole page, and
489
523
  // a full-page shot of a long storefront makes one card a few pixels tall.
490
524
  // The clip comes from the SAME measurement pass the boxes do, so what is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.100.5",
3
+ "version": "0.100.6",
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",