@domandigital/craft 0.11.0 → 0.13.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/dist/audit.cjs CHANGED
@@ -20,6 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/audit/index.ts
21
21
  var audit_exports = {};
22
22
  __export(audit_exports, {
23
+ PROVENANCE_BUDGET_MS: () => PROVENANCE_BUDGET_MS,
24
+ PROVENANCE_MAX_IMAGES: () => PROVENANCE_MAX_IMAGES,
25
+ VISUAL_MAX_HEIGHT: () => VISUAL_MAX_HEIGHT,
23
26
  audit: () => audit,
24
27
  collectInPage: () => collectInPage,
25
28
  loadPlaywright: () => loadPlaywright,
@@ -1032,14 +1035,14 @@ function contractionHits(ctx) {
1032
1035
  for (const doc2 of documents(ctx)) {
1033
1036
  if (doc2.words < 800) continue;
1034
1037
  const text = doc2.blocks.map((b) => withoutHeadings(b.text)).join("\n");
1035
- const count2 = (text.match(CONTRACTION) ?? []).length;
1036
- const rate = count2 * 1e3 / doc2.words;
1038
+ const count3 = (text.match(CONTRACTION) ?? []).length;
1039
+ const rate = count3 * 1e3 / doc2.words;
1037
1040
  if (rate < 1) {
1038
1041
  const first = sentences(doc2)[0];
1039
1042
  hits.push({
1040
1043
  path: doc2.path,
1041
1044
  offset: first?.offset ?? 0,
1042
- message: `${count2} contraction${count2 === 1 ? "" : "s"} in ${thousands(doc2.words)} words. Prose with none reads stiff; formal legal pages are the exception`
1045
+ message: `${count3} contraction${count3 === 1 ? "" : "s"} in ${thousands(doc2.words)} words. Prose with none reads stiff; formal legal pages are the exception`
1043
1046
  });
1044
1047
  }
1045
1048
  }
@@ -1162,16 +1165,16 @@ function filler(words, seed = 1, options = {}) {
1162
1165
  return state % n;
1163
1166
  };
1164
1167
  const out = [];
1165
- let count2 = 0;
1168
+ let count3 = 0;
1166
1169
  let i = 0;
1167
- while (count2 < words) {
1170
+ while (count3 < words) {
1168
1171
  const length = uniform ?? shape[i % shape.length];
1169
1172
  const s = [];
1170
1173
  for (let w = 0; w < length; w += 1) s.push(FILLER_WORDS[next(FILLER_WORDS.length)]);
1171
1174
  if (contractions && i % 6 === 2) s.splice(1, 0, "we're");
1172
1175
  s[0] = s[0].charAt(0).toUpperCase() + s[0].slice(1);
1173
1176
  out.push(`${s.join(" ")}.`);
1174
- count2 += s.length;
1177
+ count3 += s.length;
1175
1178
  i += 1;
1176
1179
  }
1177
1180
  const paragraphs = [];
@@ -1567,6 +1570,7 @@ var REFLEX_FONTS_2 = [
1567
1570
  "Plus Jakarta Sans",
1568
1571
  "Outfit",
1569
1572
  "Geist",
1573
+ "Cal Sans",
1570
1574
  "Sora",
1571
1575
  "Instrument Sans",
1572
1576
  "Instrument Serif",
@@ -1788,7 +1792,7 @@ function iconTiles(file) {
1788
1792
  return sized && has(unit, /^rounded-(?:md|lg|xl|2xl|full)$/) && has(unit, /^(?:items-center|place-items-center|place-content-center)$/) && has(unit, /^bg-/);
1789
1793
  });
1790
1794
  }
1791
- var ICON_LIBRARY = /from\s+["'](?:lucide-react|@heroicons\/react[^"']*|react-icons[^"']*|@phosphor-icons\/react|@tabler\/icons-react|@radix-ui\/react-icons)["']/;
1795
+ var ICON_LIBRARY = /from\s+["'](?:lucide-react|@heroicons\/react[^"']*|react-icons[^"']*|@phosphor-icons\/react|@tabler\/icons-react|@radix-ui\/react-icons|@iconscout\/react-unicons[^"']*|@mui\/icons-material[^"']*|react-material-symbols[^"']*)["']/;
1792
1796
  function iconTileStackHits(ctx) {
1793
1797
  const hits = [];
1794
1798
  for (const file of ctx.files) {
@@ -1935,6 +1939,12 @@ function shadcnHits(ctx) {
1935
1939
  const detail = unused.length > 0 ? `; ${unused.length} imported nowhere` : "";
1936
1940
  return [{ path: ui[0].path, offset: 0, message: `${ui.length} stock shadcn primitives${detail}` }];
1937
1941
  }
1942
+ function shadcnCardHits(ctx) {
1943
+ return eachUnit(
1944
+ ctx,
1945
+ (unit) => has(unit, /^bg-card$/) && has(unit, /^text-card-foreground$/) && has(unit, /^border$/) && has(unit, /^rounded-(?:lg|xl)$/) && has(unit, /^shadow(?:-sm)?$/) ? "the registry Card recipe, unchanged" : null
1946
+ );
1947
+ }
1938
1948
  function marqueeHits(ctx) {
1939
1949
  const hits = [];
1940
1950
  const pattern = /@keyframes\s+[\w-]*marquee|animate-(?:marquee|scroll-x|infinite-scroll)\b|<Marquee\b|["']react-fast-marquee["']|ui\/marquee["']|animation(?:-name)?\s*:\s*[^;]*marquee/i;
@@ -2152,6 +2162,23 @@ const inter = Inter({ subsets: ["latin"] });`),
2152
2162
  pass: [f3("src/components/ui/button.tsx", `export function Button() { return null; }`)]
2153
2163
  }
2154
2164
  },
2165
+ {
2166
+ id: "shadcn-card-stock",
2167
+ name: "Stock shadcn Card",
2168
+ generation: 1,
2169
+ severity: "warn",
2170
+ surface: "source",
2171
+ why: "The registry Card (bg-card, a plain border, rounded-lg or rounded-xl, shadow-sm) is the container every generated page is built from. Left as shipped, every card on the site looks like every other shadcn site's.",
2172
+ fix: "Give the card this site's radius and shadow from the restraint budget, or drop the shadow and let a visible border carry it.",
2173
+ detect: shadcnCardHits,
2174
+ fixtures: {
2175
+ flag: [
2176
+ f3("components/ui/card.tsx", `className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)}`),
2177
+ f3("components/ui/card.tsx", `className={cn("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm", className)}`)
2178
+ ],
2179
+ pass: [f3("components/ui/card.tsx", `className={cn("rounded-sm border-2 border-ink bg-card text-card-foreground", className)}`)]
2180
+ }
2181
+ },
2155
2182
  {
2156
2183
  id: "cream-palette",
2157
2184
  name: "Cream ground",
@@ -2395,7 +2422,7 @@ function excerptAt(text, offset, max = 140) {
2395
2422
  }
2396
2423
 
2397
2424
  // src/snapshot/types.ts
2398
- var SNAPSHOT_VERSION = 1;
2425
+ var SNAPSHOT_VERSION = 2;
2399
2426
 
2400
2427
  // src/snapshot/fixture.ts
2401
2428
  function makeSnapshot(patch = {}) {
@@ -2728,11 +2755,433 @@ var RENDERED_PATHS = {
2728
2755
  }
2729
2756
  };
2730
2757
 
2758
+ // src/fingerprint/index.ts
2759
+ var FINGERPRINT_VERSION = 2;
2760
+ var CHROMATIC = 0.03;
2761
+ var MIN_ACCENT_AREA = 2e4;
2762
+ var oklch = (value) => {
2763
+ const parsed = parseColour(value);
2764
+ return parsed && parsed.alpha > 0.5 ? parsed.oklch : null;
2765
+ };
2766
+ function accentOf(s) {
2767
+ const buttons = /* @__PURE__ */ new Map();
2768
+ for (const c of s.controls) {
2769
+ const o = oklch(c.background);
2770
+ if (o && o.c >= CHROMATIC) buttons.set(c.background, (buttons.get(c.background) ?? 0) + 1);
2771
+ }
2772
+ const topButton = [...buttons].sort((a, b) => b[1] - a[1])[0];
2773
+ if (topButton) return oklch(topButton[0]);
2774
+ const bg = s.colours.backgrounds.map((b) => ({ o: oklch(b.value), w: b.area })).filter((x) => x.o && x.o.c >= CHROMATIC && x.w >= MIN_ACCENT_AREA).sort((a, b) => b.w - a.w)[0];
2775
+ if (bg) return bg.o;
2776
+ const text = s.colours.text.map((t) => ({ o: oklch(t.value), w: t.chars })).filter((x) => x.o && x.o.c >= CHROMATIC).sort((a, b) => b.w - a.w)[0];
2777
+ return text ? text.o : null;
2778
+ }
2779
+ function faces(s) {
2780
+ const byChars = [...s.fonts].sort((a, b) => b.chars - a.chars);
2781
+ const byDisplay = [...s.fonts].sort((a, b) => b.displayChars - a.displayChars);
2782
+ const bodyName = normaliseFamily(byChars[0]?.family ?? "system-ui");
2783
+ const displayName = normaliseFamily((byDisplay[0]?.displayChars ? byDisplay[0].family : byChars[0]?.family) ?? "system-ui");
2784
+ return {
2785
+ display: { family: displayName, class: fontClass(displayName) },
2786
+ body: { family: bodyName, class: fontClass(bodyName) }
2787
+ };
2788
+ }
2789
+ function median(values) {
2790
+ if (values.length === 0) return null;
2791
+ const sorted = [...values].sort((a, b) => a - b);
2792
+ const mid = Math.floor(sorted.length / 2);
2793
+ return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
2794
+ }
2795
+ function fingerprint(s) {
2796
+ const effects = [];
2797
+ if (s.effects.glass > 0) effects.push("glass-panel");
2798
+ if (s.effects.gradientText > 0) effects.push("gradient-text");
2799
+ if (s.effects.glows > 0 || s.effects.gradients.some((g) => g.radial)) effects.push("radial-spotlight-glow");
2800
+ if (s.effects.gridBackgrounds > 0) effects.push("grid-background");
2801
+ if (s.effects.marquees > 0) effects.push("marquee");
2802
+ if (s.effects.hairlineShadowCards >= 3) effects.push("thin-border-wide-shadow");
2803
+ if (s.effects.eyebrowChip) effects.push("hero-eyebrow-chip");
2804
+ if (s.motion.introOverlay) effects.push("intro-cinematic");
2805
+ const below = s.sections.filter((x) => x.top > s.viewport.height).length;
2806
+ return {
2807
+ version: FINGERPRINT_VERSION,
2808
+ accent: accentOf(s),
2809
+ ground: oklch(s.ground) ?? { l: 1, c: 0, h: 0 },
2810
+ ...faces(s),
2811
+ roundness: median(s.controls.map((c) => Math.min(0.5, c.radiusPx / Math.max(1, c.heightPx)))),
2812
+ motion: below ? Math.min(1, s.motion.hiddenSections / below) : 0,
2813
+ effects: effects.sort(),
2814
+ layout: s.sections.map((x) => x.kind),
2815
+ ...s.sections.length > 0 && s.sections.every((x) => x.role && x.geometry) ? {
2816
+ sections: s.sections.map((x) => ({
2817
+ role: x.role,
2818
+ centred: x.geometry.centredShare,
2819
+ width: x.geometry.contentWidthRatio,
2820
+ symmetry: x.geometry.mirrorSymmetry,
2821
+ controls: x.geometry.controls,
2822
+ cards: x.cards,
2823
+ background: x.geometry.background === s.ground ? null : oklch(x.geometry.background),
2824
+ badges: (x.badges ?? []).map((b) => b.toLowerCase()),
2825
+ avatars: x.avatars ?? 0,
2826
+ carousel: x.carousel ?? false,
2827
+ figures: x.figures ?? 0
2828
+ }))
2829
+ } : {}
2830
+ };
2831
+ }
2832
+
2833
+ // src/fingerprint/component.ts
2834
+ var PROMO_BADGE = /\b(?:most popular|popular|recommended|best value|best seller|bestseller|most chosen)\b/i;
2835
+
2836
+ // src/snapshot/rendered-tells.ts
2837
+ var hit2 = (s, message, excerpt) => ({ path: s.url, offset: 0, message, excerpt: excerpt ?? message });
2838
+ var GROUND = "rgb(255, 255, 255)";
2839
+ var BAND = "rgb(31, 58, 46)";
2840
+ var geo = (patch = {}) => ({
2841
+ centredShare: 0.1,
2842
+ mirrorSymmetry: 0.6,
2843
+ whitespaceRatio: 0.7,
2844
+ contentWidthRatio: 0.85,
2845
+ background: GROUND,
2846
+ controls: 0,
2847
+ ...patch
2848
+ });
2849
+ function withSection(index, patch, roles = []) {
2850
+ const base = makeSnapshot();
2851
+ return {
2852
+ ...base,
2853
+ sections: base.sections.map((s, i) => ({ ...s, role: roles[i] ?? s.kind, geometry: geo(), badges: [], avatars: 0, carousel: false, figures: 0, ...i === index ? patch : {} }))
2854
+ };
2855
+ }
2856
+ var measured = (s) => s.geometry !== void 0 && s.role !== void 0;
2857
+ var RENDERED_TELLS = [
2858
+ {
2859
+ id: "cta-band-stock",
2860
+ name: "Stock call-to-action band",
2861
+ generation: 1,
2862
+ severity: "warn",
2863
+ surface: "rendered",
2864
+ why: "A full-width coloured band with a centred heading, one line and one or two buttons is what a model closes every section run with. It asks for the booking the same way on every site.",
2865
+ fix: "Keep the ask, change the band: put it where the decision is made (next to the prices, after the proof), in the client's own words, laid out like the rest of the page rather than as a centred slab.",
2866
+ rendered: {
2867
+ detect: (s) => s.sections.filter((x) => measured(x) && (x.role === "cta-band" || x.role === "footer-cta")).filter((x) => {
2868
+ const g = x.geometry;
2869
+ return g.centredShare >= 0.8 && g.background !== s.ground && g.controls >= 1 && g.controls <= 2 && g.contentWidthRatio <= 0.7;
2870
+ }).map((x) => hit2(s, `a centred ${x.role === "footer-cta" ? "closing " : ""}band on its own colour with ${x.geometry.controls === 1 ? "one button" : "two buttons"}`, x.label)),
2871
+ fixtures: {
2872
+ flag: [
2873
+ withSection(4, { role: "footer-cta", label: "Boiler out today?", geometry: geo({ centredShare: 1, background: BAND, controls: 1, contentWidthRatio: 0.45 }) }),
2874
+ withSection(3, { role: "cta-band", label: "Ready to book?", geometry: geo({ centredShare: 0.9, background: BAND, controls: 2, contentWidthRatio: 0.5 }) })
2875
+ ],
2876
+ pass: [
2877
+ makeSnapshot(),
2878
+ // The same ask, laid out like the page: left-aligned on the ground.
2879
+ withSection(4, { role: "footer-cta", label: "Book a visit", geometry: geo({ centredShare: 0.1, background: GROUND, controls: 1, contentWidthRatio: 0.85 }) })
2880
+ ]
2881
+ }
2882
+ }
2883
+ },
2884
+ {
2885
+ id: "pricing-trio-popular",
2886
+ name: "Three-tier pricing with a popular badge",
2887
+ generation: 1,
2888
+ severity: "warn",
2889
+ surface: "rendered",
2890
+ why: "Three price cards with the middle one badged 'Most popular' is the SaaS pricing page, applied to a plumber or a salon whether or not anyone chose the middle option.",
2891
+ fix: "Keep the prices. Show them the way the trade quotes (a price list, per job, per visit), and drop the badge unless it is true and the client can say how many people chose it.",
2892
+ rendered: {
2893
+ detect: (s) => s.sections.filter((x) => measured(x) && x.role === "pricing" && x.cards === 3).filter((x) => (x.badges ?? []).some((b) => PROMO_BADGE.test(b))).map((x) => hit2(s, `three price cards, one badged "${(x.badges ?? []).find((b) => PROMO_BADGE.test(b))}"`, x.label)),
2894
+ fixtures: {
2895
+ flag: [withSection(3, { role: "pricing", kind: "cards", cards: 3, badges: ["Most popular"], label: "Plans" })],
2896
+ pass: [
2897
+ makeSnapshot(),
2898
+ withSection(3, { role: "pricing", kind: "cards", cards: 3, badges: [], label: "Prices" }),
2899
+ withSection(3, { role: "pricing", kind: "text", cards: 0, badges: [], label: "Price list" })
2900
+ ]
2901
+ }
2902
+ }
2903
+ },
2904
+ {
2905
+ id: "testimonial-avatar-carousel",
2906
+ name: "Avatar testimonial carousel",
2907
+ generation: 1,
2908
+ severity: "warn",
2909
+ surface: "rendered",
2910
+ why: "Round headshots over quotes in a sliding carousel is the stock testimonial block. Most visitors see the first slide only, and stock or AI faces make every quote read as invented.",
2911
+ fix: "Show the reviews all at once, where they come from (the Google rating, the named job, the town), with real photos of the work rather than of the reviewer.",
2912
+ rendered: {
2913
+ detect: (s) => s.sections.filter((x) => measured(x) && x.role === "testimonials" && x.carousel === true && (x.avatars ?? 0) >= 2).map((x) => hit2(s, `${x.avatars} round portraits in a sliding testimonial carousel`, x.label)),
2914
+ fixtures: {
2915
+ flag: [withSection(2, { role: "testimonials", avatars: 3, carousel: true, label: "What our clients say" })],
2916
+ pass: [
2917
+ makeSnapshot(),
2918
+ withSection(2, { role: "testimonials", avatars: 3, carousel: false, label: "Reviews" }),
2919
+ withSection(2, { role: "testimonials", avatars: 0, carousel: true, label: "Reviews" })
2920
+ ]
2921
+ }
2922
+ }
2923
+ },
2924
+ {
2925
+ id: "faq-accordion-closer",
2926
+ name: "FAQ accordion as the closer",
2927
+ generation: 2,
2928
+ severity: "warn",
2929
+ surface: "rendered",
2930
+ why: "Ending the page on a collapsed FAQ, often followed only by a band, is the model's default page ending. The answers a buyer needs are hidden behind clicks at the point they decide.",
2931
+ fix: "Answer the questions that block a booking where they arise (price next to prices, area next to the map), and end on the call to action or the proof.",
2932
+ rendered: {
2933
+ detect: (s) => {
2934
+ const body = s.sections.filter((x) => x.role !== "footer-cta" && x.role !== "cta-band");
2935
+ const last = body[body.length - 1];
2936
+ return last && measured(last) && last.role === "faq" ? [hit2(s, "the page ends on a question-and-answer list", last.label)] : [];
2937
+ },
2938
+ fixtures: {
2939
+ flag: [
2940
+ withSection(4, { role: "faq", label: "Common questions" }),
2941
+ {
2942
+ ...withSection(3, { role: "faq", label: "FAQ" }),
2943
+ sections: withSection(3, { role: "faq", label: "FAQ" }).sections.map((x, i) => i === 4 ? { ...x, role: "footer-cta" } : x)
2944
+ }
2945
+ ],
2946
+ pass: [makeSnapshot(), withSection(2, { role: "faq", label: "Common questions" })]
2947
+ }
2948
+ }
2949
+ },
2950
+ {
2951
+ id: "stats-row",
2952
+ name: "Row of big numbers",
2953
+ generation: 1,
2954
+ severity: "warn",
2955
+ surface: "rendered",
2956
+ why: "Three or four large figures in a row (500+ clients, 98% satisfaction, 10 years) is the stock proof block, and the numbers are often round, unsourced or invented.",
2957
+ fix: "Keep a figure only if it is true and sourced, and put it in a sentence next to what it proves. One real number in context beats four in a row.",
2958
+ rendered: {
2959
+ detect: (s) => s.sections.filter((x, i) => measured(x) && (x.role === "stats" || x.kind === "stats") && (x.figures ?? 0) >= 3 && (x.figures ?? 0) <= 6 && !(i === 1 && s.sections[0]?.kind === "hero")).map((x) => hit2(s, `${x.figures} large figures in a row`, x.label)),
2960
+ fixtures: {
2961
+ flag: [withSection(3, { role: "stats", kind: "stats", figures: 4, label: "500+" })],
2962
+ pass: [
2963
+ makeSnapshot(),
2964
+ withSection(3, { role: "text", kind: "text", figures: 1, label: "Since 2009" }),
2965
+ withSection(1, { role: "stats", kind: "stats", figures: 4, label: "500+" })
2966
+ ]
2967
+ }
2968
+ }
2969
+ },
2970
+ {
2971
+ id: "centred-everything",
2972
+ name: "Every section centred",
2973
+ generation: 2,
2974
+ severity: "warn",
2975
+ surface: "rendered",
2976
+ why: "When almost every section stacks a centred heading over centred text, the page has no reading line and every block looks like the one before. It is the layout nothing was decided for.",
2977
+ fix: "Pick an alignment and hold it: left-aligned text with a clear edge, keeping centring for the one moment that earns it.",
2978
+ rendered: {
2979
+ detect: (s) => {
2980
+ const m = s.sections.filter(measured);
2981
+ if (m.length < 4) return [];
2982
+ const centred = m.filter((x) => x.geometry.centredShare >= 0.7).length;
2983
+ return centred / m.length >= 0.8 ? [hit2(s, `${centred} of ${m.length} sections centre their text`)] : [];
2984
+ },
2985
+ fixtures: {
2986
+ flag: [{ ...makeSnapshot(), sections: makeSnapshot().sections.map((x) => ({ ...x, role: x.kind, geometry: geo({ centredShare: 0.9 }) })) }],
2987
+ pass: [
2988
+ makeSnapshot(),
2989
+ { ...makeSnapshot(), sections: makeSnapshot().sections.map((x, i) => ({ ...x, role: x.kind, geometry: geo({ centredShare: i < 2 ? 0.9 : 0.1 }) })) }
2990
+ ]
2991
+ }
2992
+ }
2993
+ }
2994
+ ];
2995
+
2996
+ // src/snapshot/imagery-tells.ts
2997
+ var hit3 = (s, message, excerpt) => ({ path: s.url, offset: 0, message, excerpt: excerpt ?? message });
2998
+ var STOCK_PHOTO_HOSTS = {
2999
+ "unsplash.com": "Unsplash",
3000
+ "pexels.com": "Pexels",
3001
+ "pixabay.com": "Pixabay",
3002
+ "istockphoto.com": "iStock",
3003
+ "gettyimages.com": "Getty Images",
3004
+ "shutterstock.com": "Shutterstock",
3005
+ "ftcdn.net": "Adobe Stock",
3006
+ "dreamstime.com": "Dreamstime",
3007
+ "depositphotos.com": "Depositphotos",
3008
+ "freepik.com": "Freepik",
3009
+ "rawpixel.com": "rawpixel",
3010
+ "stocksnap.io": "StockSnap",
3011
+ "burst.shopifycdn.com": "Burst",
3012
+ "picsum.photos": "Lorem Picsum",
3013
+ "loremflickr.com": "LoremFlickr",
3014
+ "placehold.co": "a placeholder service",
3015
+ "placeholder.com": "a placeholder service",
3016
+ "dummyimage.com": "a placeholder service"
3017
+ };
3018
+ var STOCK_AVATAR_HOSTS = {
3019
+ "randomuser.me": "randomuser.me",
3020
+ "pravatar.cc": "Pravatar",
3021
+ "dicebear.com": "DiceBear",
3022
+ "xsgames.co": "a random-face service",
3023
+ "thispersondoesnotexist.com": "a generated face",
3024
+ "generated.photos": "a generated face"
3025
+ };
3026
+ var STOCK_FILENAMES = [
3027
+ [/(?:^|[/_-])shutterstock[_-]?\d{4,}/i, "Shutterstock"],
3028
+ [/(?:^|[/_-])istock(?:photo)?[_-]?\d{4,}/i, "iStock"],
3029
+ [/(?:^|[/_-])adobestock[_-]?\d{4,}/i, "Adobe Stock"],
3030
+ [/(?:^|[/_-])gettyimages[_-]?\d{4,}/i, "Getty Images"],
3031
+ [/(?:^|[/_-])depositphotos[_-]?\d{4,}/i, "Depositphotos"],
3032
+ [/(?:^|[/_-])dreamstime[_-]/i, "Dreamstime"],
3033
+ [/(?:^|[/_-])pexels-[a-z0-9-]*\d{4,}/i, "Pexels"],
3034
+ [/-unsplash\.(?:jpe?g|png|webp|avif)(?:[?#]|$)/i, "Unsplash"],
3035
+ // Unsplash's photo ids: photo-<13-digit timestamp>-<12 hex>.
3036
+ [/photo-1\d{12}-[0-9a-f]{12}/, "Unsplash"]
3037
+ ];
3038
+ var byHost = (host, table) => {
3039
+ if (!host) return null;
3040
+ const h = host.toLowerCase();
3041
+ for (const [domain, name] of Object.entries(table)) if (h === domain || h.endsWith(`.${domain}`)) return name;
3042
+ return null;
3043
+ };
3044
+ function stockSource(image) {
3045
+ const host = byHost(image.host, STOCK_PHOTO_HOSTS);
3046
+ if (host) return host;
3047
+ let path = image.src.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i, "").replace(/[?#].*$/, "");
3048
+ try {
3049
+ path = decodeURIComponent(path);
3050
+ } catch {
3051
+ }
3052
+ for (const [re, name] of STOCK_FILENAMES) if (re.test(path)) return name;
3053
+ return null;
3054
+ }
3055
+ function stockAvatarSource(image) {
3056
+ return byHost(image.host, STOCK_AVATAR_HOSTS) ?? stockSource(image);
3057
+ }
3058
+ var picture = (patch = {}) => ({
3059
+ src: "https://example.test/images/boiler-swap-hinton.jpg",
3060
+ host: "example.test",
3061
+ width: 640,
3062
+ height: 480,
3063
+ top: 1800,
3064
+ role: "photo",
3065
+ alt: "The new combi boiler fitted in a kitchen cupboard in Hinton",
3066
+ decorative: false,
3067
+ section: 2,
3068
+ background: false,
3069
+ ...patch
3070
+ });
3071
+ var withImages = (images) => ({ ...makeSnapshot(), images });
3072
+ var AI_XMP = { digitalSourceType: "trainedAlgorithmicMedia", source: "xmp", c2pa: false, bytes: 48e3 };
3073
+ var NOTHING = { digitalSourceType: null, source: null, c2pa: false, bytes: 48e3 };
3074
+ var count2 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
3075
+ var IMAGERY_TELLS = [
3076
+ {
3077
+ id: "stock-photo",
3078
+ name: "Stock photography",
3079
+ generation: 1,
3080
+ severity: "warn",
3081
+ surface: "rendered",
3082
+ why: "A picture from a stock library is the picture every other site in the trade can use. It shows a job the client did not do, in a kitchen that is not theirs, and a visitor who has seen it before stops believing the rest.",
3083
+ fix: "Use a photo of the client's own work, premises or people, even a plain one taken on a phone. Where there is none yet, use fewer pictures rather than a library one.",
3084
+ rendered: {
3085
+ detect: (s) => {
3086
+ const found = (s.images ?? []).filter((i) => i.role === "photo" || i.role === "illustration").map((i) => ({ image: i, from: stockSource(i) })).filter((x) => x.from);
3087
+ if (found.length === 0) return [];
3088
+ const names = [...new Set(found.map((x) => x.from))].join(", ");
3089
+ return [hit3(s, `${count2(found.length, "picture")} from ${names}`, found[0].image.src)];
3090
+ },
3091
+ fixtures: {
3092
+ flag: [
3093
+ withImages([picture({ src: "https://images.unsplash.com/photo-1581578731548-c64695cc6952?w=1600", host: "images.unsplash.com", alt: "Plumber fixing a sink" })]),
3094
+ // Downloaded and self-hosted, found by the library's own file name.
3095
+ withImages([picture({ src: "https://example.test/img/shutterstock_1234567890.jpg" })])
3096
+ ],
3097
+ pass: [makeSnapshot(), withImages([picture()]), withImages([picture({ role: "icon", width: 48, height: 48, src: "https://images.unsplash.com/photo-1581578731548-c64695cc6952", host: "images.unsplash.com" })])]
3098
+ }
3099
+ }
3100
+ },
3101
+ {
3102
+ id: "stock-avatar",
3103
+ name: "Stock or placeholder faces",
3104
+ generation: 1,
3105
+ severity: "warn",
3106
+ surface: "rendered",
3107
+ why: "Round portraits from a placeholder-face service or a stock library next to reviews make every quote read as invented, and some of those faces are generated people who do not exist.",
3108
+ fix: "Drop the portraits. Name the reviewer, the town and the job, and link the review to where it was left.",
3109
+ rendered: {
3110
+ detect: (s) => {
3111
+ const found = (s.images ?? []).filter((i) => i.role === "avatar").map((i) => ({ image: i, from: stockAvatarSource(i) })).filter((x) => x.from);
3112
+ if (found.length === 0) return [];
3113
+ const names = [...new Set(found.map((x) => x.from))].join(", ");
3114
+ return [hit3(s, `${count2(found.length, "portrait")} from ${names}`, found[0].image.src)];
3115
+ },
3116
+ fixtures: {
3117
+ flag: [
3118
+ withImages([picture(), picture({ role: "avatar", width: 56, height: 56, src: "https://i.pravatar.cc/150?img=12", host: "i.pravatar.cc", alt: "Sarah" })]),
3119
+ withImages([picture({ role: "avatar", width: 64, height: 64, src: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?crop=faces", host: "images.unsplash.com" })])
3120
+ ],
3121
+ pass: [makeSnapshot(), withImages([picture(), picture({ role: "avatar", width: 56, height: 56, src: "https://example.test/team/sam.jpg", alt: "Sam, engineer" })])]
3122
+ }
3123
+ }
3124
+ },
3125
+ {
3126
+ id: "ai-image",
3127
+ name: "Generated image",
3128
+ generation: 2,
3129
+ severity: "warn",
3130
+ surface: "rendered",
3131
+ why: "The file itself says a model made it (its XMP or Content Credentials name a trained-model source). A generated picture stands in for work the client did not photograph, and anyone can read the label.",
3132
+ fix: "Replace it with a photo of the real thing: the work, the premises, the people. Where there is none yet, use fewer pictures.",
3133
+ rendered: {
3134
+ detect: (s) => {
3135
+ const found = (s.images ?? []).filter((i) => i.provenance?.digitalSourceType);
3136
+ if (found.length === 0) return [];
3137
+ const first = found[0].provenance;
3138
+ const where = first.source === "xmp" ? "its XMP metadata" : first.source === "c2pa" ? "its Content Credentials" : "its metadata";
3139
+ return [hit3(s, `${count2(found.length, "image")} labelled as made by a generative model (${first.digitalSourceType} in ${where})`, found[0].src)];
3140
+ },
3141
+ fixtures: {
3142
+ flag: [
3143
+ withImages([picture({ provenance: AI_XMP })]),
3144
+ withImages([picture({ provenance: { digitalSourceType: "compositeWithTrainedAlgorithmicMedia", source: "c2pa", c2pa: true, bytes: 12e4 } })])
3145
+ ],
3146
+ // Credentials that say nothing about a model, and an image never read, are not findings.
3147
+ pass: [makeSnapshot(), withImages([picture({ provenance: NOTHING })]), withImages([picture({ provenance: { ...NOTHING, c2pa: true } })]), withImages([picture()])]
3148
+ }
3149
+ }
3150
+ },
3151
+ {
3152
+ id: "no-real-imagery",
3153
+ name: "No photograph on the page",
3154
+ generation: 1,
3155
+ severity: "warn",
3156
+ surface: "rendered",
3157
+ why: "A page with no photograph at all, only icons and illustrations, is the page a model builds when it has no assets. Icon tiles stand in for the evidence a buyer looks for: the work, the premises, the people.",
3158
+ fix: "Add one real photo of the work where the claim is made: a finished job next to the service, the team next to the booking. One plain photo beats any number of icons.",
3159
+ rendered: {
3160
+ detect: (s) => {
3161
+ if (!s.images || s.sections.length < 4) return [];
3162
+ if (s.images.some((i) => i.role === "photo")) return [];
3163
+ const icons = s.images.filter((i) => i.role === "icon" || i.role === "illustration").length;
3164
+ return [hit3(s, `no photograph on the page${icons ? `: ${count2(icons, "icon or illustration", "icons and illustrations")} instead` : ""}`)];
3165
+ },
3166
+ fixtures: {
3167
+ flag: [
3168
+ withImages([picture({ role: "icon", width: 48, height: 48, src: "https://example.test/icons/wrench.svg" }), picture({ role: "illustration", width: 480, height: 360, src: "https://example.test/hero.svg" })]),
3169
+ withImages([])
3170
+ ],
3171
+ // A snapshot with no image record is never judged; nor is a page too short to be a site.
3172
+ pass: [makeSnapshot(), withImages([picture()]), { ...withImages([]), sections: makeSnapshot().sections.slice(0, 3) }]
3173
+ }
3174
+ }
3175
+ }
3176
+ ];
3177
+
2731
3178
  // src/character/check.ts
2732
- var CATALOGUE_VERSION = "2026.09.8";
2733
- var CATALOGUE = [...SOURCE_TELLS, ...COPY_TELLS, ...RESEARCH_TELLS, ...DENSITY_TELLS].map(
2734
- (t) => RENDERED_PATHS[t.id] ? { ...t, rendered: RENDERED_PATHS[t.id] } : t
2735
- );
3179
+ var CATALOGUE_VERSION = "2026.09.11";
3180
+ var CATALOGUE = [
3181
+ ...[...SOURCE_TELLS, ...COPY_TELLS, ...RESEARCH_TELLS, ...DENSITY_TELLS].map((t) => RENDERED_PATHS[t.id] ? { ...t, rendered: RENDERED_PATHS[t.id] } : t),
3182
+ ...RENDERED_TELLS,
3183
+ ...IMAGERY_TELLS
3184
+ ];
2736
3185
  function tellById(id) {
2737
3186
  return CATALOGUE.find((t) => t.id === id);
2738
3187
  }
@@ -2754,17 +3203,17 @@ var MARKER = /\b(?:copy|craft)-ok\b/;
2754
3203
  function marked(lines, line) {
2755
3204
  return MARKER.test(lines[line - 1] ?? "") || MARKER.test(lines[line - 2] ?? "");
2756
3205
  }
2757
- function toFinding(tell, hit2, texts) {
2758
- const text = texts.get(hit2.path) ?? "";
3206
+ function toFinding(tell, hit4, texts) {
3207
+ const text = texts.get(hit4.path) ?? "";
2759
3208
  return {
2760
3209
  tell: tell.id,
2761
3210
  name: tell.name,
2762
3211
  generation: tell.generation,
2763
3212
  severity: tell.severity,
2764
- path: hit2.path,
2765
- line: texts.has(hit2.path) ? lineAt(text, hit2.offset) : 0,
2766
- excerpt: hit2.excerpt ?? excerptAt(text, hit2.offset),
2767
- message: hit2.message,
3213
+ path: hit4.path,
3214
+ line: texts.has(hit4.path) ? lineAt(text, hit4.offset) : 0,
3215
+ excerpt: hit4.excerpt ?? excerptAt(text, hit4.offset),
3216
+ message: hit4.message,
2768
3217
  fix: tell.fix,
2769
3218
  ...tell.surface === "copy" ? { house: houseRule(tell.id, tell.name).tier } : {}
2770
3219
  };
@@ -2783,14 +3232,14 @@ function report(tells, files, run, options) {
2783
3232
  };
2784
3233
  const excepted = /* @__PURE__ */ new Map();
2785
3234
  for (const tell of selected) {
2786
- for (const hit2 of run(tell)) {
2787
- const exception = applied.find((e) => e.tell === tell.id && (!e.path || hit2.path.includes(e.path)));
3235
+ for (const hit4 of run(tell)) {
3236
+ const exception = applied.find((e) => e.tell === tell.id && (!e.path || hit4.path.includes(e.path)));
2788
3237
  if (exception) {
2789
3238
  excepted.set(exception, (excepted.get(exception) ?? 0) + 1);
2790
3239
  continue;
2791
3240
  }
2792
- const finding = toFinding(tell, hit2, texts);
2793
- if (marked(linesOf(hit2.path), finding.line)) {
3241
+ const finding = toFinding(tell, hit4, texts);
3242
+ if (marked(linesOf(hit4.path), finding.line)) {
2794
3243
  suppressed.push({ tell: tell.id, path: finding.path, line: finding.line });
2795
3244
  continue;
2796
3245
  }
@@ -2808,7 +3257,7 @@ function report(tells, files, run, options) {
2808
3257
  catalogueVersion: CATALOGUE_VERSION,
2809
3258
  findings,
2810
3259
  rejectedExceptions: rejected,
2811
- excepted: [...excepted].map(([e, count2]) => ({ tell: e.tell, because: e.because, count: count2 })),
3260
+ excepted: [...excepted].map(([e, count3]) => ({ tell: e.tell, because: e.because, count: count3 })),
2812
3261
  suppressed,
2813
3262
  summary: {
2814
3263
  files: files.length,
@@ -2826,66 +3275,6 @@ function auditSnapshot(snapshot, options = {}) {
2826
3275
  return result;
2827
3276
  }
2828
3277
 
2829
- // src/fingerprint/index.ts
2830
- var FINGERPRINT_VERSION = 1;
2831
- var CHROMATIC = 0.03;
2832
- var MIN_ACCENT_AREA = 2e4;
2833
- var oklch = (value) => {
2834
- const parsed = parseColour(value);
2835
- return parsed && parsed.alpha > 0.5 ? parsed.oklch : null;
2836
- };
2837
- function accentOf(s) {
2838
- const buttons = /* @__PURE__ */ new Map();
2839
- for (const c of s.controls) {
2840
- const o = oklch(c.background);
2841
- if (o && o.c >= CHROMATIC) buttons.set(c.background, (buttons.get(c.background) ?? 0) + 1);
2842
- }
2843
- const topButton = [...buttons].sort((a, b) => b[1] - a[1])[0];
2844
- if (topButton) return oklch(topButton[0]);
2845
- const bg = s.colours.backgrounds.map((b) => ({ o: oklch(b.value), w: b.area })).filter((x) => x.o && x.o.c >= CHROMATIC && x.w >= MIN_ACCENT_AREA).sort((a, b) => b.w - a.w)[0];
2846
- if (bg) return bg.o;
2847
- const text = s.colours.text.map((t) => ({ o: oklch(t.value), w: t.chars })).filter((x) => x.o && x.o.c >= CHROMATIC).sort((a, b) => b.w - a.w)[0];
2848
- return text ? text.o : null;
2849
- }
2850
- function faces(s) {
2851
- const byChars = [...s.fonts].sort((a, b) => b.chars - a.chars);
2852
- const byDisplay = [...s.fonts].sort((a, b) => b.displayChars - a.displayChars);
2853
- const bodyName = normaliseFamily(byChars[0]?.family ?? "system-ui");
2854
- const displayName = normaliseFamily((byDisplay[0]?.displayChars ? byDisplay[0].family : byChars[0]?.family) ?? "system-ui");
2855
- return {
2856
- display: { family: displayName, class: fontClass(displayName) },
2857
- body: { family: bodyName, class: fontClass(bodyName) }
2858
- };
2859
- }
2860
- function median(values) {
2861
- if (values.length === 0) return null;
2862
- const sorted = [...values].sort((a, b) => a - b);
2863
- const mid = Math.floor(sorted.length / 2);
2864
- return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
2865
- }
2866
- function fingerprint(s) {
2867
- const effects = [];
2868
- if (s.effects.glass > 0) effects.push("glass-panel");
2869
- if (s.effects.gradientText > 0) effects.push("gradient-text");
2870
- if (s.effects.glows > 0 || s.effects.gradients.some((g) => g.radial)) effects.push("radial-spotlight-glow");
2871
- if (s.effects.gridBackgrounds > 0) effects.push("grid-background");
2872
- if (s.effects.marquees > 0) effects.push("marquee");
2873
- if (s.effects.hairlineShadowCards >= 3) effects.push("thin-border-wide-shadow");
2874
- if (s.effects.eyebrowChip) effects.push("hero-eyebrow-chip");
2875
- if (s.motion.introOverlay) effects.push("intro-cinematic");
2876
- const below = s.sections.filter((x) => x.top > s.viewport.height).length;
2877
- return {
2878
- version: FINGERPRINT_VERSION,
2879
- accent: accentOf(s),
2880
- ground: oklch(s.ground) ?? { l: 1, c: 0, h: 0 },
2881
- ...faces(s),
2882
- roundness: median(s.controls.map((c) => Math.min(0.5, c.radiusPx / Math.max(1, c.heightPx)))),
2883
- motion: below ? Math.min(1, s.motion.hiddenSections / below) : 0,
2884
- effects: effects.sort(),
2885
- layout: s.sections.map((x) => x.kind)
2886
- };
2887
- }
2888
-
2889
3278
  // src/audit/collect.ts
2890
3279
  function collectInPage() {
2891
3280
  const vw = window.innerWidth;
@@ -2983,18 +3372,26 @@ function collectInPage() {
2983
3372
  top: Math.round(box(h).top)
2984
3373
  };
2985
3374
  });
3375
+ const isButtonEl = (el) => el.tagName === "BUTTON" || el.tagName === "INPUT" && /^(submit|button)$/i.test(el.type);
3376
+ const isControl = (el) => {
3377
+ const isButton = isButtonEl(el);
3378
+ if (!isButton && el.tagName !== "A") return false;
3379
+ if (!shown(el)) return false;
3380
+ const cs = style(el);
3381
+ const b = box(el);
3382
+ const label = (el.textContent ?? el.value ?? "").replace(/\s+/g, " ").trim();
3383
+ if (!label || b.height < 24 || b.height > 90) return false;
3384
+ if (!isButton && !(painted(cs.backgroundColor) || px(cs.borderTopWidth) >= 1)) return false;
3385
+ if (!isButton && px(cs.paddingLeft) < 8) return false;
3386
+ return true;
3387
+ };
2986
3388
  const controls = [];
2987
3389
  for (const el of all) {
2988
- const tag = el.tagName;
2989
- const isButton = tag === "BUTTON" || tag === "INPUT" && /^(submit|button)$/i.test(el.type);
2990
- if (!isButton && tag !== "A") continue;
2991
- if (!shown(el)) continue;
3390
+ if (!isControl(el)) continue;
3391
+ const isButton = isButtonEl(el);
2992
3392
  const cs = style(el);
2993
3393
  const b = box(el);
2994
3394
  const label = (el.textContent ?? el.value ?? "").replace(/\s+/g, " ").trim();
2995
- if (!label || b.height < 24 || b.height > 90) continue;
2996
- if (!isButton && !(painted(cs.backgroundColor) || px(cs.borderTopWidth) >= 1)) continue;
2997
- if (!isButton && px(cs.paddingLeft) < 8) continue;
2998
3395
  const r = cs.borderTopLeftRadius;
2999
3396
  const radius = r.endsWith("%") ? parseFloat(r) / 100 * b.height : px(r);
3000
3397
  controls.push({
@@ -3074,20 +3471,122 @@ function collectInPage() {
3074
3471
  }
3075
3472
  return best;
3076
3473
  };
3077
- const sections = blocks.slice(0, 40).map((el, index) => {
3474
+ const backgroundOf = (el) => {
3475
+ for (let n = el; n && n !== document.documentElement; n = n.parentElement) {
3476
+ const c = style(n).backgroundColor;
3477
+ if (painted(c)) return c;
3478
+ }
3479
+ return ground;
3480
+ };
3481
+ const geometryOf = (el, b) => {
3482
+ const leaves = Array.from(el.querySelectorAll("*")).slice(0, 1500).filter((n) => (ownText(n).length > 1 || /^(IMG|SVG|VIDEO|PICTURE|BUTTON|INPUT|TEXTAREA|SELECT)$/i.test(n.tagName)) && shown(n)).slice(0, 400);
3483
+ const centreX = b.left + b.width / 2;
3484
+ let left = 0;
3485
+ let right = 0;
3486
+ let covered = 0;
3487
+ let minX = Infinity;
3488
+ let maxX = -Infinity;
3489
+ let textBlocks = 0;
3490
+ let centred = 0;
3491
+ for (const n of leaves) {
3492
+ const r = box(n);
3493
+ const area = r.width * r.height;
3494
+ covered += area;
3495
+ minX = Math.min(minX, r.left);
3496
+ maxX = Math.max(maxX, r.left + r.width);
3497
+ const split = Math.max(0, Math.min(r.width, centreX - r.left));
3498
+ left += split * r.height;
3499
+ right += (r.width - split) * r.height;
3500
+ if (ownText(n).length > 1) {
3501
+ textBlocks += 1;
3502
+ const mid = r.left + r.width / 2;
3503
+ if (style(n).textAlign === "center" || Math.abs(mid - centreX) < vw * 0.03 && r.width < b.width * 0.8) centred += 1;
3504
+ }
3505
+ }
3506
+ const round = (v) => Math.round(v * 1e3) / 1e3;
3507
+ return {
3508
+ centredShare: textBlocks ? round(centred / textBlocks) : 0,
3509
+ mirrorSymmetry: left + right > 0 ? round(1 - Math.abs(left - right) / (left + right)) : 1,
3510
+ whitespaceRatio: round(Math.max(0, 1 - Math.min(1, covered / Math.max(1, b.width * b.height)))),
3511
+ contentWidthRatio: leaves.length ? round(Math.min(1, (maxX - minX) / vw)) : 0,
3512
+ background: backgroundOf(el),
3513
+ controls: Array.from(el.querySelectorAll("a, button, input")).slice(0, 200).filter(isControl).length
3514
+ };
3515
+ };
3516
+ const CURRENCY = /[£$€]\s?\d/;
3517
+ const roleOf = (el, kind, geo2, b, cards, iconCards, last) => {
3518
+ if (kind === "marquee" || kind === "hero") return kind;
3519
+ const heading = (el.querySelector("h1, h2, h3")?.textContent ?? "").toLowerCase();
3520
+ const leaves = Array.from(el.querySelectorAll("*")).slice(0, 1500);
3521
+ const own = leaves.map(ownText);
3522
+ const questions = own.filter((t) => /\?$/.test(t) && t.length > 8).length;
3523
+ if (el.querySelectorAll("details").length >= 3 || el.querySelectorAll("[aria-expanded]").length >= 3 || /\bfaq|frequently asked|questions\b/.test(heading) && questions >= 3) return "faq";
3524
+ const prices = own.filter((t) => CURRENCY.test(t) && t.length < 40).length;
3525
+ if (prices >= 2 && (cards >= 2 || /pric|plan|package/.test(heading))) return "pricing";
3526
+ const quotes = el.querySelectorAll("blockquote, q").length;
3527
+ if (quotes >= 2 || /testimonial|review|what (?:our )?(?:clients|customers|people) say/.test(heading)) return "testimonials";
3528
+ const steps = Math.max(0, ...Array.from(el.querySelectorAll("ol")).map((ol) => ol.children.length));
3529
+ const numbered = own.filter((t) => /^(?:step\s*)?0?[1-9][.:]?$/i.test(t)).length;
3530
+ if (steps >= 3 || numbered >= 3 || /how it works|our process|\bsteps?\b/.test(heading)) return "process";
3531
+ const form = el.querySelector("form");
3532
+ const fields = form ? form.querySelectorAll("input:not([type=hidden]):not([type=submit]), textarea, select").length : 0;
3533
+ if (fields >= 2 || /contact|get in touch/.test(heading)) return "contact";
3534
+ const portraits = Array.from(el.querySelectorAll("img")).filter((i) => {
3535
+ const r = box(i);
3536
+ return r.width >= 80 && r.width <= 420 && Math.abs(r.width - r.height) < r.width * 0.25;
3537
+ }).length;
3538
+ if (portraits >= 3 && /team|people|meet|who we are/.test(heading)) return "team";
3539
+ if (kind === "stats" || kind === "logos") return kind;
3540
+ const words = (el.textContent ?? "").replace(/\s+/g, " ").trim().length;
3541
+ const setApart = geo2.background !== ground || geo2.centredShare >= 0.6;
3542
+ if (setApart && heading && b.height <= vh * 0.9 && geo2.controls >= 1 && geo2.controls <= 2 && words < 400 && cards < 3) return last ? "footer-cta" : "cta-band";
3543
+ if (cards >= 3 && iconCards >= 2) return "features";
3544
+ return kind;
3545
+ };
3546
+ const partsOf = (el) => {
3547
+ const inside = Array.from(el.querySelectorAll("*")).slice(0, 1500).filter(shown);
3548
+ const badges = [];
3549
+ for (const n of inside) {
3550
+ const t = ownText(n);
3551
+ if (t.length < 2 || t.length > 24 || badges.length >= 5) continue;
3552
+ const cs = style(n);
3553
+ const r = box(n);
3554
+ const radius = px(cs.borderTopLeftRadius);
3555
+ const drawn = painted(cs.backgroundColor) || px(cs.borderTopWidth) >= 1;
3556
+ if (drawn && r.height <= 40 && r.width <= 240 && radius >= r.height / 3 && !isControl(n)) badges.push(t);
3557
+ }
3558
+ const avatars = inside.filter((n) => {
3559
+ if (n.tagName !== "IMG") return false;
3560
+ const r = box(n);
3561
+ const rad = style(n).borderTopLeftRadius;
3562
+ const round = rad.endsWith("%") ? parseFloat(rad) >= 40 : px(rad) >= r.width * 0.4;
3563
+ return r.width <= 96 && r.width >= 16 && Math.abs(r.width - r.height) <= r.width * 0.15 && round;
3564
+ }).length;
3565
+ const carousel = inside.some((n) => {
3566
+ const cs = style(n);
3567
+ if (n.getAttribute("aria-roledescription") === "carousel" || cs.scrollSnapType && cs.scrollSnapType !== "none") return true;
3568
+ if (/^(auto|scroll|hidden)$/.test(cs.overflowX) && n.children.length >= 3 && n.scrollWidth > n.clientWidth * 1.2) return true;
3569
+ return /^(BUTTON|A)$/.test(n.tagName) && /\b(prev|previous|next)\b/i.test(n.getAttribute("aria-label") ?? "");
3570
+ });
3571
+ return { badges, avatars, carousel };
3572
+ };
3573
+ const kept = blocks.slice(0, 40);
3574
+ const sections = kept.map((el, index) => {
3078
3575
  const b = box(el);
3079
3576
  const heading = el.querySelector("h1, h2, h3");
3080
3577
  const label = (heading?.textContent ?? el.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, 60);
3081
- const images = Array.from(el.querySelectorAll("img, svg")).filter((i) => shown(i) && box(i).height <= 90);
3578
+ const images2 = Array.from(el.querySelectorAll("img, svg")).filter((i) => shown(i) && box(i).height <= 90);
3082
3579
  const textChars = (el.textContent ?? "").replace(/\s+/g, "").length;
3083
3580
  const numbers = Array.from(el.querySelectorAll("*")).filter((n) => /^[£$€]?\d[\d,.]*\s?(?:[%+kKmM★]|\/5|\+)?$/.test(ownText(n)) && px(style(n).fontSize) >= 24).length;
3084
3581
  const { cards, iconCards } = cardsIn(el);
3085
3582
  let kind = "text";
3086
3583
  if (marqueeTargets.some((t) => el.contains(t))) kind = "marquee";
3087
3584
  else if (h1 && el.contains(h1) || index === 0 && b.top < vh) kind = "hero";
3088
- else if (images.length >= 4 && textChars < 300) kind = "logos";
3585
+ else if (images2.length >= 4 && textChars < 300) kind = "logos";
3089
3586
  else if (numbers >= 3 && textChars < 600) kind = "stats";
3090
3587
  else if (cards >= 3) kind = "cards";
3588
+ const geometry = geometryOf(el, b);
3589
+ const parts2 = partsOf(el);
3091
3590
  return {
3092
3591
  top: Math.round(b.top),
3093
3592
  height: Math.round(b.height),
@@ -3095,7 +3594,11 @@ function collectInPage() {
3095
3594
  label,
3096
3595
  cards,
3097
3596
  iconCards,
3098
- hiddenAtLoad: b.top > vh && hiddenAtLoad(el)
3597
+ hiddenAtLoad: b.top > vh && hiddenAtLoad(el),
3598
+ role: roleOf(el, kind, geometry, b, cards, iconCards, index === kept.length - 1),
3599
+ geometry,
3600
+ ...parts2,
3601
+ figures: numbers
3099
3602
  };
3100
3603
  });
3101
3604
  if (header && sections.length === 0) {
@@ -3177,6 +3680,81 @@ function collectInPage() {
3177
3680
  const width = para.getBoundingClientRect().width - px(cs.paddingLeft) - px(cs.paddingRight);
3178
3681
  if (avg > 0 && width > 0) bodyLineLengthCh = Math.round(width / avg);
3179
3682
  }
3683
+ const unwrap = (raw) => {
3684
+ if (raw.startsWith("data:")) return raw.slice(0, 64);
3685
+ try {
3686
+ const u = new URL(raw, location.href);
3687
+ const inner = /\/_(?:next|vercel)\/image$/.test(u.pathname) ? u.searchParams.get("url") : null;
3688
+ if (inner) return new URL(inner, location.href).href;
3689
+ const cf = u.pathname.match(/^\/cdn-cgi\/image\/[^/]+\/(.+)$/);
3690
+ if (cf) return /^https?:\/\//.test(cf[1]) ? cf[1] : new URL(`/${cf[1]}`, location.href).href;
3691
+ return u.href;
3692
+ } catch {
3693
+ return raw.slice(0, 200);
3694
+ }
3695
+ };
3696
+ const roundBox = (el, w) => {
3697
+ const rad = style(el).borderTopLeftRadius;
3698
+ return rad.endsWith("%") ? parseFloat(rad) >= 40 : px(rad) >= w * 0.4;
3699
+ };
3700
+ const sectionOf = (el) => {
3701
+ const i = kept.findIndex((k) => k.contains(el));
3702
+ return i === -1 ? null : i;
3703
+ };
3704
+ const roleOfImage = (el, src, w, h, alt) => {
3705
+ const vector = /\.svg(?:[?#]|$)/i.test(src) || src.startsWith("data:image/svg");
3706
+ const square = Math.abs(w - h) <= w * 0.15;
3707
+ if (w >= 16 && w <= 96 && square && (roundBox(el, w) || el.parentElement !== null && roundBox(el.parentElement, w))) return "avatar";
3708
+ const section = sectionOf(el);
3709
+ const hint = `${alt ?? ""} ${src} ${typeof el.className === "string" ? el.className : ""}`;
3710
+ if (/\blogo\b/i.test(hint) || section !== null && sections[section]?.kind === "logos" || el.closest("header, footer, nav") && h <= 120) return "logo";
3711
+ if (Math.max(w, h) <= (vector ? 120 : 72)) return "icon";
3712
+ if (vector) return "illustration";
3713
+ return w >= 160 && h >= 120 ? "photo" : "icon";
3714
+ };
3715
+ const images = [];
3716
+ const seenImage = /* @__PURE__ */ new Set();
3717
+ const addImage = (el, raw, alt, decorative, background) => {
3718
+ const b = box(el);
3719
+ if (!raw || b.width < 8 || b.height < 8) return;
3720
+ const src = unwrap(raw);
3721
+ const key = `${src} ${Math.round(b.top)} ${Math.round(b.left)}`;
3722
+ if (seenImage.has(key)) return;
3723
+ seenImage.add(key);
3724
+ let host = null;
3725
+ try {
3726
+ host = src.startsWith("data:") ? null : new URL(src).hostname;
3727
+ } catch {
3728
+ host = null;
3729
+ }
3730
+ images.push({
3731
+ src,
3732
+ host,
3733
+ width: Math.round(b.width),
3734
+ height: Math.round(b.height),
3735
+ top: Math.round(b.top),
3736
+ role: roleOfImage(el, src, b.width, b.height, alt),
3737
+ alt,
3738
+ decorative,
3739
+ section: sectionOf(el),
3740
+ background
3741
+ });
3742
+ };
3743
+ for (const img of Array.from(document.querySelectorAll("img")).slice(0, 400)) {
3744
+ if (!shown(img)) continue;
3745
+ const alt = img.getAttribute("alt");
3746
+ const decorative = alt === "" || img.getAttribute("aria-hidden") === "true" || /^(?:presentation|none)$/.test(img.getAttribute("role") ?? "");
3747
+ addImage(img, img.currentSrc || img.getAttribute("src") || "", alt, decorative, false);
3748
+ }
3749
+ for (const el of all) {
3750
+ const bgImage = style(el).backgroundImage || "";
3751
+ if (!bgImage.includes("url(")) continue;
3752
+ const b = box(el);
3753
+ if (b.width < 160 || b.height < 120 || !shown(el)) continue;
3754
+ const m = bgImage.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);
3755
+ if (m) addImage(el, m[1], null, true, true);
3756
+ }
3757
+ images.sort((a, b) => b.width * b.height - a.width * a.height);
3180
3758
  const toList = (m) => Array.from(m, ([value, v]) => ({ value, area: Math.round(v.area), chars: v.chars })).sort((a, b) => b.area - a.area || b.chars - a.chars);
3181
3759
  const nums = (s) => Array.from(s).sort((a, b) => a - b);
3182
3760
  return {
@@ -3188,7 +3766,15 @@ function collectInPage() {
3188
3766
  headings: headings2,
3189
3767
  controls,
3190
3768
  sections,
3769
+ rhythmVariance: (() => {
3770
+ const hs = sections.map((x) => x.height);
3771
+ if (hs.length < 2) return null;
3772
+ const mean = hs.reduce((t, v) => t + v, 0) / hs.length;
3773
+ const sd = Math.sqrt(hs.reduce((t, v) => t + (v - mean) ** 2, 0) / hs.length);
3774
+ return mean > 0 ? Math.round(sd / mean * 1e3) / 1e3 : null;
3775
+ })(),
3191
3776
  effects,
3777
+ images: images.slice(0, 60),
3192
3778
  motion: {
3193
3779
  hiddenSections: sections.filter((s) => s.hiddenAtLoad).length,
3194
3780
  sections: sections.length,
@@ -3221,7 +3807,192 @@ function overlayInPage() {
3221
3807
  return false;
3222
3808
  }
3223
3809
 
3810
+ // src/direction/png.ts
3811
+ var import_node_zlib = require("zlib");
3812
+ function decodePng(buf) {
3813
+ const sig = [137, 80, 78, 71, 13, 10, 26, 10];
3814
+ if (!sig.every((b, i) => buf[i] === b)) throw new Error("not a PNG");
3815
+ const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
3816
+ let pos = 8;
3817
+ let width = 0;
3818
+ let height = 0;
3819
+ let depth = 0;
3820
+ let colour = 0;
3821
+ let interlace = 0;
3822
+ const idat = [];
3823
+ while (pos < buf.length) {
3824
+ const len = view.getUint32(pos);
3825
+ const type = String.fromCharCode(...buf.subarray(pos + 4, pos + 8));
3826
+ const data = buf.subarray(pos + 8, pos + 8 + len);
3827
+ if (type === "IHDR") {
3828
+ width = view.getUint32(pos + 8);
3829
+ height = view.getUint32(pos + 12);
3830
+ depth = data[8];
3831
+ colour = data[9];
3832
+ interlace = data[12];
3833
+ } else if (type === "IDAT") idat.push(data);
3834
+ else if (type === "IEND") break;
3835
+ pos += 12 + len;
3836
+ }
3837
+ const channels = { 0: 1, 2: 3, 4: 2, 6: 4 }[colour];
3838
+ if (depth !== 8 || !channels || interlace !== 0) throw new Error(`unsupported PNG (depth ${depth}, colour type ${colour}${interlace ? ", interlaced" : ""}); export it as 8-bit RGB`);
3839
+ const raw = (0, import_node_zlib.inflateSync)(Buffer.concat(idat.map((d) => Buffer.from(d))));
3840
+ const stride = width * channels;
3841
+ const out = new Uint8Array(width * height * 4);
3842
+ const prev = new Uint8Array(stride);
3843
+ const line = new Uint8Array(stride);
3844
+ for (let y = 0; y < height; y += 1) {
3845
+ const filter = raw[y * (stride + 1)];
3846
+ const src = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1));
3847
+ for (let x = 0; x < stride; x += 1) {
3848
+ const a = x >= channels ? line[x - channels] : 0;
3849
+ const b = prev[x];
3850
+ const c = x >= channels ? prev[x - channels] : 0;
3851
+ let v = src[x];
3852
+ if (filter === 1) v += a;
3853
+ else if (filter === 2) v += b;
3854
+ else if (filter === 3) v += a + b >> 1;
3855
+ else if (filter === 4) {
3856
+ const p = a + b - c;
3857
+ const pa = Math.abs(p - a);
3858
+ const pb = Math.abs(p - b);
3859
+ const pc = Math.abs(p - c);
3860
+ v += pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
3861
+ }
3862
+ line[x] = v & 255;
3863
+ }
3864
+ for (let x = 0; x < width; x += 1) {
3865
+ const i = x * channels;
3866
+ const o = (y * width + x) * 4;
3867
+ if (channels >= 3) {
3868
+ out[o] = line[i];
3869
+ out[o + 1] = line[i + 1];
3870
+ out[o + 2] = line[i + 2];
3871
+ out[o + 3] = channels === 4 ? line[i + 3] : 255;
3872
+ } else {
3873
+ out[o] = out[o + 1] = out[o + 2] = line[i];
3874
+ out[o + 3] = channels === 2 ? line[i + 1] : 255;
3875
+ }
3876
+ }
3877
+ prev.set(line);
3878
+ }
3879
+ return { width, height, rgba: out };
3880
+ }
3881
+
3882
+ // src/snapshot/visual.ts
3883
+ var EDGE_STEP = 32;
3884
+ function visualMeasures(img, maxSamples = 1e6) {
3885
+ const { width: w, height: h, rgba } = img;
3886
+ if (w < 2 || h < 2 || rgba.length < w * h * 4) throw new Error(`visualMeasures: ${w}x${h} image with ${rgba.length} bytes`);
3887
+ const step = Math.max(1, Math.ceil(Math.sqrt(w * h / maxSamples)));
3888
+ const lum = (x, y) => {
3889
+ const i = (y * w + x) * 4;
3890
+ return 0.2126 * rgba[i] + 0.7152 * rgba[i + 1] + 0.0722 * rgba[i + 2];
3891
+ };
3892
+ let n = 0;
3893
+ let sumRg = 0;
3894
+ let sumYb = 0;
3895
+ let sumRg2 = 0;
3896
+ let sumYb2 = 0;
3897
+ let edges = 0;
3898
+ let edgeN = 0;
3899
+ let asym = 0;
3900
+ let asymN = 0;
3901
+ for (let y = 0; y < h; y += step) {
3902
+ for (let x = 0; x < w; x += step) {
3903
+ const i = (y * w + x) * 4;
3904
+ const r = rgba[i];
3905
+ const g = rgba[i + 1];
3906
+ const b = rgba[i + 2];
3907
+ const rg = r - g;
3908
+ const yb = 0.5 * (r + g) - b;
3909
+ sumRg += rg;
3910
+ sumYb += yb;
3911
+ sumRg2 += rg * rg;
3912
+ sumYb2 += yb * yb;
3913
+ n += 1;
3914
+ const l = lum(x, y);
3915
+ if (x + step < w && y + step < h) {
3916
+ if (Math.abs(lum(x + step, y) - l) + Math.abs(lum(x, y + step) - l) > EDGE_STEP) edges += 1;
3917
+ edgeN += 1;
3918
+ }
3919
+ if (x < w / 2) {
3920
+ asym += Math.abs(l - lum(w - 1 - x, y));
3921
+ asymN += 1;
3922
+ }
3923
+ }
3924
+ }
3925
+ const meanRg = sumRg / n;
3926
+ const meanYb = sumYb / n;
3927
+ const sdRg = Math.sqrt(Math.max(0, sumRg2 / n - meanRg * meanRg));
3928
+ const sdYb = Math.sqrt(Math.max(0, sumYb2 / n - meanYb * meanYb));
3929
+ const colourfulness = Math.sqrt(sdRg ** 2 + sdYb ** 2) + 0.3 * Math.sqrt(meanRg ** 2 + meanYb ** 2);
3930
+ const round = (v, d = 3) => Math.round(v * 10 ** d) / 10 ** d;
3931
+ return {
3932
+ colourfulness: round(colourfulness, 1),
3933
+ edgeDensity: round(edgeN ? edges / edgeN : 0),
3934
+ symmetry: round(asymN ? 1 - asym / asymN / 255 : 1),
3935
+ width: w,
3936
+ height: h,
3937
+ sampled: n
3938
+ };
3939
+ }
3940
+
3941
+ // src/snapshot/provenance.ts
3942
+ var PROVENANCE_SCAN_BYTES = 256 * 1024;
3943
+ var AI_SOURCE_TYPES = ["compositeWithTrainedAlgorithmicMedia", "trainedAlgorithmicMedia"];
3944
+ var MARKER2 = new RegExp(`(?:${AI_SOURCE_TYPES.join("|")})`);
3945
+ var C2PA_BOX = /jumd[\s\S]{16,24}c2pa/;
3946
+ var C2PA_PNG = /caBX/;
3947
+ function latin1(bytes) {
3948
+ let out = "";
3949
+ for (let i = 0; i < bytes.length; i += 8192) {
3950
+ out += String.fromCharCode(...bytes.subarray(i, Math.min(bytes.length, i + 8192)));
3951
+ }
3952
+ return out;
3953
+ }
3954
+ function xmpPackets(text) {
3955
+ const out = [];
3956
+ const open = /<x:xmpmeta\b|<\?xpacket begin/g;
3957
+ let m;
3958
+ while (m = open.exec(text)) {
3959
+ const close = text.indexOf(m[0].startsWith("<x:") ? "</x:xmpmeta>" : "<?xpacket end", m.index);
3960
+ out.push([m.index, close === -1 ? text.length : close]);
3961
+ if (close === -1) break;
3962
+ open.lastIndex = close;
3963
+ }
3964
+ return out;
3965
+ }
3966
+ function scanProvenance(bytes) {
3967
+ const head = bytes.subarray(0, PROVENANCE_SCAN_BYTES);
3968
+ const text = latin1(head);
3969
+ const c2pa = C2PA_BOX.test(text) || text.startsWith("\x89PNG") && C2PA_PNG.test(text);
3970
+ const m = MARKER2.exec(text);
3971
+ if (!m) return { digitalSourceType: null, source: null, c2pa, bytes: head.length };
3972
+ const inXmp = xmpPackets(text).some(([a, b]) => m.index >= a && m.index < b);
3973
+ return { digitalSourceType: m[0], source: inXmp ? "xmp" : c2pa ? "c2pa" : "other", c2pa, bytes: head.length };
3974
+ }
3975
+
3224
3976
  // src/audit/index.ts
3977
+ var PROVENANCE_MAX_IMAGES = 24;
3978
+ var PROVENANCE_BUDGET_MS = 2e4;
3979
+ async function readProvenance(page, images, timeoutMs) {
3980
+ if (!page.request) return;
3981
+ const deadline = Date.now() + PROVENANCE_BUDGET_MS;
3982
+ const wanted = [...new Set(images.filter((i) => i.role !== "icon" && i.role !== "logo" && /^https?:\/\//.test(i.src)).map((i) => i.src))].slice(0, PROVENANCE_MAX_IMAGES);
3983
+ for (const src of wanted) {
3984
+ const left = deadline - Date.now();
3985
+ if (left < 500) break;
3986
+ try {
3987
+ const res = await page.request.get(src, { headers: { Range: `bytes=0-${PROVENANCE_SCAN_BYTES - 1}` }, timeout: Math.min(timeoutMs, left) });
3988
+ if (!res.ok()) continue;
3989
+ const provenance = scanProvenance(await res.body());
3990
+ for (const image of images) if (image.src === src) image.provenance = provenance;
3991
+ } catch {
3992
+ }
3993
+ }
3994
+ }
3995
+ var VISUAL_MAX_HEIGHT = 6e3;
3225
3996
  async function loadPlaywright() {
3226
3997
  for (const name of ["playwright", "playwright-core"]) {
3227
3998
  try {
@@ -3239,12 +4010,24 @@ async function snapshotPage(page, url, options = {}) {
3239
4010
  await page.waitForTimeout(options.introWindowMs ?? 5e3);
3240
4011
  const late = await page.evaluate(overlayInPage).catch(() => false);
3241
4012
  const data = await page.evaluate(collectInPage);
4013
+ if (data.images && options.provenance !== false) await readProvenance(page, data.images, 8e3);
4014
+ let visual;
4015
+ if (page.screenshot && options.visual !== false) {
4016
+ try {
4017
+ const height = Math.min(data.pageHeight, VISUAL_MAX_HEIGHT);
4018
+ const png = await page.screenshot({ fullPage: true, type: "png", clip: { x: 0, y: 0, width: data.viewport.width, height } });
4019
+ visual = visualMeasures(decodePng(png));
4020
+ } catch {
4021
+ visual = void 0;
4022
+ }
4023
+ }
3242
4024
  return {
3243
4025
  version: SNAPSHOT_VERSION,
3244
4026
  url,
3245
4027
  capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
3246
4028
  ...data,
3247
- motion: { ...data.motion, introOverlay: early && !late }
4029
+ motion: { ...data.motion, introOverlay: early && !late },
4030
+ ...visual ? { visual } : {}
3248
4031
  };
3249
4032
  }
3250
4033
  async function launch(pw, url, options) {
@@ -3291,6 +4074,9 @@ async function audit(url, options = {}) {
3291
4074
  }
3292
4075
  // Annotate the CommonJS export names for ESM import in node:
3293
4076
  0 && (module.exports = {
4077
+ PROVENANCE_BUDGET_MS,
4078
+ PROVENANCE_MAX_IMAGES,
4079
+ VISUAL_MAX_HEIGHT,
3294
4080
  audit,
3295
4081
  collectInPage,
3296
4082
  loadPlaywright,