@taprootio/site-authoring 0.42.0 → 0.56.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.
Files changed (80) hide show
  1. package/README.md +110 -12
  2. package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
  3. package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
  4. package/package.json +4 -3
  5. package/src/api.js +242 -23
  6. package/src/appearance-contract.js +264 -3
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/authors-contract.js +71 -3
  9. package/src/block-flow.js +103 -1
  10. package/src/brand-color.js +22 -0
  11. package/src/breadcrumb-artwork.js +234 -0
  12. package/src/breadcrumb-separators.js +11 -0
  13. package/src/changelog.json +160 -0
  14. package/src/chrome-features.js +6 -2
  15. package/src/chrome-input.js +1 -0
  16. package/src/chrome-paint-catalog-taproot.json +3 -3
  17. package/src/chrome-report.js +91 -12
  18. package/src/cli.js +136 -38
  19. package/src/constants.js +1 -0
  20. package/src/content/components.js +27 -4
  21. package/src/content/external-link.js +2 -1
  22. package/src/content/markdown.js +271 -101
  23. package/src/content/tiptap-prosemirror.ts +125 -43
  24. package/src/content/validate-document.js +4 -1
  25. package/src/content-inset.js +48 -0
  26. package/src/errors.js +1 -0
  27. package/src/espalier-shared.js +26 -0
  28. package/src/field-suggestions.js +40 -0
  29. package/src/fixture-init.js +22 -5
  30. package/src/font-catalog.js +11 -1
  31. package/src/footer-brand-inputs.js +22 -3
  32. package/src/footer-content.js +1 -0
  33. package/src/footer-contract.js +11 -0
  34. package/src/footer-cta-styles.js +6 -0
  35. package/src/footer-draft-hash.js +4 -2
  36. package/src/footer-fit.js +62 -15
  37. package/src/footer-workspace.js +44 -7
  38. package/src/latest-posts-tags.js +57 -0
  39. package/src/page-metadata.js +15 -13
  40. package/src/page-structure-checks.js +5 -0
  41. package/src/page-tag-badge-modes.js +6 -0
  42. package/src/page-tag-writes.js +158 -0
  43. package/src/page-type-tags.js +16 -0
  44. package/src/presentation-reference.js +297 -86
  45. package/src/recipe-page-options.js +22 -0
  46. package/src/recipe-step-contract.js +164 -0
  47. package/src/recipe-step-contract.json +65 -0
  48. package/src/reference-help.js +182 -79
  49. package/src/session.js +39 -24
  50. package/src/setting-reference.js +239 -48
  51. package/src/settings-catalog.js +63 -0
  52. package/src/site-check-findings.js +23 -5
  53. package/src/site-check-rules.json +1 -0
  54. package/src/site-health-findings.js +13 -13
  55. package/src/styling-fixed-values.js +71 -0
  56. package/src/tag-destination-warnings.js +35 -0
  57. package/src/template-token-reach.json +242 -0
  58. package/src/theme-proposals.js +18 -27
  59. package/src/theme-resolve.js +265 -23
  60. package/src/theme-validation.js +118 -7
  61. package/src/token-reach.js +222 -0
  62. package/src/typed-page-reference.js +94 -16
  63. package/src/typed-pages.js +233 -74
  64. package/src/verbs/authors.js +198 -33
  65. package/src/verbs/deploy.js +6 -0
  66. package/src/verbs/footer-push.js +30 -5
  67. package/src/verbs/forms-push.js +11 -3
  68. package/src/verbs/index.js +4 -2
  69. package/src/verbs/pages-delete.js +19 -10
  70. package/src/verbs/pages-push.js +225 -71
  71. package/src/verbs/plan.js +10 -4
  72. package/src/verbs/pull.js +324 -69
  73. package/src/verbs/staging-review.js +27 -1
  74. package/src/verbs/status.js +22 -0
  75. package/src/verbs/theme-push.js +93 -25
  76. package/src/verbs/theme-resolve.js +189 -55
  77. package/src/verbs/validate.js +6 -5
  78. package/src/workspace-check.js +35 -3
  79. package/src/workspace.js +73 -2
  80. package/test/fixtures/default-site-theme.json +516 -0
