@domandigital/craft 0.19.2 → 0.20.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/CHANGELOG.md +12 -0
- package/README.md +51 -0
- package/STANDARD.md +86 -3
- package/dist/{chunk-EKGHL4D2.js → chunk-3CD3DTEI.js} +2 -2
- package/dist/{chunk-EDM4L5WJ.js → chunk-H4UF2I7V.js} +1 -1
- package/dist/chunk-IJUZ7RV4.js +151 -0
- package/dist/{chunk-D2PEKYKH.js → chunk-LZVTN2KI.js} +22 -9
- package/dist/{chunk-ZKZCPVQ6.js → chunk-RFU5CIST.js} +2 -2
- package/dist/{cli-T3IA7IQK.js → cli-3IAIKGCP.js} +3 -3
- package/dist/{cli-OS5ESEJV.js → cli-5DONIRMR.js} +4 -4
- package/dist/{cli-VLNOQYEL.js → cli-73JCUXAV.js} +2 -2
- package/dist/{cli-GUEBFFF3.js → cli-EDQNTWDD.js} +2 -2
- package/dist/{cli-KTN5OXHZ.js → cli-EOXIJOJN.js} +3 -3
- package/dist/cli-YHS2VPWQ.js +122 -0
- package/dist/{cli-BZSJIUQH.js → cli-YUVATZD5.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/phone.cjs +548 -21
- package/dist/phone.d.cts +265 -28
- package/dist/phone.d.ts +265 -28
- package/dist/phone.js +534 -21
- package/dist/viewports-cli-RYV4LDQK.js +683 -0
- package/package.json +1 -1
- package/dist/cli-RAH4CKYY.js +0 -249
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @domandigital/craft
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 63dfae5: Every viewport, and a phone optimised beyond fit (DOM-787, part of DOM-772). `@domandigital/craft/phone` gains `measureViewports(page, options)`, `measureSite(browser, options)` and a `craft viewports` command beside `craft phone-first`. They take a page through the ladder (320, 375, 390, 430, landscape 844 x 390, 768, 1024, 1280, 1440, 1920, phone first in order and in every report) and a width sweep from 320 to 1920 in 16 to 32px steps, resizing the one loaded page in place. At any width: sideways scroll, visible text over other visible text and a cut-off page title, with the exact widths that fail. On a short phone (375 x 667): the main action (`mainAction`, a selector, global or per route) on the first screen or pinned; fixed and sticky layers over a quarter of the screen; images more than 2.5 times their displayed width or narrower than it; phone, email and number fields with the wrong `type` or `inputmode`; personal-data fields with no `autocomplete`; UK phone numbers in the text that are not `tel:` links. On a landscape phone: header and fixed layers over half the height. At 1440 and 1920: body lines over 80 characters and stretched images. Every threshold has a house default (`DEFAULT_THRESHOLDS`) and can be overridden. The new checks are baselined like the 375px ones: they use the same `phone-first.baseline.json` and `craft phone-first --measured`, and `measurePhone` and the existing baseline format work as before. STANDARD.md section 10 gains "Optimised for the phone" and "Every viewport is intended".
|
|
8
|
+
|
|
9
|
+
## 0.19.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 95af0f3: `craft phone-first` folds digits only in an element's text, so `<h1>` stays `<h1>` in a baseline, and says how many of a breach it found ("3 of them", "2 found, the baseline allows 1") (DOM-775).
|
|
14
|
+
|
|
3
15
|
## 0.19.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -266,6 +266,57 @@ baseline that claims more than is there, so it only shrinks: fix a breach and
|
|
|
266
266
|
lower its count in the same PR. `--update-baseline` writes the baseline that
|
|
267
267
|
makes the current run pass; run it once when the gate goes in.
|
|
268
268
|
|
|
269
|
+
## Every viewport
|
|
270
|
+
|
|
271
|
+
Fitting at 375 is the floor (STANDARD.md section 10, DOM-787). The
|
|
272
|
+
every-viewport measure takes a page through the ladder (320, 375, 390, 430,
|
|
273
|
+
landscape 844 x 390, 768, 1024, 1280, 1440, 1920, phone first in order and in
|
|
274
|
+
every report) and a width sweep from 320 to 1920 in 16 to 32px steps, resizing
|
|
275
|
+
the one loaded page in place:
|
|
276
|
+
|
|
277
|
+
- **At any width:** sideways scroll, visible text over other visible text, a
|
|
278
|
+
cut-off page title (`h1`), and text under 12px. A failure names the exact
|
|
279
|
+
widths: `(at 320-352, 400)`.
|
|
280
|
+
- **On a short phone (375 x 667):** the main action (`mainAction`, a selector,
|
|
281
|
+
global or per route) is on the first screen or pinned; fixed and sticky
|
|
282
|
+
layers together cover at most 25% of the screen; an image is not more than
|
|
283
|
+
2.5 times wider than shown (`oversized`) nor narrower than shown
|
|
284
|
+
(`upscaled`); a field that looks like a phone, email or number uses
|
|
285
|
+
`type="tel"`, `type="email"` or an `inputmode`; a name, email, phone or
|
|
286
|
+
address field carries `autocomplete`; a UK phone number in the text is a
|
|
287
|
+
`tel:` link.
|
|
288
|
+
- **On a landscape phone (844 x 390):** header and fixed layers leave at least
|
|
289
|
+
half the height.
|
|
290
|
+
- **At 1440 and 1920:** body lines are at most 80 characters (width over the
|
|
291
|
+
`ch` of the element's own font) and no image is stretched past its file.
|
|
292
|
+
|
|
293
|
+
Each threshold has a house default (`DEFAULT_THRESHOLDS`) and can be
|
|
294
|
+
overridden per site or portal.
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
import { PHONE, measureViewports } from "@domandigital/craft/phone";
|
|
298
|
+
|
|
299
|
+
test.use(PHONE);
|
|
300
|
+
test(`every viewport: ${route}`, async ({ page }) => {
|
|
301
|
+
await page.goto(route);
|
|
302
|
+
// Resizes this page in place; writes phone-first/measured/<route>.json.
|
|
303
|
+
await measureViewports(page, { route, mainAction: ".hero a" });
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
`measureViewports` works on the page the suite opened and signed in, so a
|
|
308
|
+
portal keeps its fixtures. `measureSite(browser, { base, routes })` opens each
|
|
309
|
+
route itself, the phone half in a phone context and the wide half in a desktop
|
|
310
|
+
one, for a page anyone can open: create-site's `measure.mjs` uses it.
|
|
311
|
+
`craft viewports --url <base> --route /` is the same for the command line: it
|
|
312
|
+
measures, writes the measured routes, and judges them against the same
|
|
313
|
+
`phone-first.baseline.json`. The new checks are baselined like the 375px ones:
|
|
314
|
+
existing failures are listed (one line per element and check, with the widths
|
|
315
|
+
left out so a failure at one more width is not a new failure), a new failure
|
|
316
|
+
fails, and a baseline that claims more than is there fails too.
|
|
317
|
+
`craft phone-first --measured` judges the same files, and keeps working on
|
|
318
|
+
routes measured only at 375 with `measurePhone`.
|
|
319
|
+
|
|
269
320
|
## API
|
|
270
321
|
|
|
271
322
|
| Area | Exports |
|
package/STANDARD.md
CHANGED
|
@@ -161,6 +161,8 @@ Mobile first is a rule about **order and floor**, not about a layout. The phone
|
|
|
161
161
|
is designed, built and measured first, and every wider layout is derived from
|
|
162
162
|
it. A desktop layout squeezed onto a phone keeps the desktop's priorities and
|
|
163
163
|
drops whatever did not fit; a phone layout widened keeps what matters and adds.
|
|
164
|
+
Fitting on a phone is the floor. The bar is a page optimised for the phone and
|
|
165
|
+
intended at every width, and the two sub-sections below set it.
|
|
164
166
|
|
|
165
167
|
- **The phone is the base.** Base styles are the phone layout. Wider layouts
|
|
166
168
|
are added with `min-width` queries only (Tailwind: unprefixed is the phone,
|
|
@@ -169,7 +171,7 @@ drops whatever did not fit; a phone layout widened keeps what matters and adds.
|
|
|
169
171
|
- **375px is the floor.** Every surface is designed and measured at **375 CSS
|
|
170
172
|
px** first, the narrowest iPhone width in common use (SE, mini, X to 11 Pro).
|
|
171
173
|
Nothing scrolls sideways at 375. 390 is still measured: it is the width the
|
|
172
|
-
design is accepted at.
|
|
174
|
+
design is accepted at. 320 still works (see "Every viewport is intended").
|
|
173
175
|
- **Touch targets at least 44 × 44 CSS px.** A link inside a sentence is exempt,
|
|
174
176
|
as in WCAG's own inline exception. 24px (SC 2.5.8, AA) is what an audit asks
|
|
175
177
|
for; 44 is the house bar.
|
|
@@ -182,6 +184,86 @@ drops whatever did not fit; a phone layout widened keeps what matters and adds.
|
|
|
182
184
|
|
|
183
185
|
*Source: WCAG 2.2 SC 2.5.5 (Target Size, Enhanced), SC 2.5.8 and SC 1.4.4; Apple Human Interface Guidelines, "Accessibility" (44 × 44 pt hit targets); WebKit's focus zoom on fields under 16px; Lighthouse's default mobile emulation; Google Search Central, "Mobile-first indexing"; Luke Wroblewski, "Mobile First" (2011).*
|
|
184
186
|
|
|
187
|
+
### Optimised for the phone
|
|
188
|
+
|
|
189
|
+
A visitor on a phone has a small screen, one thumb, a slow connection and a
|
|
190
|
+
task. The page is built for that and measured on a **short phone, 375 × 667**
|
|
191
|
+
(an iPhone SE), the least height a visitor has.
|
|
192
|
+
|
|
193
|
+
- **The first screen says what this is and offers the main action.** At
|
|
194
|
+
375 × 667, with no scroll, the visitor can read what the page is and who it
|
|
195
|
+
is for, and can reach the main action: call, book, buy or enquire. On a long
|
|
196
|
+
page the main action stays in thumb reach, pinned to the bottom edge or
|
|
197
|
+
repeated, because the lower half is the half a thumb reaches.
|
|
198
|
+
- **Thumb reach.** Most people tap with one thumb. Frequent actions sit in the
|
|
199
|
+
lower two thirds of the screen; a control that only the top corner holds is
|
|
200
|
+
for rare use.
|
|
201
|
+
- **Use what a phone can do.** A telephone number is a `tel:` link, a text
|
|
202
|
+
message address an `sms:` link and a street address a map link, so one tap
|
|
203
|
+
calls, messages or navigates. Each field asks for the keyboard that fits:
|
|
204
|
+
`type="tel"`, `type="email"`, `inputmode="numeric"` or `"decimal"`. A field
|
|
205
|
+
that asks for personal data carries `autocomplete` (`name`, `email`, `tel`,
|
|
206
|
+
`street-address`, `postal-code`), so the phone fills it. Nothing needs hover:
|
|
207
|
+
what hover reveals is also there on tap and on focus. Anything pinned to an
|
|
208
|
+
edge keeps clear of the safe area (`env(safe-area-inset-*)`, with
|
|
209
|
+
`viewport-fit=cover`), so the notch, the home indicator and rounded corners
|
|
210
|
+
never cover it.
|
|
211
|
+
- **Overlays take at most a quarter of a short screen.** The header, a cookie
|
|
212
|
+
bar, a chat button and every other fixed or sticky layer together cover at
|
|
213
|
+
most 25% of 375 × 667. A dialog the visitor opens is theirs and is not
|
|
214
|
+
counted; a layer that is there on arrival is.
|
|
215
|
+
- **Images are sized for the phone.** `srcset` and `sizes` give a 2x screen a
|
|
216
|
+
file about twice its displayed width. A file more than about 2.5 times its
|
|
217
|
+
displayed width is oversized: the phone downloads pixels it throws away. A
|
|
218
|
+
file narrower than its displayed width is upscaled and soft.
|
|
219
|
+
- **It is fast on a throttled phone.** On the mobile Lighthouse profile
|
|
220
|
+
(simulated slow 4G, 4x CPU slowdown): Largest Contentful Paint 2.5 s or
|
|
221
|
+
less, Interaction to Next Paint 200 ms or less, Cumulative Layout Shift 0.1
|
|
222
|
+
or less.
|
|
223
|
+
- **Landscape is usable.** A phone is held either way up. At 844 × 390 nothing
|
|
224
|
+
needed is hidden behind a fixed layer, the header and fixed layers leave at
|
|
225
|
+
least half the height, and no content is cut off.
|
|
226
|
+
|
|
227
|
+
*Source: Steven Hoober, "How Do Users Really Hold Mobile Devices?" (UXmatters, 2013) and "Design for Fingers, Touch, and People" (UXmatters, 2017); Josh Clark, "Designing for Touch" (A Book Apart, 2015); RFC 3966 (`tel:`), RFC 5724 (`sms:`) and RFC 5870 (`geo:`); WHATWG HTML Standard, `inputmode` and the autofill field names; WCAG 2.2 SC 1.3.5 (Identify Input Purpose) and SC 1.3.4 (Orientation); W3C Media Queries Level 4, the `hover` and `pointer` features; CSS Environment Variables Module Level 1 (`env(safe-area-inset-*)`) and WebKit, "Designing Websites for iPhone X" (2017); Google Search Central, "Helping users easily access content on mobile" (intrusive interstitials); web.dev, "Web Vitals" (the good thresholds for LCP, INP and CLS) and "Serve responsive images".*
|
|
228
|
+
|
|
229
|
+
### Every viewport is intended
|
|
230
|
+
|
|
231
|
+
A page is seen at every width from a 320px phone to a 1920px screen, and each
|
|
232
|
+
width gets a layout someone meant. Five bands each look designed:
|
|
233
|
+
|
|
234
|
+
| Band | Width in CSS px |
|
|
235
|
+
| --- | --- |
|
|
236
|
+
| Phone | 320 to 479 |
|
|
237
|
+
| Large phone | 480 to 767 |
|
|
238
|
+
| Tablet | 768 to 1023 |
|
|
239
|
+
| Laptop | 1024 to 1439 |
|
|
240
|
+
| Wide | 1440 and up |
|
|
241
|
+
|
|
242
|
+
- **A tablet is a layout of its own.** At 768 to 1023 the page is neither the
|
|
243
|
+
phone stretched across the width nor the laptop squeezed to fit. The tablet
|
|
244
|
+
band is designed and captured like the others.
|
|
245
|
+
- **320 works.** Content reflows at 320 CSS px with no sideways scroll and no
|
|
246
|
+
loss of information or function (WCAG SC 1.4.10, the same as 400% zoom on a
|
|
247
|
+
1280px screen).
|
|
248
|
+
- **Lines are 45 to 80 characters.** Body text keeps a readable measure at
|
|
249
|
+
every width. On a wide screen it is capped (`max-width` in `ch`), and the
|
|
250
|
+
layout holds to a sensible width instead of stretching with the window.
|
|
251
|
+
Images are never shown larger than their file.
|
|
252
|
+
- **The sweep catches what the breakpoints miss.** The ladder (320, 375, 390,
|
|
253
|
+
430, 844 × 390 landscape, 768, 1024, 1280, 1440, 1920) is captured, and one
|
|
254
|
+
page load is resized from 320 to 1920 in steps of 16 to 32px. At any width
|
|
255
|
+
nothing scrolls sideways, no visible text sits on other visible text and no
|
|
256
|
+
page title is cut off. The report names the exact widths that fail, phone
|
|
257
|
+
first.
|
|
258
|
+
|
|
259
|
+
The measure is `@domandigital/craft/phone` (`measureViewports`,
|
|
260
|
+
`measureSite`, `craft viewports`): one measure that create-site's
|
|
261
|
+
`measure.mjs` and every portal gate use. Each check can be baselined: a
|
|
262
|
+
repo's existing failures are listed in the open, a new failure fails, and the
|
|
263
|
+
baseline only shrinks.
|
|
264
|
+
|
|
265
|
+
*Source: WCAG 2.2 SC 1.4.10 (Reflow) and SC 1.4.8 (Visual Presentation: no more than 80 characters a line); Robert Bringhurst, "The Elements of Typographic Style", chapter 2, "Rhythm and Proportion" (45 to 75 characters a line); Ethan Marcotte, "Responsive Web Design" (A List Apart, 2010); web.dev, "Responsive web design basics".*
|
|
266
|
+
|
|
185
267
|
## 11. What is deliberately not a rule
|
|
186
268
|
|
|
187
269
|
The package emits **plain CSS custom properties** precisely so these stay free:
|
|
@@ -193,8 +275,9 @@ The package emits **plain CSS custom properties** precisely so these stay free:
|
|
|
193
275
|
- **Where tokens live.** A `:root` block, a generated file, a Tailwind theme:
|
|
194
276
|
the package does not care.
|
|
195
277
|
- **Layout, grid and component structure.** Not a rule, at any width. Section
|
|
196
|
-
10 fixes the order the widths are designed in
|
|
197
|
-
|
|
278
|
+
10 fixes the order the widths are designed in, the floor they are measured
|
|
279
|
+
at and the five bands each is designed for; what each layout looks like
|
|
280
|
+
stays free. Layout *defaults*
|
|
198
281
|
(hero straight into a trust strip, three icon cards, a reveal on every
|
|
199
282
|
section) are measured as character in [CHARACTER.md](./CHARACTER.md), as
|
|
200
283
|
warnings with a declared-exception path, never as rules here.
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
describeTypicality,
|
|
7
7
|
loadNull
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-H4UF2I7V.js";
|
|
9
9
|
import {
|
|
10
10
|
SOURCE_FILE,
|
|
11
11
|
finish,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
parseFlags,
|
|
15
15
|
prepareReport,
|
|
16
16
|
readPaths
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LZVTN2KI.js";
|
|
18
18
|
import {
|
|
19
19
|
toJson
|
|
20
20
|
} from "./chunk-QIEDBL4J.js";
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// src/phone/judge.ts
|
|
2
|
+
var EMPTY_BASELINE = { static: [], measured: [] };
|
|
3
|
+
var MEDIA = /@(?:custom-)?media\b([^{;]*)/g;
|
|
4
|
+
var CAPS_WIDTH = /\bmax-(?:device-)?width\s*:|\bwidth\s*<|>=?\s*(?:device-)?width\b/i;
|
|
5
|
+
var VARIANT = /(?<![\w@-])max-(\[[^\]\s]+\]|[a-z0-9]+):/g;
|
|
6
|
+
var NOT_VARIANTS = /* @__PURE__ */ new Set(["width", "height", "lines", "resolution", "zoom", "inline-size", "block-size"]);
|
|
7
|
+
var OK = /mobile-first-ok\b:?(.*)/;
|
|
8
|
+
function reasonOf(line) {
|
|
9
|
+
const m = line?.match(OK);
|
|
10
|
+
return m ? m[1].replace(/\*\/|-->|[{}]/g, "").trim() : null;
|
|
11
|
+
}
|
|
12
|
+
function scanPhoneFirst(files, exceptions = []) {
|
|
13
|
+
const excusedFiles = new Set(exceptions.filter((e) => e.reason?.trim()).map((e) => e.file));
|
|
14
|
+
const findings = [];
|
|
15
|
+
let excused = 0;
|
|
16
|
+
for (const { path, text } of files) {
|
|
17
|
+
if (excusedFiles.has(path)) continue;
|
|
18
|
+
const lines = text.split("\n");
|
|
19
|
+
const lineOf = (index) => text.slice(0, index).split("\n").length;
|
|
20
|
+
const found = [];
|
|
21
|
+
for (const m of text.matchAll(MEDIA)) {
|
|
22
|
+
if (CAPS_WIDTH.test(m[1])) found.push({ line: lineOf(m.index), what: `${m[0].slice(0, m[0].length - m[1].length)}${m[1].replace(/\s+/g, " ").trimEnd()}` });
|
|
23
|
+
}
|
|
24
|
+
for (const m of text.matchAll(VARIANT)) {
|
|
25
|
+
if (!NOT_VARIANTS.has(m[1])) found.push({ line: lineOf(m.index), what: m[0] });
|
|
26
|
+
}
|
|
27
|
+
for (const { line, what } of found.sort((a, b) => a.line - b.line)) {
|
|
28
|
+
const here = reasonOf(lines[line - 1]);
|
|
29
|
+
const above = reasonOf(lines[line - 2]);
|
|
30
|
+
if (here || above) {
|
|
31
|
+
excused++;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
findings.push({ file: path, line, what: here === "" || above === "" ? `${what} (mobile-first-ok with no reason)` : what });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { findings, excused };
|
|
38
|
+
}
|
|
39
|
+
function checkExceptions(exceptions, exists) {
|
|
40
|
+
const problems = [];
|
|
41
|
+
exceptions.forEach((e, i) => {
|
|
42
|
+
const at = `exceptions[${i}]`;
|
|
43
|
+
const x = e;
|
|
44
|
+
if (typeof x?.file !== "string" || !x.file.trim()) problems.push(`${at}: names no file`);
|
|
45
|
+
else if (typeof x.reason !== "string" || !x.reason.trim()) problems.push(`${at} (${x.file}): no reason. Say why this file needs a max-width query, or remove the exception.`);
|
|
46
|
+
else if (!exists(x.file)) problems.push(`${at}: ${x.file} is not there. Remove the exception.`);
|
|
47
|
+
});
|
|
48
|
+
return problems;
|
|
49
|
+
}
|
|
50
|
+
var normaliseElement = (element) => element.replace(/("[^]*)$/, (text) => text.replace(/\d+/g, "#"));
|
|
51
|
+
var tally = (items, key) => {
|
|
52
|
+
const m = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
const k = key(item);
|
|
55
|
+
const had = m.get(k);
|
|
56
|
+
if (had) had.count++;
|
|
57
|
+
else m.set(k, { item, count: 1 });
|
|
58
|
+
}
|
|
59
|
+
return m;
|
|
60
|
+
};
|
|
61
|
+
function judgeStatic(findings, baseline) {
|
|
62
|
+
const byFile = tally(findings, (f) => f.file);
|
|
63
|
+
const allowed = new Map(baseline.static.map((b) => [b.file, b.count]));
|
|
64
|
+
const fresh = [];
|
|
65
|
+
const stale = [];
|
|
66
|
+
let known = 0;
|
|
67
|
+
for (const [file, { count }] of byFile) {
|
|
68
|
+
const allow = allowed.get(file) ?? 0;
|
|
69
|
+
known += Math.min(count, allow);
|
|
70
|
+
if (count > allow) {
|
|
71
|
+
const here = findings.filter((f) => f.file === file);
|
|
72
|
+
const lead = allow ? `${file}: ${count} desktop-first rules, the baseline allows ${allow}. One of these is new:` : `${file}:`;
|
|
73
|
+
fresh.push(`${lead}
|
|
74
|
+
${here.map((f) => ` line ${f.line}: ${f.what}`).join("\n")}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (const { file, count } of baseline.static) {
|
|
78
|
+
const now = byFile.get(file)?.count ?? 0;
|
|
79
|
+
if (now < count) stale.push(`${file}: the baseline allows ${count}, there ${now === 1 ? "is" : "are"} ${now} now. Lower it to ${now}${now ? "" : " (remove the line)"}.`);
|
|
80
|
+
}
|
|
81
|
+
return { fresh, stale, known };
|
|
82
|
+
}
|
|
83
|
+
var measuredKey = (route, check, element) => `${route}\0${check}\0${element}`;
|
|
84
|
+
function judgeMeasured(routes, baseline) {
|
|
85
|
+
const fresh = [];
|
|
86
|
+
const stale = [];
|
|
87
|
+
let known = 0;
|
|
88
|
+
const allowed = new Map(baseline.measured.map((b) => [measuredKey(b.route, b.check, b.element), b.count]));
|
|
89
|
+
const seen = /* @__PURE__ */ new Map();
|
|
90
|
+
const measured = new Set(routes.map((r) => r.route));
|
|
91
|
+
for (const { route, findings } of routes) {
|
|
92
|
+
const counted = tally(findings, (f) => measuredKey(route, f.check, normaliseElement(f.element)));
|
|
93
|
+
for (const [key, { item, count }] of counted) {
|
|
94
|
+
seen.set(key, count);
|
|
95
|
+
const allow = allowed.get(key) ?? 0;
|
|
96
|
+
known += Math.min(count, allow);
|
|
97
|
+
if (count > allow) {
|
|
98
|
+
const times = allow ? ` (${count} found, the baseline allows ${allow})` : count > 1 ? ` (${count} of them)` : "";
|
|
99
|
+
fresh.push(`${route}: ${LABEL[item.check]} ${item.element}: ${item.detail}${times}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const missing = /* @__PURE__ */ new Set();
|
|
104
|
+
for (const b of baseline.measured) {
|
|
105
|
+
const key = measuredKey(b.route, b.check, b.element);
|
|
106
|
+
if (!measured.has(b.route)) {
|
|
107
|
+
if (!missing.has(b.route)) stale.push(`${b.route}: in the baseline but not measured this run. Measure it, or remove its lines.`);
|
|
108
|
+
missing.add(b.route);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const now = seen.get(key) ?? 0;
|
|
112
|
+
if (now < b.count) stale.push(`${b.route}: ${LABEL[b.check]} ${b.element}: the baseline allows ${b.count}, ${now} found. Lower it to ${now}${now ? "" : " (remove the line)"}.`);
|
|
113
|
+
}
|
|
114
|
+
return { fresh, stale, known };
|
|
115
|
+
}
|
|
116
|
+
var LABEL = {
|
|
117
|
+
scroll: "scrolls sideways",
|
|
118
|
+
target: "small target",
|
|
119
|
+
field: "small field",
|
|
120
|
+
text: "small text",
|
|
121
|
+
title: "title cut off",
|
|
122
|
+
overlap: "text overlaps text",
|
|
123
|
+
action: "main action out of reach",
|
|
124
|
+
layers: "fixed layers cover too much",
|
|
125
|
+
landscape: "landscape screen eaten by fixed layers",
|
|
126
|
+
image: "image not sized for its place",
|
|
127
|
+
input: "wrong keyboard",
|
|
128
|
+
autocomplete: "field the phone cannot fill in",
|
|
129
|
+
tel: "phone number is not a link",
|
|
130
|
+
linelength: "line too long"
|
|
131
|
+
};
|
|
132
|
+
function writeBaseline(findings, routes, note) {
|
|
133
|
+
const byFile = tally(findings, (f) => f.file);
|
|
134
|
+
const measured = routes.flatMap(
|
|
135
|
+
({ route, findings: findings2 }) => [...tally(findings2, (f) => measuredKey(route, f.check, normaliseElement(f.element))).values()].map(({ item, count }) => ({ route, check: item.check, element: normaliseElement(item.element), count }))
|
|
136
|
+
);
|
|
137
|
+
return {
|
|
138
|
+
...note ? { note } : {},
|
|
139
|
+
static: [...byFile.values()].map(({ item, count }) => ({ file: item.file, count, found: findings.filter((f) => f.file === item.file).map((f) => f.what) })).sort((a, b) => a.file.localeCompare(b.file)),
|
|
140
|
+
measured: measured.sort((a, b) => a.route.localeCompare(b.route) || a.check.localeCompare(b.check) || a.element.localeCompare(b.element))
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
EMPTY_BASELINE,
|
|
146
|
+
scanPhoneFirst,
|
|
147
|
+
checkExceptions,
|
|
148
|
+
judgeStatic,
|
|
149
|
+
judgeMeasured,
|
|
150
|
+
writeBaseline
|
|
151
|
+
};
|
|
@@ -392,6 +392,7 @@ Usage
|
|
|
392
392
|
craft register brief <plain|persuasive|warm|literary> [--json]
|
|
393
393
|
craft register check <file> --as <register> [--json]
|
|
394
394
|
craft phone-first [--config phone-first.json] [--measured <dir>] [--update-baseline] [--json]
|
|
395
|
+
craft viewports [--url <base>] [--route <path>]... [--config viewports.json] [--out <dir>] [--captures <dir>] [--baseline <file>] [--update-baseline] [--no-sweep] [--json]
|
|
395
396
|
|
|
396
397
|
scan Markup, component code and stylesheets (source and compiled CSS).
|
|
397
398
|
--staged reads the git index, for a pre-commit hook.
|
|
@@ -454,6 +455,15 @@ phone-first The phone-first gate for a portal or app (STANDARD.md section
|
|
|
454
455
|
cut-off title), unless phone-first.baseline.json already lists it.
|
|
455
456
|
A baseline that claims more than is there fails too: it only
|
|
456
457
|
shrinks. Exit 1 on a breach, 2 on bad usage.
|
|
458
|
+
viewports Every viewport, for a running site (STANDARD.md section 10). Opens
|
|
459
|
+
each route at the ladder (320, 375, 390, 430, 844 x 390 landscape,
|
|
460
|
+
768, 1024, 1280, 1440, 1920) and sweeps 320 to 1920: sideways
|
|
461
|
+
scroll, text over text and a cut-off title at any width; on a
|
|
462
|
+
375 x 667 phone the main action, fixed layers, image sizes, field
|
|
463
|
+
keyboards, autocomplete and tap-to-call; landscape; line length and
|
|
464
|
+
stretched images at 1440 and 1920. Writes the measured routes for
|
|
465
|
+
craft phone-first --measured and judges them against the same
|
|
466
|
+
baseline. Needs playwright. Exit 1 on a breach, 2 on bad usage.
|
|
457
467
|
|
|
458
468
|
ci options (scan, copy, audit)
|
|
459
469
|
--baseline <file> Report only findings the baseline does not already
|
|
@@ -621,7 +631,7 @@ async function briefFor(flags, cwd) {
|
|
|
621
631
|
if (typeof brief === "string" && brief.trim()) return brief;
|
|
622
632
|
} else if (flags.direction) throw new Error(`no such file: ${flags.direction}`);
|
|
623
633
|
if (flags.null) {
|
|
624
|
-
const { loadNull } = await import("./cli-
|
|
634
|
+
const { loadNull } = await import("./cli-EDQNTWDD.js");
|
|
625
635
|
return loadNull(flags.null, cwd).brief;
|
|
626
636
|
}
|
|
627
637
|
return void 0;
|
|
@@ -647,34 +657,37 @@ async function compareWithCompetitor(flags, io) {
|
|
|
647
657
|
function run(argv, io) {
|
|
648
658
|
const [command, ...rest] = argv;
|
|
649
659
|
if (command === "direction") {
|
|
650
|
-
return import("./cli-
|
|
660
|
+
return import("./cli-YUVATZD5.js").then((m) => m.runDirection(rest, io));
|
|
651
661
|
}
|
|
652
662
|
if (command === "report" || command === "retrofit") {
|
|
653
|
-
return import("./cli-
|
|
663
|
+
return import("./cli-5DONIRMR.js").then((m) => m.runReport(command, rest, io));
|
|
654
664
|
}
|
|
655
665
|
if (command === "register") {
|
|
656
666
|
return import("./cli-VPARW6FY.js").then((m) => m.runRegister(rest, io));
|
|
657
667
|
}
|
|
658
668
|
if (command === "estate") {
|
|
659
|
-
return import("./cli-
|
|
669
|
+
return import("./cli-3IAIKGCP.js").then((m) => m.runEstate(rest, io));
|
|
660
670
|
}
|
|
661
671
|
if (command === "null") {
|
|
662
|
-
return import("./cli-
|
|
672
|
+
return import("./cli-EDQNTWDD.js").then((m) => m.runNull(rest, io));
|
|
663
673
|
}
|
|
664
674
|
if (command === "calibrate") {
|
|
665
|
-
return import("./cli-
|
|
675
|
+
return import("./cli-73JCUXAV.js").then((m) => m.runCalibrate(rest, io));
|
|
666
676
|
}
|
|
667
677
|
if (command === "tells" && rest[0] === "harvest") {
|
|
668
|
-
return import("./cli-
|
|
678
|
+
return import("./cli-EDQNTWDD.js").then((m) => m.runHarvest(rest, io)).catch((error) => {
|
|
669
679
|
io.err(`craft: ${error.message}`);
|
|
670
680
|
return 2;
|
|
671
681
|
});
|
|
672
682
|
}
|
|
673
683
|
if (command === "phone-first") {
|
|
674
|
-
return import("./cli-
|
|
684
|
+
return import("./cli-YHS2VPWQ.js").then((m) => m.runPhoneFirst(rest, io));
|
|
685
|
+
}
|
|
686
|
+
if (command === "viewports") {
|
|
687
|
+
return import("./viewports-cli-RYV4LDQK.js").then((m) => m.runViewports(rest, io));
|
|
675
688
|
}
|
|
676
689
|
if (command === "snapshot" || command === "audit") {
|
|
677
|
-
return import("./cli-
|
|
690
|
+
return import("./cli-EOXIJOJN.js").then((m) => m.runAudit(command, rest, io));
|
|
678
691
|
}
|
|
679
692
|
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
680
693
|
io.out(HELP);
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
} from "./chunk-4LJFZH2I.js";
|
|
8
8
|
import {
|
|
9
9
|
loadNull
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-H4UF2I7V.js";
|
|
11
11
|
import {
|
|
12
12
|
parseFlags
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-LZVTN2KI.js";
|
|
14
14
|
import {
|
|
15
15
|
toJson
|
|
16
16
|
} from "./chunk-QIEDBL4J.js";
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
formatPairs,
|
|
5
5
|
loadEstate,
|
|
6
6
|
runEstate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RFU5CIST.js";
|
|
8
8
|
import "./chunk-4LJFZH2I.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-H4UF2I7V.js";
|
|
10
10
|
import "./chunk-OQXTQQAU.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-LZVTN2KI.js";
|
|
12
12
|
import "./chunk-QIEDBL4J.js";
|
|
13
13
|
import "./chunk-WUACK2HX.js";
|
|
14
14
|
import "./chunk-WK2WMWTH.js";
|
|
@@ -3,21 +3,21 @@ import {
|
|
|
3
3
|
} from "./chunk-OKVHWXYV.js";
|
|
4
4
|
import {
|
|
5
5
|
merge
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3CD3DTEI.js";
|
|
7
7
|
import "./chunk-VDUIIWG7.js";
|
|
8
8
|
import "./chunk-JYNXGCYZ.js";
|
|
9
9
|
import {
|
|
10
10
|
SIBLING_AT,
|
|
11
11
|
compareToEstate,
|
|
12
12
|
loadEstate
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RFU5CIST.js";
|
|
14
14
|
import {
|
|
15
15
|
PAGE_TYPES,
|
|
16
16
|
validateDirection
|
|
17
17
|
} from "./chunk-4LJFZH2I.js";
|
|
18
18
|
import {
|
|
19
19
|
loadNull
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-H4UF2I7V.js";
|
|
21
21
|
import "./chunk-OQXTQQAU.js";
|
|
22
22
|
import {
|
|
23
23
|
COPY_FILE,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
loadExceptions,
|
|
29
29
|
parseFlags,
|
|
30
30
|
readPaths
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-LZVTN2KI.js";
|
|
32
32
|
import {
|
|
33
33
|
toJson
|
|
34
34
|
} from "./chunk-QIEDBL4J.js";
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
expandNullTargets,
|
|
6
6
|
loadNull
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-H4UF2I7V.js";
|
|
8
8
|
import "./chunk-OQXTQQAU.js";
|
|
9
9
|
import {
|
|
10
10
|
parseFlags
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LZVTN2KI.js";
|
|
12
12
|
import {
|
|
13
13
|
toJson
|
|
14
14
|
} from "./chunk-QIEDBL4J.js";
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
runHarvest,
|
|
10
10
|
runNull,
|
|
11
11
|
serveDir
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-H4UF2I7V.js";
|
|
13
13
|
import "./chunk-OQXTQQAU.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-LZVTN2KI.js";
|
|
15
15
|
import "./chunk-QIEDBL4J.js";
|
|
16
16
|
import "./chunk-WUACK2HX.js";
|
|
17
17
|
import "./chunk-WK2WMWTH.js";
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
merge,
|
|
5
5
|
resolvePages,
|
|
6
6
|
runAudit
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3CD3DTEI.js";
|
|
8
8
|
import "./chunk-VDUIIWG7.js";
|
|
9
9
|
import "./chunk-JYNXGCYZ.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-H4UF2I7V.js";
|
|
11
11
|
import "./chunk-OQXTQQAU.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-LZVTN2KI.js";
|
|
13
13
|
import "./chunk-QIEDBL4J.js";
|
|
14
14
|
import "./chunk-WUACK2HX.js";
|
|
15
15
|
import "./chunk-WK2WMWTH.js";
|