@taprootio/site-authoring 0.41.1 → 0.55.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 (78) hide show
  1. package/README.md +50 -0
  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 +170 -11
  6. package/src/appearance-contract.js +278 -8
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/block-flow.js +103 -1
  9. package/src/brand-color.js +39 -4
  10. package/src/breadcrumb-artwork.js +234 -0
  11. package/src/breadcrumb-separators.js +11 -0
  12. package/src/changelog.json +154 -0
  13. package/src/chrome-features.js +152 -0
  14. package/src/chrome-input.js +147 -0
  15. package/src/chrome-output.js +92 -0
  16. package/src/chrome-paint-catalog-taproot.json +52 -0
  17. package/src/chrome-report.js +173 -0
  18. package/src/cli.js +48 -17
  19. package/src/content/components.js +27 -4
  20. package/src/content/external-link.js +2 -1
  21. package/src/content/markdown.js +271 -101
  22. package/src/content/tiptap-prosemirror.ts +125 -43
  23. package/src/content/validate-document.js +4 -1
  24. package/src/content-inset.js +48 -0
  25. package/src/errors.js +1 -0
  26. package/src/espalier-shared.js +26 -0
  27. package/src/field-suggestions.js +40 -0
  28. package/src/fixture-init.js +22 -5
  29. package/src/font-catalog.js +11 -1
  30. package/src/footer-brand-inputs.js +25 -2
  31. package/src/footer-content.js +38 -0
  32. package/src/footer-contract.js +11 -0
  33. package/src/footer-cta-styles.js +6 -0
  34. package/src/footer-draft-hash.js +4 -2
  35. package/src/footer-fit.js +62 -15
  36. package/src/footer-workspace.js +60 -16
  37. package/src/header-presentation.js +16 -0
  38. package/src/latest-posts-tags.js +57 -0
  39. package/src/page-structure-checks.js +5 -0
  40. package/src/page-tag-badge-modes.js +6 -0
  41. package/src/page-tag-writes.js +158 -0
  42. package/src/page-type-tags.js +16 -0
  43. package/src/presentation-reference.js +312 -86
  44. package/src/recipe-page-options.js +22 -0
  45. package/src/recipe-step-contract.js +164 -0
  46. package/src/recipe-step-contract.json +65 -0
  47. package/src/reference-help.js +164 -78
  48. package/src/session.js +39 -24
  49. package/src/setting-reference.js +239 -48
  50. package/src/settings-catalog.js +63 -0
  51. package/src/site-check-findings.js +25 -5
  52. package/src/site-check-rules.json +3 -1
  53. package/src/site-health-findings.js +13 -13
  54. package/src/site-navigation-groups.js +70 -0
  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 +305 -51
  60. package/src/theme-validation.js +126 -6
  61. package/src/token-reach.js +222 -0
  62. package/src/typed-page-reference.js +72 -15
  63. package/src/typed-pages.js +171 -71
  64. package/src/verbs/deploy.js +6 -0
  65. package/src/verbs/footer-push.js +30 -5
  66. package/src/verbs/forms-push.js +11 -3
  67. package/src/verbs/pages-delete.js +19 -10
  68. package/src/verbs/pages-push.js +125 -36
  69. package/src/verbs/plan.js +10 -4
  70. package/src/verbs/pull.js +277 -67
  71. package/src/verbs/staging-review.js +27 -1
  72. package/src/verbs/status.js +22 -0
  73. package/src/verbs/theme-push.js +249 -120
  74. package/src/verbs/theme-resolve.js +310 -47
  75. package/src/verbs/validate.js +71 -17
  76. package/src/workspace-check.js +37 -4
  77. package/src/workspace.js +37 -1
  78. package/test/fixtures/default-site-theme.json +516 -0
