impeccable 3.6.0 → 3.6.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 +3 -3
- package/README.npm.md +3 -3
- package/README.repo.md +39 -11
- package/cli/bin/commands/ignores.mjs +4 -0
- package/cli/bin/commands/skills.mjs +135 -57
- package/cli/engine/browser/injected/index.mjs +136 -5
- package/cli/engine/cli/main.mjs +10 -16
- package/cli/engine/design-system.mjs +199 -9
- package/cli/engine/detect-antipatterns-browser.js +350 -37
- package/cli/engine/engines/browser/detect-url.mjs +64 -2
- package/cli/engine/engines/regex/detect-text.mjs +155 -7
- package/cli/engine/engines/static-html/css-cascade.mjs +56 -7
- package/cli/engine/engines/static-html/detect-html.mjs +3 -5
- package/cli/engine/registry/antipatterns.mjs +18 -0
- package/cli/engine/rules/checks.mjs +175 -30
- package/cli/engine/shared/color.mjs +8 -0
- package/cli/engine/shared/constants.mjs +17 -2
- package/cli/lib/download-providers.js +1 -0
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
WCAG_LARGE_BOLD_TEXT_PX,
|
|
10
10
|
WCAG_LARGE_TEXT_PX,
|
|
11
11
|
isBrandFontOnOwnDomain,
|
|
12
|
+
primaryFontFace,
|
|
12
13
|
} from '../shared/constants.mjs';
|
|
13
14
|
import {
|
|
14
15
|
CSS_NAMED_COLORS,
|
|
@@ -331,7 +332,7 @@ function checkIconTile(opts) {
|
|
|
331
332
|
function resolveSerif(fontFamily) {
|
|
332
333
|
if (!fontFamily) return { primary: null, isSerif: false };
|
|
333
334
|
const tokens = fontFamily.split(',').map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase());
|
|
334
|
-
const primary =
|
|
335
|
+
const primary = primaryFontFace(fontFamily, GENERIC_FONTS);
|
|
335
336
|
if (!primary) return { primary: null, isSerif: false };
|
|
336
337
|
if (KNOWN_SERIF_FONTS.has(primary)) return { primary, isSerif: true };
|
|
337
338
|
if (tokens.includes('serif')) return { primary, isSerif: true };
|
|
@@ -682,8 +683,13 @@ function enclosingCssSelector(cssText, index) {
|
|
|
682
683
|
if (!cssText || !Number.isFinite(index)) return null;
|
|
683
684
|
const open = cssText.lastIndexOf('{', index);
|
|
684
685
|
if (open === -1) return null;
|
|
686
|
+
// A match inside an inline style fragment (`style="…"` appended to the
|
|
687
|
+
// corpus by buildHtmlPatternCorpora) has no enclosing rule; the previous
|
|
688
|
+
// `{` belongs to some other selector.
|
|
689
|
+
const closeBeforeIndex = cssText.lastIndexOf('}', index);
|
|
690
|
+
if (closeBeforeIndex > open) return null;
|
|
685
691
|
const prevClose = Math.max(cssText.lastIndexOf('}', open - 1), cssText.lastIndexOf(';', open - 1));
|
|
686
|
-
const raw = cssText.slice(prevClose + 1, open).trim().replace(/\s+/g, ' ');
|
|
692
|
+
const raw = cssText.slice(prevClose + 1, open).replace(/\/\*[\s\S]*?\*\//g, '').trim().replace(/\s+/g, ' ');
|
|
687
693
|
if (!raw || raw.startsWith('@') || /^\d/.test(raw) || /[{}<]/.test(raw)) return null;
|
|
688
694
|
// Keyframe steps: percentage steps fail the digit test above, but `from`
|
|
689
695
|
// and `to` would read as (never-matching) type selectors and get a valid
|
|
@@ -721,20 +727,19 @@ function scanCssTextForGlow(content) {
|
|
|
721
727
|
return results;
|
|
722
728
|
}
|
|
723
729
|
|
|
724
|
-
// Decorative grid
|
|
730
|
+
// Decorative two-axis grid backgrounds drawn with hairline
|
|
725
731
|
// linear-gradient layers tiled by a fixed pixel cell. Shared by the HTML
|
|
726
732
|
// pattern pass and the regex source engine so standalone CSS, component
|
|
727
733
|
// styles, and inline styles receive the same coverage. Both signals must
|
|
728
734
|
// co-occur in one declaration block; unrelated rules must not add up across
|
|
729
|
-
// the file.
|
|
730
|
-
//
|
|
735
|
+
// the file. A single hairline is a line, divider, or rail, not a grid, even
|
|
736
|
+
// when tiled by a 2D px cell. Returns [{ index, snippet }], capped at one
|
|
737
|
+
// finding per source to match the page-level HTML check's existing behavior.
|
|
731
738
|
function scanCssTextForGridBackground(content) {
|
|
732
739
|
const hairlineRe = /\b\d{1,3}px\s*,\s*transparent\s+\d{1,3}px/gi;
|
|
733
740
|
const invertedHairlineRe = /transparent\s+calc\(100%\s*-\s*\d{1,3}px\)/gi;
|
|
734
741
|
const sizeDeclPxRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\b/i;
|
|
735
|
-
const sizeDeclPxPairRe = /background-size\s*:[^;{}"']*\b\d{1,3}px\s+\d{1,3}px/i;
|
|
736
742
|
const shorthandPxAnyRe = /\/\s*\d{1,3}px\b/;
|
|
737
|
-
const shorthandPxPairRe = /\/\s*\d{1,3}px\s+\d{1,3}px/;
|
|
738
743
|
const bgDeclRe = /\bbackground(?:-image)?\s*:\s*([^;{}"']*)/gi;
|
|
739
744
|
const blockRe = /\{([^{}]*)\}|style\s*=\s*"([^"]*)"|style\s*=\s*'([^']*)'/gi;
|
|
740
745
|
let blk;
|
|
@@ -751,13 +756,10 @@ function scanCssTextForGridBackground(content) {
|
|
|
751
756
|
}
|
|
752
757
|
if (hairlineCount === 0) continue;
|
|
753
758
|
const hasPxCell = sizeDeclPxRe.test(block) || shorthandPxAnyRe.test(bgJoined);
|
|
754
|
-
|
|
755
|
-
if ((hairlineCount >= 2 && hasPxCell) || hasPxPairCell) {
|
|
759
|
+
if (hairlineCount >= 2 && hasPxCell) {
|
|
756
760
|
return [{
|
|
757
761
|
index: blk.index,
|
|
758
|
-
snippet:
|
|
759
|
-
? 'two-axis grid-line gradient background'
|
|
760
|
-
: 'px-tiled hairline line-field background',
|
|
762
|
+
snippet: 'two-axis grid-line gradient background',
|
|
761
763
|
}];
|
|
762
764
|
}
|
|
763
765
|
}
|
|
@@ -1453,6 +1455,95 @@ function scanHtmlForShapeAssembledIllustration(html) {
|
|
|
1453
1455
|
return findings;
|
|
1454
1456
|
}
|
|
1455
1457
|
|
|
1458
|
+
|
|
1459
|
+
// --- Organic clip-path polygons ----------------------------------------------
|
|
1460
|
+
// A `clip-path: polygon(...)` with many vertices, or `clip-path: path(...)`
|
|
1461
|
+
// with curves, is CSS approximating an organic contour: a torn edge, a blob,
|
|
1462
|
+
// a silhouette. The approximation reads as the cheap version of the effect
|
|
1463
|
+
// (the craft floor's geometric-occlusion-mask ban), and it is the signature
|
|
1464
|
+
// of a comp's produced material being replaced with code. Geometric clips
|
|
1465
|
+
// (cut corners, diagonals, hexagons, arrows: few vertices, or vertices on
|
|
1466
|
+
// the 0/50/100 grid) pass; circle()/inset()/ellipse() pass; a mask-image
|
|
1467
|
+
// from an alpha matte passes.
|
|
1468
|
+
const ORGANIC_POLYGON_MIN_VERTICES = 10;
|
|
1469
|
+
function scanCssTextForOrganicClipPath(styleText) {
|
|
1470
|
+
const findings = [];
|
|
1471
|
+
const re = /clip-path\s*:\s*(polygon|path)\s*\(([^)]*(?:\)[^;}]*)?)/gi;
|
|
1472
|
+
let m;
|
|
1473
|
+
while ((m = re.exec(styleText)) !== null) {
|
|
1474
|
+
const kind = m[1].toLowerCase();
|
|
1475
|
+
const body = m[2];
|
|
1476
|
+
if (kind === 'path') {
|
|
1477
|
+
// curves (C, S, Q, T, A, absolute or relative) drawing a contour, not a
|
|
1478
|
+
// rectilinear M/L/Z outline; letters in path data are only commands
|
|
1479
|
+
const curves = (body.match(/[CSQTA]/gi) || []).length;
|
|
1480
|
+
if (curves < 3) continue;
|
|
1481
|
+
findings.push({ id: 'organic-clip-path', snippet: `clip-path: path() with ${curves} curve segments`, selector: enclosingCssSelector(styleText, m.index) || undefined });
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
const points = body.split(',').map((p) => p.trim()).filter(Boolean);
|
|
1485
|
+
if (points.length < ORGANIC_POLYGON_MIN_VERTICES) continue;
|
|
1486
|
+
// Vertices sitting on a coarse grid (multiples of 25%) are geometric; a
|
|
1487
|
+
// contour has arbitrary values.
|
|
1488
|
+
let offGrid = 0;
|
|
1489
|
+
for (const p of points) {
|
|
1490
|
+
const nums = p.match(/-?[\d.]+/g) || [];
|
|
1491
|
+
for (const n of nums) { const v = parseFloat(n); if (Math.abs(v - Math.round(v / 25) * 25) > 0.5) offGrid++; }
|
|
1492
|
+
}
|
|
1493
|
+
if (offGrid < points.length) continue;
|
|
1494
|
+
findings.push({ id: 'organic-clip-path', snippet: `clip-path: polygon() with ${points.length} vertices approximating an organic contour`, selector: enclosingCssSelector(styleText, m.index) || undefined });
|
|
1495
|
+
}
|
|
1496
|
+
return findings;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
// --- Buried raster ------------------------------------------------------------
|
|
1500
|
+
// A raster (background-image url or <img>) that never reaches the screen:
|
|
1501
|
+
// under a near-opaque gradient wash in the same background stack, or on an
|
|
1502
|
+
// element at near-zero opacity. It is how a produced texture "ships" while
|
|
1503
|
+
// the page shows flat color, and the finish reviewer cannot see it either.
|
|
1504
|
+
// A tint under 0.9 alpha passes (hero darkening); a blend mode passes
|
|
1505
|
+
// (multiply/overlay keep the material visible); opacity >= 0.15 passes.
|
|
1506
|
+
function scanCssTextForBuriedRaster(styleText) {
|
|
1507
|
+
const findings = [];
|
|
1508
|
+
// background stacks: split declarations, look for url() + a gradient whose
|
|
1509
|
+
// stops all carry alpha >= 0.9 (or opaque hex/named colors)
|
|
1510
|
+
const declRe = /background(?:-image)?\s*:\s*([^;}]+)/gi;
|
|
1511
|
+
let m;
|
|
1512
|
+
while ((m = declRe.exec(styleText)) !== null) {
|
|
1513
|
+
const value = m[1];
|
|
1514
|
+
if (!/url\(/i.test(value) || !/gradient\(/i.test(value)) continue;
|
|
1515
|
+
// a blend mode declared in the same rule keeps the raster visible
|
|
1516
|
+
const ruleStart = styleText.lastIndexOf('{', m.index);
|
|
1517
|
+
const ruleEnd = styleText.indexOf('}', m.index);
|
|
1518
|
+
const rule = styleText.slice(ruleStart < 0 ? 0 : ruleStart, ruleEnd < 0 ? styleText.length : ruleEnd);
|
|
1519
|
+
if (/background-blend-mode\s*:\s*(?!normal)/i.test(rule) || /mix-blend-mode\s*:\s*(?!normal)/i.test(rule)) continue;
|
|
1520
|
+
// Layers are painted first-on-top: only a wash listed BEFORE the url()
|
|
1521
|
+
// covers it. An image on top of a gradient is not buried.
|
|
1522
|
+
const firstUrl = value.search(/url\(/i);
|
|
1523
|
+
const gradients = [...value.matchAll(/(?:linear|radial|conic)-gradient\([^()]*(?:\([^()]*\)[^()]*)*\)/gi)].filter((gm) => gm.index < firstUrl).map((gm) => gm[0]);
|
|
1524
|
+
let opaqueWash = false;
|
|
1525
|
+
// an alpha token normalized to 0..1: '0.8' -> 0.8, '80%' -> 0.8
|
|
1526
|
+
const alphaOf = (a) => { if (a == null) return 1; const v = parseFloat(a); return String(a).trim().endsWith('%') ? v / 100 : v; };
|
|
1527
|
+
for (const g of gradients) {
|
|
1528
|
+
const alphas = [...g.matchAll(/rgba?\(\s*[\d.]+%?\s*,?\s*[\d.]+%?\s*,?\s*[\d.]+%?\s*(?:[,/]\s*([\d.]+%?))?\s*\)|hsla?\([^)]*?(?:[,/]\s*([\d.]+%?))?\s*\)/gi)].map((a) => alphaOf(a[1] ?? a[2]));
|
|
1529
|
+
const stripped = g.replace(/rgba?\([^)]*\)|hsla?\([^)]*\)/gi, '');
|
|
1530
|
+
// hex stops: 4- and 8-digit forms carry their own alpha
|
|
1531
|
+
for (const h of stripped.matchAll(/#([0-9a-f]{3,8})\b/gi)) {
|
|
1532
|
+
const hex = h[1];
|
|
1533
|
+
if (hex.length === 4) alphas.push(parseInt(hex[3] + hex[3], 16) / 255);
|
|
1534
|
+
else if (hex.length === 8) alphas.push(parseInt(hex.slice(6), 16) / 255);
|
|
1535
|
+
else alphas.push(1);
|
|
1536
|
+
}
|
|
1537
|
+
const named = /\b(?:white|black|ivory|beige|linen|snow|cream)\b/i.test(stripped);
|
|
1538
|
+
if (named) alphas.push(1);
|
|
1539
|
+
if (alphas.length && alphas.every((a) => !Number.isFinite(a) || a >= 0.9)) { opaqueWash = true; break; }
|
|
1540
|
+
}
|
|
1541
|
+
if (!opaqueWash) continue;
|
|
1542
|
+
findings.push({ id: 'buried-raster', snippet: `raster under a near-opaque gradient wash: ${value.trim().slice(0, 90)}`, selector: enclosingCssSelector(styleText, m.index) || undefined });
|
|
1543
|
+
}
|
|
1544
|
+
return findings;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1456
1547
|
// Scoped scan corpora for the page-level pattern checks. CSS-property
|
|
1457
1548
|
// regexes run over the whole source string fire on documentation ABOUT
|
|
1458
1549
|
// css — `<code>background-clip: text</code>` prose, <pre> samples, HTML
|
|
@@ -1625,6 +1716,10 @@ function checkHtmlPatterns(html, corpora) {
|
|
|
1625
1716
|
// Shape-assembled illustrations (large pictorial SVGs built from primitives)
|
|
1626
1717
|
findings.push(...scanHtmlForShapeAssembledIllustration(html));
|
|
1627
1718
|
|
|
1719
|
+
// Organic clip-path contours and rasters buried under washes or opacity
|
|
1720
|
+
findings.push(...scanCssTextForOrganicClipPath(styleText));
|
|
1721
|
+
findings.push(...scanCssTextForBuriedRaster(styleText));
|
|
1722
|
+
|
|
1628
1723
|
// Auto-scrolling marquees (<marquee> or infinite horizontal loop animations)
|
|
1629
1724
|
findings.push(...scanCssTextForMarquee(styleText, html));
|
|
1630
1725
|
|
|
@@ -2752,7 +2847,7 @@ function checkElementAIPaletteDOM(el) {
|
|
|
2752
2847
|
}
|
|
2753
2848
|
|
|
2754
2849
|
// Check for neon text (vivid cyan/purple color on dark background)
|
|
2755
|
-
const textColor = parseRgb(style.color);
|
|
2850
|
+
const textColor = parseRgb(style.color) || parseAnyColor(style.color);
|
|
2756
2851
|
if (textColor && hasChroma(textColor, 80)) {
|
|
2757
2852
|
const hue = getHue(textColor);
|
|
2758
2853
|
const isAIPalette = (hue >= 160 && hue <= 200) || (hue >= 260 && hue <= 310);
|
|
@@ -3095,14 +3190,30 @@ function isNonRenderedText(el, tag, style) {
|
|
|
3095
3190
|
function checkQuality(opts) {
|
|
3096
3191
|
const { el, tag, style, hasDirectText, textLen, fontSize, lineHeightPx, letterSpacingPx, rect, lineMax = 80, viewportWidth = 0, win = null } = opts;
|
|
3097
3192
|
const findings = [];
|
|
3098
|
-
//
|
|
3099
|
-
//
|
|
3100
|
-
//
|
|
3101
|
-
//
|
|
3102
|
-
//
|
|
3103
|
-
//
|
|
3193
|
+
// A raster (<img>, or an element with a background url) at near-zero
|
|
3194
|
+
// opacity never reaches the screen: the produced material ships as a
|
|
3195
|
+
// compliance token. The CSS-text scan catches the stylesheet form; this
|
|
3196
|
+
// catches computed opacity on the element itself (both engines).
|
|
3197
|
+
// Skip browser extension injected elements BEFORE any finding is pushed
|
|
3198
|
+
// (a low-opacity raster those hosts inject used to be recorded and then
|
|
3199
|
+
// returned by this very skip). Read the id via getAttribute whenever
|
|
3200
|
+
// `el.id` is not a string: on a <form> (and other [LegacyOverrideBuiltIns]
|
|
3201
|
+
// hosts) a named control like <input name="id"> shadows the builtin `id`
|
|
3202
|
+
// getter and returns the control element, whose `.startsWith` is undefined
|
|
3203
|
+
// and throws (issue #407 — every Shopify product form ships an
|
|
3204
|
+
// <input name="id">).
|
|
3104
3205
|
const elId = typeof el.id === 'string' ? el.id : (el.getAttribute?.('id') || '');
|
|
3105
3206
|
if (elId.startsWith('claude-') || elId.startsWith('cic-')) return findings;
|
|
3207
|
+
{
|
|
3208
|
+
const op = parseFloat(style.opacity);
|
|
3209
|
+
if (Number.isFinite(op) && op < 0.15 && op >= 0) {
|
|
3210
|
+
const bg = String(style.backgroundImage || '');
|
|
3211
|
+
if (tag === 'img' || /url\(/i.test(bg)) {
|
|
3212
|
+
const label = tag === 'img' ? (el.getAttribute && el.getAttribute('alt')) || '' : (el.textContent || '').trim().slice(0, 40);
|
|
3213
|
+
findings.push({ id: 'buried-raster', snippet: `${tag === 'img' ? '<img>' : 'raster background'} at opacity ${op}${label ? ` "${label}"` : ''}` });
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3106
3217
|
|
|
3107
3218
|
// --- Line length too long --- (browser-only: needs rect.width)
|
|
3108
3219
|
if (rect && hasDirectText && QUALITY_TEXT_TAGS.has(tag) && rect.width > 0 && textLen > lineMax) {
|
|
@@ -3820,8 +3931,7 @@ function checkTypography() {
|
|
|
3820
3931
|
const style = getComputedStyle(el);
|
|
3821
3932
|
const ff = style.fontFamily;
|
|
3822
3933
|
if (!ff) continue;
|
|
3823
|
-
const
|
|
3824
|
-
const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
|
|
3934
|
+
const primary = primaryFontFace(ff);
|
|
3825
3935
|
if (!primary) continue;
|
|
3826
3936
|
fontUsage.set(primary, (fontUsage.get(primary) || 0) + 1);
|
|
3827
3937
|
totalTextElements++;
|
|
@@ -4066,8 +4176,7 @@ function checkPageTypography(doc, win) {
|
|
|
4066
4176
|
if (rule.type !== 1) continue;
|
|
4067
4177
|
const ff = rule.style?.fontFamily;
|
|
4068
4178
|
if (!ff) continue;
|
|
4069
|
-
const
|
|
4070
|
-
const primary = stack.find(f => f && !GENERIC_FONTS.has(f));
|
|
4179
|
+
const primary = primaryFontFace(ff);
|
|
4071
4180
|
if (primary) {
|
|
4072
4181
|
fonts.add(primary);
|
|
4073
4182
|
if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
|
|
@@ -4086,11 +4195,10 @@ function checkPageTypography(doc, win) {
|
|
|
4086
4195
|
const ffRe = /font-family\s*:\s*([^;}]+)/gi;
|
|
4087
4196
|
let fm;
|
|
4088
4197
|
while ((fm = ffRe.exec(html)) !== null) {
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
}
|
|
4198
|
+
const primary = primaryFontFace(fm[1]);
|
|
4199
|
+
if (primary) {
|
|
4200
|
+
fonts.add(primary);
|
|
4201
|
+
if (OVERUSED_FONTS.has(primary)) overusedFound.add(primary);
|
|
4094
4202
|
}
|
|
4095
4203
|
}
|
|
4096
4204
|
|
|
@@ -5166,6 +5274,36 @@ function checkTextOcclusionDOM() {
|
|
|
5166
5274
|
// reads as an opaque box.
|
|
5167
5275
|
const effectiveOpacity = effectiveOpacityDOM;
|
|
5168
5276
|
|
|
5277
|
+
// The part of an element that is actually painted, after every scrolling or
|
|
5278
|
+
// clipping ancestor has had its say.
|
|
5279
|
+
//
|
|
5280
|
+
// getBoundingClientRect reports where a box would be if nothing cut it off,
|
|
5281
|
+
// so a paragraph half scrolled out of a panel still reports its full height,
|
|
5282
|
+
// and the half that is clipped away lands wherever the page continues below
|
|
5283
|
+
// the panel. The elementFromPoint probe then samples coordinates the text is
|
|
5284
|
+
// not painted at, finds whatever genuinely is painted there, and reports the
|
|
5285
|
+
// text as buried under it. Any sticky footer or toolbar beneath a scroll
|
|
5286
|
+
// region produces this, and it is the shape most likely to be waved off as
|
|
5287
|
+
// noise, which costs the rule its credibility on the findings that are real.
|
|
5288
|
+
//
|
|
5289
|
+
// Border box rather than padding box on purpose: it errs toward probing, and
|
|
5290
|
+
// giving up a scrollbar gutter's width would drop true findings at the right
|
|
5291
|
+
// edge of a scroller.
|
|
5292
|
+
const paintedRect = (el, rect) => {
|
|
5293
|
+
let left = rect.left, top = rect.top, right = rect.right, bottom = rect.bottom;
|
|
5294
|
+
for (let cur = el.parentElement; cur && cur !== document.documentElement; cur = cur.parentElement) {
|
|
5295
|
+
let cs; try { cs = getComputedStyle(cur); } catch { continue; }
|
|
5296
|
+
const clipsX = String(cs.overflowX || 'visible') !== 'visible';
|
|
5297
|
+
const clipsY = String(cs.overflowY || 'visible') !== 'visible';
|
|
5298
|
+
if (!clipsX && !clipsY) continue;
|
|
5299
|
+
let b; try { b = cur.getBoundingClientRect(); } catch { continue; }
|
|
5300
|
+
if (clipsX) { left = Math.max(left, b.left); right = Math.min(right, b.right); }
|
|
5301
|
+
if (clipsY) { top = Math.max(top, b.top); bottom = Math.min(bottom, b.bottom); }
|
|
5302
|
+
if (right - left < 1 || bottom - top < 1) return null;
|
|
5303
|
+
}
|
|
5304
|
+
return { left, top, right, bottom, width: right - left, height: bottom - top };
|
|
5305
|
+
};
|
|
5306
|
+
|
|
5169
5307
|
// Collect renderable text owners in / near the first viewport for the
|
|
5170
5308
|
// elementFromPoint probe. SVG <text> counts too.
|
|
5171
5309
|
const textEls = [];
|
|
@@ -5178,8 +5316,13 @@ function checkTextOcclusionDOM() {
|
|
|
5178
5316
|
if (text.length < 2) continue;
|
|
5179
5317
|
if (!isPaintedForOcclusion(el)) continue;
|
|
5180
5318
|
if (effectiveOpacity(el) <= 0.02) continue;
|
|
5181
|
-
let
|
|
5182
|
-
if (
|
|
5319
|
+
let full; try { full = el.getBoundingClientRect(); } catch { continue; }
|
|
5320
|
+
if (full.width < 6 || full.height < 6) continue;
|
|
5321
|
+
// Probe only where the text is on screen. A run clipped down to a sliver is
|
|
5322
|
+
// dropped rather than sampled: a few pixels of visible text cannot support
|
|
5323
|
+
// a coverage fraction worth reporting either way.
|
|
5324
|
+
const rect = paintedRect(el, full);
|
|
5325
|
+
if (!rect || rect.width < 6 || rect.height < 6) continue;
|
|
5183
5326
|
// Viewport-bound probe: keep text whose box overlaps the live viewport.
|
|
5184
5327
|
if (rect.bottom <= 0 || rect.top >= vh) continue;
|
|
5185
5328
|
textEls.push({ el, rect, text, inSvg });
|
|
@@ -5448,6 +5591,8 @@ export {
|
|
|
5448
5591
|
cssLengthToPx,
|
|
5449
5592
|
scanCssTextForPulsingDot,
|
|
5450
5593
|
scanHtmlForShapeAssembledIllustration,
|
|
5594
|
+
scanCssTextForOrganicClipPath,
|
|
5595
|
+
scanCssTextForBuriedRaster,
|
|
5451
5596
|
buildHtmlPatternCorpora,
|
|
5452
5597
|
checkHtmlPatterns,
|
|
5453
5598
|
readOwnBackgroundColor,
|
|
@@ -103,14 +103,22 @@ function extractColorFunctionTokens(value) {
|
|
|
103
103
|
function parseGradientColors(bgImage) {
|
|
104
104
|
if (!bgImage || !bgImage.includes('gradient')) return [];
|
|
105
105
|
const colors = [];
|
|
106
|
+
const tokenSpans = [];
|
|
107
|
+
let from = 0;
|
|
106
108
|
// Stops arrive in whatever syntax the author wrote and the browser kept.
|
|
107
109
|
// A dark ground painted as `linear-gradient(oklch(...), oklch(...))` used
|
|
108
110
|
// to read as a gradient with no stops at all.
|
|
109
111
|
for (const token of extractColorFunctionTokens(bgImage)) {
|
|
112
|
+
const start = bgImage.indexOf(token, from);
|
|
113
|
+
if (start < 0) break;
|
|
114
|
+
tokenSpans.push({ start, end: start + token.length });
|
|
115
|
+
from = start + token.length;
|
|
110
116
|
const c = parseAnyColor(token);
|
|
111
117
|
if (c) colors.push(c);
|
|
112
118
|
}
|
|
113
119
|
for (const m of bgImage.matchAll(/#([0-9a-f]{6}|[0-9a-f]{3})\b/gi)) {
|
|
120
|
+
// Nested hex inside color-mix is an ingredient, not a stop (issue #578).
|
|
121
|
+
if (tokenSpans.some(s => m.index >= s.start && m.index < s.end)) continue;
|
|
114
122
|
const h = m[1];
|
|
115
123
|
if (h.length === 6) {
|
|
116
124
|
colors.push({ r: parseInt(h.slice(0,2),16), g: parseInt(h.slice(2,4),16), b: parseInt(h.slice(4,6),16), a: 1 });
|
|
@@ -56,13 +56,27 @@ function isBrandFontOnOwnDomain(font) {
|
|
|
56
56
|
return allowed.some(suffix => host === suffix || host.endsWith('.' + suffix));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
// Overused-font primary selection skips only CSS generics so a system stack
|
|
60
|
+
// keeps the system face as primary; GENERIC_FONTS still includes platform
|
|
61
|
+
// faces for design-system/serif resolution.
|
|
62
|
+
const CSS_GENERIC_FONTS = new Set([
|
|
60
63
|
'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy',
|
|
64
|
+
'inherit', 'initial', 'unset', 'revert',
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
const GENERIC_FONTS = new Set([
|
|
68
|
+
...CSS_GENERIC_FONTS,
|
|
61
69
|
'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded',
|
|
62
70
|
'-apple-system', 'blinkmacsystemfont', 'segoe ui',
|
|
63
|
-
'inherit', 'initial', 'unset', 'revert',
|
|
64
71
|
]);
|
|
65
72
|
|
|
73
|
+
function primaryFontFace(fontFamily, skip = CSS_GENERIC_FONTS) {
|
|
74
|
+
return String(fontFamily || '')
|
|
75
|
+
.split(',')
|
|
76
|
+
.map(f => f.trim().replace(/^['"]|['"]$/g, '').toLowerCase())
|
|
77
|
+
.find(f => f && !skip.has(f)) || null;
|
|
78
|
+
}
|
|
79
|
+
|
|
66
80
|
// WCAG large text thresholds are defined in points: 18pt normal text and
|
|
67
81
|
// 14pt bold text. Browsers expose font-size in CSS pixels at 96px per inch.
|
|
68
82
|
const WCAG_LARGE_TEXT_PX = 18 * (96 / 72);
|
|
@@ -104,6 +118,7 @@ export {
|
|
|
104
118
|
BRAND_FONT_DOMAINS,
|
|
105
119
|
isBrandFontOnOwnDomain,
|
|
106
120
|
GENERIC_FONTS,
|
|
121
|
+
primaryFontFace,
|
|
107
122
|
WCAG_LARGE_TEXT_PX,
|
|
108
123
|
WCAG_LARGE_BOLD_TEXT_PX,
|
|
109
124
|
EM_DASH_FLOOR,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "impeccable",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"author": "Paul Bakaus",
|
|
5
5
|
"description": "Design skills, commands, and anti-pattern detection for AI coding agents",
|
|
6
6
|
"keywords": [
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@ai-sdk/google": "^4.0.8",
|
|
90
90
|
"@ai-sdk/openai": "^4.0.7",
|
|
91
91
|
"@anthropic-ai/claude-agent-sdk": "^0.3.165",
|
|
92
|
-
"@anthropic-ai/sdk": "^0.
|
|
92
|
+
"@anthropic-ai/sdk": "^0.122.0",
|
|
93
93
|
"@babel/parser": "^8.0.4",
|
|
94
94
|
"ai": "^7.0.14",
|
|
95
95
|
"archiver": "^8.0.0",
|