stitch2 0.21.0 → 0.22.1

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/check.js CHANGED
@@ -47,12 +47,19 @@ const auditOpts = { comfortable: config.comfortableTarget, durations: (() => { t
47
47
  const server = await startServer(0);
48
48
  /** The tallest render, in CSS px: a long landing page is shot whole (the canvas draws frames up to the same height). */
49
49
  const MAX_RENDER_HEIGHT = 20000;
50
- const browser = await chromium.launch();
51
- const page = await browser.newPage({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 });
50
+ let browser = await chromium.launch();
51
+ let page = await browser.newPage({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 });
52
52
  const results = {};
53
53
  const components = {};
54
54
  const stateRows = {};
55
- for (const s of screens) {
55
+ for (const [i, s] of screens.entries()) {
56
+ if (i > 0 && i % 50 === 0) {
57
+ // Chromium gets fragile after hundreds of page loads in one browser; a fresh one keeps long runs alive.
58
+ await page.close().catch(() => { });
59
+ await browser.close().catch(() => { });
60
+ browser = await chromium.launch();
61
+ page = await browser.newPage({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 });
62
+ }
56
63
  await page.setViewportSize({ width: s.width, height: 844 });
57
64
  await page
58
65
  .goto(`http://127.0.0.1:${server.port}/${s.path}`, { waitUntil: 'networkidle', timeout: 30_000 })
@@ -335,7 +335,7 @@ export function reuseIssues(path, page) {
335
335
  if (familyOf(path) !== 'screens')
336
336
  return [];
337
337
  return page.handBuilt.slice(0, 10).map((h) => ({
338
- severity: 'warning',
338
+ severity: 'error',
339
339
  type: 'reuse',
340
340
  message: `${nameOf(h.kind)} built by hand; use <${NAMES[h.kind]?.[1] ?? 'the catalog component'}> (see the component catalog, ${config.catalogDir})`,
341
341
  selector: h.selector,
package/dist/report.js CHANGED
@@ -22,11 +22,18 @@ const esc = (s) => String(s ?? '')
22
22
  .replaceAll('>', '&gt;')
23
23
  .replaceAll('"', '&quot;');
24
24
  const server = await startServer(0);
25
- const browser = await chromium.launch();
26
- const page = await browser.newPage({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 });
25
+ let browser = await chromium.launch();
26
+ let page = await browser.newPage({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 });
27
27
  const known = {};
28
28
  const crops = {}; // kind -> path -> image files
29
- for (const s of screens) {
29
+ for (const [i, s] of screens.entries()) {
30
+ if (i > 0 && i % 50 === 0) {
31
+ // Chromium gets fragile after hundreds of page loads in one browser; a fresh one keeps long runs alive.
32
+ await page.close().catch(() => { });
33
+ await browser.close().catch(() => { });
34
+ browser = await chromium.launch();
35
+ page = await browser.newPage({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2 });
36
+ }
30
37
  await page.setViewportSize({ width: s.width, height: 844 });
31
38
  await page
32
39
  .goto(`http://127.0.0.1:${server.port}/${s.path}`, { waitUntil: 'networkidle', timeout: 30_000 })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitch2",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
4
4
  "description": "A design canvas, layout and type checks, component consistency and screen versioning for agent-built UI, on Google's DESIGN.md format.",
5
5
  "license": "MIT",
6
6
  "author": "ifokeev",
@@ -54,8 +54,9 @@ References, read before the first screen:
54
54
  and translate it with **stitch2-translate**. Never add classes to a component to change how it looks, and never write a colour value (hex,
55
55
  `rgb()`, `hsl()`): only DESIGN.md's colours, as token classes or `var(--<prefix>-<name>)`.
56
56
  5. **Check** `stitch2 check <path> --shots --strict`. Fix every error (overflow, wrapped labels, content under
57
- fixed bars, fixed bars overlapping each other, tap targets, contrast, cramped text) and every warning about type (`type-*`), hand-built
58
- components (`reuse`), components that differ from the catalog (`consistency`) and colour values (`color`).
57
+ fixed bars, fixed bars overlapping each other, tap targets, contrast, cramped text), a hand-built copy of a
58
+ catalog component (`reuse`: use the component or extend it, never rebuild it), and every warning about type
59
+ (`type-*`), components that differ from the catalog (`consistency`) and colour values (`color`).
59
60
  Text running into other text (`text-overlap`) or out of its card (`overflow`) is an error; a short label cut
60
61
  short with an ellipsis (`truncated`) is a warning to fix with room, not a smaller size. Google's rules are
61
62
  warnings too (`text-small`, `edge-margin`, `measure`, `tap-spacing`, `placeholder-label`, `unnamed-control`,
@@ -11,6 +11,8 @@ colour, icons and states. Users learn an element once; every variant costs atten
11
11
 
12
12
  ## The ladder
13
13
 
14
+ Open the catalog first (on the canvas, or its render under `<design>/renders/`): every element of the
15
+ screen is mapped to a component before any markup is written, and the mapping is part of the hand-over.
14
16
  Go down only when the step above cannot work:
15
17
 
16
18
  1. **Use** a component as it is.
@@ -69,9 +71,11 @@ series) is added to DESIGN.md first, with a line in the prose saying where it is
69
71
 
70
72
  ## What the checks report
71
73
 
72
- - **reuse**: on a lab screen, an element that looks like a catalog component but was built by hand (a bottom
73
- bar with three or more buttons, an h1, a primary-filled button, a pill chip, a header icon button, a caps
74
- label).
74
+ - **reuse** (an error: it fails `check --strict` and blocks the hand-over): on a lab screen, an element that
75
+ looks like a catalog component but was built by hand (a bottom bar with three or more buttons, an h1,
76
+ a primary-filled button, a pill chip, a header icon button, a caps label). A screen that duplicates a
77
+ component instead of using it is not handed over: use the component, or extend it (step 4 of the ladder)
78
+ when it cannot do what the screen needs.
75
79
  - **consistency**: a component whose size, radius, font, icon set or icons differ from the catalog's version
76
80
  (or, without a catalog, from the majority of screens in its family), or that appears in two versions on one
77
81
  screen. `stitch2 consistency` shows the same as cropped images; see the stitch2-consistency skill.