@tokenoftrust/storefront-runner 6.11.2 → 6.11.3

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.
@@ -209,7 +209,7 @@ const notice = block.notice?.trim();
209
209
  )
210
210
  }
211
211
  <Heading class="display-hero">
212
- <span class:list={["block", light && "text-[var(--color-primary)]"]}>{block.headline}</span>
212
+ <span class:list={["block", light ? "text-[var(--color-primary)]" : "text-[var(--color-primary-contrast)]"]}>{block.headline}</span>
213
213
  {
214
214
  block.headlineAccent && (
215
215
  <span class:list={["relative block w-fit", light ? "text-[var(--color-accent-ink)]" : "text-[var(--color-accent)]"]}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "6.11.2",
3
+ "version": "6.11.3",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",
@@ -50,7 +50,7 @@ import { isForbiddenPublicPath, publicBinaryFindings } from "../../agency-kit/to
50
50
  import { pageSlugFindings } from "../../agency-kit/tools/lib/page-slugs.mjs";
51
51
  import { ANALYTICS_DECLARATION_FILE, analyticsDeclarationFindings } from "../../agency-kit/tools/lib/analytics-declaration.mjs";
52
52
  import { validateVisualParityClosure } from "../../packages/cli/src/visual-parity.mjs";
53
- import { declaredObligations, isRegulatedCompliance, validateDeclaredConfig } from "../../packages/cli/src/declared-config.mjs";
53
+ import { contrastRatio, declaredObligations, isRegulatedCompliance, validateDeclaredConfig } from "../../packages/cli/src/declared-config.mjs";
54
54
 
55
55
  /** Catalogued embed slugs a tenant may opt into (mirror of EMBED_PROVIDERS). */
56
56
  const KNOWN_EMBED_SLUGS = new Set(KNOWN_EMBEDS.map((p) => p.slug));
@@ -356,6 +356,66 @@ function validateThemeHeadings(theme, file) {
356
356
  return out;
357
357
  }
358
358
 
359
+ const THEME_HEX_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
360
+ const REFERENCE_THEME_COLORS = Object.freeze({
361
+ bg: "#F4F1EA",
362
+ surface: "#FCFAF5",
363
+ text: "#1C2624",
364
+ muted: "#5C6663",
365
+ primary: "#1F3A34",
366
+ "primary-contrast": "#F4F1EA",
367
+ });
368
+ const WCAG_AA_CONTRAST = 4.5;
369
+
370
+ function hexContrastRatio(a, b) {
371
+ if (typeof a !== "string" || typeof b !== "string") return null;
372
+ const ca = a.trim();
373
+ const cb = b.trim();
374
+ if (!THEME_HEX_RE.test(ca) || !THEME_HEX_RE.test(cb)) return null;
375
+ return contrastRatio(ca, cb);
376
+ }
377
+
378
+ /**
379
+ * theme.json WCAG AA contrast: resolved foreground/background pairs (including the
380
+ * bold hero headline's `--color-primary-contrast` on `--color-primary` when
381
+ * `brand.heroVariant` is `"bold"` or omitted) must meet 4.5:1.
382
+ */
383
+ export function validateThemeContrast(theme, file) {
384
+ const out = [];
385
+ if (theme == null || typeof theme !== "object" || Array.isArray(theme)) return out;
386
+ const rawColor = theme.color && typeof theme.color === "object" && !Array.isArray(theme.color) ? theme.color : {};
387
+ const color = { ...REFERENCE_THEME_COLORS, ...rawColor };
388
+ const heroVariant = theme?.brand?.heroVariant ?? "bold";
389
+ const pairs = [
390
+ { fg: "text", bg: "bg", label: "body text (color.text on color.bg)", level: ERROR },
391
+ { fg: "text", bg: "surface", label: "surface text (color.text on color.surface)", level: ERROR },
392
+ heroVariant === "light"
393
+ ? { fg: "primary", bg: "bg", label: "light hero headline (color.primary on color.bg)", level: ERROR }
394
+ : {
395
+ fg: "primary-contrast",
396
+ bg: "primary",
397
+ label: "bold hero headline (color.primary-contrast on color.primary)",
398
+ level: ERROR,
399
+ },
400
+ { fg: "muted", bg: "bg", label: "secondary text (color.muted on color.bg)", level: WARN },
401
+ ];
402
+ for (const pair of pairs) {
403
+ const ratio = hexContrastRatio(color[pair.fg], color[pair.bg]);
404
+ if (ratio !== null && ratio < WCAG_AA_CONTRAST) {
405
+ out.push(
406
+ mk(
407
+ pair.level,
408
+ "theme-contrast",
409
+ file,
410
+ `${pair.label} contrast (${color[pair.fg]} on ${color[pair.bg]}) is ${ratio.toFixed(2)}:1 — below WCAG AA ${WCAG_AA_CONTRAST}:1`,
411
+ `adjust color.${pair.fg} or color.${pair.bg} in ${file} to achieve at least ${WCAG_AA_CONTRAST}:1 contrast`,
412
+ ),
413
+ );
414
+ }
415
+ }
416
+ return out;
417
+ }
418
+
359
419
  const SUPPORTED_BLOCK_CONTRACTS = new Set(BLOCK_PALETTE_SUPPORTED_CONTRACTS);
360
420
  const KNOWN_BLOCKS = new Set([
361
421
  "hero",
@@ -1168,6 +1228,7 @@ export function validateTenant(tenantDir, opts = {}) {
1168
1228
  );
1169
1229
  } else {
1170
1230
  findings.push(...validateThemeHeadings(theme, rel(themePath)));
1231
+ findings.push(...validateThemeContrast(theme, rel(themePath)));
1171
1232
  }
1172
1233
  }
1173
1234