@@ -158,34 +158,23 @@ function toneName(token) {
158
158
  }
159
159
 
160
160
  /**
161
- * The theme with `token` pinned to `lightness` through a tone, on the lint's
162
- * surface. A root without a marker already treats every mapping as a pin, so
163
- * none is added; one is extended, never replaced.
161
+ * Pin a token on one surface. A root without a marker already treats every
162
+ * mapping as a pin.
164
163
  */
165
- function pinnedTheme(theme, surface, root, token, source, tone, lightness) {
166
- const mapping = { source, lightness: `tone:${tone}` };
167
- if (surface === root) {
168
- return {
169
- ...theme,
170
- tones: { ...theme.tones, [tone]: lightness },
171
- semanticMappings: { ...theme.semanticMappings, [token]: mapping },
172
- ...(Array.isArray(theme.explicitMappingTokens)
173
- ? { explicitMappingTokens: [...new Set([...theme.explicitMappingTokens, token])] }
174
- : {}),
175
- };
176
- }
177
- const context = theme.contexts?.[surface] ?? {};
178
- return {
179
- ...theme,
180
- contexts: {
181
- ...theme.contexts,
182
- [surface]: {
183
- ...context,
184
- tones: { ...context.tones, [tone]: lightness },
185
- semanticMappings: { ...context.semanticMappings, [token]: mapping },
186
- },
187
- },
164
+ export function pinnedTheme(theme, context, token, mapping, tones) {
165
+ const surface = context === null ? theme : theme.contexts?.[context] ?? {};
166
+ const pinned = {
167
+ ...surface,
168
+ semanticMappings: { ...surface.semanticMappings, [token]: mapping },
169
+ ...(tones === undefined ? {} : { tones: { ...surface.tones, ...tones } }),
188
170
  };
171
+ if (context !== null) {
172
+ return { ...theme, contexts: { ...theme.contexts, [context]: pinned } };
173
+ }
174
+ if (Array.isArray(theme.explicitMappingTokens)) {
175
+ pinned.explicitMappingTokens = [...new Set([...theme.explicitMappingTokens, token])];
176
+ }
177
+ return pinned;
189
178
  }
190
179
 
191
180
  function surfaceOf(report, root) {
@@ -211,6 +200,7 @@ function proposeLintFix(item, themes, fit, engine, budget, before) {
211
200
  const base = entry === undefined ? null : engine.parseCssColor(entry.resolved);
212
201
  if (base === null || base === undefined || typeof entry.source !== "string") return undefined;
213
202
  const root = fit.ROOT_SURFACE;
203
+ const context = report.surface === root ? null : report.surface;
214
204
  const tone = toneName(target);
215
205
  const lightnesses = [];
216
206
  for (let step = 1; lightnesses.length < MAXIMUM_CANDIDATES && step <= 1 / LIGHTNESS_STEP; step += 1) {
@@ -221,7 +211,8 @@ function proposeLintFix(item, themes, fit, engine, budget, before) {
221
211
  for (const lightness of lightnesses) {
222
212
  if (budget.remaining <= 0) return undefined;
223
213
  budget.remaining -= 1;
224
- const patched = pinnedTheme(themes[scheme], report.surface, root, target, entry.source, tone, lightness);
214
+ const mapping = { source: entry.source, lightness: `tone:${tone}` };
215
+ const patched = pinnedTheme(themes[scheme], context, target, mapping, { [tone]: lightness });
225
216
  const encoded = encodePair(...withScheme(themes, scheme, patched));
226
217
  let after;
227
218
  try {
@@ -1,7 +1,12 @@
1
1
  import {
2
2
  AA_LARGE_RATIO,
3
3
  AA_TEXT_RATIO,
4
+ DEFAULT_DARK_THEME,
5
+ DEFAULT_LIGHT_THEME,
6
+ LIGHTNESS_KEYS,
7
+ mergeTheme,
4
8
  parseTheme,
9
+ resolveContextTheme,
5
10
  SEMANTIC_COLOR_NAMES,
6
11
  TOKEN_PAIRINGS,
7
12
  wcagRatio,
@@ -11,17 +16,16 @@ import { CHROME_NAVIGATION_UNAVAILABLE_MESSAGE } from "./chrome-input.js";
11
16
  import { CHROME_UNAVAILABLE_MESSAGE, decodeChromePair, floorTo } from "./chrome-output.js";
12
17
  import { SiteAuthoringError } from "./errors.js";
13
18
  import { loadEspalierShared } from "./espalier-shared.js";
19
+ import { pinnedTheme } from "./theme-proposals.js";
14
20
  import { validateAndEncodeThemePair } from "./theme-validation.js";
21
+ import { formatTokenPaints, getTokenDerivation } from "./token-reach.js";
15
22
 
16
23
  /**
17
24
  * `theme resolve` (TR01228): the colors Espalier compiles from a stored theme,
18
25
  * with the contrast of every ink-on-surface pairing it defines.
19
26
  *
20
- * Nothing here compiles a color. The fit report suite is the same compile
21
- * `theme push` lints and the page renders through (`computeThemeProperties`,
22
- * and `resolveContextTheme` for each context), so a resolved value cannot
23
- * disagree with the render. This module only reads that result and measures
24
- * it.
27
+ * The fit report suite uses the same compiler as the page. The raw trace from
28
+ * that compiler gives the pre-fit APCA measurements and verifies passing stops.
25
29
  */
26
30
 
27
31
  export const THEME_STYLES_FILE = "settings/taproot-styles.json";
@@ -34,10 +38,11 @@ const LARGE_TEXT_LC = 60;
34
38
  export const CONTRAST_TEXT_BELOW_AA = "theme.contrast_text_below_aa";
35
39
 
36
40
  const THEME_SCHEMES = Object.freeze(["light", "dark"]);
41
+ const THEME_DEFAULTS = Object.freeze({ light: DEFAULT_LIGHT_THEME, dark: DEFAULT_DARK_THEME });
37
42
 
38
43
  let engines;
44
+ let traceCompiler;
39
45
 
40
- /** The fit report and color engine are Espalier modules beside the exported theme module (see espalier-shared.js). */
41
46
  export function loadThemeEngines() {
42
47
  engines ??= Promise.all([
43
48
  loadEspalierShared("theme-fit-report.js"),
@@ -46,6 +51,13 @@ export function loadThemeEngines() {
46
51
  return engines;
47
52
  }
48
53
 
54
+ /** Only adjusted colors need the exact Espalier pin's raw compiler trace. */
55
+ export function loadThemeTraceCompiler() {
56
+ traceCompiler ??= loadEspalierShared("../root/helpers/compute-theme-properties.js")
57
+ .then(({ computeThemeProperties }) => computeThemeProperties);
58
+ return traceCompiler;
59
+ }
60
+
49
61
  /** The sRGB the engine gamut-maps a compiled color to, as channels in 0..1 and as #rrggbb. */
50
62
  function toSrgb(color, value) {
51
63
  const parsed = color.parseCssColor(value);
@@ -91,12 +103,73 @@ function contrastFlag(pair, scheme, context) {
91
103
  };
92
104
  }
93
105
 
94
- function describeSurface(color, report, scheme, rootSurface) {
95
- const context = report.surface === rootSurface ? null : report.surface;
106
+ function measureLc(color, foreground, background) {
107
+ return Math.abs(color.apcaContrast(foreground, background));
108
+ }
109
+
110
+ function emittedLc(color, foreground, background) {
111
+ return measureLc(color, color.parseOklch(foreground), color.parseOklch(background));
112
+ }
113
+
114
+ function describeTokenContrast(color, token, raw) {
115
+ const { requested, resolved, apca: { against, againstColor, targetLc }, anchor } = token;
116
+ return {
117
+ requested,
118
+ resolved,
119
+ against,
120
+ againstColor,
121
+ targetLc,
122
+ requestedLc: measureLc(color, raw.requested, raw.contrast.background),
123
+ resolvedLc: emittedLc(color, resolved, againstColor),
124
+ ...(anchor === undefined ? {} : { reference: anchor.reference, deltaE: anchor.deltaE }),
125
+ };
126
+ }
127
+
128
+ function traceSurface(computeThemeProperties, theme, scheme, footerTrace) {
129
+ const trace = [];
130
+ computeThemeProperties(theme, scheme, trace, undefined, undefined, footerTrace);
131
+ return new Map(trace.map((entry) => [entry.token, entry]));
132
+ }
133
+
134
+ function effectiveSurface(theme, context) {
135
+ return context === null ? theme : resolveContextTheme(theme, context);
136
+ }
137
+
138
+ function candidateStops(effective) {
139
+ return LIGHTNESS_KEYS.map((stop) => ({ stop, lightness: effective.lightness[stop] }));
140
+ }
141
+
142
+ function passingStopFieldBytes(stop) {
143
+ // Adding a field takes one comma and all of its object body bytes.
144
+ return Buffer.byteLength(JSON.stringify({ passingStop: stop }), "utf8") - 1;
145
+ }
146
+
147
+ function nearestPassingStop({ fit, color }, theme, effective, stops, scheme, context, token, trace, footer = false) {
148
+ const { base, requested: { l: requestedL }, contrast: { background, targetLc } } = trace;
149
+ const { min, max } = effective.chroma[token.token];
150
+ const emittedBackground = color.serializeOklch(background);
151
+ // Equal distances keep ramp order.
152
+ const ordered = [...stops].sort((left, right) => Math.abs(left.lightness - requestedL) - Math.abs(right.lightness - requestedL));
153
+ for (const candidate of ordered) {
154
+ const requested = color.deriveSemantic(base, candidate.lightness, min, max);
155
+ if (measureLc(color, requested, background) < targetLc) continue;
156
+ if (emittedLc(color, color.serializeOklch(requested), emittedBackground) < targetLc) continue;
157
+ const mapping = { source: token.source, lightness: candidate.stop };
158
+ const patched = mergeTheme(THEME_DEFAULTS[scheme], pinnedTheme(theme, context, token.token, mapping));
159
+ const report = fit.themeFitReport(patched, scheme, { context: context ?? undefined });
160
+ const fitted = (footer ? report.footerTokens : report.tokens).find((entry) => entry.token === token.token);
161
+ if (fitted.explicit !== "declared" || fitted.adjusted) continue;
162
+ if (emittedLc(color, fitted.resolved, fitted.apca.againstColor) >= fitted.apca.targetLc) return candidate;
163
+ }
164
+ return null;
165
+ }
166
+
167
+ function describeSurface(color, report, scheme, context, trace) {
96
168
  const resolved = new Map();
97
169
  const tokens = report.tokens.map((token) => {
98
170
  const measured = toSrgb(color, token.resolved);
99
171
  resolved.set(token.token, measured);
172
+ const derivation = getTokenDerivation(token.token);
100
173
  return {
101
174
  token: token.token,
102
175
  value: token.resolved,
@@ -104,8 +177,11 @@ function describeSurface(color, report, scheme, rootSurface) {
104
177
  origin: origin(token),
105
178
  source: token.source,
106
179
  lightness: token.lightness,
107
- // Only when APCA enforcement moved it off the requested value; absent is the usual case.
108
- ...(token.adjusted ? { adjusted: true } : {}),
180
+ derivesFrom: derivation === null ? null : { role: derivation.role, slot: derivation.slot },
181
+ ...(token.adjusted ? {
182
+ adjusted: true,
183
+ contrast: describeTokenContrast(color, token, trace.get(token.token)),
184
+ } : {}),
109
185
  };
110
186
  });
111
187
  const pairs = [];
@@ -115,7 +191,7 @@ function describeSurface(color, report, scheme, rootSurface) {
115
191
  if (foreground === undefined || background === undefined) continue;
116
192
  const required = pairing.targetLc <= LARGE_TEXT_LC ? AA_LARGE_RATIO : AA_TEXT_RATIO;
117
193
  const ratio = wcagRatio(foreground.srgb, background.srgb);
118
- const lc = Math.abs(color.apcaContrast(foreground.parsed, background.parsed));
194
+ const lc = measureLc(color, foreground.parsed, background.parsed);
119
195
  pairs.push({
120
196
  token: ink,
121
197
  background: pairing.bg,
@@ -129,7 +205,13 @@ function describeSurface(color, report, scheme, rootSurface) {
129
205
  }
130
206
  const flags = pairs.filter((pair) => !pair.aa).map((pair) => contrastFlag(pair, scheme, context));
131
207
  return {
132
- surface: { context, tokens, pairs, pinned: tokens.filter((token) => token.origin !== "compiled").map((token) => token.token) },
208
+ surface: {
209
+ context,
210
+ tokens,
211
+ pairs,
212
+ pinned: tokens.filter((token) => token.origin !== "compiled").map((token) => token.token),
213
+ componentProperties: report.componentProperties,
214
+ },
133
215
  flags,
134
216
  };
135
217
  }
@@ -142,12 +224,16 @@ function describeSurface(color, report, scheme, rootSurface) {
142
224
  * Throws what `theme push` would throw for an incomplete or invalid theme, and
143
225
  * a `theme.context_unknown` refusal for a context the theme does not declare.
144
226
  */
145
- export async function resolveThemePair(lightTheme, darkTheme, { scheme, context } = {}) {
227
+ export async function resolveThemePair(lightTheme, darkTheme, {
228
+ scheme, context, footerContext, deferPassingStops = false,
229
+ } = {}) {
146
230
  const encoded = validateAndEncodeThemePair(lightTheme, darkTheme);
147
231
  const { light, dark } = encoded;
148
- const { fit, color } = await loadThemeEngines();
232
+ const themeEngines = await loadThemeEngines();
233
+ const { fit, color } = themeEngines;
149
234
  // The stored pair is encoded and parsed back, as theme push's fit lints do, so this is what the page resolves.
150
- const suite = fit.themeFitReportSuite(parseTheme(light) ?? {}, parseTheme(dark) ?? {});
235
+ const themes = { light: parseTheme(light) ?? {}, dark: parseTheme(dark) ?? {} };
236
+ const suite = fit.themeFitReportSuite(themes.light, themes.dark);
151
237
  const contexts = suite.surfaces.filter((surface) => surface !== fit.ROOT_SURFACE);
152
238
  if (context !== undefined && !contexts.includes(context)) {
153
239
  throw new SiteAuthoringError(
@@ -159,21 +245,79 @@ export async function resolveThemePair(lightTheme, darkTheme, { scheme, context
159
245
  );
160
246
  }
161
247
 
248
+ const details = new WeakMap();
249
+ // The verb checks the preliminary surface against its budget before fitting candidates.
250
+ function enrichSurface(name, surface) {
251
+ const detail = details.get(surface);
252
+ if (detail === undefined) return surface;
253
+ detail.complete ??= {
254
+ ...surface,
255
+ tokens: surface.tokens.map((token) => token.adjusted ? {
256
+ ...token,
257
+ contrast: {
258
+ ...token.contrast,
259
+ passingStop: nearestPassingStop(
260
+ themeEngines, themes[name], detail.effective, detail.stops, name, surface.context, token,
261
+ detail.trace.get(token.token),
262
+ ),
263
+ },
264
+ } : token),
265
+ ...(surface.footerInks ? {
266
+ footerInks: surface.footerInks.map(ink => ink.adjusted ? {
267
+ ...ink,
268
+ passingStop: nearestPassingStop(
269
+ themeEngines, themes[name], detail.effective, detail.stops, name, surface.context, ink,
270
+ detail.footerTrace.get(ink.token), true,
271
+ ),
272
+ } : ink),
273
+ } : {}),
274
+ };
275
+ return detail.complete;
276
+ }
277
+
162
278
  const schemes = [];
163
279
  const flags = [];
280
+ let computeThemeProperties;
164
281
  for (const name of THEME_SCHEMES) {
165
282
  if (scheme !== undefined && scheme !== name) continue;
283
+ const root = mergeTheme(THEME_DEFAULTS[name], themes[name]);
166
284
  const surfaces = [];
167
285
  for (const report of suite[name]) {
168
286
  if (context !== undefined && report.surface !== context) continue;
169
- const described = describeSurface(color, report, name, fit.ROOT_SURFACE);
170
- surfaces.push(described.surface);
287
+ const contextName = report.surface === fit.ROOT_SURFACE ? null : report.surface;
288
+ const footerTokens = footerContext === contextName ? report.footerTokens : undefined;
289
+ const requiresTrace = report.adjustedTokens.length > 0 || footerTokens !== undefined;
290
+ const effective = requiresTrace ? effectiveSurface(root, contextName) : undefined;
291
+ const footerTrace = footerTokens === undefined ? undefined : [];
292
+ if (requiresTrace) computeThemeProperties ??= await loadThemeTraceCompiler();
293
+ const trace = requiresTrace ? traceSurface(computeThemeProperties, effective, name, footerTrace) : new Map();
294
+ const footers = new Map(footerTrace?.map(entry => [entry.token, entry]));
295
+ const described = describeSurface(color, report, name, contextName, trace);
296
+ if (footerTokens !== undefined) {
297
+ described.surface.footerInks = footerTokens.map(token => ({
298
+ token: token.token,
299
+ source: token.source,
300
+ lightness: token.lightness,
301
+ adjusted: token.adjusted,
302
+ ...describeTokenContrast(color, token, footers.get(token.token)),
303
+ }));
304
+ }
305
+ if (requiresTrace) {
306
+ const stops = candidateStops(effective);
307
+ const largestStop = Math.max(passingStopFieldBytes(null), ...stops.map(passingStopFieldBytes));
308
+ details.set(described.surface, {
309
+ effective, trace, stops, footerTrace: footers,
310
+ passingStopBytes: (report.adjustedTokens.length + (footerTokens?.filter(token => token.adjusted).length ?? 0))
311
+ * largestStop,
312
+ });
313
+ }
314
+ surfaces.push(deferPassingStops ? described.surface : enrichSurface(name, described.surface));
171
315
  flags.push(...described.flags);
172
316
  }
173
317
  schemes.push({ scheme: name, surfaces });
174
318
  }
175
319
  const pairs = schemes.flatMap((entry) => entry.surfaces).flatMap((surface) => surface.pairs);
176
- return Object.defineProperty({
320
+ return Object.defineProperties({
177
321
  contexts,
178
322
  schemes,
179
323
  flags,
@@ -182,7 +326,11 @@ export async function resolveThemePair(lightTheme, darkTheme, { scheme, context
182
326
  belowAa: pairs.filter((pair) => !pair.aa).length,
183
327
  belowApca: pairs.filter((pair) => !pair.apcaMet).length,
184
328
  },
185
- }, "encoded", { value: encoded });
329
+ }, {
330
+ encoded: { value: encoded },
331
+ enrichSurface: { value: enrichSurface },
332
+ passingStopByteBound: { value: (surface) => details.get(surface)?.passingStopBytes ?? 0 },
333
+ });
186
334
  }
187
335
 
188
336
  const TOKEN_ORDER = new Map(SEMANTIC_COLOR_NAMES.map((name, index) => [name, index]));
@@ -196,6 +344,45 @@ function table(rows) {
196
344
  return rows.map((row) => ` ${row.map((cell, column) => pad(cell, widths[column])).join(" ").trimEnd()}`).join("\n");
197
345
  }
198
346
 
347
+ function formatComponentContrast({ apca, adjusted, targetLc }) {
348
+ if (apca === undefined) return "";
349
+ return `Lc ${floorTo(apca.fromLc, 1)} → ${floorTo(apca.toLc, 1)} (target ${targetLc}) on ${apca.against} `
350
+ + `(${apca.againstColor}), ${adjusted ? "adjusted" : "unchanged"}`;
351
+ }
352
+
353
+ function displayLc(value, target) {
354
+ const shown = floorTo(value, 1);
355
+ return value < target && shown >= target ? target - 0.1 : shown;
356
+ }
357
+
358
+ function colorLightness(oklch) {
359
+ return oklch.slice("oklch(".length, oklch.indexOf(" "));
360
+ }
361
+
362
+ function formatTokenContrast({ token, contrast }, context) {
363
+ const { requested, resolved, against, targetLc, requestedLc, resolvedLc, passingStop } = contrast;
364
+ const ground = context === null ? against : `${context} ${against}`;
365
+ const renderedLightness = colorLightness(resolved);
366
+ const sentences = [
367
+ `${token} requested L ${colorLightness(requested)} reaches Lc ${displayLc(requestedLc, targetLc)} against ${ground}.`,
368
+ `Target Lc ${targetLc}.`,
369
+ `Renders at L ${renderedLightness}.`,
370
+ ];
371
+ if (resolvedLc < targetLc) sentences.push(`Rendered contrast still falls short at Lc ${displayLc(resolvedLc, targetLc)}.`);
372
+ if (passingStop === null) {
373
+ if (resolvedLc >= targetLc) {
374
+ sentences.push(`Try a custom tone at L ${renderedLightness} and rerun theme resolve to verify the pin.`);
375
+ } else {
376
+ sentences.push("No named stop passes.");
377
+ }
378
+ } else if (passingStop !== undefined) sentences.push(`Pin lightness \`${passingStop.stop}\` to pass without a lift.`);
379
+ return sentences.join(" ");
380
+ }
381
+
382
+ function surfaceName(context) {
383
+ return context === null ? "page (root)" : `context ${context}`;
384
+ }
385
+
199
386
  /**
200
387
  * The human table for a result. Tokens keep Espalier's own order, so a
201
388
  * background and its layers read together; a pinned or inherited value is
@@ -205,17 +392,27 @@ export function formatThemeResolve(result) {
205
392
  const lines = [`Compiled colors from the ${result.source === "site" ? "site's" : "workspace"} theme.`];
206
393
  for (const { scheme, surfaces } of result.schemes) {
207
394
  for (const surface of surfaces) {
208
- lines.push("", `${scheme} · ${surface.context === null ? "page (root)" : `context ${surface.context}`}`);
395
+ lines.push("", `${scheme} · ${surfaceName(surface.context)}`);
209
396
  const tokens = [...surface.tokens].sort((left, right) => TOKEN_ORDER.get(left.token) - TOKEN_ORDER.get(right.token));
210
397
  lines.push(table([
211
- ["token", "value", "hex", "from"],
398
+ ["token", "value", "hex", "from", "static role plan"],
212
399
  ...tokens.map((token) => [
213
400
  token.token,
214
401
  token.value,
215
402
  token.hex ?? "-",
216
403
  `${token.origin === "compiled" ? "" : `${token.origin.replace("_", " ")}: `}${token.source} @ ${token.lightness}${token.adjusted ? " (adjusted for contrast)" : ""}`,
404
+ token.derivesFrom ? `${token.derivesFrom.role}.${token.derivesFrom.slot}` : "-",
217
405
  ]),
218
406
  ]));
407
+ const adjusted = tokens.filter((token) => token.contrast !== undefined);
408
+ for (const token of adjusted) lines.push(` ${formatTokenContrast(token, surface.context)}`);
409
+ for (const ink of surface.footerInks ?? []) {
410
+ lines.push(` ${formatTokenContrast({ token: "footer " + ink.token, contrast: ink }, surface.context)}`);
411
+ lines.push(` Requested ${ink.requested}. Rendered ${ink.resolved} at Lc ${displayLc(ink.resolvedLc, ink.targetLc)}.`);
412
+ }
413
+ if (surface.footerLinkOnLayer2) {
414
+ lines.push(" The site-chrome table shows resting footer links on layer2.");
415
+ }
219
416
  lines.push("", table([
220
417
  ["ink", "on", "ratio", "needs", "apca", ""],
221
418
  ...surface.pairs.map((pair) => [
@@ -227,6 +424,27 @@ export function formatThemeResolve(result) {
227
424
  pair.aa ? "ok" : "BELOW AA",
228
425
  ]),
229
426
  ]));
427
+ if (surface.badgePaint?.length) {
428
+ lines.push("", "Tag badges", table([
429
+ ["element/state", "ink", "on", "ratio", "needs", ""],
430
+ ...surface.badgePaint.map(pair => [
431
+ `${pair.element}/${pair.state}`, pair.foreground, pair.background,
432
+ `${pair.ratio.toFixed(2)}:1`, `${pair.required.toFixed(2)}:1`, pair.ratio < pair.required ? (pair.kind === "ring" ? "BELOW AA" : "LOW CONTRAST") : "ok",
433
+ ]),
434
+ ]));
435
+ }
436
+ if (surface.componentProperties.length > 0) {
437
+ lines.push("", "Component properties");
438
+ for (const property of surface.componentProperties) {
439
+ const override = property.overridesRoot ? "yes" : "no";
440
+ const contrast = formatComponentContrast(property);
441
+ lines.push(
442
+ ` ${property.name}`,
443
+ ` Authored ${JSON.stringify(property.authored)} → resolved ${property.resolved}. Root override ${override}.`,
444
+ );
445
+ if (contrast !== "") lines.push(` ${contrast}`);
446
+ }
447
+ }
230
448
  }
231
449
  }
232
450
  for (const [scheme, entries] of Object.entries(result.chrome ?? {})) {
@@ -256,9 +474,33 @@ export function formatThemeResolve(result) {
256
474
  lines.push("", belowAa === 0
257
475
  ? `All ${pairs}${measured} pairs meet WCAG AA.`
258
476
  : `${belowAa} of ${pairs}${measured} pairs are below WCAG AA${flags}.`);
477
+ if (result.paintCatalog !== undefined) {
478
+ lines.push("", "What selected tokens paint", ...formatTokenPaints(result.tokens, result.paintCatalog));
479
+ }
480
+ if (result.omittedTokens?.length > 0) {
481
+ lines.push("", `Paint details omitted for ${result.omittedTokens.join(", ")}. See '${result.omittedTokensHelp}'.`);
482
+ }
259
483
  if (result.omittedSurfaces !== undefined) {
260
- const names = result.omittedSurfaces.items.map((entry) => `${entry.scheme}/${entry.context ?? "root"}`);
261
- lines.push(`Not shown (result size): ${names.join(", ")}${result.omittedSurfaces.truncated ? ", and more" : ""}. Narrow with --scheme and --context.`);
484
+ const { items, count, oversizedCount = 0, retryRootSchemes = [], truncated } = result.omittedSurfaces;
485
+ const oversizedLabel = "too large under the narrowest selectors";
486
+ lines.push("", `Omitted surfaces (${count} total, ${oversizedCount} ${oversizedLabel})`);
487
+ for (const { scheme, context, reason } of items) {
488
+ const note = reason === "surface_too_large" ? ` [${oversizedLabel}]` : "";
489
+ lines.push(` ${scheme} · ${surfaceName(context)}${note}`);
490
+ }
491
+ if (truncated) lines.push(" Additional omitted surfaces exceed the name list budget.");
492
+ for (const scheme of retryRootSchemes) {
493
+ lines.push(`Use --scheme ${scheme} to view the omitted ${scheme} root page.`);
494
+ }
495
+ if (retryRootSchemes.length > 0) lines.push("A root retry keeps its scheme's named contexts and chrome.");
496
+ if (count > oversizedCount + retryRootSchemes.length) {
497
+ lines.push("Use --scheme and --context to view named contexts that fit when selected.");
498
+ lines.push("Read full names under lightTheme.contexts or darkTheme.contexts in settings/taproot-styles.json.");
499
+ if (result.source === "site") {
500
+ lines.push("Run taproot-site pull in a separate workspace for the same site to preserve local edits.");
501
+ }
502
+ }
503
+ if (oversizedCount > 0) lines.push("Shorten long component property values or context names to view oversized surfaces.");
262
504
  }
263
505
  return `${lines.join("\n")}\n`;
264
506
  }