@domandigital/craft 0.12.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/CHANGELOG.md +20 -0
- package/CHARACTER.md +92 -1
- package/dist/{audit-5QWFLZ6L.js → audit-5TYDYRXV.js} +6 -3
- package/dist/audit.cjs +613 -88
- package/dist/audit.d.cts +81 -1
- package/dist/audit.d.ts +81 -1
- package/dist/audit.js +611 -88
- package/dist/{chunk-J3QUROJ5.js → chunk-3VTPI7BU.js} +9 -8
- package/dist/{chunk-ZKVJ7K6X.js → chunk-CZDOMIVS.js} +1 -1
- package/dist/chunk-ESCVTKPN.js +217 -0
- package/dist/{chunk-AL6MRG6V.js → chunk-GMVXADJ6.js} +2912 -2102
- package/dist/{chunk-PU5G5DUC.js → chunk-IMB4V34S.js} +26 -13
- package/dist/{chunk-CDAJUS5U.js → chunk-K2BZN4GA.js} +49 -14
- package/dist/{chunk-ULPI335S.js → chunk-ZLDA2SYB.js} +168 -8
- package/dist/{chunk-S3NZAVU6.js → chunk-ZZ5CKOJP.js} +1 -1
- package/dist/cli-BKJMLD3H.js +18 -0
- package/dist/{cli-ZPJIWVEP.js → cli-DRKAMFAH.js} +5 -7
- package/dist/{cli-C3JLFXMG.js → cli-ILH7OO5G.js} +4 -5
- package/dist/{cli-ZB2VJ7CY.js → cli-J5ECRCD4.js} +13 -15
- package/dist/cli-N2IDXH7W.js +20 -0
- package/dist/cli.js +2 -2
- package/dist/index.cjs +929 -401
- package/dist/index.d.cts +408 -196
- package/dist/index.d.ts +408 -196
- package/dist/index.js +911 -401
- package/package.json +1 -1
- package/word-lists.json +1 -1
- package/dist/chunk-LHGY43LL.js +0 -462
- package/dist/chunk-PZ4MF2VV.js +0 -117
- package/dist/cli-2DY3V3SF.js +0 -17
- package/dist/cli-QM2AQQMF.js +0 -19
package/dist/index.js
CHANGED
|
@@ -2250,14 +2250,14 @@ function contractionHits(ctx) {
|
|
|
2250
2250
|
for (const doc2 of documents(ctx)) {
|
|
2251
2251
|
if (doc2.words < 800) continue;
|
|
2252
2252
|
const text = doc2.blocks.map((b) => withoutHeadings(b.text)).join("\n");
|
|
2253
|
-
const
|
|
2254
|
-
const rate =
|
|
2253
|
+
const count3 = (text.match(CONTRACTION) ?? []).length;
|
|
2254
|
+
const rate = count3 * 1e3 / doc2.words;
|
|
2255
2255
|
if (rate < 1) {
|
|
2256
2256
|
const first = sentences(doc2)[0];
|
|
2257
2257
|
hits.push({
|
|
2258
2258
|
path: doc2.path,
|
|
2259
2259
|
offset: first?.offset ?? 0,
|
|
2260
|
-
message: `${
|
|
2260
|
+
message: `${count3} contraction${count3 === 1 ? "" : "s"} in ${thousands(doc2.words)} words. Prose with none reads stiff; formal legal pages are the exception`
|
|
2261
2261
|
});
|
|
2262
2262
|
}
|
|
2263
2263
|
}
|
|
@@ -2380,16 +2380,16 @@ function filler(words2, seed = 1, options = {}) {
|
|
|
2380
2380
|
return state % n;
|
|
2381
2381
|
};
|
|
2382
2382
|
const out = [];
|
|
2383
|
-
let
|
|
2383
|
+
let count3 = 0;
|
|
2384
2384
|
let i = 0;
|
|
2385
|
-
while (
|
|
2385
|
+
while (count3 < words2) {
|
|
2386
2386
|
const length = uniform ?? shape[i % shape.length];
|
|
2387
2387
|
const s = [];
|
|
2388
2388
|
for (let w = 0; w < length; w += 1) s.push(FILLER_WORDS[next(FILLER_WORDS.length)]);
|
|
2389
2389
|
if (contractions && i % 6 === 2) s.splice(1, 0, "we're");
|
|
2390
2390
|
s[0] = s[0].charAt(0).toUpperCase() + s[0].slice(1);
|
|
2391
2391
|
out.push(`${s.join(" ")}.`);
|
|
2392
|
-
|
|
2392
|
+
count3 += s.length;
|
|
2393
2393
|
i += 1;
|
|
2394
2394
|
}
|
|
2395
2395
|
const paragraphs = [];
|
|
@@ -4254,11 +4254,810 @@ var RENDERED_PATHS = {
|
|
|
4254
4254
|
}
|
|
4255
4255
|
};
|
|
4256
4256
|
|
|
4257
|
+
// src/fingerprint/index.ts
|
|
4258
|
+
var FINGERPRINT_VERSION = 2;
|
|
4259
|
+
var CHROMATIC = 0.03;
|
|
4260
|
+
var MIN_ACCENT_AREA = 2e4;
|
|
4261
|
+
var oklch = (value) => {
|
|
4262
|
+
const parsed = parseColour(value);
|
|
4263
|
+
return parsed && parsed.alpha > 0.5 ? parsed.oklch : null;
|
|
4264
|
+
};
|
|
4265
|
+
function accentOf(s) {
|
|
4266
|
+
const buttons = /* @__PURE__ */ new Map();
|
|
4267
|
+
for (const c of s.controls) {
|
|
4268
|
+
const o = oklch(c.background);
|
|
4269
|
+
if (o && o.c >= CHROMATIC) buttons.set(c.background, (buttons.get(c.background) ?? 0) + 1);
|
|
4270
|
+
}
|
|
4271
|
+
const topButton = [...buttons].sort((a, b) => b[1] - a[1])[0];
|
|
4272
|
+
if (topButton) return oklch(topButton[0]);
|
|
4273
|
+
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];
|
|
4274
|
+
if (bg) return bg.o;
|
|
4275
|
+
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];
|
|
4276
|
+
return text ? text.o : null;
|
|
4277
|
+
}
|
|
4278
|
+
function faces(s) {
|
|
4279
|
+
const byChars = [...s.fonts].sort((a, b) => b.chars - a.chars);
|
|
4280
|
+
const byDisplay = [...s.fonts].sort((a, b) => b.displayChars - a.displayChars);
|
|
4281
|
+
const bodyName = normaliseFamily(byChars[0]?.family ?? "system-ui");
|
|
4282
|
+
const displayName = normaliseFamily((byDisplay[0]?.displayChars ? byDisplay[0].family : byChars[0]?.family) ?? "system-ui");
|
|
4283
|
+
return {
|
|
4284
|
+
display: { family: displayName, class: fontClass(displayName) },
|
|
4285
|
+
body: { family: bodyName, class: fontClass(bodyName) }
|
|
4286
|
+
};
|
|
4287
|
+
}
|
|
4288
|
+
function median(values) {
|
|
4289
|
+
if (values.length === 0) return null;
|
|
4290
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
4291
|
+
const mid = Math.floor(sorted.length / 2);
|
|
4292
|
+
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
4293
|
+
}
|
|
4294
|
+
function fingerprint(s) {
|
|
4295
|
+
const effects = [];
|
|
4296
|
+
if (s.effects.glass > 0) effects.push("glass-panel");
|
|
4297
|
+
if (s.effects.gradientText > 0) effects.push("gradient-text");
|
|
4298
|
+
if (s.effects.glows > 0 || s.effects.gradients.some((g) => g.radial)) effects.push("radial-spotlight-glow");
|
|
4299
|
+
if (s.effects.gridBackgrounds > 0) effects.push("grid-background");
|
|
4300
|
+
if (s.effects.marquees > 0) effects.push("marquee");
|
|
4301
|
+
if (s.effects.hairlineShadowCards >= 3) effects.push("thin-border-wide-shadow");
|
|
4302
|
+
if (s.effects.eyebrowChip) effects.push("hero-eyebrow-chip");
|
|
4303
|
+
if (s.motion.introOverlay) effects.push("intro-cinematic");
|
|
4304
|
+
const below = s.sections.filter((x) => x.top > s.viewport.height).length;
|
|
4305
|
+
return {
|
|
4306
|
+
version: FINGERPRINT_VERSION,
|
|
4307
|
+
accent: accentOf(s),
|
|
4308
|
+
ground: oklch(s.ground) ?? { l: 1, c: 0, h: 0 },
|
|
4309
|
+
...faces(s),
|
|
4310
|
+
roundness: median(s.controls.map((c) => Math.min(0.5, c.radiusPx / Math.max(1, c.heightPx)))),
|
|
4311
|
+
motion: below ? Math.min(1, s.motion.hiddenSections / below) : 0,
|
|
4312
|
+
effects: effects.sort(),
|
|
4313
|
+
layout: s.sections.map((x) => x.kind),
|
|
4314
|
+
...s.sections.length > 0 && s.sections.every((x) => x.role && x.geometry) ? {
|
|
4315
|
+
sections: s.sections.map((x) => ({
|
|
4316
|
+
role: x.role,
|
|
4317
|
+
centred: x.geometry.centredShare,
|
|
4318
|
+
width: x.geometry.contentWidthRatio,
|
|
4319
|
+
symmetry: x.geometry.mirrorSymmetry,
|
|
4320
|
+
controls: x.geometry.controls,
|
|
4321
|
+
cards: x.cards,
|
|
4322
|
+
background: x.geometry.background === s.ground ? null : oklch(x.geometry.background),
|
|
4323
|
+
badges: (x.badges ?? []).map((b) => b.toLowerCase()),
|
|
4324
|
+
avatars: x.avatars ?? 0,
|
|
4325
|
+
carousel: x.carousel ?? false,
|
|
4326
|
+
figures: x.figures ?? 0
|
|
4327
|
+
}))
|
|
4328
|
+
} : {}
|
|
4329
|
+
};
|
|
4330
|
+
}
|
|
4331
|
+
var DISTANCE_WEIGHTS = { accent: 0.25, type: 0.25, ground: 0.1, shape: 0.1, motion: 0.1, effects: 0.1, layout: 0.1 };
|
|
4332
|
+
function levenshtein(a, b, cost = (x, y) => x === y ? 0 : 1) {
|
|
4333
|
+
const row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
4334
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
4335
|
+
let prev = row[0];
|
|
4336
|
+
row[0] = i;
|
|
4337
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
4338
|
+
const cur = row[j];
|
|
4339
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + cost(a[i - 1], b[j - 1]));
|
|
4340
|
+
prev = cur;
|
|
4341
|
+
}
|
|
4342
|
+
}
|
|
4343
|
+
return row[b.length];
|
|
4344
|
+
}
|
|
4345
|
+
function sectionCost(x, y) {
|
|
4346
|
+
if (x.role !== y.role) return 1;
|
|
4347
|
+
return Math.min(0.5, (Math.abs(x.centred - y.centred) + Math.abs(x.width - y.width)) / 2);
|
|
4348
|
+
}
|
|
4349
|
+
function layoutDistance(a, b) {
|
|
4350
|
+
if (a.sections && b.sections) {
|
|
4351
|
+
const longest2 = Math.max(a.sections.length, b.sections.length);
|
|
4352
|
+
return longest2 === 0 ? 0 : levenshtein(a.sections, b.sections, sectionCost) / longest2;
|
|
4353
|
+
}
|
|
4354
|
+
const longest = Math.max(a.layout.length, b.layout.length);
|
|
4355
|
+
return longest === 0 ? 0 : levenshtein(a.layout, b.layout) / longest;
|
|
4356
|
+
}
|
|
4357
|
+
var clamp = (n) => Math.max(0, Math.min(1, n));
|
|
4358
|
+
function faceDistance(a, b) {
|
|
4359
|
+
if (a.family.toLowerCase() === b.family.toLowerCase()) return 0;
|
|
4360
|
+
return a.class === b.class ? 0.5 : 1;
|
|
4361
|
+
}
|
|
4362
|
+
function fingerprintDistance(a, b) {
|
|
4363
|
+
const accent = a.accent && b.accent ? clamp(deltaEOk(a.accent, b.accent) / 0.3) : a.accent || b.accent ? 1 : 0;
|
|
4364
|
+
const ground = clamp(deltaEOk(a.ground, b.ground) / 0.15);
|
|
4365
|
+
const type = 0.6 * faceDistance(a.display, b.display) + 0.4 * faceDistance(a.body, b.body);
|
|
4366
|
+
const shape = a.roundness === null || b.roundness === null ? a.roundness === b.roundness ? 0 : 0.5 : clamp(Math.abs(a.roundness - b.roundness) / 0.5);
|
|
4367
|
+
const motion = clamp(Math.abs(a.motion - b.motion));
|
|
4368
|
+
const union = /* @__PURE__ */ new Set([...a.effects, ...b.effects]);
|
|
4369
|
+
const shared = a.effects.filter((e) => b.effects.includes(e)).length;
|
|
4370
|
+
const effects = union.size === 0 ? 0 : 1 - shared / union.size;
|
|
4371
|
+
const layout = layoutDistance(a, b);
|
|
4372
|
+
const parts2 = { accent, ground, type, shape, motion, effects, layout };
|
|
4373
|
+
const total = Object.keys(DISTANCE_WEIGHTS).reduce((sum, k) => sum + DISTANCE_WEIGHTS[k] * parts2[k], 0);
|
|
4374
|
+
return { total: Math.round(total * 1e3) / 1e3, parts: parts2 };
|
|
4375
|
+
}
|
|
4376
|
+
function nearest(target2, set, k = set.length) {
|
|
4377
|
+
return set.map((item) => ({ id: item.id, distance: fingerprintDistance(target2, item.fingerprint) })).sort((x, y) => x.distance.total - y.distance.total).slice(0, k);
|
|
4378
|
+
}
|
|
4379
|
+
|
|
4380
|
+
// src/null/index.ts
|
|
4381
|
+
var NULL_VERSION = 1;
|
|
4382
|
+
function nullPrompt(brief) {
|
|
4383
|
+
return [
|
|
4384
|
+
`Build the home page for this business: ${brief.trim()}`,
|
|
4385
|
+
"",
|
|
4386
|
+
"Write it as one complete, self-contained HTML file. You may load fonts and libraries from a CDN. Use real copy, not placeholder text. Reply with the HTML only."
|
|
4387
|
+
].join("\n");
|
|
4388
|
+
}
|
|
4389
|
+
function extractHtml(reply) {
|
|
4390
|
+
const start = reply.search(/<!doctype html|<html[\s>]/i);
|
|
4391
|
+
if (start < 0) return null;
|
|
4392
|
+
const end = reply.toLowerCase().lastIndexOf("</html>");
|
|
4393
|
+
const html = end > start ? reply.slice(start, end + "</html>".length) : reply.slice(start).replace(/\s*```\s*$/, "");
|
|
4394
|
+
return html.length > 200 ? html : null;
|
|
4395
|
+
}
|
|
4396
|
+
var MIN_RUNS = 5;
|
|
4397
|
+
var TYPICAL_AT = 0.1;
|
|
4398
|
+
function meanNearest(distances, k) {
|
|
4399
|
+
const sorted = [...distances].sort((a, b) => a - b).slice(0, k);
|
|
4400
|
+
return sorted.reduce((s, d) => s + d, 0) / sorted.length;
|
|
4401
|
+
}
|
|
4402
|
+
function median2(values) {
|
|
4403
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
4404
|
+
const mid = Math.floor(sorted.length / 2);
|
|
4405
|
+
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
4406
|
+
}
|
|
4407
|
+
function typicality(target2, runs, k = 3) {
|
|
4408
|
+
if (runs.length < MIN_RUNS) throw new Error(`a null model needs at least ${MIN_RUNS} runs; this one has ${runs.length}`);
|
|
4409
|
+
const kk = Math.min(k, runs.length - 1);
|
|
4410
|
+
const toTarget = runs.map((r) => ({ id: r.id, distance: fingerprintDistance(target2, r.fingerprint).total }));
|
|
4411
|
+
const distance = meanNearest(
|
|
4412
|
+
toTarget.map((t) => t.distance),
|
|
4413
|
+
kk
|
|
4414
|
+
);
|
|
4415
|
+
const loo = runs.map(
|
|
4416
|
+
(r, i) => meanNearest(
|
|
4417
|
+
runs.filter((_, j) => j !== i).map((o) => fingerprintDistance(r.fingerprint, o.fingerprint).total),
|
|
4418
|
+
kk
|
|
4419
|
+
)
|
|
4420
|
+
);
|
|
4421
|
+
const score = loo.filter((d) => d >= distance).length / loo.length;
|
|
4422
|
+
return {
|
|
4423
|
+
score: Math.round(score * 100) / 100,
|
|
4424
|
+
typical: score >= TYPICAL_AT,
|
|
4425
|
+
distance: Math.round(distance * 1e3) / 1e3,
|
|
4426
|
+
baseline: Math.round(median2(loo) * 1e3) / 1e3,
|
|
4427
|
+
nearest: toTarget.sort((a, b) => a.distance - b.distance).slice(0, kk),
|
|
4428
|
+
shared: sharedChoices(target2, runs)
|
|
4429
|
+
};
|
|
4430
|
+
}
|
|
4431
|
+
var HUES = [
|
|
4432
|
+
["red", 0, 45],
|
|
4433
|
+
["orange", 45, 75],
|
|
4434
|
+
["yellow", 75, 110],
|
|
4435
|
+
["green", 110, 165],
|
|
4436
|
+
["teal", 165, 215],
|
|
4437
|
+
["blue", 215, 265],
|
|
4438
|
+
["violet", 265, 315],
|
|
4439
|
+
["pink", 315, 360]
|
|
4440
|
+
];
|
|
4441
|
+
function hueName(o) {
|
|
4442
|
+
if (!o) return "none";
|
|
4443
|
+
if (o.c < 0.03) return "neutral";
|
|
4444
|
+
return HUES.find(([, lo, hi]) => o.h >= lo && o.h < hi)?.[0] ?? "red";
|
|
4445
|
+
}
|
|
4446
|
+
function groundName(o) {
|
|
4447
|
+
if (o.l < 0.3) return "dark";
|
|
4448
|
+
if (isCream(o)) return "cream";
|
|
4449
|
+
if (o.l >= 0.97 && o.c < 0.012) return "white";
|
|
4450
|
+
return o.c < 0.02 ? "grey" : "tinted";
|
|
4451
|
+
}
|
|
4452
|
+
function shapeName(roundness) {
|
|
4453
|
+
if (roundness === null) return "no buttons";
|
|
4454
|
+
if (roundness >= 0.45) return "pill";
|
|
4455
|
+
return roundness >= 0.15 ? "soft" : "square";
|
|
4456
|
+
}
|
|
4457
|
+
function choicesOf(fp) {
|
|
4458
|
+
return {
|
|
4459
|
+
display: [fp.display.family],
|
|
4460
|
+
body: [fp.body.family],
|
|
4461
|
+
accent: [hueName(fp.accent)],
|
|
4462
|
+
ground: [groundName(fp.ground)],
|
|
4463
|
+
shape: [shapeName(fp.roundness)],
|
|
4464
|
+
motion: [fp.motion >= 0.6 ? "reveals most sections" : fp.motion > 0 ? "reveals some sections" : "no scroll reveals"],
|
|
4465
|
+
effects: fp.effects,
|
|
4466
|
+
opening: [fp.layout.slice(0, 3).join(" > ") || "none"]
|
|
4467
|
+
};
|
|
4468
|
+
}
|
|
4469
|
+
function sharedChoices(target2, runs) {
|
|
4470
|
+
const mine = choicesOf(target2);
|
|
4471
|
+
const all = runs.map((r) => choicesOf(r.fingerprint));
|
|
4472
|
+
const out = [];
|
|
4473
|
+
for (const [part, values] of Object.entries(mine)) {
|
|
4474
|
+
for (const value of values) {
|
|
4475
|
+
const count3 = all.filter((c) => c[part].includes(value)).length;
|
|
4476
|
+
if (count3 / runs.length >= 0.25) out.push({ part, value, runs: count3, of: runs.length });
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
return out.sort((a, b) => b.runs - a.runs);
|
|
4480
|
+
}
|
|
4481
|
+
var REFLEX_1 = new Set(REFLEX_FONTS_1.map((f4) => f4.toLowerCase()));
|
|
4482
|
+
var REFLEX_2 = new Set(REFLEX_FONTS_2.map((f4) => f4.toLowerCase()));
|
|
4483
|
+
function knownFor(kind, value, sample) {
|
|
4484
|
+
if (kind === "face") return REFLEX_1.has(value.toLowerCase()) ? "reflex-font" : REFLEX_2.has(value.toLowerCase()) ? "reflex-font-2" : null;
|
|
4485
|
+
if (kind === "accent" && value === "violet") return sample.some((f4) => f4.accent && isAiViolet(f4.accent)) ? "ai-violet" : null;
|
|
4486
|
+
if (kind === "ground" && value === "cream") return "cream-palette";
|
|
4487
|
+
if (kind === "shape" && value === "pill") return "pill-everything";
|
|
4488
|
+
if (kind === "motion" && value === "reveals most sections") return "reveal-everywhere";
|
|
4489
|
+
if (kind === "tell") return value;
|
|
4490
|
+
if (kind === "opening" && /^hero > (?:logos|stats)/.test(value)) return "hero-then-proof";
|
|
4491
|
+
return null;
|
|
4492
|
+
}
|
|
4493
|
+
var STOP = new Set(
|
|
4494
|
+
"a an the and or but of to in on for with at by from as is are be we our you your us it its this that these those will can all more get has have not no any".split(" ")
|
|
4495
|
+
);
|
|
4496
|
+
function grams(text) {
|
|
4497
|
+
const out = /* @__PURE__ */ new Set();
|
|
4498
|
+
for (const clause of text.toLowerCase().replace(/[’']/g, "'").split(/[.!?;:|()\u2013\u2014\u00b7•]+|,\s/)) {
|
|
4499
|
+
const words2 = clause.match(/[a-z][a-z'-]*/g) ?? [];
|
|
4500
|
+
for (let n = 2; n <= 4; n += 1) {
|
|
4501
|
+
for (let i = 0; i + n <= words2.length; i += 1) {
|
|
4502
|
+
const g = words2.slice(i, i + n);
|
|
4503
|
+
if (STOP.has(g[0]) || STOP.has(g[n - 1])) continue;
|
|
4504
|
+
if (g.filter((w) => !STOP.has(w)).length < 2) continue;
|
|
4505
|
+
out.add(g.join(" "));
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
return out;
|
|
4510
|
+
}
|
|
4511
|
+
var GRAMMAR = /* @__PURE__ */ new Set([
|
|
4512
|
+
"privacy policy",
|
|
4513
|
+
"cookie policy",
|
|
4514
|
+
"rights reserved",
|
|
4515
|
+
"all rights reserved",
|
|
4516
|
+
"terms of service",
|
|
4517
|
+
"terms and conditions",
|
|
4518
|
+
"terms conditions",
|
|
4519
|
+
"how it works",
|
|
4520
|
+
"what we do",
|
|
4521
|
+
"about us",
|
|
4522
|
+
"contact us",
|
|
4523
|
+
"get in touch",
|
|
4524
|
+
"opening hours",
|
|
4525
|
+
"read more",
|
|
4526
|
+
"learn more",
|
|
4527
|
+
"book now",
|
|
4528
|
+
"free quote",
|
|
4529
|
+
"our services",
|
|
4530
|
+
"quick links",
|
|
4531
|
+
"email address",
|
|
4532
|
+
"phone number",
|
|
4533
|
+
"full name",
|
|
4534
|
+
"first name",
|
|
4535
|
+
"last name",
|
|
4536
|
+
"your name",
|
|
4537
|
+
"your email",
|
|
4538
|
+
"send message"
|
|
4539
|
+
]);
|
|
4540
|
+
var LEGAL = /©|©|\bregistered (?:in|office|number)\b|\bcompany (?:no|number|reg)|\bvat (?:no|number|reg)/i;
|
|
4541
|
+
var NOISE = /\S+@\S+|https?:\/\/\S+|\b[\w-]+(?:\.[\w-]+)*\.(?:co\.uk|com|org|net|uk|io)\b|\b\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)\b|\d+/gi;
|
|
4542
|
+
function textGrams(text) {
|
|
4543
|
+
if (LEGAL.test(text)) return /* @__PURE__ */ new Set();
|
|
4544
|
+
const out = grams(text.replace(NOISE, " | "));
|
|
4545
|
+
for (const g of out) if (GRAMMAR.has(g)) out.delete(g);
|
|
4546
|
+
return out;
|
|
4547
|
+
}
|
|
4548
|
+
function properNouns(brief) {
|
|
4549
|
+
return new Set((brief.match(/\b[A-Z][a-z]+/g) ?? []).map((w) => w.toLowerCase()).filter((w) => !STOP.has(w)));
|
|
4550
|
+
}
|
|
4551
|
+
function harvest(models, options = {}) {
|
|
4552
|
+
const minShare = options.minShare ?? 0.25;
|
|
4553
|
+
const runs = models.flatMap((m, b) => m.runs.map((r) => ({ ...r, brief: b })));
|
|
4554
|
+
const of = runs.length;
|
|
4555
|
+
if (of === 0) return [];
|
|
4556
|
+
const multiBrief = models.length > 1;
|
|
4557
|
+
const sample = runs.map((r) => r.fingerprint);
|
|
4558
|
+
const tally = /* @__PURE__ */ new Map();
|
|
4559
|
+
const add = (kind, value, run, brief, example) => {
|
|
4560
|
+
const key = `${kind}\0${value}`;
|
|
4561
|
+
const t = tally.get(key) ?? { kind, value, runs: /* @__PURE__ */ new Set(), briefs: /* @__PURE__ */ new Set(), example };
|
|
4562
|
+
t.runs.add(run);
|
|
4563
|
+
t.briefs.add(brief);
|
|
4564
|
+
tally.set(key, t);
|
|
4565
|
+
};
|
|
4566
|
+
runs.forEach((r, i) => {
|
|
4567
|
+
const c = choicesOf(r.fingerprint);
|
|
4568
|
+
for (const f4 of /* @__PURE__ */ new Set([...c.display, ...c.body])) add("face", f4, i, r.brief);
|
|
4569
|
+
add("accent", c.accent[0], i, r.brief);
|
|
4570
|
+
add("ground", c.ground[0], i, r.brief);
|
|
4571
|
+
add("shape", c.shape[0], i, r.brief);
|
|
4572
|
+
add("motion", c.motion[0], i, r.brief);
|
|
4573
|
+
add("opening", c.opening[0], i, r.brief);
|
|
4574
|
+
for (const t of r.tells) add("tell", t, i, r.brief);
|
|
4575
|
+
});
|
|
4576
|
+
const out = [];
|
|
4577
|
+
for (const t of tally.values()) {
|
|
4578
|
+
if (t.runs.size / of < minShare) continue;
|
|
4579
|
+
if (t.kind === "accent" && (t.value === "none" || t.value === "neutral")) continue;
|
|
4580
|
+
if (t.kind === "shape" && t.value === "no buttons") continue;
|
|
4581
|
+
if (t.kind === "ground" && (t.value === "white" || t.value === "grey")) continue;
|
|
4582
|
+
if (t.kind === "motion" && t.value === "no scroll reveals") continue;
|
|
4583
|
+
out.push({ kind: t.kind, value: t.value, runs: t.runs.size, of, briefs: t.briefs.size, known: knownFor(t.kind, t.value, sample) });
|
|
4584
|
+
}
|
|
4585
|
+
const phraseMin = Math.max(3, Math.ceil(of * minShare * 0.4));
|
|
4586
|
+
const names = models.map((m) => properNouns(m.brief));
|
|
4587
|
+
const phrases2 = /* @__PURE__ */ new Map();
|
|
4588
|
+
runs.forEach((r, i) => {
|
|
4589
|
+
for (const text of r.copy) {
|
|
4590
|
+
for (const g of textGrams(text)) {
|
|
4591
|
+
if (g.split(" ").some((w) => names[r.brief].has(w))) continue;
|
|
4592
|
+
const p = phrases2.get(g) ?? { runs: /* @__PURE__ */ new Set(), briefs: /* @__PURE__ */ new Set(), example: text.trim().slice(0, 140) };
|
|
4593
|
+
p.runs.add(i);
|
|
4594
|
+
p.briefs.add(r.brief);
|
|
4595
|
+
phrases2.set(g, p);
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
});
|
|
4599
|
+
const kept = [...phrases2].filter(([, p]) => p.runs.size >= phraseMin && (!multiBrief || p.briefs.size >= 2)).sort((a, b) => b[1].runs.size - a[1].runs.size || b[0].length - a[0].length);
|
|
4600
|
+
const maximal = kept.filter(([g, p]) => !kept.some(([h, q]) => h !== g && h.includes(g) && q.runs.size >= 0.8 * p.runs.size));
|
|
4601
|
+
for (const [g, p] of maximal.slice(0, 40)) {
|
|
4602
|
+
out.push({ kind: "phrase", value: g, runs: p.runs.size, of, briefs: p.briefs.size, known: options.copyTell?.(g) ?? null, example: p.example });
|
|
4603
|
+
}
|
|
4604
|
+
const order = ["face", "accent", "ground", "shape", "motion", "opening", "tell", "phrase"];
|
|
4605
|
+
return out.sort((a, b) => order.indexOf(a.kind) - order.indexOf(b.kind) || b.runs - a.runs);
|
|
4606
|
+
}
|
|
4607
|
+
function hueSwatch(runs, hue) {
|
|
4608
|
+
const hits = runs.map((r) => r.fingerprint.accent).filter((o) => !!o && hueName(o) === hue);
|
|
4609
|
+
if (hits.length === 0) return null;
|
|
4610
|
+
const centre = hits.reduce((best, o) => hits.reduce((s, p) => s + deltaEOk(o, p), 0) < hits.reduce((s, p) => s + deltaEOk(best, p), 0) ? o : best);
|
|
4611
|
+
return formatHex(oklchToRgb(centre));
|
|
4612
|
+
}
|
|
4613
|
+
|
|
4614
|
+
// src/fingerprint/component.ts
|
|
4615
|
+
var PROMO_BADGE = /\b(?:most popular|popular|recommended|best value|best seller|bestseller|most chosen)\b/i;
|
|
4616
|
+
function componentsOf(fp, role) {
|
|
4617
|
+
return (fp.sections ?? []).filter((s) => s.role === role);
|
|
4618
|
+
}
|
|
4619
|
+
var clamp2 = (n) => Math.max(0, Math.min(1, n));
|
|
4620
|
+
var diff = (a, b, scale) => a === void 0 || b === void 0 ? null : clamp2(Math.abs(a - b) / scale);
|
|
4621
|
+
function componentDistance(a, b) {
|
|
4622
|
+
if (a.role !== b.role) return 1;
|
|
4623
|
+
const promo = (s) => (s.badges ?? []).some((t) => PROMO_BADGE.test(t));
|
|
4624
|
+
const parts2 = [
|
|
4625
|
+
diff(a.centred, b.centred, 1),
|
|
4626
|
+
diff(a.width, b.width, 0.5),
|
|
4627
|
+
diff(a.symmetry, b.symmetry, 0.5),
|
|
4628
|
+
diff(a.controls, b.controls, 2),
|
|
4629
|
+
diff(a.cards, b.cards, 3),
|
|
4630
|
+
diff(a.figures, b.figures, 3),
|
|
4631
|
+
diff(a.avatars, b.avatars, 3),
|
|
4632
|
+
a.carousel === void 0 || b.carousel === void 0 ? null : a.carousel === b.carousel ? 0 : 1,
|
|
4633
|
+
a.badges === void 0 || b.badges === void 0 ? null : promo(a) === promo(b) ? 0 : 1,
|
|
4634
|
+
a.background === void 0 || b.background === void 0 ? null : a.background === null || b.background === null ? a.background === b.background ? 0 : 1 : clamp2(deltaEOk(a.background, b.background) / 0.3)
|
|
4635
|
+
];
|
|
4636
|
+
const known = parts2.filter((p) => p !== null);
|
|
4637
|
+
return known.length === 0 ? 0 : Math.round(known.reduce((s, p) => s + p, 0) / known.length * 1e3) / 1e3;
|
|
4638
|
+
}
|
|
4639
|
+
function componentShared(a, b) {
|
|
4640
|
+
if (a.role !== b.role) return [];
|
|
4641
|
+
const out = [];
|
|
4642
|
+
const both = (f4) => f4(a) && f4(b);
|
|
4643
|
+
if (both((s) => s.centred >= 0.7)) out.push("centred");
|
|
4644
|
+
else if (both((s) => s.centred < 0.3)) out.push("left-aligned");
|
|
4645
|
+
if (both((s) => s.width <= 0.6)) out.push("narrow column");
|
|
4646
|
+
else if (both((s) => s.width >= 0.8)) out.push("full width");
|
|
4647
|
+
if (a.controls !== void 0 && a.controls === b.controls && a.controls > 0) out.push(`${a.controls} button${a.controls === 1 ? "" : "s"}`);
|
|
4648
|
+
if (a.cards !== void 0 && a.cards === b.cards && a.cards >= 2) out.push(`${a.cards} cards`);
|
|
4649
|
+
if (both((s) => (s.figures ?? 0) >= 3)) out.push("a row of figures");
|
|
4650
|
+
if (both((s) => (s.avatars ?? 0) >= 2)) out.push("avatars");
|
|
4651
|
+
if (both((s) => s.carousel === true)) out.push("carousel");
|
|
4652
|
+
if (both((s) => (s.badges ?? []).some((t) => PROMO_BADGE.test(t)))) out.push("promo badge");
|
|
4653
|
+
if (a.background && b.background && deltaEOk(a.background, b.background) <= 0.06) out.push("same coloured band");
|
|
4654
|
+
else if (a.background === null && b.background === null) out.push("on the page ground");
|
|
4655
|
+
return out;
|
|
4656
|
+
}
|
|
4657
|
+
function closestComponents(a, b, role) {
|
|
4658
|
+
let best = null;
|
|
4659
|
+
for (const x of componentsOf(a, role)) {
|
|
4660
|
+
for (const y of componentsOf(b, role)) {
|
|
4661
|
+
const distance = componentDistance(x, y);
|
|
4662
|
+
if (!best || distance < best.distance) best = { distance, shared: componentShared(x, y) };
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
return best;
|
|
4666
|
+
}
|
|
4667
|
+
function estateComponentPairs(register, role) {
|
|
4668
|
+
const out = [];
|
|
4669
|
+
const s = register.sites;
|
|
4670
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
4671
|
+
for (let j = i + 1; j < s.length; j += 1) {
|
|
4672
|
+
const c = closestComponents(s[i].fingerprint, s[j].fingerprint, role);
|
|
4673
|
+
if (c) out.push({ a: s[i].id, b: s[j].id, ...c });
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
return out.sort((x, y) => x.distance - y.distance);
|
|
4677
|
+
}
|
|
4678
|
+
var meanNearest2 = (d, k) => {
|
|
4679
|
+
const s = [...d].sort((a, b) => a - b).slice(0, k);
|
|
4680
|
+
return s.reduce((t, v) => t + v, 0) / s.length;
|
|
4681
|
+
};
|
|
4682
|
+
function componentTypicality(target2, runs, k = 3) {
|
|
4683
|
+
const pool = runs.flatMap((r) => componentsOf(r.fingerprint, target2.role).slice(0, 1));
|
|
4684
|
+
if (pool.length < MIN_RUNS) return null;
|
|
4685
|
+
const kk = Math.min(k, pool.length - 1);
|
|
4686
|
+
const distance = meanNearest2(pool.map((p) => componentDistance(target2, p)), kk);
|
|
4687
|
+
const loo = pool.map((p, i) => meanNearest2(pool.filter((_, j) => j !== i).map((o) => componentDistance(p, o)), kk));
|
|
4688
|
+
const score = loo.filter((d) => d >= distance).length / loo.length;
|
|
4689
|
+
const sorted = [...loo].sort((a, b) => a - b);
|
|
4690
|
+
const mid = Math.floor(sorted.length / 2);
|
|
4691
|
+
const baseline = sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
4692
|
+
return {
|
|
4693
|
+
role: target2.role,
|
|
4694
|
+
score: Math.round(score * 100) / 100,
|
|
4695
|
+
typical: score >= TYPICAL_AT,
|
|
4696
|
+
distance: Math.round(distance * 1e3) / 1e3,
|
|
4697
|
+
baseline: Math.round(baseline * 1e3) / 1e3,
|
|
4698
|
+
runs: pool.length
|
|
4699
|
+
};
|
|
4700
|
+
}
|
|
4701
|
+
var COMPONENT_ROLES = ["cta-band", "footer-cta", "pricing", "testimonials", "faq", "process", "features", "team", "contact", "stats"];
|
|
4702
|
+
function componentTypicalities(fp, runs, k = 3) {
|
|
4703
|
+
const out = [];
|
|
4704
|
+
for (const role of COMPONENT_ROLES) {
|
|
4705
|
+
const first = componentsOf(fp, role)[0];
|
|
4706
|
+
const t = first ? componentTypicality(first, runs, k) : null;
|
|
4707
|
+
if (t) out.push(t);
|
|
4708
|
+
}
|
|
4709
|
+
return out;
|
|
4710
|
+
}
|
|
4711
|
+
|
|
4712
|
+
// src/snapshot/rendered-tells.ts
|
|
4713
|
+
var hit2 = (s, message, excerpt) => ({ path: s.url, offset: 0, message, excerpt: excerpt ?? message });
|
|
4714
|
+
var GROUND = "rgb(255, 255, 255)";
|
|
4715
|
+
var BAND = "rgb(31, 58, 46)";
|
|
4716
|
+
var geo = (patch = {}) => ({
|
|
4717
|
+
centredShare: 0.1,
|
|
4718
|
+
mirrorSymmetry: 0.6,
|
|
4719
|
+
whitespaceRatio: 0.7,
|
|
4720
|
+
contentWidthRatio: 0.85,
|
|
4721
|
+
background: GROUND,
|
|
4722
|
+
controls: 0,
|
|
4723
|
+
...patch
|
|
4724
|
+
});
|
|
4725
|
+
function withSection(index, patch, roles = []) {
|
|
4726
|
+
const base = makeSnapshot();
|
|
4727
|
+
return {
|
|
4728
|
+
...base,
|
|
4729
|
+
sections: base.sections.map((s, i) => ({ ...s, role: roles[i] ?? s.kind, geometry: geo(), badges: [], avatars: 0, carousel: false, figures: 0, ...i === index ? patch : {} }))
|
|
4730
|
+
};
|
|
4731
|
+
}
|
|
4732
|
+
var measured = (s) => s.geometry !== void 0 && s.role !== void 0;
|
|
4733
|
+
var RENDERED_TELLS = [
|
|
4734
|
+
{
|
|
4735
|
+
id: "cta-band-stock",
|
|
4736
|
+
name: "Stock call-to-action band",
|
|
4737
|
+
generation: 1,
|
|
4738
|
+
severity: "warn",
|
|
4739
|
+
surface: "rendered",
|
|
4740
|
+
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.",
|
|
4741
|
+
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.",
|
|
4742
|
+
rendered: {
|
|
4743
|
+
detect: (s) => s.sections.filter((x) => measured(x) && (x.role === "cta-band" || x.role === "footer-cta")).filter((x) => {
|
|
4744
|
+
const g = x.geometry;
|
|
4745
|
+
return g.centredShare >= 0.8 && g.background !== s.ground && g.controls >= 1 && g.controls <= 2 && g.contentWidthRatio <= 0.7;
|
|
4746
|
+
}).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)),
|
|
4747
|
+
fixtures: {
|
|
4748
|
+
flag: [
|
|
4749
|
+
withSection(4, { role: "footer-cta", label: "Boiler out today?", geometry: geo({ centredShare: 1, background: BAND, controls: 1, contentWidthRatio: 0.45 }) }),
|
|
4750
|
+
withSection(3, { role: "cta-band", label: "Ready to book?", geometry: geo({ centredShare: 0.9, background: BAND, controls: 2, contentWidthRatio: 0.5 }) })
|
|
4751
|
+
],
|
|
4752
|
+
pass: [
|
|
4753
|
+
makeSnapshot(),
|
|
4754
|
+
// The same ask, laid out like the page: left-aligned on the ground.
|
|
4755
|
+
withSection(4, { role: "footer-cta", label: "Book a visit", geometry: geo({ centredShare: 0.1, background: GROUND, controls: 1, contentWidthRatio: 0.85 }) })
|
|
4756
|
+
]
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
},
|
|
4760
|
+
{
|
|
4761
|
+
id: "pricing-trio-popular",
|
|
4762
|
+
name: "Three-tier pricing with a popular badge",
|
|
4763
|
+
generation: 1,
|
|
4764
|
+
severity: "warn",
|
|
4765
|
+
surface: "rendered",
|
|
4766
|
+
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.",
|
|
4767
|
+
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.",
|
|
4768
|
+
rendered: {
|
|
4769
|
+
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)),
|
|
4770
|
+
fixtures: {
|
|
4771
|
+
flag: [withSection(3, { role: "pricing", kind: "cards", cards: 3, badges: ["Most popular"], label: "Plans" })],
|
|
4772
|
+
pass: [
|
|
4773
|
+
makeSnapshot(),
|
|
4774
|
+
withSection(3, { role: "pricing", kind: "cards", cards: 3, badges: [], label: "Prices" }),
|
|
4775
|
+
withSection(3, { role: "pricing", kind: "text", cards: 0, badges: [], label: "Price list" })
|
|
4776
|
+
]
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
},
|
|
4780
|
+
{
|
|
4781
|
+
id: "testimonial-avatar-carousel",
|
|
4782
|
+
name: "Avatar testimonial carousel",
|
|
4783
|
+
generation: 1,
|
|
4784
|
+
severity: "warn",
|
|
4785
|
+
surface: "rendered",
|
|
4786
|
+
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.",
|
|
4787
|
+
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.",
|
|
4788
|
+
rendered: {
|
|
4789
|
+
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)),
|
|
4790
|
+
fixtures: {
|
|
4791
|
+
flag: [withSection(2, { role: "testimonials", avatars: 3, carousel: true, label: "What our clients say" })],
|
|
4792
|
+
pass: [
|
|
4793
|
+
makeSnapshot(),
|
|
4794
|
+
withSection(2, { role: "testimonials", avatars: 3, carousel: false, label: "Reviews" }),
|
|
4795
|
+
withSection(2, { role: "testimonials", avatars: 0, carousel: true, label: "Reviews" })
|
|
4796
|
+
]
|
|
4797
|
+
}
|
|
4798
|
+
}
|
|
4799
|
+
},
|
|
4800
|
+
{
|
|
4801
|
+
id: "faq-accordion-closer",
|
|
4802
|
+
name: "FAQ accordion as the closer",
|
|
4803
|
+
generation: 2,
|
|
4804
|
+
severity: "warn",
|
|
4805
|
+
surface: "rendered",
|
|
4806
|
+
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.",
|
|
4807
|
+
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.",
|
|
4808
|
+
rendered: {
|
|
4809
|
+
detect: (s) => {
|
|
4810
|
+
const body = s.sections.filter((x) => x.role !== "footer-cta" && x.role !== "cta-band");
|
|
4811
|
+
const last = body[body.length - 1];
|
|
4812
|
+
return last && measured(last) && last.role === "faq" ? [hit2(s, "the page ends on a question-and-answer list", last.label)] : [];
|
|
4813
|
+
},
|
|
4814
|
+
fixtures: {
|
|
4815
|
+
flag: [
|
|
4816
|
+
withSection(4, { role: "faq", label: "Common questions" }),
|
|
4817
|
+
{
|
|
4818
|
+
...withSection(3, { role: "faq", label: "FAQ" }),
|
|
4819
|
+
sections: withSection(3, { role: "faq", label: "FAQ" }).sections.map((x, i) => i === 4 ? { ...x, role: "footer-cta" } : x)
|
|
4820
|
+
}
|
|
4821
|
+
],
|
|
4822
|
+
pass: [makeSnapshot(), withSection(2, { role: "faq", label: "Common questions" })]
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
},
|
|
4826
|
+
{
|
|
4827
|
+
id: "stats-row",
|
|
4828
|
+
name: "Row of big numbers",
|
|
4829
|
+
generation: 1,
|
|
4830
|
+
severity: "warn",
|
|
4831
|
+
surface: "rendered",
|
|
4832
|
+
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.",
|
|
4833
|
+
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.",
|
|
4834
|
+
rendered: {
|
|
4835
|
+
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)),
|
|
4836
|
+
fixtures: {
|
|
4837
|
+
flag: [withSection(3, { role: "stats", kind: "stats", figures: 4, label: "500+" })],
|
|
4838
|
+
pass: [
|
|
4839
|
+
makeSnapshot(),
|
|
4840
|
+
withSection(3, { role: "text", kind: "text", figures: 1, label: "Since 2009" }),
|
|
4841
|
+
withSection(1, { role: "stats", kind: "stats", figures: 4, label: "500+" })
|
|
4842
|
+
]
|
|
4843
|
+
}
|
|
4844
|
+
}
|
|
4845
|
+
},
|
|
4846
|
+
{
|
|
4847
|
+
id: "centred-everything",
|
|
4848
|
+
name: "Every section centred",
|
|
4849
|
+
generation: 2,
|
|
4850
|
+
severity: "warn",
|
|
4851
|
+
surface: "rendered",
|
|
4852
|
+
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.",
|
|
4853
|
+
fix: "Pick an alignment and hold it: left-aligned text with a clear edge, keeping centring for the one moment that earns it.",
|
|
4854
|
+
rendered: {
|
|
4855
|
+
detect: (s) => {
|
|
4856
|
+
const m = s.sections.filter(measured);
|
|
4857
|
+
if (m.length < 4) return [];
|
|
4858
|
+
const centred = m.filter((x) => x.geometry.centredShare >= 0.7).length;
|
|
4859
|
+
return centred / m.length >= 0.8 ? [hit2(s, `${centred} of ${m.length} sections centre their text`)] : [];
|
|
4860
|
+
},
|
|
4861
|
+
fixtures: {
|
|
4862
|
+
flag: [{ ...makeSnapshot(), sections: makeSnapshot().sections.map((x) => ({ ...x, role: x.kind, geometry: geo({ centredShare: 0.9 }) })) }],
|
|
4863
|
+
pass: [
|
|
4864
|
+
makeSnapshot(),
|
|
4865
|
+
{ ...makeSnapshot(), sections: makeSnapshot().sections.map((x, i) => ({ ...x, role: x.kind, geometry: geo({ centredShare: i < 2 ? 0.9 : 0.1 }) })) }
|
|
4866
|
+
]
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
];
|
|
4871
|
+
|
|
4872
|
+
// src/snapshot/imagery-tells.ts
|
|
4873
|
+
var hit3 = (s, message, excerpt) => ({ path: s.url, offset: 0, message, excerpt: excerpt ?? message });
|
|
4874
|
+
var STOCK_PHOTO_HOSTS = {
|
|
4875
|
+
"unsplash.com": "Unsplash",
|
|
4876
|
+
"pexels.com": "Pexels",
|
|
4877
|
+
"pixabay.com": "Pixabay",
|
|
4878
|
+
"istockphoto.com": "iStock",
|
|
4879
|
+
"gettyimages.com": "Getty Images",
|
|
4880
|
+
"shutterstock.com": "Shutterstock",
|
|
4881
|
+
"ftcdn.net": "Adobe Stock",
|
|
4882
|
+
"dreamstime.com": "Dreamstime",
|
|
4883
|
+
"depositphotos.com": "Depositphotos",
|
|
4884
|
+
"freepik.com": "Freepik",
|
|
4885
|
+
"rawpixel.com": "rawpixel",
|
|
4886
|
+
"stocksnap.io": "StockSnap",
|
|
4887
|
+
"burst.shopifycdn.com": "Burst",
|
|
4888
|
+
"picsum.photos": "Lorem Picsum",
|
|
4889
|
+
"loremflickr.com": "LoremFlickr",
|
|
4890
|
+
"placehold.co": "a placeholder service",
|
|
4891
|
+
"placeholder.com": "a placeholder service",
|
|
4892
|
+
"dummyimage.com": "a placeholder service"
|
|
4893
|
+
};
|
|
4894
|
+
var STOCK_AVATAR_HOSTS = {
|
|
4895
|
+
"randomuser.me": "randomuser.me",
|
|
4896
|
+
"pravatar.cc": "Pravatar",
|
|
4897
|
+
"dicebear.com": "DiceBear",
|
|
4898
|
+
"xsgames.co": "a random-face service",
|
|
4899
|
+
"thispersondoesnotexist.com": "a generated face",
|
|
4900
|
+
"generated.photos": "a generated face"
|
|
4901
|
+
};
|
|
4902
|
+
var STOCK_FILENAMES = [
|
|
4903
|
+
[/(?:^|[/_-])shutterstock[_-]?\d{4,}/i, "Shutterstock"],
|
|
4904
|
+
[/(?:^|[/_-])istock(?:photo)?[_-]?\d{4,}/i, "iStock"],
|
|
4905
|
+
[/(?:^|[/_-])adobestock[_-]?\d{4,}/i, "Adobe Stock"],
|
|
4906
|
+
[/(?:^|[/_-])gettyimages[_-]?\d{4,}/i, "Getty Images"],
|
|
4907
|
+
[/(?:^|[/_-])depositphotos[_-]?\d{4,}/i, "Depositphotos"],
|
|
4908
|
+
[/(?:^|[/_-])dreamstime[_-]/i, "Dreamstime"],
|
|
4909
|
+
[/(?:^|[/_-])pexels-[a-z0-9-]*\d{4,}/i, "Pexels"],
|
|
4910
|
+
[/-unsplash\.(?:jpe?g|png|webp|avif)(?:[?#]|$)/i, "Unsplash"],
|
|
4911
|
+
// Unsplash's photo ids: photo-<13-digit timestamp>-<12 hex>.
|
|
4912
|
+
[/photo-1\d{12}-[0-9a-f]{12}/, "Unsplash"]
|
|
4913
|
+
];
|
|
4914
|
+
var byHost = (host, table) => {
|
|
4915
|
+
if (!host) return null;
|
|
4916
|
+
const h = host.toLowerCase();
|
|
4917
|
+
for (const [domain, name] of Object.entries(table)) if (h === domain || h.endsWith(`.${domain}`)) return name;
|
|
4918
|
+
return null;
|
|
4919
|
+
};
|
|
4920
|
+
function stockSource(image) {
|
|
4921
|
+
const host = byHost(image.host, STOCK_PHOTO_HOSTS);
|
|
4922
|
+
if (host) return host;
|
|
4923
|
+
let path = image.src.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i, "").replace(/[?#].*$/, "");
|
|
4924
|
+
try {
|
|
4925
|
+
path = decodeURIComponent(path);
|
|
4926
|
+
} catch {
|
|
4927
|
+
}
|
|
4928
|
+
for (const [re, name] of STOCK_FILENAMES) if (re.test(path)) return name;
|
|
4929
|
+
return null;
|
|
4930
|
+
}
|
|
4931
|
+
function stockAvatarSource(image) {
|
|
4932
|
+
return byHost(image.host, STOCK_AVATAR_HOSTS) ?? stockSource(image);
|
|
4933
|
+
}
|
|
4934
|
+
var picture = (patch = {}) => ({
|
|
4935
|
+
src: "https://example.test/images/boiler-swap-hinton.jpg",
|
|
4936
|
+
host: "example.test",
|
|
4937
|
+
width: 640,
|
|
4938
|
+
height: 480,
|
|
4939
|
+
top: 1800,
|
|
4940
|
+
role: "photo",
|
|
4941
|
+
alt: "The new combi boiler fitted in a kitchen cupboard in Hinton",
|
|
4942
|
+
decorative: false,
|
|
4943
|
+
section: 2,
|
|
4944
|
+
background: false,
|
|
4945
|
+
...patch
|
|
4946
|
+
});
|
|
4947
|
+
var withImages = (images) => ({ ...makeSnapshot(), images });
|
|
4948
|
+
var AI_XMP = { digitalSourceType: "trainedAlgorithmicMedia", source: "xmp", c2pa: false, bytes: 48e3 };
|
|
4949
|
+
var NOTHING = { digitalSourceType: null, source: null, c2pa: false, bytes: 48e3 };
|
|
4950
|
+
var count2 = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
4951
|
+
var IMAGERY_TELLS = [
|
|
4952
|
+
{
|
|
4953
|
+
id: "stock-photo",
|
|
4954
|
+
name: "Stock photography",
|
|
4955
|
+
generation: 1,
|
|
4956
|
+
severity: "warn",
|
|
4957
|
+
surface: "rendered",
|
|
4958
|
+
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.",
|
|
4959
|
+
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.",
|
|
4960
|
+
rendered: {
|
|
4961
|
+
detect: (s) => {
|
|
4962
|
+
const found = (s.images ?? []).filter((i) => i.role === "photo" || i.role === "illustration").map((i) => ({ image: i, from: stockSource(i) })).filter((x) => x.from);
|
|
4963
|
+
if (found.length === 0) return [];
|
|
4964
|
+
const names = [...new Set(found.map((x) => x.from))].join(", ");
|
|
4965
|
+
return [hit3(s, `${count2(found.length, "picture")} from ${names}`, found[0].image.src)];
|
|
4966
|
+
},
|
|
4967
|
+
fixtures: {
|
|
4968
|
+
flag: [
|
|
4969
|
+
withImages([picture({ src: "https://images.unsplash.com/photo-1581578731548-c64695cc6952?w=1600", host: "images.unsplash.com", alt: "Plumber fixing a sink" })]),
|
|
4970
|
+
// Downloaded and self-hosted, found by the library's own file name.
|
|
4971
|
+
withImages([picture({ src: "https://example.test/img/shutterstock_1234567890.jpg" })])
|
|
4972
|
+
],
|
|
4973
|
+
pass: [makeSnapshot(), withImages([picture()]), withImages([picture({ role: "icon", width: 48, height: 48, src: "https://images.unsplash.com/photo-1581578731548-c64695cc6952", host: "images.unsplash.com" })])]
|
|
4974
|
+
}
|
|
4975
|
+
}
|
|
4976
|
+
},
|
|
4977
|
+
{
|
|
4978
|
+
id: "stock-avatar",
|
|
4979
|
+
name: "Stock or placeholder faces",
|
|
4980
|
+
generation: 1,
|
|
4981
|
+
severity: "warn",
|
|
4982
|
+
surface: "rendered",
|
|
4983
|
+
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.",
|
|
4984
|
+
fix: "Drop the portraits. Name the reviewer, the town and the job, and link the review to where it was left.",
|
|
4985
|
+
rendered: {
|
|
4986
|
+
detect: (s) => {
|
|
4987
|
+
const found = (s.images ?? []).filter((i) => i.role === "avatar").map((i) => ({ image: i, from: stockAvatarSource(i) })).filter((x) => x.from);
|
|
4988
|
+
if (found.length === 0) return [];
|
|
4989
|
+
const names = [...new Set(found.map((x) => x.from))].join(", ");
|
|
4990
|
+
return [hit3(s, `${count2(found.length, "portrait")} from ${names}`, found[0].image.src)];
|
|
4991
|
+
},
|
|
4992
|
+
fixtures: {
|
|
4993
|
+
flag: [
|
|
4994
|
+
withImages([picture(), picture({ role: "avatar", width: 56, height: 56, src: "https://i.pravatar.cc/150?img=12", host: "i.pravatar.cc", alt: "Sarah" })]),
|
|
4995
|
+
withImages([picture({ role: "avatar", width: 64, height: 64, src: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?crop=faces", host: "images.unsplash.com" })])
|
|
4996
|
+
],
|
|
4997
|
+
pass: [makeSnapshot(), withImages([picture(), picture({ role: "avatar", width: 56, height: 56, src: "https://example.test/team/sam.jpg", alt: "Sam, engineer" })])]
|
|
4998
|
+
}
|
|
4999
|
+
}
|
|
5000
|
+
},
|
|
5001
|
+
{
|
|
5002
|
+
id: "ai-image",
|
|
5003
|
+
name: "Generated image",
|
|
5004
|
+
generation: 2,
|
|
5005
|
+
severity: "warn",
|
|
5006
|
+
surface: "rendered",
|
|
5007
|
+
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.",
|
|
5008
|
+
fix: "Replace it with a photo of the real thing: the work, the premises, the people. Where there is none yet, use fewer pictures.",
|
|
5009
|
+
rendered: {
|
|
5010
|
+
detect: (s) => {
|
|
5011
|
+
const found = (s.images ?? []).filter((i) => i.provenance?.digitalSourceType);
|
|
5012
|
+
if (found.length === 0) return [];
|
|
5013
|
+
const first = found[0].provenance;
|
|
5014
|
+
const where = first.source === "xmp" ? "its XMP metadata" : first.source === "c2pa" ? "its Content Credentials" : "its metadata";
|
|
5015
|
+
return [hit3(s, `${count2(found.length, "image")} labelled as made by a generative model (${first.digitalSourceType} in ${where})`, found[0].src)];
|
|
5016
|
+
},
|
|
5017
|
+
fixtures: {
|
|
5018
|
+
flag: [
|
|
5019
|
+
withImages([picture({ provenance: AI_XMP })]),
|
|
5020
|
+
withImages([picture({ provenance: { digitalSourceType: "compositeWithTrainedAlgorithmicMedia", source: "c2pa", c2pa: true, bytes: 12e4 } })])
|
|
5021
|
+
],
|
|
5022
|
+
// Credentials that say nothing about a model, and an image never read, are not findings.
|
|
5023
|
+
pass: [makeSnapshot(), withImages([picture({ provenance: NOTHING })]), withImages([picture({ provenance: { ...NOTHING, c2pa: true } })]), withImages([picture()])]
|
|
5024
|
+
}
|
|
5025
|
+
}
|
|
5026
|
+
},
|
|
5027
|
+
{
|
|
5028
|
+
id: "no-real-imagery",
|
|
5029
|
+
name: "No photograph on the page",
|
|
5030
|
+
generation: 1,
|
|
5031
|
+
severity: "warn",
|
|
5032
|
+
surface: "rendered",
|
|
5033
|
+
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.",
|
|
5034
|
+
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.",
|
|
5035
|
+
rendered: {
|
|
5036
|
+
detect: (s) => {
|
|
5037
|
+
if (!s.images || s.sections.length < 4) return [];
|
|
5038
|
+
if (s.images.some((i) => i.role === "photo")) return [];
|
|
5039
|
+
const icons = s.images.filter((i) => i.role === "icon" || i.role === "illustration").length;
|
|
5040
|
+
return [hit3(s, `no photograph on the page${icons ? `: ${count2(icons, "icon or illustration", "icons and illustrations")} instead` : ""}`)];
|
|
5041
|
+
},
|
|
5042
|
+
fixtures: {
|
|
5043
|
+
flag: [
|
|
5044
|
+
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" })]),
|
|
5045
|
+
withImages([])
|
|
5046
|
+
],
|
|
5047
|
+
// A snapshot with no image record is never judged; nor is a page too short to be a site.
|
|
5048
|
+
pass: [makeSnapshot(), withImages([picture()]), { ...withImages([]), sections: makeSnapshot().sections.slice(0, 3) }]
|
|
5049
|
+
}
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
];
|
|
5053
|
+
|
|
4257
5054
|
// src/character/check.ts
|
|
4258
|
-
var CATALOGUE_VERSION = "2026.09.
|
|
4259
|
-
var CATALOGUE = [
|
|
4260
|
-
(t) => RENDERED_PATHS[t.id] ? { ...t, rendered: RENDERED_PATHS[t.id] } : t
|
|
4261
|
-
|
|
5055
|
+
var CATALOGUE_VERSION = "2026.09.11";
|
|
5056
|
+
var CATALOGUE = [
|
|
5057
|
+
...[...SOURCE_TELLS, ...COPY_TELLS, ...RESEARCH_TELLS, ...DENSITY_TELLS].map((t) => RENDERED_PATHS[t.id] ? { ...t, rendered: RENDERED_PATHS[t.id] } : t),
|
|
5058
|
+
...RENDERED_TELLS,
|
|
5059
|
+
...IMAGERY_TELLS
|
|
5060
|
+
];
|
|
4262
5061
|
function tellById(id) {
|
|
4263
5062
|
return CATALOGUE.find((t) => t.id === id);
|
|
4264
5063
|
}
|
|
@@ -4280,17 +5079,17 @@ var MARKER = /\b(?:copy|craft)-ok\b/;
|
|
|
4280
5079
|
function marked(lines, line) {
|
|
4281
5080
|
return MARKER.test(lines[line - 1] ?? "") || MARKER.test(lines[line - 2] ?? "");
|
|
4282
5081
|
}
|
|
4283
|
-
function toFinding(tell,
|
|
4284
|
-
const text = texts.get(
|
|
5082
|
+
function toFinding(tell, hit4, texts) {
|
|
5083
|
+
const text = texts.get(hit4.path) ?? "";
|
|
4285
5084
|
return {
|
|
4286
5085
|
tell: tell.id,
|
|
4287
5086
|
name: tell.name,
|
|
4288
5087
|
generation: tell.generation,
|
|
4289
5088
|
severity: tell.severity,
|
|
4290
|
-
path:
|
|
4291
|
-
line: texts.has(
|
|
4292
|
-
excerpt:
|
|
4293
|
-
message:
|
|
5089
|
+
path: hit4.path,
|
|
5090
|
+
line: texts.has(hit4.path) ? lineAt(text, hit4.offset) : 0,
|
|
5091
|
+
excerpt: hit4.excerpt ?? excerptAt(text, hit4.offset),
|
|
5092
|
+
message: hit4.message,
|
|
4294
5093
|
fix: tell.fix,
|
|
4295
5094
|
...tell.surface === "copy" ? { house: houseRule(tell.id, tell.name).tier } : {}
|
|
4296
5095
|
};
|
|
@@ -4309,14 +5108,14 @@ function report(tells, files, run, options) {
|
|
|
4309
5108
|
};
|
|
4310
5109
|
const excepted = /* @__PURE__ */ new Map();
|
|
4311
5110
|
for (const tell of selected) {
|
|
4312
|
-
for (const
|
|
4313
|
-
const exception = applied.find((e) => e.tell === tell.id && (!e.path ||
|
|
5111
|
+
for (const hit4 of run(tell)) {
|
|
5112
|
+
const exception = applied.find((e) => e.tell === tell.id && (!e.path || hit4.path.includes(e.path)));
|
|
4314
5113
|
if (exception) {
|
|
4315
5114
|
excepted.set(exception, (excepted.get(exception) ?? 0) + 1);
|
|
4316
5115
|
continue;
|
|
4317
5116
|
}
|
|
4318
|
-
const finding = toFinding(tell,
|
|
4319
|
-
if (marked(linesOf(
|
|
5117
|
+
const finding = toFinding(tell, hit4, texts);
|
|
5118
|
+
if (marked(linesOf(hit4.path), finding.line)) {
|
|
4320
5119
|
suppressed.push({ tell: tell.id, path: finding.path, line: finding.line });
|
|
4321
5120
|
continue;
|
|
4322
5121
|
}
|
|
@@ -4334,7 +5133,7 @@ function report(tells, files, run, options) {
|
|
|
4334
5133
|
catalogueVersion: CATALOGUE_VERSION,
|
|
4335
5134
|
findings,
|
|
4336
5135
|
rejectedExceptions: rejected,
|
|
4337
|
-
excepted: [...excepted].map(([e,
|
|
5136
|
+
excepted: [...excepted].map(([e, count3]) => ({ tell: e.tell, because: e.because, count: count3 })),
|
|
4338
5137
|
suppressed,
|
|
4339
5138
|
summary: {
|
|
4340
5139
|
files: files.length,
|
|
@@ -4370,6 +5169,7 @@ function auditSnapshot(snapshot, options = {}) {
|
|
|
4370
5169
|
}
|
|
4371
5170
|
function runTell(tell, files) {
|
|
4372
5171
|
if (tell.surface === "source") return tell.detect({ files: files.map(parseFile) });
|
|
5172
|
+
if (tell.surface === "rendered") throw new Error(`${tell.id} is seen on a rendered page only; run tell.rendered.detect(snapshot)`);
|
|
4373
5173
|
return tell.detect(copyContext(files));
|
|
4374
5174
|
}
|
|
4375
5175
|
function catalogueTable() {
|
|
@@ -4822,6 +5622,41 @@ function toJson(data) {
|
|
|
4822
5622
|
return JSON.stringify({ schemaVersion: JSON_SCHEMA_VERSION, ...data }, null, 2);
|
|
4823
5623
|
}
|
|
4824
5624
|
|
|
5625
|
+
// src/snapshot/provenance.ts
|
|
5626
|
+
var PROVENANCE_SCAN_BYTES = 256 * 1024;
|
|
5627
|
+
var AI_SOURCE_TYPES = ["compositeWithTrainedAlgorithmicMedia", "trainedAlgorithmicMedia"];
|
|
5628
|
+
var MARKER2 = new RegExp(`(?:${AI_SOURCE_TYPES.join("|")})`);
|
|
5629
|
+
var C2PA_BOX = /jumd[\s\S]{16,24}c2pa/;
|
|
5630
|
+
var C2PA_PNG = /caBX/;
|
|
5631
|
+
function latin1(bytes) {
|
|
5632
|
+
let out = "";
|
|
5633
|
+
for (let i = 0; i < bytes.length; i += 8192) {
|
|
5634
|
+
out += String.fromCharCode(...bytes.subarray(i, Math.min(bytes.length, i + 8192)));
|
|
5635
|
+
}
|
|
5636
|
+
return out;
|
|
5637
|
+
}
|
|
5638
|
+
function xmpPackets(text) {
|
|
5639
|
+
const out = [];
|
|
5640
|
+
const open = /<x:xmpmeta\b|<\?xpacket begin/g;
|
|
5641
|
+
let m;
|
|
5642
|
+
while (m = open.exec(text)) {
|
|
5643
|
+
const close = text.indexOf(m[0].startsWith("<x:") ? "</x:xmpmeta>" : "<?xpacket end", m.index);
|
|
5644
|
+
out.push([m.index, close === -1 ? text.length : close]);
|
|
5645
|
+
if (close === -1) break;
|
|
5646
|
+
open.lastIndex = close;
|
|
5647
|
+
}
|
|
5648
|
+
return out;
|
|
5649
|
+
}
|
|
5650
|
+
function scanProvenance(bytes) {
|
|
5651
|
+
const head = bytes.subarray(0, PROVENANCE_SCAN_BYTES);
|
|
5652
|
+
const text = latin1(head);
|
|
5653
|
+
const c2pa = C2PA_BOX.test(text) || text.startsWith("\x89PNG") && C2PA_PNG.test(text);
|
|
5654
|
+
const m = MARKER2.exec(text);
|
|
5655
|
+
if (!m) return { digitalSourceType: null, source: null, c2pa, bytes: head.length };
|
|
5656
|
+
const inXmp = xmpPackets(text).some(([a, b]) => m.index >= a && m.index < b);
|
|
5657
|
+
return { digitalSourceType: m[0], source: inXmp ? "xmp" : c2pa ? "c2pa" : "other", c2pa, bytes: head.length };
|
|
5658
|
+
}
|
|
5659
|
+
|
|
4825
5660
|
// src/snapshot/migrate.ts
|
|
4826
5661
|
var READABLE_SNAPSHOT_VERSIONS = [1, 2];
|
|
4827
5662
|
function readSnapshot(data, source = "snapshot") {
|
|
@@ -4863,143 +5698,34 @@ function visualMeasures(img, maxSamples = 1e6) {
|
|
|
4863
5698
|
const yb = 0.5 * (r + g) - b;
|
|
4864
5699
|
sumRg += rg;
|
|
4865
5700
|
sumYb += yb;
|
|
4866
|
-
sumRg2 += rg * rg;
|
|
4867
|
-
sumYb2 += yb * yb;
|
|
4868
|
-
n += 1;
|
|
4869
|
-
const l = lum(x, y);
|
|
4870
|
-
if (x + step < w && y + step < h) {
|
|
4871
|
-
if (Math.abs(lum(x + step, y) - l) + Math.abs(lum(x, y + step) - l) > EDGE_STEP) edges += 1;
|
|
4872
|
-
edgeN += 1;
|
|
4873
|
-
}
|
|
4874
|
-
if (x < w / 2) {
|
|
4875
|
-
asym += Math.abs(l - lum(w - 1 - x, y));
|
|
4876
|
-
asymN += 1;
|
|
4877
|
-
}
|
|
4878
|
-
}
|
|
4879
|
-
}
|
|
4880
|
-
const meanRg = sumRg / n;
|
|
4881
|
-
const meanYb = sumYb / n;
|
|
4882
|
-
const sdRg = Math.sqrt(Math.max(0, sumRg2 / n - meanRg * meanRg));
|
|
4883
|
-
const sdYb = Math.sqrt(Math.max(0, sumYb2 / n - meanYb * meanYb));
|
|
4884
|
-
const colourfulness = Math.sqrt(sdRg ** 2 + sdYb ** 2) + 0.3 * Math.sqrt(meanRg ** 2 + meanYb ** 2);
|
|
4885
|
-
const round2 = (v, d = 3) => Math.round(v * 10 ** d) / 10 ** d;
|
|
4886
|
-
return {
|
|
4887
|
-
colourfulness: round2(colourfulness, 1),
|
|
4888
|
-
edgeDensity: round2(edgeN ? edges / edgeN : 0),
|
|
4889
|
-
symmetry: round2(asymN ? 1 - asym / asymN / 255 : 1),
|
|
4890
|
-
width: w,
|
|
4891
|
-
height: h,
|
|
4892
|
-
sampled: n
|
|
4893
|
-
};
|
|
4894
|
-
}
|
|
4895
|
-
|
|
4896
|
-
// src/fingerprint/index.ts
|
|
4897
|
-
var FINGERPRINT_VERSION = 2;
|
|
4898
|
-
var CHROMATIC = 0.03;
|
|
4899
|
-
var MIN_ACCENT_AREA = 2e4;
|
|
4900
|
-
var oklch = (value) => {
|
|
4901
|
-
const parsed = parseColour(value);
|
|
4902
|
-
return parsed && parsed.alpha > 0.5 ? parsed.oklch : null;
|
|
4903
|
-
};
|
|
4904
|
-
function accentOf(s) {
|
|
4905
|
-
const buttons = /* @__PURE__ */ new Map();
|
|
4906
|
-
for (const c of s.controls) {
|
|
4907
|
-
const o = oklch(c.background);
|
|
4908
|
-
if (o && o.c >= CHROMATIC) buttons.set(c.background, (buttons.get(c.background) ?? 0) + 1);
|
|
4909
|
-
}
|
|
4910
|
-
const topButton = [...buttons].sort((a, b) => b[1] - a[1])[0];
|
|
4911
|
-
if (topButton) return oklch(topButton[0]);
|
|
4912
|
-
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];
|
|
4913
|
-
if (bg) return bg.o;
|
|
4914
|
-
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];
|
|
4915
|
-
return text ? text.o : null;
|
|
4916
|
-
}
|
|
4917
|
-
function faces(s) {
|
|
4918
|
-
const byChars = [...s.fonts].sort((a, b) => b.chars - a.chars);
|
|
4919
|
-
const byDisplay = [...s.fonts].sort((a, b) => b.displayChars - a.displayChars);
|
|
4920
|
-
const bodyName = normaliseFamily(byChars[0]?.family ?? "system-ui");
|
|
4921
|
-
const displayName = normaliseFamily((byDisplay[0]?.displayChars ? byDisplay[0].family : byChars[0]?.family) ?? "system-ui");
|
|
4922
|
-
return {
|
|
4923
|
-
display: { family: displayName, class: fontClass(displayName) },
|
|
4924
|
-
body: { family: bodyName, class: fontClass(bodyName) }
|
|
4925
|
-
};
|
|
4926
|
-
}
|
|
4927
|
-
function median(values) {
|
|
4928
|
-
if (values.length === 0) return null;
|
|
4929
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
4930
|
-
const mid = Math.floor(sorted.length / 2);
|
|
4931
|
-
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
4932
|
-
}
|
|
4933
|
-
function fingerprint(s) {
|
|
4934
|
-
const effects = [];
|
|
4935
|
-
if (s.effects.glass > 0) effects.push("glass-panel");
|
|
4936
|
-
if (s.effects.gradientText > 0) effects.push("gradient-text");
|
|
4937
|
-
if (s.effects.glows > 0 || s.effects.gradients.some((g) => g.radial)) effects.push("radial-spotlight-glow");
|
|
4938
|
-
if (s.effects.gridBackgrounds > 0) effects.push("grid-background");
|
|
4939
|
-
if (s.effects.marquees > 0) effects.push("marquee");
|
|
4940
|
-
if (s.effects.hairlineShadowCards >= 3) effects.push("thin-border-wide-shadow");
|
|
4941
|
-
if (s.effects.eyebrowChip) effects.push("hero-eyebrow-chip");
|
|
4942
|
-
if (s.motion.introOverlay) effects.push("intro-cinematic");
|
|
4943
|
-
const below = s.sections.filter((x) => x.top > s.viewport.height).length;
|
|
4944
|
-
return {
|
|
4945
|
-
version: FINGERPRINT_VERSION,
|
|
4946
|
-
accent: accentOf(s),
|
|
4947
|
-
ground: oklch(s.ground) ?? { l: 1, c: 0, h: 0 },
|
|
4948
|
-
...faces(s),
|
|
4949
|
-
roundness: median(s.controls.map((c) => Math.min(0.5, c.radiusPx / Math.max(1, c.heightPx)))),
|
|
4950
|
-
motion: below ? Math.min(1, s.motion.hiddenSections / below) : 0,
|
|
4951
|
-
effects: effects.sort(),
|
|
4952
|
-
layout: s.sections.map((x) => x.kind),
|
|
4953
|
-
...s.sections.length > 0 && s.sections.every((x) => x.role && x.geometry) ? { sections: s.sections.map((x) => ({ role: x.role, centred: x.geometry.centredShare, width: x.geometry.contentWidthRatio })) } : {}
|
|
4954
|
-
};
|
|
4955
|
-
}
|
|
4956
|
-
var DISTANCE_WEIGHTS = { accent: 0.25, type: 0.25, ground: 0.1, shape: 0.1, motion: 0.1, effects: 0.1, layout: 0.1 };
|
|
4957
|
-
function levenshtein(a, b, cost = (x, y) => x === y ? 0 : 1) {
|
|
4958
|
-
const row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
4959
|
-
for (let i = 1; i <= a.length; i += 1) {
|
|
4960
|
-
let prev = row[0];
|
|
4961
|
-
row[0] = i;
|
|
4962
|
-
for (let j = 1; j <= b.length; j += 1) {
|
|
4963
|
-
const cur = row[j];
|
|
4964
|
-
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + cost(a[i - 1], b[j - 1]));
|
|
4965
|
-
prev = cur;
|
|
4966
|
-
}
|
|
4967
|
-
}
|
|
4968
|
-
return row[b.length];
|
|
4969
|
-
}
|
|
4970
|
-
function sectionCost(x, y) {
|
|
4971
|
-
if (x.role !== y.role) return 1;
|
|
4972
|
-
return Math.min(0.5, (Math.abs(x.centred - y.centred) + Math.abs(x.width - y.width)) / 2);
|
|
4973
|
-
}
|
|
4974
|
-
function layoutDistance(a, b) {
|
|
4975
|
-
if (a.sections && b.sections) {
|
|
4976
|
-
const longest2 = Math.max(a.sections.length, b.sections.length);
|
|
4977
|
-
return longest2 === 0 ? 0 : levenshtein(a.sections, b.sections, sectionCost) / longest2;
|
|
4978
|
-
}
|
|
4979
|
-
const longest = Math.max(a.layout.length, b.layout.length);
|
|
4980
|
-
return longest === 0 ? 0 : levenshtein(a.layout, b.layout) / longest;
|
|
4981
|
-
}
|
|
4982
|
-
var clamp = (n) => Math.max(0, Math.min(1, n));
|
|
4983
|
-
function faceDistance(a, b) {
|
|
4984
|
-
if (a.family.toLowerCase() === b.family.toLowerCase()) return 0;
|
|
4985
|
-
return a.class === b.class ? 0.5 : 1;
|
|
4986
|
-
}
|
|
4987
|
-
function fingerprintDistance(a, b) {
|
|
4988
|
-
const accent = a.accent && b.accent ? clamp(deltaEOk(a.accent, b.accent) / 0.3) : a.accent || b.accent ? 1 : 0;
|
|
4989
|
-
const ground = clamp(deltaEOk(a.ground, b.ground) / 0.15);
|
|
4990
|
-
const type = 0.6 * faceDistance(a.display, b.display) + 0.4 * faceDistance(a.body, b.body);
|
|
4991
|
-
const shape = a.roundness === null || b.roundness === null ? a.roundness === b.roundness ? 0 : 0.5 : clamp(Math.abs(a.roundness - b.roundness) / 0.5);
|
|
4992
|
-
const motion = clamp(Math.abs(a.motion - b.motion));
|
|
4993
|
-
const union = /* @__PURE__ */ new Set([...a.effects, ...b.effects]);
|
|
4994
|
-
const shared = a.effects.filter((e) => b.effects.includes(e)).length;
|
|
4995
|
-
const effects = union.size === 0 ? 0 : 1 - shared / union.size;
|
|
4996
|
-
const layout = layoutDistance(a, b);
|
|
4997
|
-
const parts2 = { accent, ground, type, shape, motion, effects, layout };
|
|
4998
|
-
const total = Object.keys(DISTANCE_WEIGHTS).reduce((sum, k) => sum + DISTANCE_WEIGHTS[k] * parts2[k], 0);
|
|
4999
|
-
return { total: Math.round(total * 1e3) / 1e3, parts: parts2 };
|
|
5000
|
-
}
|
|
5001
|
-
function nearest(target2, set, k = set.length) {
|
|
5002
|
-
return set.map((item) => ({ id: item.id, distance: fingerprintDistance(target2, item.fingerprint) })).sort((x, y) => x.distance.total - y.distance.total).slice(0, k);
|
|
5701
|
+
sumRg2 += rg * rg;
|
|
5702
|
+
sumYb2 += yb * yb;
|
|
5703
|
+
n += 1;
|
|
5704
|
+
const l = lum(x, y);
|
|
5705
|
+
if (x + step < w && y + step < h) {
|
|
5706
|
+
if (Math.abs(lum(x + step, y) - l) + Math.abs(lum(x, y + step) - l) > EDGE_STEP) edges += 1;
|
|
5707
|
+
edgeN += 1;
|
|
5708
|
+
}
|
|
5709
|
+
if (x < w / 2) {
|
|
5710
|
+
asym += Math.abs(l - lum(w - 1 - x, y));
|
|
5711
|
+
asymN += 1;
|
|
5712
|
+
}
|
|
5713
|
+
}
|
|
5714
|
+
}
|
|
5715
|
+
const meanRg = sumRg / n;
|
|
5716
|
+
const meanYb = sumYb / n;
|
|
5717
|
+
const sdRg = Math.sqrt(Math.max(0, sumRg2 / n - meanRg * meanRg));
|
|
5718
|
+
const sdYb = Math.sqrt(Math.max(0, sumYb2 / n - meanYb * meanYb));
|
|
5719
|
+
const colourfulness = Math.sqrt(sdRg ** 2 + sdYb ** 2) + 0.3 * Math.sqrt(meanRg ** 2 + meanYb ** 2);
|
|
5720
|
+
const round2 = (v, d = 3) => Math.round(v * 10 ** d) / 10 ** d;
|
|
5721
|
+
return {
|
|
5722
|
+
colourfulness: round2(colourfulness, 1),
|
|
5723
|
+
edgeDensity: round2(edgeN ? edges / edgeN : 0),
|
|
5724
|
+
symmetry: round2(asymN ? 1 - asym / asymN / 255 : 1),
|
|
5725
|
+
width: w,
|
|
5726
|
+
height: h,
|
|
5727
|
+
sampled: n
|
|
5728
|
+
};
|
|
5003
5729
|
}
|
|
5004
5730
|
|
|
5005
5731
|
// src/direction/types.ts
|
|
@@ -5136,9 +5862,9 @@ function licencesJson() {
|
|
|
5136
5862
|
var PREFERENCE = /\b(?:client (?:likes|liked|wants|wanted|asked|chose|prefers?)|(?:we|they|i) (?:like|liked|love|loved|prefer)|on[- ]trend|trendy|popular|what (?:everyone|competitors) (?:uses?|does)|brand (?:colou?r|font|guidelines?) (?:is|are|says?))\b/i;
|
|
5137
5863
|
var MOOD = /\b(?:modern|clean|fresh|professional|trustworthy|premium|elegant|sleek|timeless|minimal(?:ist)?|bold|vibrant|friendly|approachable|luxur(?:y|ious)|sophisticated|contemporary|stylish|warm|inviting|high[- ]end)\b/gi;
|
|
5138
5864
|
var VALUE_WORDS = /* @__PURE__ */ new Set(["green", "blue", "navy", "black", "white", "cream", "grey", "gray", "gold", "yellow", "orange", "purple", "violet", "pink", "brown", "teal", "bottle", "dark", "light", "deep", "pale", "bright", "colour", "color", "font", "face", "serif", "sans", "type", "lettering"]);
|
|
5139
|
-
var
|
|
5865
|
+
var STOP2 = /* @__PURE__ */ new Set(["with", "that", "this", "from", "their", "they", "have", "been", "were", "which", "what", "when", "where", "there", "about", "into", "onto", "over", "same", "each", "every"]);
|
|
5140
5866
|
function words(text) {
|
|
5141
|
-
return new Set((text.toLowerCase().match(/[a-z][a-z'-]{3,}/g) ?? []).map((w) => w.replace(/'s$/, "")).filter((w) => !
|
|
5867
|
+
return new Set((text.toLowerCase().match(/[a-z][a-z'-]{3,}/g) ?? []).map((w) => w.replace(/'s$/, "")).filter((w) => !STOP2.has(w) && !VALUE_WORDS.has(w)));
|
|
5142
5868
|
}
|
|
5143
5869
|
function tellFor(key, value) {
|
|
5144
5870
|
if (key === "accent") {
|
|
@@ -5271,14 +5997,14 @@ function validateDirection(input, ctx = {}) {
|
|
|
5271
5997
|
if (fp && typeof c.value === "string") {
|
|
5272
5998
|
if ((key === "accent" || key === "ground") && parseColour(c.value)) {
|
|
5273
5999
|
const declared = parseColour(c.value).oklch;
|
|
5274
|
-
const
|
|
5275
|
-
if (
|
|
5276
|
-
warn(`${at}.value`, `the page does not show it: its ${key} measures oklch(${
|
|
6000
|
+
const measured2 = key === "accent" ? fp.accent : fp.ground;
|
|
6001
|
+
if (measured2 && deltaEOk(declared, measured2) > 0.08) {
|
|
6002
|
+
warn(`${at}.value`, `the page does not show it: its ${key} measures oklch(${measured2.l.toFixed(2)} ${measured2.c.toFixed(3)} ${measured2.h.toFixed(0)})`);
|
|
5277
6003
|
}
|
|
5278
6004
|
}
|
|
5279
6005
|
if (key === "display" || key === "body") {
|
|
5280
|
-
const
|
|
5281
|
-
if (normaliseFamily(c.value).toLowerCase() !==
|
|
6006
|
+
const measured2 = key === "display" ? fp.display.family : fp.body.family;
|
|
6007
|
+
if (normaliseFamily(c.value).toLowerCase() !== measured2.toLowerCase()) warn(`${at}.value`, `the page sets ${measured2}, not ${c.value}`);
|
|
5282
6008
|
}
|
|
5283
6009
|
}
|
|
5284
6010
|
if (ok) decided += 1;
|
|
@@ -5289,8 +6015,8 @@ function validateDirection(input, ctx = {}) {
|
|
|
5289
6015
|
// src/direction/init.ts
|
|
5290
6016
|
var hex = (o) => {
|
|
5291
6017
|
const { r, g, b } = oklchToRgb(o);
|
|
5292
|
-
const
|
|
5293
|
-
return formatHex({ r:
|
|
6018
|
+
const clamp3 = (n) => Math.min(1, Math.max(0, n));
|
|
6019
|
+
return formatHex({ r: clamp3(r), g: clamp3(g), b: clamp3(b) });
|
|
5294
6020
|
};
|
|
5295
6021
|
function initDirection(input) {
|
|
5296
6022
|
const fp = input.current;
|
|
@@ -5430,240 +6156,6 @@ function propose(input) {
|
|
|
5430
6156
|
};
|
|
5431
6157
|
}
|
|
5432
6158
|
|
|
5433
|
-
// src/null/index.ts
|
|
5434
|
-
var NULL_VERSION = 1;
|
|
5435
|
-
function nullPrompt(brief) {
|
|
5436
|
-
return [
|
|
5437
|
-
`Build the home page for this business: ${brief.trim()}`,
|
|
5438
|
-
"",
|
|
5439
|
-
"Write it as one complete, self-contained HTML file. You may load fonts and libraries from a CDN. Use real copy, not placeholder text. Reply with the HTML only."
|
|
5440
|
-
].join("\n");
|
|
5441
|
-
}
|
|
5442
|
-
function extractHtml(reply) {
|
|
5443
|
-
const start = reply.search(/<!doctype html|<html[\s>]/i);
|
|
5444
|
-
if (start < 0) return null;
|
|
5445
|
-
const end = reply.toLowerCase().lastIndexOf("</html>");
|
|
5446
|
-
const html = end > start ? reply.slice(start, end + "</html>".length) : reply.slice(start).replace(/\s*```\s*$/, "");
|
|
5447
|
-
return html.length > 200 ? html : null;
|
|
5448
|
-
}
|
|
5449
|
-
var MIN_RUNS = 5;
|
|
5450
|
-
var TYPICAL_AT = 0.1;
|
|
5451
|
-
function meanNearest(distances, k) {
|
|
5452
|
-
const sorted = [...distances].sort((a, b) => a - b).slice(0, k);
|
|
5453
|
-
return sorted.reduce((s, d) => s + d, 0) / sorted.length;
|
|
5454
|
-
}
|
|
5455
|
-
function median2(values) {
|
|
5456
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
5457
|
-
const mid = Math.floor(sorted.length / 2);
|
|
5458
|
-
return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
5459
|
-
}
|
|
5460
|
-
function typicality(target2, runs, k = 3) {
|
|
5461
|
-
if (runs.length < MIN_RUNS) throw new Error(`a null model needs at least ${MIN_RUNS} runs; this one has ${runs.length}`);
|
|
5462
|
-
const kk = Math.min(k, runs.length - 1);
|
|
5463
|
-
const toTarget = runs.map((r) => ({ id: r.id, distance: fingerprintDistance(target2, r.fingerprint).total }));
|
|
5464
|
-
const distance = meanNearest(
|
|
5465
|
-
toTarget.map((t) => t.distance),
|
|
5466
|
-
kk
|
|
5467
|
-
);
|
|
5468
|
-
const loo = runs.map(
|
|
5469
|
-
(r, i) => meanNearest(
|
|
5470
|
-
runs.filter((_, j) => j !== i).map((o) => fingerprintDistance(r.fingerprint, o.fingerprint).total),
|
|
5471
|
-
kk
|
|
5472
|
-
)
|
|
5473
|
-
);
|
|
5474
|
-
const score = loo.filter((d) => d >= distance).length / loo.length;
|
|
5475
|
-
return {
|
|
5476
|
-
score: Math.round(score * 100) / 100,
|
|
5477
|
-
typical: score >= TYPICAL_AT,
|
|
5478
|
-
distance: Math.round(distance * 1e3) / 1e3,
|
|
5479
|
-
baseline: Math.round(median2(loo) * 1e3) / 1e3,
|
|
5480
|
-
nearest: toTarget.sort((a, b) => a.distance - b.distance).slice(0, kk),
|
|
5481
|
-
shared: sharedChoices(target2, runs)
|
|
5482
|
-
};
|
|
5483
|
-
}
|
|
5484
|
-
var HUES = [
|
|
5485
|
-
["red", 0, 45],
|
|
5486
|
-
["orange", 45, 75],
|
|
5487
|
-
["yellow", 75, 110],
|
|
5488
|
-
["green", 110, 165],
|
|
5489
|
-
["teal", 165, 215],
|
|
5490
|
-
["blue", 215, 265],
|
|
5491
|
-
["violet", 265, 315],
|
|
5492
|
-
["pink", 315, 360]
|
|
5493
|
-
];
|
|
5494
|
-
function hueName(o) {
|
|
5495
|
-
if (!o) return "none";
|
|
5496
|
-
if (o.c < 0.03) return "neutral";
|
|
5497
|
-
return HUES.find(([, lo, hi]) => o.h >= lo && o.h < hi)?.[0] ?? "red";
|
|
5498
|
-
}
|
|
5499
|
-
function groundName(o) {
|
|
5500
|
-
if (o.l < 0.3) return "dark";
|
|
5501
|
-
if (isCream(o)) return "cream";
|
|
5502
|
-
if (o.l >= 0.97 && o.c < 0.012) return "white";
|
|
5503
|
-
return o.c < 0.02 ? "grey" : "tinted";
|
|
5504
|
-
}
|
|
5505
|
-
function shapeName(roundness) {
|
|
5506
|
-
if (roundness === null) return "no buttons";
|
|
5507
|
-
if (roundness >= 0.45) return "pill";
|
|
5508
|
-
return roundness >= 0.15 ? "soft" : "square";
|
|
5509
|
-
}
|
|
5510
|
-
function choicesOf(fp) {
|
|
5511
|
-
return {
|
|
5512
|
-
display: [fp.display.family],
|
|
5513
|
-
body: [fp.body.family],
|
|
5514
|
-
accent: [hueName(fp.accent)],
|
|
5515
|
-
ground: [groundName(fp.ground)],
|
|
5516
|
-
shape: [shapeName(fp.roundness)],
|
|
5517
|
-
motion: [fp.motion >= 0.6 ? "reveals most sections" : fp.motion > 0 ? "reveals some sections" : "no scroll reveals"],
|
|
5518
|
-
effects: fp.effects,
|
|
5519
|
-
opening: [fp.layout.slice(0, 3).join(" > ") || "none"]
|
|
5520
|
-
};
|
|
5521
|
-
}
|
|
5522
|
-
function sharedChoices(target2, runs) {
|
|
5523
|
-
const mine = choicesOf(target2);
|
|
5524
|
-
const all = runs.map((r) => choicesOf(r.fingerprint));
|
|
5525
|
-
const out = [];
|
|
5526
|
-
for (const [part, values] of Object.entries(mine)) {
|
|
5527
|
-
for (const value of values) {
|
|
5528
|
-
const count2 = all.filter((c) => c[part].includes(value)).length;
|
|
5529
|
-
if (count2 / runs.length >= 0.25) out.push({ part, value, runs: count2, of: runs.length });
|
|
5530
|
-
}
|
|
5531
|
-
}
|
|
5532
|
-
return out.sort((a, b) => b.runs - a.runs);
|
|
5533
|
-
}
|
|
5534
|
-
var REFLEX_1 = new Set(REFLEX_FONTS_1.map((f4) => f4.toLowerCase()));
|
|
5535
|
-
var REFLEX_2 = new Set(REFLEX_FONTS_2.map((f4) => f4.toLowerCase()));
|
|
5536
|
-
function knownFor(kind, value, sample) {
|
|
5537
|
-
if (kind === "face") return REFLEX_1.has(value.toLowerCase()) ? "reflex-font" : REFLEX_2.has(value.toLowerCase()) ? "reflex-font-2" : null;
|
|
5538
|
-
if (kind === "accent" && value === "violet") return sample.some((f4) => f4.accent && isAiViolet(f4.accent)) ? "ai-violet" : null;
|
|
5539
|
-
if (kind === "ground" && value === "cream") return "cream-palette";
|
|
5540
|
-
if (kind === "shape" && value === "pill") return "pill-everything";
|
|
5541
|
-
if (kind === "motion" && value === "reveals most sections") return "reveal-everywhere";
|
|
5542
|
-
if (kind === "tell") return value;
|
|
5543
|
-
if (kind === "opening" && /^hero > (?:logos|stats)/.test(value)) return "hero-then-proof";
|
|
5544
|
-
return null;
|
|
5545
|
-
}
|
|
5546
|
-
var STOP2 = new Set(
|
|
5547
|
-
"a an the and or but of to in on for with at by from as is are be we our you your us it its this that these those will can all more get has have not no any".split(" ")
|
|
5548
|
-
);
|
|
5549
|
-
function grams(text) {
|
|
5550
|
-
const out = /* @__PURE__ */ new Set();
|
|
5551
|
-
for (const clause of text.toLowerCase().replace(/[’']/g, "'").split(/[.!?;:|()\u2013\u2014\u00b7•]+|,\s/)) {
|
|
5552
|
-
const words2 = clause.match(/[a-z][a-z'-]*/g) ?? [];
|
|
5553
|
-
for (let n = 2; n <= 4; n += 1) {
|
|
5554
|
-
for (let i = 0; i + n <= words2.length; i += 1) {
|
|
5555
|
-
const g = words2.slice(i, i + n);
|
|
5556
|
-
if (STOP2.has(g[0]) || STOP2.has(g[n - 1])) continue;
|
|
5557
|
-
if (g.filter((w) => !STOP2.has(w)).length < 2) continue;
|
|
5558
|
-
out.add(g.join(" "));
|
|
5559
|
-
}
|
|
5560
|
-
}
|
|
5561
|
-
}
|
|
5562
|
-
return out;
|
|
5563
|
-
}
|
|
5564
|
-
var GRAMMAR = /* @__PURE__ */ new Set([
|
|
5565
|
-
"privacy policy",
|
|
5566
|
-
"cookie policy",
|
|
5567
|
-
"rights reserved",
|
|
5568
|
-
"all rights reserved",
|
|
5569
|
-
"terms of service",
|
|
5570
|
-
"terms and conditions",
|
|
5571
|
-
"terms conditions",
|
|
5572
|
-
"how it works",
|
|
5573
|
-
"what we do",
|
|
5574
|
-
"about us",
|
|
5575
|
-
"contact us",
|
|
5576
|
-
"get in touch",
|
|
5577
|
-
"opening hours",
|
|
5578
|
-
"read more",
|
|
5579
|
-
"learn more",
|
|
5580
|
-
"book now",
|
|
5581
|
-
"free quote",
|
|
5582
|
-
"our services",
|
|
5583
|
-
"quick links",
|
|
5584
|
-
"email address",
|
|
5585
|
-
"phone number",
|
|
5586
|
-
"full name",
|
|
5587
|
-
"first name",
|
|
5588
|
-
"last name",
|
|
5589
|
-
"your name",
|
|
5590
|
-
"your email",
|
|
5591
|
-
"send message"
|
|
5592
|
-
]);
|
|
5593
|
-
var LEGAL = /©|©|\bregistered (?:in|office|number)\b|\bcompany (?:no|number|reg)|\bvat (?:no|number|reg)/i;
|
|
5594
|
-
var NOISE = /\S+@\S+|https?:\/\/\S+|\b[\w-]+(?:\.[\w-]+)*\.(?:co\.uk|com|org|net|uk|io)\b|\b\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)\b|\d+/gi;
|
|
5595
|
-
function textGrams(text) {
|
|
5596
|
-
if (LEGAL.test(text)) return /* @__PURE__ */ new Set();
|
|
5597
|
-
const out = grams(text.replace(NOISE, " | "));
|
|
5598
|
-
for (const g of out) if (GRAMMAR.has(g)) out.delete(g);
|
|
5599
|
-
return out;
|
|
5600
|
-
}
|
|
5601
|
-
function properNouns(brief) {
|
|
5602
|
-
return new Set((brief.match(/\b[A-Z][a-z]+/g) ?? []).map((w) => w.toLowerCase()).filter((w) => !STOP2.has(w)));
|
|
5603
|
-
}
|
|
5604
|
-
function harvest(models, options = {}) {
|
|
5605
|
-
const minShare = options.minShare ?? 0.25;
|
|
5606
|
-
const runs = models.flatMap((m, b) => m.runs.map((r) => ({ ...r, brief: b })));
|
|
5607
|
-
const of = runs.length;
|
|
5608
|
-
if (of === 0) return [];
|
|
5609
|
-
const multiBrief = models.length > 1;
|
|
5610
|
-
const sample = runs.map((r) => r.fingerprint);
|
|
5611
|
-
const tally = /* @__PURE__ */ new Map();
|
|
5612
|
-
const add = (kind, value, run, brief, example) => {
|
|
5613
|
-
const key = `${kind}\0${value}`;
|
|
5614
|
-
const t = tally.get(key) ?? { kind, value, runs: /* @__PURE__ */ new Set(), briefs: /* @__PURE__ */ new Set(), example };
|
|
5615
|
-
t.runs.add(run);
|
|
5616
|
-
t.briefs.add(brief);
|
|
5617
|
-
tally.set(key, t);
|
|
5618
|
-
};
|
|
5619
|
-
runs.forEach((r, i) => {
|
|
5620
|
-
const c = choicesOf(r.fingerprint);
|
|
5621
|
-
for (const f4 of /* @__PURE__ */ new Set([...c.display, ...c.body])) add("face", f4, i, r.brief);
|
|
5622
|
-
add("accent", c.accent[0], i, r.brief);
|
|
5623
|
-
add("ground", c.ground[0], i, r.brief);
|
|
5624
|
-
add("shape", c.shape[0], i, r.brief);
|
|
5625
|
-
add("motion", c.motion[0], i, r.brief);
|
|
5626
|
-
add("opening", c.opening[0], i, r.brief);
|
|
5627
|
-
for (const t of r.tells) add("tell", t, i, r.brief);
|
|
5628
|
-
});
|
|
5629
|
-
const out = [];
|
|
5630
|
-
for (const t of tally.values()) {
|
|
5631
|
-
if (t.runs.size / of < minShare) continue;
|
|
5632
|
-
if (t.kind === "accent" && (t.value === "none" || t.value === "neutral")) continue;
|
|
5633
|
-
if (t.kind === "shape" && t.value === "no buttons") continue;
|
|
5634
|
-
if (t.kind === "ground" && (t.value === "white" || t.value === "grey")) continue;
|
|
5635
|
-
if (t.kind === "motion" && t.value === "no scroll reveals") continue;
|
|
5636
|
-
out.push({ kind: t.kind, value: t.value, runs: t.runs.size, of, briefs: t.briefs.size, known: knownFor(t.kind, t.value, sample) });
|
|
5637
|
-
}
|
|
5638
|
-
const phraseMin = Math.max(3, Math.ceil(of * minShare * 0.4));
|
|
5639
|
-
const names = models.map((m) => properNouns(m.brief));
|
|
5640
|
-
const phrases2 = /* @__PURE__ */ new Map();
|
|
5641
|
-
runs.forEach((r, i) => {
|
|
5642
|
-
for (const text of r.copy) {
|
|
5643
|
-
for (const g of textGrams(text)) {
|
|
5644
|
-
if (g.split(" ").some((w) => names[r.brief].has(w))) continue;
|
|
5645
|
-
const p = phrases2.get(g) ?? { runs: /* @__PURE__ */ new Set(), briefs: /* @__PURE__ */ new Set(), example: text.trim().slice(0, 140) };
|
|
5646
|
-
p.runs.add(i);
|
|
5647
|
-
p.briefs.add(r.brief);
|
|
5648
|
-
phrases2.set(g, p);
|
|
5649
|
-
}
|
|
5650
|
-
}
|
|
5651
|
-
});
|
|
5652
|
-
const kept = [...phrases2].filter(([, p]) => p.runs.size >= phraseMin && (!multiBrief || p.briefs.size >= 2)).sort((a, b) => b[1].runs.size - a[1].runs.size || b[0].length - a[0].length);
|
|
5653
|
-
const maximal = kept.filter(([g, p]) => !kept.some(([h, q]) => h !== g && h.includes(g) && q.runs.size >= 0.8 * p.runs.size));
|
|
5654
|
-
for (const [g, p] of maximal.slice(0, 40)) {
|
|
5655
|
-
out.push({ kind: "phrase", value: g, runs: p.runs.size, of, briefs: p.briefs.size, known: options.copyTell?.(g) ?? null, example: p.example });
|
|
5656
|
-
}
|
|
5657
|
-
const order = ["face", "accent", "ground", "shape", "motion", "opening", "tell", "phrase"];
|
|
5658
|
-
return out.sort((a, b) => order.indexOf(a.kind) - order.indexOf(b.kind) || b.runs - a.runs);
|
|
5659
|
-
}
|
|
5660
|
-
function hueSwatch(runs, hue) {
|
|
5661
|
-
const hits = runs.map((r) => r.fingerprint.accent).filter((o) => !!o && hueName(o) === hue);
|
|
5662
|
-
if (hits.length === 0) return null;
|
|
5663
|
-
const centre = hits.reduce((best, o) => hits.reduce((s, p) => s + deltaEOk(o, p), 0) < hits.reduce((s, p) => s + deltaEOk(best, p), 0) ? o : best);
|
|
5664
|
-
return formatHex(oklchToRgb(centre));
|
|
5665
|
-
}
|
|
5666
|
-
|
|
5667
6159
|
// src/estate/index.ts
|
|
5668
6160
|
var ESTATE_VERSION = 1;
|
|
5669
6161
|
var SIBLING_AT = 0.31;
|
|
@@ -5920,6 +6412,7 @@ function retrofitPlan(report2, direction) {
|
|
|
5920
6412
|
}
|
|
5921
6413
|
export {
|
|
5922
6414
|
AI_PHRASES,
|
|
6415
|
+
AI_SOURCE_TYPES,
|
|
5923
6416
|
AI_VIOLET,
|
|
5924
6417
|
AI_WORDS,
|
|
5925
6418
|
BASELINE_VERSION,
|
|
@@ -5927,6 +6420,7 @@ export {
|
|
|
5927
6420
|
CATALOGUE,
|
|
5928
6421
|
CATALOGUE_VERSION,
|
|
5929
6422
|
CHOICE_KEYS,
|
|
6423
|
+
COMPONENT_ROLES,
|
|
5930
6424
|
DEFAULT_IGNORE,
|
|
5931
6425
|
DENSITIES,
|
|
5932
6426
|
DENSITY_NAMES,
|
|
@@ -5944,6 +6438,7 @@ export {
|
|
|
5944
6438
|
HOUSE_BUDGET,
|
|
5945
6439
|
HOUSE_LOCKED,
|
|
5946
6440
|
HOUSE_TYPE,
|
|
6441
|
+
IMAGERY_TELLS,
|
|
5947
6442
|
JSON_SCHEMA_VERSION,
|
|
5948
6443
|
LICENCES,
|
|
5949
6444
|
LIGHTNESS_CURVE,
|
|
@@ -5953,12 +6448,15 @@ export {
|
|
|
5953
6448
|
NULL_VERSION,
|
|
5954
6449
|
PILL_LIMIT,
|
|
5955
6450
|
PLAINER_WORDS,
|
|
6451
|
+
PROMO_BADGE,
|
|
5956
6452
|
PROPOSED,
|
|
6453
|
+
PROVENANCE_SCAN_BYTES,
|
|
5957
6454
|
RAMP_STEPS,
|
|
5958
6455
|
READABLE_SNAPSHOT_VERSIONS,
|
|
5959
6456
|
REFLEX_FONTS_1,
|
|
5960
6457
|
REFLEX_FONTS_2,
|
|
5961
6458
|
RENDERED_PATHS,
|
|
6459
|
+
RENDERED_TELLS,
|
|
5962
6460
|
REVEAL_LIMIT,
|
|
5963
6461
|
REVIEW_PHRASES,
|
|
5964
6462
|
SCALE,
|
|
@@ -5969,6 +6467,8 @@ export {
|
|
|
5969
6467
|
SOURCE_KINDS,
|
|
5970
6468
|
SPACE_STEPS,
|
|
5971
6469
|
SPRING,
|
|
6470
|
+
STOCK_AVATAR_HOSTS,
|
|
6471
|
+
STOCK_PHOTO_HOSTS,
|
|
5972
6472
|
STOCK_PHRASES,
|
|
5973
6473
|
TELL_HEAVY,
|
|
5974
6474
|
TYPE_STEPS,
|
|
@@ -5987,8 +6487,14 @@ export {
|
|
|
5987
6487
|
checkPair,
|
|
5988
6488
|
checkRestraint,
|
|
5989
6489
|
choicesOf,
|
|
6490
|
+
closestComponents,
|
|
5990
6491
|
compareFacts,
|
|
5991
6492
|
compareToEstate,
|
|
6493
|
+
componentDistance,
|
|
6494
|
+
componentShared,
|
|
6495
|
+
componentTypicalities,
|
|
6496
|
+
componentTypicality,
|
|
6497
|
+
componentsOf,
|
|
5992
6498
|
craftTokens,
|
|
5993
6499
|
createBaseline,
|
|
5994
6500
|
deltaEOk,
|
|
@@ -5997,6 +6503,7 @@ export {
|
|
|
5997
6503
|
densityTokens,
|
|
5998
6504
|
emitCss,
|
|
5999
6505
|
emptyEstate,
|
|
6506
|
+
estateComponentPairs,
|
|
6000
6507
|
estatePairs,
|
|
6001
6508
|
exitDuration,
|
|
6002
6509
|
extractHtml,
|
|
@@ -6050,6 +6557,7 @@ export {
|
|
|
6050
6557
|
readSnapshot,
|
|
6051
6558
|
retrofitPlan,
|
|
6052
6559
|
runTell,
|
|
6560
|
+
scanProvenance,
|
|
6053
6561
|
scanSource,
|
|
6054
6562
|
sectionRhythm,
|
|
6055
6563
|
semantic,
|
|
@@ -6058,6 +6566,8 @@ export {
|
|
|
6058
6566
|
sharedParts,
|
|
6059
6567
|
shouldAnimate,
|
|
6060
6568
|
siblingLine,
|
|
6569
|
+
stockAvatarSource,
|
|
6570
|
+
stockSource,
|
|
6061
6571
|
tailwindV3Preset,
|
|
6062
6572
|
tailwindV4Theme,
|
|
6063
6573
|
tellById,
|