@@ -0,0 +1,147 @@
1
+ import { NAV_ITEM_KIND_EXTERNAL_URL, NAV_ITEM_KIND_PAGE, PAGE_STATUS_PUBLISHED } from "./api.js";
2
+ import { resolveBrandColors, resolveBrandColorSourceFields, resolveBrandColorToken, resolveFooterBrandColors } from "./brand-color.js";
3
+ import { chromeFeatures } from "./chrome-features.js";
4
+ import { isCanonicalUuid } from "./errors.js";
5
+ import { validateFooterDocument } from "./footer-contract.js";
6
+ import { resolveFooterLogoPairs } from "./footer-branding.js";
7
+ import { resolveHeaderLogoPairs } from "./header-presentation.js";
8
+ import { logoInputsFromSettings } from "./logo-inputs.js";
9
+ import { sharedDeclaredThemeContextNames } from "./theme-contexts.js";
10
+ import { validateNavigationWorkspaceDocument } from "./verbs/nav-push.js";
11
+ import { NAVIGATION_FILE_NAME, normalizePagePath, readWorkspaceJson, WORKSPACE_LIMITS } from "./workspace.js";
12
+
13
+ export const CHROME_NAVIGATION_UNAVAILABLE_MESSAGE =
14
+ "Navigation contrast was not checked because navigation information was unavailable.";
15
+
16
+ export const CHROME_OFFLINE_PAGE_LIMITATION =
17
+ "navigation or footer page-link contrast for destinations without a published path in the workspace inventory";
18
+
19
+ export const CHROME_REPORT_NAME_RULE = "theme.chrome_report_name";
20
+
21
+ // The workspace has no eligibility projection until TR01385.
22
+ export function selectNameReportEligibility({ saved, current, manifest }) {
23
+ return undefined;
24
+ }
25
+
26
+ function isSettingsOnly(resources) {
27
+ return resources.settingsOnly === true || resources.manifest?.authoringSurface !== undefined;
28
+ }
29
+
30
+ /** Take optional workspace evidence while the caller still owns its read snapshot. */
31
+ export async function captureChromeResources(resources) {
32
+ if (resources.workspaceDir === undefined || isSettingsOnly(resources) || Object.hasOwn(resources, "navigation")) return resources;
33
+ const { manifest, siteId, workspaceDir, knownPageResourceIds } = resources;
34
+ try {
35
+ const parsed = await readWorkspaceJson(workspaceDir, NAVIGATION_FILE_NAME, WORKSPACE_LIMITS.navigationBytes);
36
+ const knownPages = manifest === undefined ? undefined : {
37
+ pageIds: new Set(manifest.pages.map((page) => page?.pageId).filter(isCanonicalUuid)),
38
+ resourceIds: knownPageResourceIds,
39
+ };
40
+ const navigation = validateNavigationWorkspaceDocument(parsed, siteId, knownPages);
41
+ return { ...resources, navigation };
42
+ } catch {
43
+ return { ...resources, navigation: undefined };
44
+ }
45
+ }
46
+
47
+ function workspacePublishedPagePaths(manifest) {
48
+ const paths = new Map();
49
+ for (const page of manifest?.pages ?? []) {
50
+ if (page?.status !== PAGE_STATUS_PUBLISHED || !isCanonicalUuid(page.resourceId)) continue;
51
+ const path = normalizePagePath(page.path);
52
+ if (path !== undefined) paths.set(page.resourceId, `/${path}`);
53
+ }
54
+ return paths;
55
+ }
56
+
57
+ function resolveNavigation(items, pagePaths) {
58
+ return items?.map((item) => ({
59
+ ...item,
60
+ url: item.kind === NAV_ITEM_KIND_PAGE
61
+ ? (pagePaths === undefined ? "/" : pagePaths.get(item.resourceId) ?? "")
62
+ : item.kind === NAV_ITEM_KIND_EXTERNAL_URL
63
+ ? item.externalUrl
64
+ : "",
65
+ children: resolveNavigation(item.children, pagePaths) ?? [],
66
+ }));
67
+ }
68
+
69
+ function resolveLogoPairs(style, header, footer, media, delivery) {
70
+ const input = logoInputsFromSettings(style, footer, media);
71
+ // Local art is represented by an image identity. An authoritative response
72
+ // can also say that an assigned image has no delivery URL.
73
+ for (const name of ["light", "dark", "lightCompact", "darkCompact"]) {
74
+ const id = `${name}LogoId`;
75
+ const url = `${name}LogoUrl`;
76
+ const delivered = delivery?.styleSettings;
77
+ if (delivered?.[id] && delivered[id] === style?.[id]) {
78
+ input[url] = typeof delivered[url] === "string" ? delivered[url] : "";
79
+ }
80
+ }
81
+ for (const scheme of ["light", "dark"]) {
82
+ const delivered = delivery?.sitePublishingPreferences?.footerSettings?.[scheme];
83
+ if (delivered?.logoId && delivered.logoId === footer?.[scheme]?.logoId) {
84
+ input[`${scheme}FooterLogoUrl`] = typeof delivered.logoUrl === "string" ? delivered.logoUrl : "";
85
+ }
86
+ }
87
+ return {
88
+ header: resolveHeaderLogoPairs({ ...input, logoVariant: header?.logoVariant }),
89
+ footer: resolveFooterLogoPairs({ ...input, logoVariant: footer?.logoVariant }),
90
+ };
91
+ }
92
+
93
+ function checkedFooterSettings(publishing, resources) {
94
+ if (Object.hasOwn(resources, "footerSettings")) return resources.footerSettings;
95
+ if (publishing?.footerSettings === undefined) return undefined;
96
+ try {
97
+ return validateFooterDocument(publishing.footerSettings, {
98
+ knownPageResourceIds: resources.knownPageResourceIds,
99
+ knownImageIds: resources.knownImageIds,
100
+ });
101
+ } catch {
102
+ return undefined;
103
+ }
104
+ }
105
+
106
+ /** The report uses the appearance and resources already accepted by the caller. */
107
+ export function buildChromeInput({ appearance, resources, nameReportEnabled }) {
108
+ const { style, header, footerPresentation } = appearance;
109
+ const publishing = resources.presentation === undefined
110
+ ? appearance.publishing
111
+ : resources.presentation.sitePublishingPreferences;
112
+ const footer = checkedFooterSettings(publishing, resources);
113
+ const footerSettings = footer === undefined ? undefined : { ...footer, ...footerPresentation };
114
+ const settingsOnly = isSettingsOnly(resources);
115
+ const footerPagePaths = settingsOnly ? new Map()
116
+ : resources.source === "site" ? undefined
117
+ : workspacePublishedPagePaths(resources.manifest);
118
+ const navItems = settingsOnly ? undefined : resolveNavigation(resources.navigation?.navItems, footerPagePaths);
119
+ const logoPairs = resolveLogoPairs(style, header, footerSettings, resources.mediaManifest?.media, resources.presentation);
120
+ const headerBrandColors = resolveBrandColors(header, resolveBrandColorToken);
121
+ const features = chromeFeatures({
122
+ headerSettings: header,
123
+ footerSettings,
124
+ navItems,
125
+ footerPagePaths,
126
+ logoPairs,
127
+ searchEnabled: publishing?.allowSearch === true,
128
+ hasIconSprite: true,
129
+ nameReportEnabled: footerSettings === undefined ? undefined : nameReportEnabled,
130
+ });
131
+ const contexts = new Set(sharedDeclaredThemeContextNames(style?.lightTheme, style?.darkTheme));
132
+ const surfaces = [
133
+ { role: "header", context: header?.context || null, brandColors: headerBrandColors, features: features.header },
134
+ {
135
+ role: "footer",
136
+ context: footerSettings?.enabled === true ? footerSettings.context || null : null,
137
+ brandColors: resolveFooterBrandColors(headerBrandColors),
138
+ features: features.footer,
139
+ },
140
+ ];
141
+ return {
142
+ paintSurfaces: surfaces.filter(({ context, features }) => features !== undefined && (context === null || contexts.has(context))),
143
+ brandColorSourceFields: resolveBrandColorSourceFields(header),
144
+ badgeSettings: settingsOnly ? undefined : resources.badgeSettings ?? publishing,
145
+ navigationUnavailable: navItems === undefined,
146
+ };
147
+ }
@@ -0,0 +1,92 @@
1
+ export const CHROME_UNAVAILABLE_MESSAGE = "Chrome contrast was not checked because the theme report was unavailable.";
2
+
3
+ const CONTEXT_DISPLAY_LENGTH = 128;
4
+
5
+ // Shown ratios round down, so a pair 0.004 short of AA never displays as 4.50.
6
+ export function floorTo(value, places) {
7
+ const scale = 10 ** places;
8
+ return Math.floor(value * scale + 1e-9) / scale;
9
+ }
10
+
11
+ export function displayChromeRatio(ratio, required) {
12
+ const shown = floorTo(ratio, 2);
13
+ // The tolerance in floorTo can otherwise round a value just below AA up to AA.
14
+ return ratio < required && shown >= required ? required - 0.01 : shown;
15
+ }
16
+
17
+ export function displayChromeContext(context) {
18
+ if (context === null || context.length <= CONTEXT_DISPLAY_LENGTH) return { context };
19
+ return {
20
+ context: context.slice(0, CONTEXT_DISPLAY_LENGTH),
21
+ contextTruncated: true,
22
+ contextLength: context.length,
23
+ };
24
+ }
25
+
26
+ function dictionary(values) {
27
+ const items = [...new Set(values)].sort();
28
+ return { items, indexes: new Map(items.map((item, index) => [item, index])) };
29
+ }
30
+
31
+ function identityKey({ element, foreground, background, state, kind }) {
32
+ return JSON.stringify([element, foreground, background, state, kind]);
33
+ }
34
+
35
+ /** Index the selected paint while retaining the callers' scheme, card and row order. */
36
+ export function indexChromePaint(entries) {
37
+ const identities = new Map();
38
+ for (const cards of Object.values(entries)) {
39
+ for (const { pairs } of cards) {
40
+ for (const pair of pairs) identities.set(identityKey(pair), pair);
41
+ }
42
+ }
43
+ const pairs = [...identities.values()];
44
+ const elements = dictionary(pairs.map(({ element }) => element));
45
+ const colors = dictionary(pairs.flatMap(({ foreground, background }) => [foreground, background]));
46
+ const states = dictionary(pairs.map(({ state }) => state));
47
+ const kinds = dictionary(pairs.map(({ kind }) => kind));
48
+ // Sorting each dictionary makes an index stay the same or shrink when entries are removed.
49
+ const pairKeys = dictionary(identities.keys());
50
+ const chromeCatalog = {
51
+ elements: elements.items,
52
+ colors: colors.items,
53
+ states: states.items,
54
+ kinds: kinds.items,
55
+ pairs: pairKeys.items.map((key) => {
56
+ const { element, foreground, background, state, kind } = identities.get(key);
57
+ return [
58
+ elements.indexes.get(element),
59
+ colors.indexes.get(foreground),
60
+ colors.indexes.get(background),
61
+ states.indexes.get(state),
62
+ kinds.indexes.get(kind),
63
+ ];
64
+ }),
65
+ };
66
+ const chrome = Object.fromEntries(Object.entries(entries).map(([scheme, cards]) => [
67
+ scheme,
68
+ cards.map(({ role, context, pairs }) => ({
69
+ role,
70
+ ...displayChromeContext(context),
71
+ pairs: pairs.map((pair) => [
72
+ pairKeys.indexes.get(identityKey(pair)),
73
+ displayChromeRatio(pair.ratio, pair.required),
74
+ pair.required,
75
+ ]),
76
+ })),
77
+ ]));
78
+ return { chrome, chromeCatalog };
79
+ }
80
+
81
+ export function decodeChromePair(catalog, [identityIndex, ratio, required]) {
82
+ const [element, foreground, background, state, kind] = catalog.pairs[identityIndex];
83
+ return {
84
+ element: catalog.elements[element],
85
+ foreground: catalog.colors[foreground],
86
+ background: catalog.colors[background],
87
+ state: catalog.states[state],
88
+ kind: catalog.kinds[kind],
89
+ ratio,
90
+ required,
91
+ };
92
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "footer": [
3
+ {
4
+ "element": "social-link",
5
+ "foreground": "footer-link-ink",
6
+ "background": "layer2",
7
+ "state": "rest",
8
+ "kind": "graphic",
9
+ "flags": ["socialLinks"]
10
+ },
11
+ {
12
+ "element": "social-link",
13
+ "foreground": "linkHover",
14
+ "background": "linkHoverBg",
15
+ "state": "hover",
16
+ "kind": "graphic",
17
+ "flags": ["socialLinks"]
18
+ },
19
+ {
20
+ "element": "social-link",
21
+ "foreground": "footer-link-ink",
22
+ "background": "layer2",
23
+ "state": "focus",
24
+ "kind": "graphic",
25
+ "flags": ["socialLinks"]
26
+ },
27
+ {
28
+ "element": "social-link",
29
+ "foreground": "footer-link-ink",
30
+ "background": "layer2",
31
+ "state": "focus",
32
+ "kind": "ring",
33
+ "flags": ["socialLinks"]
34
+ },
35
+ {
36
+ "element": "social-link",
37
+ "foreground": "linkHover",
38
+ "background": "linkHoverBg",
39
+ "state": "hover-focus",
40
+ "kind": "graphic",
41
+ "flags": ["socialLinks"]
42
+ },
43
+ {
44
+ "element": "social-link",
45
+ "foreground": "linkHover",
46
+ "background": "layer2",
47
+ "state": "hover-focus",
48
+ "kind": "ring",
49
+ "flags": ["socialLinks"]
50
+ }
51
+ ]
52
+ }
@@ -0,0 +1,173 @@
1
+ import { parseTheme, semanticToCSS, wcagRatio } from "@taprootio/espalier/shared/theme";
2
+
3
+ import { APPEARANCE_FILES } from "./appearance-contract.js";
4
+ import { RECIPE_TAGS_BAR_PAINT_DEFAULTS, resolveRecipeTagsBarColor } from "./brand-color.js";
5
+ import { standaloneFooterActionEntries } from "./chrome-features.js";
6
+ import { buildChromeInput } from "./chrome-input.js";
7
+ import { CHROME_UNAVAILABLE_MESSAGE, displayChromeContext, displayChromeRatio } from "./chrome-output.js";
8
+ import taprootCatalog from "./chrome-paint-catalog-taproot.json" with { type: "json" };
9
+ import { CLI_BINARY_NAME } from "./constants.js";
10
+ import { BADGE_FOCUS_RING, loadEspalierShared, supportsBadgeFocusRing } from "./espalier-shared.js";
11
+ import { normalizePageTagBadges } from "./page-tag-badge-modes.js";
12
+ import { normalizeRecipeTagsContent, normalizeRecipeTagsIcon } from "./recipe-page-options.js";
13
+ import { SETTINGS_TYPE_SITE_HEADER, SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES } from "./settings-catalog.js";
14
+ import { CONTRAST_TEXT_BELOW_AA, THEME_STYLES_FILE } from "./theme-resolve.js";
15
+ import { loadFitReport } from "./theme-validation.js";
16
+ import { describeChromeToken } from "./token-reach.js";
17
+
18
+ export { CHROME_UNAVAILABLE_MESSAGE } from "./chrome-output.js";
19
+
20
+ const SCHEMES = ["light", "dark"];
21
+ const THEME_RESOLVE_GUIDANCE = `See ${CLI_BINARY_NAME} theme resolve.`;
22
+
23
+ const RECIPE_BAR_ICON = "recipe-tag-icon";
24
+ export const RECIPE_TAG_ICON_CONTRAST = "theme.recipe_tag_icon_contrast";
25
+
26
+ async function measureBadgePaint(suite, settings, rootSurface) {
27
+ if (settings === undefined) return { light: [], dark: [] };
28
+ const { parsePaintColor, compositePaint, paintRequiredRatio } = await loadEspalierShared("paint-color.js");
29
+ const hasFocusRing = supportsBadgeFocusRing();
30
+ const mode = normalizePageTagBadges(settings.pageTagBadges);
31
+ const barContents = normalizeRecipeTagsContent(settings.recipeTagsContent);
32
+ const hasTagLinks = Object.keys(settings.tagDestinations ?? {}).length > 0;
33
+ const hasMetadataLinks = Object.keys(settings.recipeMetadataDestinations ?? {}).length > 0;
34
+ const barLinks = hasTagLinks || (barContents !== "tags" && hasMetadataLinks);
35
+ const barIcon = normalizeRecipeTagsIcon(settings.recipeTagsIcon) !== "none";
36
+ const resolveBarColor = (value, fallback, colors) => {
37
+ // Theme resolve accepts partially edited preferences as optional evidence.
38
+ if (value != null && typeof value !== "string") return null;
39
+ const paint = resolveRecipeTagsBarColor(value, fallback);
40
+ const absolute = paint.startsWith("var(") ? colors.get(paint.slice(4, -1)) : paint;
41
+ return absolute === undefined ? null : parsePaintColor(absolute);
42
+ };
43
+
44
+ return Object.fromEntries(SCHEMES.map(scheme => [scheme, (suite[scheme] ?? []).flatMap(surface => {
45
+ const context = surface.surface === rootSurface ? null : surface.surface;
46
+ const colors = new Map(surface.tokens.map(({ token, resolved }) => [semanticToCSS(token), resolved]));
47
+ const parsed = (token) => {
48
+ const color = colors.get(token);
49
+ return color === undefined ? null : parsePaintColor(color);
50
+ };
51
+ const page = parsed("--esp-color-background");
52
+ const card = parsed("--esp-color-layer-1");
53
+ const barPaint = resolveBarColor(settings.recipeTagsBarBackground, RECIPE_TAGS_BAR_PAINT_DEFAULTS.background, colors);
54
+ // The tag bar paints over the recipe card's layer 1, including when its authored fill is translucent.
55
+ const bar = barPaint && card ? compositePaint(barPaint, card) : null;
56
+ const authoredRing = surface.componentProperties.find(({ name }) => name === BADGE_FOCUS_RING);
57
+ const ring = !hasFocusRing ? null
58
+ : authoredRing === undefined ? parsed("--esp-color-link") : parsePaintColor(authoredRing.resolved);
59
+ const icon = resolveBarColor(settings.recipeTagsBarColor, RECIPE_TAGS_BAR_PAINT_DEFAULTS.ink, colors);
60
+ const pairs = [];
61
+ const add = (element, foreground, ink, background, ground, state, kind) => {
62
+ if (!ink || !ground) return;
63
+ pairs.push({ element, foreground, background, state, kind,
64
+ required: paintRequiredRatio(kind), ratio: wcagRatio(compositePaint(ink, ground), ground) });
65
+ };
66
+ if (hasTagLinks && mode !== "none") add("linked-badge", BADGE_FOCUS_RING, ring, "page", page, "focus", "ring");
67
+ if (hasTagLinks && mode === "page-and-cards") {
68
+ add("linked-badge", BADGE_FOCUS_RING, ring, "card", card, "focus", "ring");
69
+ add("linked-badge", BADGE_FOCUS_RING, ring, "card-hover", parsed("--esp-color-layer-2"), "hover-focus", "ring");
70
+ }
71
+ if (barLinks) add("linked-badge", BADGE_FOCUS_RING, ring, "recipe-tag-bar", bar, "focus", "ring");
72
+ if (barIcon) add(RECIPE_BAR_ICON, "recipeTagsBarColor", icon, "recipe-tag-bar", bar, "rest", "graphic");
73
+ return pairs.length ? [{ role: "tag-badges", context, pairs }] : [];
74
+ })]));
75
+ }
76
+
77
+ function fieldFor(role, context, scheme, pair, brandColorSourceFields) {
78
+ const brandColorField = pair.foreground === "brand-color" ? brandColorSourceFields[scheme] : undefined;
79
+ if (brandColorField !== undefined) {
80
+ return { field: `site-header.${brandColorField}`, file: APPEARANCE_FILES[SETTINGS_TYPE_SITE_HEADER] };
81
+ }
82
+ if (pair.element === RECIPE_BAR_ICON) {
83
+ return { field: "site-publishing-preferences.recipeTagsBarColor", file: APPEARANCE_FILES[SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES] };
84
+ }
85
+ if (role === "tag-badges") {
86
+ const theme = context === null ? `${scheme}Theme` : `${scheme}Theme.contexts.${context}`;
87
+ return { field: `${theme}.componentProperties.${BADGE_FOCUS_RING}`, file: THEME_STYLES_FILE };
88
+ }
89
+ if (context === null) return { field: `${scheme}Theme`, file: THEME_STYLES_FILE };
90
+ return role === "header"
91
+ ? { field: "site-header.context", file: APPEARANCE_FILES[SETTINGS_TYPE_SITE_HEADER] }
92
+ : { field: "site-publishing-preferences.footerSettings.context", file: APPEARANCE_FILES[SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES] };
93
+ }
94
+
95
+ async function extraPaintEntries(nameReportEnabled) {
96
+ const { PAINT_CATALOG } = await loadEspalierShared("paint-catalog.js");
97
+ const hasFittedFooter = PAINT_CATALOG.footer.some(entry => entry.foreground === "footer-link-ink");
98
+ const footer = hasFittedFooter ? taprootCatalog.footer : taprootCatalog.footer.map(entry =>
99
+ entry.foreground === "footer-link-ink" ? { ...entry, foreground: "link" } : entry);
100
+ return {
101
+ ...taprootCatalog,
102
+ footer: nameReportEnabled === true ? [...footer, ...standaloneFooterActionEntries(PAINT_CATALOG.footer)] : footer,
103
+ };
104
+ }
105
+
106
+ /** Measure optional chrome without changing the command that accepted the appearance. */
107
+ export async function completeChromeReport(inputs, { loadFit = loadFitReport } = {}) {
108
+ let navigationUnavailable = true;
109
+ try {
110
+ const { themes, appearance, resources, nameReportEnabled } = inputs;
111
+ const input = buildChromeInput({ appearance, resources, nameReportEnabled });
112
+ ({ navigationUnavailable } = input);
113
+ const light = parseTheme(themes.light);
114
+ const dark = parseTheme(themes.dark);
115
+ if (!light || !dark) throw new Error("Missing accepted theme pair.");
116
+ const fit = await loadFit();
117
+ const extraEntries = await extraPaintEntries(nameReportEnabled);
118
+ const suite = fit.themeFitReportSuite(light, dark, { paintSurfaces: input.paintSurfaces, extraEntries });
119
+ const { paint: entries } = suite;
120
+ const badges = await measureBadgePaint(suite, input.badgeSettings, fit.ROOT_SURFACE);
121
+ const flags = [];
122
+ const warnings = [];
123
+ let pairs = 0;
124
+ for (const scheme of SCHEMES) {
125
+ for (const { role, context, pairs: measured } of [...entries[scheme], ...badges[scheme]]) {
126
+ pairs += measured.filter(({ element }) => element !== RECIPE_BAR_ICON).length;
127
+ for (const pair of measured) {
128
+ if (pair.ratio >= pair.required) continue;
129
+ const { element, foreground, background, state, kind, required } = pair;
130
+ const { field, file } = fieldFor(role, context, scheme, pair, input.brandColorSourceFields);
131
+ const ratio = displayChromeRatio(pair.ratio, required);
132
+ const shownRatio = ratio.toFixed(2);
133
+ const shownRequirement = required.toFixed(2);
134
+ const location = role === "tag-badges" && context !== null ? ` in context '${displayChromeContext(context).context}'` : "";
135
+ const decorative = element === RECIPE_BAR_ICON;
136
+ const code = decorative ? RECIPE_TAG_ICON_CONTRAST : CONTRAST_TEXT_BELOW_AA;
137
+ const paint = `${describeChromeToken(foreground, role)} over ${describeChromeToken(background, role)}`;
138
+ flags.push({
139
+ code,
140
+ area: "presentation",
141
+ file,
142
+ field,
143
+ token: foreground,
144
+ background,
145
+ scheme,
146
+ context,
147
+ ratio,
148
+ required,
149
+ message: `${role} ${element}/${state}${location} paints ${paint} at ${shownRatio}:1. ${decorative ? "Aim for" : "It needs"} ${shownRequirement}:1. ${THEME_RESOLVE_GUIDANCE}`,
150
+ role,
151
+ element,
152
+ state,
153
+ kind,
154
+ });
155
+ warnings.push(
156
+ `chrome: ${code}; ${field}; ${scheme} ${role} ${element}/${state}${location}; ${shownRatio}:1 < ${shownRequirement}:1. ${paint}. ${THEME_RESOLVE_GUIDANCE}`,
157
+ );
158
+ }
159
+ }
160
+ }
161
+ return { entries, badges, flags, warnings, contrast: { pairs, belowAa: flags.filter(({ code }) => code === CONTRAST_TEXT_BELOW_AA).length }, navigationUnavailable, unavailable: false };
162
+ } catch {
163
+ return {
164
+ entries: { light: [], dark: [] },
165
+ badges: { light: [], dark: [] },
166
+ flags: [],
167
+ warnings: [CHROME_UNAVAILABLE_MESSAGE],
168
+ contrast: { pairs: 0, belowAa: 0 },
169
+ navigationUnavailable,
170
+ unavailable: true,
171
+ };
172
+ }
173
+ }
package/src/cli.js CHANGED
@@ -85,6 +85,7 @@ import {
85
85
  getPageTypeReference,
86
86
  getSettingsReference,
87
87
  getThemeReference,
88
+ getTokenReference,
88
89
  getWorkflowReference,
89
90
  listComponentTypeReferences,
90
91
  listDesignBlueprints,
@@ -100,7 +101,7 @@ import { assertCliCurrent } from "./session.js";
100
101
  import { ApiError } from "./transport.js";
101
102
  import { imageDescriptionOptions, imageListOptions, requireImageId } from "./image-description-contract.js";
102
103
  import { formatThemeResolve } from "./theme-resolve.js";
103
- import { MAXIMUM_THEME_OPEN_MAP_KEY_SCALARS } from "./theme-validation.js";
104
+ import { encodePageTokenReach } from "./token-reach.js";
104
105
  import { VERB_HANDLERS } from "./verbs/index.js";
105
106
  import { siteNeedsWorkspaceError } from "./verbs/validate.js";
106
107
 
@@ -166,7 +167,8 @@ const VERBS = Object.freeze([
166
167
  + "sign-in, so it is refused with a directory argument or --init (validate.site_needs_workspace), and a managed "
167
168
  + "Docs site is not read. Known author-entered metadata also receives missing, "
168
169
  + "short, long and repeated-title description advice (title guidance 15–70 characters; description 50–160). "
169
- + "These are writing suggestions, never requirements. Generated custom values are checked; generated "
170
+ + "These are writing suggestions, never requirements. The terminal lists errors and publishing warnings "
171
+ + "ahead of title and description advice. Generated custom values are checked; generated "
170
172
  + "defaults, home-page settings and unknown fields are listed in siteChecks.deferredToDeployment. "
171
173
  + "siteChecks.checkedInEditor names rules only the page editor evaluates, such as a selected cover; "
172
174
  + "siteChecks.checkedBySite names rules whose evidence comes from site records; 'status' reads their "
@@ -711,22 +713,36 @@ const VERBS = Object.freeze([
711
713
  tokens: ["theme", "resolve"],
712
714
  json: true,
713
715
  resolveOptions: true,
714
- summary: "Print the colors Espalier compiles from the theme, per scheme and context, with their contrast ratios.",
716
+ summary: "Show resolved theme colors and component properties by scheme and context.",
715
717
  note: "Reads the pulled workspace's settings/taproot-styles.json offline (run pull first; no credential, no network) "
716
718
  + "and compiles it through Espalier's own pipeline, the one theme push lints and the published page renders "
717
- + "through, so a value here cannot differ from the render. For the root page and every declared context in "
719
+ + "through, so a value here cannot differ from the render. For an enabled footer, the report includes its "
720
+ + "resting link and heading inks against the painted layer2 surface. For the root page and every declared context in "
718
721
  + "each scheme it lists every semantic color token as oklch and hex (hex is the sRGB the engine gamut-maps the "
719
722
  + "color to), whether it is compiled from the roles or pinned in semanticMappings (origin compiled, pinned, "
720
- + "or inherited_pin for a root pin a context carries), and the ramp stop or anchor it came from. It also "
721
- + "measures every ink-on-surface pairing Espalier defines (text on background, links, headings, the action "
723
+ + "or inherited_pin for a root pin a context carries), and the ramp stop or anchor it came from. Each token "
724
+ + "names its static role plan and explains any contrast adjustment, including a passing lightness stop when "
725
+ + "one exists. The paint catalog shows where pinned and adjusted colors are used. It also "
726
+ + "measures the semantic ink-on-surface pairings (text on background, links, headings, the action "
722
727
  + "label, and so on): the WCAG ratio against the AA minimum (4.5:1 for text, 3:1 for large text and UI) and "
723
728
  + "the APCA Lc against Espalier's target. A pair under AA is listed in flags with the stable code "
724
729
  + "theme.contrast_text_below_aa and the field to edit (for example "
725
730
  + "darkTheme.contexts.inverted); flags never refuse, so the exit code stays 0. An invalid or incomplete theme "
726
731
  + "is refused with the code theme push and validate use, the first fault in error.code and error.field. Without --json the output "
727
- + "is a readable table; --json writes the stable result (schemes[].surfaces[].tokens and pairs, contrast, flags). "
732
+ + "is a readable table. JSON lists tokens, pairs and componentProperties in schemes[].surfaces[], plus contrast "
733
+ + "and flags. Each component row records its authored and resolved values, whether a context overrides the "
734
+ + "root, and the APCA measurements and adjustment for a paired color. WCAG ratios cover the semantic and site-chrome pairs. "
728
735
  + "--scheme and --context narrow the output only; the whole pair is always validated. A result too large for "
729
- + "the output bound names the surfaces it left out in omittedSurfaces (items, count, truncated). --site reads the site's stored theme "
736
+ + "the output bound lists omittedSurfaces. Retry an omitted named context with --scheme and --context, "
737
+ + "or an omitted root with --scheme. The root retry keeps its scheme's named contexts and chrome. "
738
+ + "omittedSurfaces.retryRootSchemes names roots that fit on retry, even if the omission list is truncated. "
739
+ + "Full context names are under lightTheme.contexts and darkTheme.contexts in settings/taproot-styles.json. "
740
+ + "When using --site, run taproot-site pull in a separate workspace for the same site to preserve local edits. "
741
+ + "The reason surface_too_large means the surface exceeds the output bound under its narrowest selection. "
742
+ + "The command reports theme.resolve_surface_too_large when a single selected surface cannot fit "
743
+ + "or every selected surface is individually oversized. "
744
+ + "If the paint catalog does not fit, omittedTokens lists the missing paint entries. See taproot-site help tokens for the full catalog. "
745
+ + "--site reads the site's stored theme "
730
746
  + "instead of the workspace (the effective theme pull would write), which compares a workspace edit with what is "
731
747
  + "live: run it with and without --site. A pair under AA is a finding to read, not a failure: a brand color "
732
748
  + "may be a deliberate choice. See 'taproot-site help theme'.",
@@ -736,9 +752,11 @@ const VERBS = Object.freeze([
736
752
  surface: SURFACE_DOCS_PRESENTATION,
737
753
  capabilities: [CAPABILITY_DESIGN],
738
754
  tokens: ["footer", "push"],
755
+ dryRun: true,
739
756
  summary: "Validate and replace the workspace's complete footer document.",
740
757
  note: "Run pull first. The command validates the whole closed footer locally, uses the pulled draft hash,"
741
- + " and refuses a concurrent remote edit with re-pull guidance.",
758
+ + " and refuses a concurrent remote edit with re-pull guidance. --dry-run reads the current draft and reports"
759
+ + " changed JSON paths, staleness and fit findings without writing to the site or workspace.",
742
760
  },
743
761
  {
744
762
  name: VERB_MEDIA_UPLOAD,
@@ -828,7 +846,9 @@ const VERBS = Object.freeze([
828
846
  summary: "Deploy to staging, or promote staging to production.",
829
847
  target: true,
830
848
  handoffOptions: true,
831
- note: "deploy --staging does not report a review URL, because the URL is a live single-use credential and this "
849
+ note: "If deploy.hosting_unavailable names Hosting, check stagingHosting in status. Activate the staging "
850
+ + "hostname in Settings > Licence & domain. For a missing Taproot-provided address on a local stack, "
851
+ + "check its user-content domain configuration. deploy --staging does not report a review URL, because the URL is a live single-use credential and this "
832
852
  + "JSON is often saved to logs. Run 'staging review' to mint one, or pass --handoff to get a fresh "
833
853
  + "single-use one in stagingPreview.url (on a managed Docs site too, where it stages settings only): open it "
834
854
  + "once, then switch the site's theme toggle to review both schemes before deploy --production. Without "
@@ -902,9 +922,10 @@ const VERBS = Object.freeze([
902
922
  surface: SURFACE_DOCS_PRESENTATION,
903
923
  capabilities: [CAPABILITY_DEPLOYMENTS],
904
924
  tokens: ["staging", "review"],
905
- summary: "Mint a fresh single-use review handoff for the site's staging host.",
925
+ summary: "Mint a fresh single-use review handoff for the site's first or later acknowledged staging release.",
906
926
  reviewPath: true,
907
- note: "The handoff URL is reported only in the final JSON as stagingPreview.url; keep it private. --path <page> opens the review on that page instead of the "
927
+ note: "Run deploy --staging first. staging.deployment_required means no staging release has been acknowledged yet. "
928
+ + "The handoff URL is reported only in the final JSON as stagingPreview.url; keep it private. --path <page> opens the review on that page instead of the "
908
929
  + "home page: a page path as 'pull' records it ('about', '/posts/one'), optionally with a query. Open it once, then use the site's theme toggle to review both "
909
930
  + "schemes. deploy --staging and redirects check report no review URL unless you pass --handoff, so this is "
910
931
  + "the usual way to get one, on a managed Docs site too. "
@@ -919,7 +940,8 @@ const VERBS = Object.freeze([
919
940
  tokens: ["status"],
920
941
  summary:
921
942
  "Report the platform authoring switch, CLI release, deployments, readiness, image processing, and site health.",
922
- note: "siteHealth summarizes the stored Site Health report of the last production release, with its findings (a rule id, severity, page, and the value found); stagedSiteHealth summarizes the staged release's report."
943
+ note: "stagingHosting reports staging host setup separately from candidate readiness. If the host is missing, "
944
+ + "check the site's Licence & domain settings and local staging host configuration. siteHealth summarizes the stored Site Health report of the last production release, with its findings (a rule id, severity, page, and the value found); stagedSiteHealth summarizes the staged release's report."
923
945
  + " Both read what a release stored when it was generated, so edits made since are outside them; run 'health --staging' or 'health --production' for each finding's file and fix."
924
946
  + " Content permission is required; a refused or failed production read fails status rather than reporting a clean site, and a failed staged read is reported as unavailable.",
925
947
  },
@@ -946,7 +968,8 @@ const VERBS = Object.freeze([
946
968
  + "supplies a safe description, and otherwise needsDescription. With --staging each finding says "
947
969
  + "newSinceProduction, and comparison says whether production had a report to compare with; without one "
948
970
  + "every finding is listed as not compared. Both lists are bounded by size, with findingsTotal, "
949
- + "imageFindingsTotal and the truncation flags. A site with no stored report says available false and why. "
971
+ + "imageFindingsTotal and the truncation flags. The terminal output for health and deploy --staging lists errors "
972
+ + "and publishing warnings ahead of title and description advice. A site with no stored report says available false and why. "
950
973
  + "A managed Docs site returns covered false. Content permission is required.",
951
974
  },
952
975
  ]);
@@ -1195,7 +1218,9 @@ function verbHelp(verb) {
1195
1218
  const boundary = verb.name === VERB_THEME_RESOLVE
1196
1219
  ? "By default this verb reads the pulled workspace and uses no credential, makes no network request, and writes "
1197
1220
  + `nothing to the workspace or the site (GITHUB_OUTPUT, when set, receives the JSON result). With --site it reads the site's presentation with the site-scoped credential from ${PUBLISH_KEY_ENVIRONMENT_VARIABLE} `
1198
- + `or the sign-in '${CLI_BINARY_NAME} ${VERB_LOGIN}' stores.${upgradeGate}`
1221
+ + `or the sign-in '${CLI_BINARY_NAME} ${VERB_LOGIN}' stores. Header and footer JSON rows are `
1222
+ + "[identityIndex, ratio, required]. Resolve identityIndex through chromeCatalog.pairs and its elements, colors, "
1223
+ + `states and kinds dictionaries.${upgradeGate}`
1199
1224
  : verb.name === VERB_VALIDATE
1200
1225
  ? "Validation uses no credential, network or write unless --site is given; it reads the configuration only to find "
1201
1226
  + "the workspace when no directory is given. With --init it reads the pulled workspace or selected configuration "
@@ -1356,6 +1381,7 @@ function parseReferenceArguments(arguments_) {
1356
1381
  || topic === "media"
1357
1382
  || topic === "preview"
1358
1383
  || topic === "theme"
1384
+ || topic === "tokens"
1359
1385
  || topic === "appearance"
1360
1386
  || topic === "settings"
1361
1387
  || topic === "footer"
@@ -1407,7 +1433,11 @@ function referenceResult(parsed) {
1407
1433
  { alternatives: PAGE_TYPES },
1408
1434
  );
1409
1435
  }
1410
- return { ...result, topic: "page", page };
1436
+ return {
1437
+ ...result,
1438
+ topic: "page",
1439
+ page: parsed.json ? { ...page, tokenReach: encodePageTokenReach(page.tokenReach) } : page,
1440
+ };
1411
1441
  }
1412
1442
  case "component": {
1413
1443
  const component = getComponentReference(parsed.subject);
@@ -1462,6 +1492,8 @@ function referenceResult(parsed) {
1462
1492
  }
1463
1493
  case "theme":
1464
1494
  return { ...result, topic: "presentation", referenceKind: "theme", reference: getThemeReference() };
1495
+ case "tokens":
1496
+ return { ...result, topic: "tokens", ...getTokenReference() };
1465
1497
  case "appearance":
1466
1498
  return { ...result, topic: "presentation", referenceKind: "appearance", reference: getAppearanceReference() };
1467
1499
  case "settings":
@@ -1605,7 +1637,6 @@ function parseThemeContext(arguments_, index) {
1605
1637
  if (
1606
1638
  typeof candidate !== "string"
1607
1639
  || candidate.length === 0
1608
- || [...candidate].length > MAXIMUM_THEME_OPEN_MAP_KEY_SCALARS
1609
1640
  || hasAsciiControl(candidate)
1610
1641
  || candidate.startsWith("--")
1611
1642
  ) {