@siyahi/tools 0.1.3-next.1 → 0.1.4-next.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/README.md +7 -2
- package/package.json +1 -1
- package/shots.mjs +10 -5
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ counted (`moved=` against `in-view=`) and listed, but do not fail it. Run `npx p
|
|
|
70
70
|
## siyahi-shots
|
|
71
71
|
|
|
72
72
|
```sh
|
|
73
|
-
npx siyahi-shots http://localhost:5173/#/page [more URLs] [--out shots] [--gutter 16] [--font Geist] [--chrome '[data-slot="sidebar"]'] [--wait-for h1]
|
|
73
|
+
npx siyahi-shots http://localhost:5173/#/page [more URLs] [--out shots] [--gutter 16] [--font Geist] [--chrome '[data-slot="sidebar"]'] [--wait-for h1] [--report]
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
Renders each URL in Chromium at 1920 and 390 pixels wide, light and dark, and
|
|
@@ -85,7 +85,12 @@ and the fonts are ready, so content a page renders after loading its data is
|
|
|
85
85
|
in the shot. A mode fails when nothing matches within 15 seconds; pass a
|
|
86
86
|
selector that only the finished page has, such as `--wait-for '[data-ready]'`. It fails when visible text or a
|
|
87
87
|
card comes closer than `--gutter` pixels to either edge, when the page scrolls
|
|
88
|
-
sideways, or when the body font is not a loaded `--font` family.
|
|
88
|
+
sideways, or when the body font is not a loaded `--font` family. Pass
|
|
89
|
+
`--report` for a static HTML report on `report.css`, which loads no font file
|
|
90
|
+
by design: the body must still name `--font` first, but the viewer's installed
|
|
91
|
+
font or the system fallback may draw it, and the run prints
|
|
92
|
+
`font=Geist (report, system fallback allowed)`. Without `--report`, a page that
|
|
93
|
+
names Geist and loads no font fails. Content that
|
|
89
94
|
scrolls sideways inside its own box is exempt from the gutter, and so is
|
|
90
95
|
anything inside `--chrome` (by default the shadcn sidebar, which sits flush to
|
|
91
96
|
the edge by design). The font default, Geist, is Siyahi's; pass another family
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siyahi/tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-next.1",
|
|
4
4
|
"description": "Checks and build helpers for Siyahi pages: a lint plugin, a font preload plugin, a theme contrast check, and screenshot and layout shift scripts.",
|
|
5
5
|
"homepage": "https://siyahi.jatinbansal.com",
|
|
6
6
|
"license": "MIT",
|
package/shots.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// <name>-1.png, <name>-2.png, … of equal height, which together cover it.
|
|
7
7
|
//
|
|
8
8
|
// siyahi-shots <url>... [--out shots] [--gutter 16] [--font Geist]
|
|
9
|
-
// [--chrome '[data-slot="sidebar"]'] [--wait-for h1]
|
|
9
|
+
// [--chrome '[data-slot="sidebar"]'] [--wait-for h1] [--report]
|
|
10
10
|
//
|
|
11
11
|
// Measures only once --wait-for (by default the page's h1) is visible, two
|
|
12
12
|
// animation frames have passed and the fonts are ready: a page that renders
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
//
|
|
16
16
|
// Checks: a gutter of at least --gutter px on both sides of visible text and
|
|
17
17
|
// cards, no sideways document scroll (also with a classic scrollbar taking its
|
|
18
|
-
// width), and --font as the loaded body font.
|
|
18
|
+
// width), and --font as the loaded body font. --report is for static HTML
|
|
19
|
+
// reports, which load no font file by design: the body must still name --font
|
|
20
|
+
// first, but the viewer's installed font or the system fallback may draw it.
|
|
21
|
+
// Exempt from the gutter: content
|
|
19
22
|
// inside a box that scrolls sideways, and anything inside --chrome, which by
|
|
20
23
|
// default is only the shadcn sidebar, flush to the edge by design. The font
|
|
21
24
|
// default is Siyahi's; other pages pass their own family.
|
|
@@ -55,11 +58,12 @@ const { values, positionals } = parseArgs({
|
|
|
55
58
|
font: { type: "string", default: "Geist" },
|
|
56
59
|
chrome: { type: "string", default: '[data-slot="sidebar"]' },
|
|
57
60
|
"wait-for": { type: "string", default: "h1" },
|
|
61
|
+
report: { type: "boolean", default: false },
|
|
58
62
|
},
|
|
59
63
|
});
|
|
60
64
|
if (positionals.length === 0) {
|
|
61
65
|
console.error(
|
|
62
|
-
"usage: siyahi-shots <url>... [--out shots] [--gutter 16] [--font Geist] [--chrome <selector>] [--wait-for <selector>]",
|
|
66
|
+
"usage: siyahi-shots <url>... [--out shots] [--gutter 16] [--font Geist] [--chrome <selector>] [--wait-for <selector>] [--report]",
|
|
63
67
|
);
|
|
64
68
|
process.exit(2);
|
|
65
69
|
}
|
|
@@ -191,7 +195,7 @@ function problemsOf(p, ready) {
|
|
|
191
195
|
if (p.overflowWithScrollbar > 0)
|
|
192
196
|
problems.push(`scrolls sideways by ${p.overflowWithScrollbar}px once a scrollbar takes its width`);
|
|
193
197
|
if (!p.font.startsWith(values.font)) problems.push(`body font is ${p.font}, not ${values.font}`);
|
|
194
|
-
else if (!p.fontLoaded) problems.push(`${p.font} is named but never loaded`);
|
|
198
|
+
else if (!p.fontLoaded && !values.report) problems.push(`${p.font} is named but never loaded`);
|
|
195
199
|
return problems;
|
|
196
200
|
}
|
|
197
201
|
|
|
@@ -202,9 +206,10 @@ for (const url of positionals) {
|
|
|
202
206
|
const { probe, ready, height, files } = await shoot(browser, url, mode);
|
|
203
207
|
const problems = problemsOf(probe, ready);
|
|
204
208
|
failed ||= problems.length > 0;
|
|
209
|
+
const font = values.report && !probe.fontLoaded ? `${probe.font} (report, system fallback allowed)` : probe.font;
|
|
205
210
|
console.log(
|
|
206
211
|
`${problems.length ? "FAIL" : "ok "} ${mode.name.padEnd(10)} gutter=${probe.gutterLeft}/${probe.gutterRight} ` +
|
|
207
|
-
`overflow=${probe.overflow}/${probe.overflowWithScrollbar} font=${
|
|
212
|
+
`overflow=${probe.overflow}/${probe.overflowWithScrollbar} font=${font} h1=${JSON.stringify(probe.h1)} ` +
|
|
208
213
|
`height=${height} ${files.join(" ")}`,
|
|
209
214
|
);
|
|
210
215
|
for (const problem of problems) console.log(` ${problem}`);
|