@taprootio/site-authoring 0.38.1 → 0.40.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 (39) hide show
  1. package/README.md +73 -17
  2. package/examples/riverbend-wellness/manifest.fixture.json +1 -1
  3. package/examples/riverbend-wellness/settings/site-publishing-preferences.json +29 -14
  4. package/package.json +2 -2
  5. package/src/api.js +4 -5
  6. package/src/appearance-contract.js +64 -55
  7. package/src/atomic-file.js +2 -1
  8. package/src/changelog.json +37 -0
  9. package/src/cli.js +2 -2
  10. package/src/content/free-form-sections.js +2 -3
  11. package/src/display-scale.js +17 -0
  12. package/src/footer-alignment.js +97 -0
  13. package/src/footer-brand-inputs.js +33 -0
  14. package/src/footer-branding.js +44 -0
  15. package/src/footer-content.js +10 -0
  16. package/src/footer-contract.js +167 -43
  17. package/src/footer-draft-hash.js +26 -27
  18. package/src/footer-fit-widths.js +10 -0
  19. package/src/footer-fit.js +328 -0
  20. package/src/footer-font-metrics.js +8345 -0
  21. package/src/footer-workspace.js +4 -6
  22. package/src/header-presentation.js +17 -15
  23. package/src/logo-inputs.js +38 -0
  24. package/src/logo-surface-checks.js +67 -0
  25. package/src/presentation-reference.js +119 -46
  26. package/src/reference-help.js +3 -3
  27. package/src/setting-reference.js +15 -4
  28. package/src/settings-catalog.js +10 -3
  29. package/src/site-check-findings.js +73 -11
  30. package/src/site-check-rules.json +4 -2
  31. package/src/theme-contexts.js +82 -0
  32. package/src/theme-resolve.js +2 -2
  33. package/src/theme-validation.js +30 -13
  34. package/src/verbs/footer-push.js +20 -9
  35. package/src/verbs/plan.js +2 -2
  36. package/src/verbs/theme-push.js +46 -41
  37. package/src/verbs/validate.js +33 -17
  38. package/src/workspace-check.js +1 -1
  39. package/src/workspace.js +1 -1
@@ -98,10 +98,8 @@ export async function advanceFooterManifest(
98
98
  expectedContentHash: computeFooterContentHash(footerSettings),
99
99
  imageIds: [...new Set([...prior.imageIds, ...footerImageIds(footerSettings)])].sort(),
100
100
  };
101
- // The ten scheme colours are part of the presentation change set, so a
102
- // footer save that moved one moved the revision too; the server reports the
103
- // new one from the same transaction and it becomes the baseline the next
104
- // theme push must carry (TR00807). One manifest write for both baselines.
101
+ // Update both baselines in one manifest write. The caller only supplies a
102
+ // presentation revision when it is already safe for this workspace to own.
105
103
  if (presentationRevision !== undefined) {
106
104
  manifest.presentation = presentationManifestEntry(presentationRevision);
107
105
  }
@@ -203,8 +201,8 @@ export function footerManifestEntry(footerSettings) {
203
201
  * `theme push` begins with a fresh server read that replaces the workspace
204
202
  * footer document, so an unpushed footer-content edit would be silently lost.
205
203
  * Refuse while the workspace footer's content hash differs from the recorded
206
- * pull baseline. The ten scheme colors `theme push` overlays are excluded
207
- * from the comparison, so a colour-only edit passes. A manifest that predates
204
+ * pull baseline. The presentation fields `theme push` owns are excluded
205
+ * from the comparison, so a context- or logo-variant-only edit passes. A manifest that predates
208
206
  * the baseline cannot prove the workspace is clean and refuses toward pull:
209
207
  * assuming "unchanged" is exactly the data loss this guard exists to stop.
210
208
  */
@@ -1,22 +1,16 @@
1
1
  // Generated from shared/header-presentation.ts by scripts/sync-field-validation.mjs. Do not edit.
2
- export const HEADER_HEIGHT_MULTIPLIER_LIMITS = Object.freeze({ minimum: 1, maximum: 5, step: 0.1 });
2
+ import { DISPLAY_SCALE_LIMITS, parseDisplayScale } from "./display-scale.js";
3
+ export const HEADER_HEIGHT_MULTIPLIER_LIMITS = DISPLAY_SCALE_LIMITS;
4
+ export const LOGO_VARIANTS = Object.freeze(["", "light", "dark"]);
5
+ /** Unknown stored values keep the existing scheme choice; writers validate the literal vocabulary. */
6
+ export function resolveLogoVariant(value) {
7
+ return value === "light" || value === "dark" ? value : "";
8
+ }
3
9
  const STANDARD_HEIGHT = Object.freeze({ tenths: 10, scale: 1, canonical: "" });
4
- const HEIGHT_MULTIPLIER = /^(?:[1-4](?:\.[0-9])?|5(?:\.0)?)$/u;
5
10
  /** Parse the authored string without floating-point remainder or whitespace normalization. */
6
11
  export function parseHeaderHeightMultiplier(value) {
7
- if (value === undefined || value === "")
8
- return STANDARD_HEIGHT;
9
- if (typeof value !== "string")
10
- return null;
11
- // JavaScript's end anchor also matches before a final newline; require the entire value.
12
- if (HEIGHT_MULTIPLIER.exec(value)?.[0] !== value)
13
- return null;
14
- const whole = value.charCodeAt(0) - 48;
15
- const fraction = value.length === 3 ? value.charCodeAt(2) - 48 : 0;
16
- const tenths = whole * 10 + fraction;
17
- return tenths === 10
18
- ? STANDARD_HEIGHT
19
- : Object.freeze({ tenths, scale: tenths / 10, canonical: `${whole}.${fraction}` });
12
+ const parsed = parseDisplayScale(value);
13
+ return parsed?.tenths === 10 ? STANDARD_HEIGHT : parsed;
20
14
  }
21
15
  /** Read old or omitted settings as standard height; writes use the strict parser. */
22
16
  export function resolveHeaderHeightMultiplier(value) {
@@ -45,6 +39,14 @@ export function resolveHeaderLogoPairs(input) {
45
39
  const first = (...pairs) => pairs.find(candidate => candidate.url !== "") ?? pairs[0];
46
40
  const resolvedLight = first(light, profile, dark);
47
41
  const resolvedDark = first(dark, light, profile);
42
+ const variant = resolveLogoVariant(input.logoVariant);
43
+ if (variant) {
44
+ const regular = variant === "light" ? resolvedLight : resolvedDark;
45
+ const compact = variant === "light"
46
+ ? first(compactLight, light, compactDark, regular)
47
+ : first(compactDark, dark, compactLight, regular);
48
+ return { light: regular, dark: regular, lightCompact: compact, darkCompact: compact };
49
+ }
48
50
  return {
49
51
  light: resolvedLight,
50
52
  dark: resolvedDark,
@@ -0,0 +1,38 @@
1
+ import { isCanonicalUuid } from "./errors.js";
2
+
3
+ const identity = value => isCanonicalUuid(value) ? value : "";
4
+ const record = value => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
5
+
6
+ /** Stable image identities can go through the URL resolver without copying its fallback rules. */
7
+ export function logoInputsFromSettings(styles = {}, footer = {}, media = {}) {
8
+ styles = record(styles);
9
+ footer = record(footer);
10
+ const dimensions = new Map(Object.values(record(media)).filter(value => isCanonicalUuid(value?.imageId)).map(value => [value.imageId, value]));
11
+ const ratio = id => {
12
+ const image = dimensions.get(id);
13
+ return Number.isFinite(image?.width) && image.width > 0 && Number.isFinite(image?.height) && image.height > 0
14
+ ? String(image.width / image.height) : "";
15
+ };
16
+ const input = {};
17
+ for (const name of ["light", "dark", "lightCompact", "darkCompact"]) {
18
+ const id = identity(styles[`${name}LogoId`]);
19
+ input[`${name}LogoUrl`] = id;
20
+ input[`${name}LogoAspectRatio`] = ratio(id);
21
+ }
22
+ for (const scheme of ["light", "dark"]) {
23
+ const id = identity(footer[scheme]?.logoId);
24
+ input[`${scheme}FooterLogoId`] = id;
25
+ input[`${scheme}FooterLogoUrl`] = id;
26
+ input[`${scheme}FooterLogoAspectRatio`] = ratio(id);
27
+ }
28
+ return input;
29
+ }
30
+
31
+ /** Shared artwork has no single intended brightness; classify the artifact that actually resolved. */
32
+ export function logoArtworkScheme(identity, input) {
33
+ if (!identity) return undefined;
34
+ const schemes = ["light", "dark"].filter(scheme => [
35
+ input[`${scheme}LogoUrl`], input[`${scheme}CompactLogoUrl`], input[`${scheme}FooterLogoUrl`],
36
+ ].includes(identity));
37
+ return schemes.length === 1 ? schemes[0] : undefined;
38
+ }
@@ -0,0 +1,67 @@
1
+ import { resolveFooterLogoPairs } from "./footer-branding.js";
2
+ import { canUseCompactHeaderLogo, LOGO_VARIANTS, resolveHeaderLogoPairs, resolveLogoVariant } from "./header-presentation.js";
3
+ import { logoArtworkScheme, logoInputsFromSettings } from "./logo-inputs.js";
4
+ import { boundedByBytes } from "./session.js";
5
+ import { describeSiteFinding, SITE_FINDINGS_MAX_BYTES } from "./site-check-findings.js";
6
+ import { loadThemeEngines } from "./theme-resolve.js";
7
+
8
+ export const LOGO_ON_SURFACE_RULE = "brand.logo_on_surface";
9
+ const FILES = Object.freeze({ header: "settings/site-header.json", footer: "settings/site-publishing-preferences.json" });
10
+
11
+ function result(items, skipped = false) {
12
+ const reported = boundedByBytes(items, SITE_FINDINGS_MAX_BYTES);
13
+ return {
14
+ findings: { total: items.length, errors: 0, warnings: items.length, items: reported.items, ...(reported.truncated ? { truncated: true } : {}) },
15
+ siteChecks: { ranOffline: [LOGO_ON_SURFACE_RULE], ...(skipped ? { skipped: [LOGO_ON_SURFACE_RULE] } : {}) },
16
+ };
17
+ }
18
+
19
+ /** A brightness heuristic over the selected artifacts, not pixel analysis or background-image analysis. */
20
+ export async function evaluateLogoSurfaceChecks({ styles, header = {}, footer = {}, profileLogoFallbackUrl, onProgress = () => {} } = {}, { loadEngines = loadThemeEngines } = {}) {
21
+ if (!styles?.lightTheme || !styles?.darkTheme) return result([], true);
22
+ // Ordinary workspaces have no site-kind metadata. Only an explicit caller can supply the profile fallback.
23
+ const input = { ...logoInputsFromSettings(styles, footer), profileLogoFallbackUrl };
24
+ const regular = resolveHeaderLogoPairs(input);
25
+ const compact = canUseCompactHeaderLogo(header.headerPosition, header.headerHeightMultiplier, Boolean(regular.light.url || regular.dark.url), header.headerMinHeightMultiplier);
26
+ const headerInput = compact ? input : { ...input, lightCompactLogoUrl: "", darkCompactLogoUrl: "" };
27
+ const surfaces = [
28
+ { name: "header", context: header.context ?? "", variant: resolveLogoVariant(header.logoVariant), kinds: compact ? ["regular", "compact"] : ["regular"], resolve: logoVariant => resolveHeaderLogoPairs({ ...headerInput, logoVariant }) },
29
+ ...(footer.enabled === true && footer.showBrand !== false ? [{ name: "footer", context: footer.context ?? "", variant: resolveLogoVariant(footer.logoVariant), kinds: ["regular"], resolve: logoVariant => resolveFooterLogoPairs({ ...input, logoVariant }) }] : []),
30
+ ];
31
+ const checks = [];
32
+ for (const surface of surfaces) {
33
+ const alternatives = new Map(LOGO_VARIANTS.map(variant => [variant, surface.resolve(variant)]));
34
+ for (const scheme of ["light", "dark"]) {
35
+ for (const kind of surface.kinds) {
36
+ const key = kind === "compact" ? `${scheme}Compact` : scheme;
37
+ const selected = alternatives.get(surface.variant)[key].url;
38
+ if (!selected || new Set(LOGO_VARIANTS.map(variant => alternatives.get(variant)[key].url)).size <= 1) continue;
39
+ const artwork = logoArtworkScheme(selected, input);
40
+ if (artwork !== undefined) checks.push({ surface, scheme, kind, artwork });
41
+ }
42
+ }
43
+ }
44
+ if (checks.length === 0) return result([], true);
45
+ let engines;
46
+ let suite;
47
+ try {
48
+ engines = await loadEngines();
49
+ suite = engines.fit.themeFitReportSuite(styles.lightTheme, styles.darkTheme);
50
+ } catch {
51
+ return result([], true);
52
+ }
53
+ const items = [];
54
+ let skipped = false;
55
+ for (const { surface, scheme, kind, artwork } of checks) {
56
+ const report = suite[scheme]?.find(value => value.surface === (surface.context || engines.fit.ROOT_SURFACE));
57
+ const token = report?.tokens.find(value => value.token === "layer2");
58
+ const parsed = token === undefined ? null : engines.color.parseCssColor(token.resolved);
59
+ if (parsed === null || !Number.isFinite(parsed.l)) { skipped = true; continue; }
60
+ if ((parsed.l < 0.5 ? "dark" : "light") === artwork) continue;
61
+ const detail = `${scheme}:${kind === "compact" ? "compact:" : ""}${artwork}`;
62
+ const item = { rule: LOGO_ON_SURFACE_RULE, severity: "warning", file: FILES[surface.name], subject: surface.name, detail };
63
+ items.push(item);
64
+ onProgress(`Warning: ${item.file} ${describeSiteFinding({ ruleId: item.rule, ...item })}.`);
65
+ }
66
+ return result(items, skipped);
67
+ }
@@ -23,11 +23,14 @@ import {
23
23
 
24
24
  import {
25
25
  APPEARANCE_FILES,
26
- APPEARANCE_FOOTER_COLOR_FIELDS,
26
+ APPEARANCE_FOOTER_FIELDS,
27
27
  APPEARANCE_READ_ONLY_FIELDS,
28
28
  APPEARANCE_SCALAR_FIELDS,
29
29
  } from "./appearance-contract.js";
30
30
  import { CLI_BINARY_NAME } from "./constants.js";
31
+ import { LOGO_VARIANTS } from "./header-presentation.js";
32
+ import { FOOTER_LOGO_BOX, FOOTER_LOGO_SCALE_LIMITS } from "./footer-branding.js";
33
+ import { FOOTER_ALIGNMENT_LAYOUTS, FOOTER_POSITION_VALUES, FOOTER_TEXT_ALIGN_VALUES } from "./footer-alignment.js";
31
34
  import {
32
35
  FOOTER_BACKGROUND_PRESENTATIONS,
33
36
  FOOTER_EXAMPLE,
@@ -436,9 +439,6 @@ export function getThemeReference() {
436
439
  };
437
440
  }
438
441
 
439
- // "linkHoverColor" reads "link hover color", so a new footer color token needs no second table.
440
- const footerColorLabel = (name) => name.replace(/([A-Z])/gu, " $1").toLowerCase();
441
-
442
442
  function appearanceColorReference(definition) {
443
443
  return definition.type === "appearance-color"
444
444
  ? {
@@ -481,16 +481,17 @@ export function getAppearanceReference() {
481
481
  type: "complete-espalier-theme",
482
482
  },
483
483
  ...scalarFields,
484
- ...APPEARANCE_FOOTER_COLOR_FIELDS.map((field) => ({
484
+ ...APPEARANCE_FOOTER_FIELDS.map(field => ({
485
485
  file: field.file,
486
486
  path: field.path,
487
- appLabel: "Footer",
488
- description: `The footer's ${
489
- footerColorLabel(field.name)
490
- } in the ${field.scheme} scheme. footer push owns the rest of the footer.`,
491
- renders: "The footer, once footerSettings.enabled is true (default false).",
487
+ appLabel: field.name === "context" ? "Footer > Colors" : "Footer > Logo",
488
+ description: field.name === "context"
489
+ ? "The footer's theme context, declared in both schemes; empty follows the page. Theme push owns it."
490
+ : "The footer's artwork choice: empty matches the scheme; light or dark forces that effective footer artwork after per-scheme overrides. Theme push owns it.",
491
+ renders: "Everything in the enabled footer, including its background, text, links and controls.",
492
492
  type: field.type,
493
- ...appearanceColorReference(field),
493
+ ...(field.values ? { values: field.values } : {}),
494
+ optional: field.optional,
494
495
  default: field.default,
495
496
  })),
496
497
  ],
@@ -516,7 +517,8 @@ export function getAppearanceReference() {
516
517
  + "Inspect at 16 and 32 pixels in light and dark browser tabs; a deliberate contrasting badge can help a favicon "
517
518
  + "remain recognizable independently of the header theme. Verify the published icon loads, not just the setting.",
518
519
  logoContrastContract:
519
- "Evaluate lightLogoId against the rendered light-scheme header and darkLogoId against the rendered dark-scheme "
520
+ "logoVariant is empty (Match the color scheme), light (Light-background logo), or dark (Dark-background logo); auto is refused. Header and footer choose independently. Deleting the key clears a forced choice on theme push. Footer artwork is chosen after its per-scheme overrides and keeps its own scale. validate reports brand.logo_on_surface when a changeable artwork slot appears on the opposite layer2 brightness; it is a heuristic, not a pixel test, and ignores footer background art. Offline workspaces do not know profile fallback metadata; unknown fallback slots are unchecked. "
521
+ + "Evaluate lightLogoId against the rendered light-scheme header and darkLogoId against the rendered dark-scheme "
520
522
  + "header at desktop and compact/mobile widths. Transparent pixels provide no contrast: inspect the visible mark, "
521
523
  + "not its canvas bounds. When one asset does not remain distinct in both schemes, supply scheme-specific logo "
522
524
  + "assets rather than relying on a shadow, outline, or header color that has not been previewed.",
@@ -541,7 +543,7 @@ export function getAppearanceReference() {
541
543
  + "are per-scheme theme fields set in settings.lightTheme/darkTheme the same way fontBrand is, and an empty "
542
544
  + "fontMenu falls back to the body font, never to headings.",
543
545
  changeSet: [
544
- "the ten footer scheme colors, overlaid onto the site's current footer document",
546
+ "the footer context and logo variant, saved alongside the theme and header presentation",
545
547
  "default scheme, assets, favicon, and header scalars",
546
548
  "the complete light theme and the complete dark theme",
547
549
  ],
@@ -553,7 +555,7 @@ export function getAppearanceReference() {
553
555
  + "one transaction or none of it does; a change to any of those fields since the pull refuses the push "
554
556
  + "(theme.concurrent_modification) and nothing is written. Footer prose, links and imagery, and the "
555
557
  + "publishing scalars are outside the revision, so an unrelated concurrent edit is preserved rather than "
556
- + "refused. footer push advances the baseline only when its save replaced that same revision.",
558
+ + "refused. Footer content saves retain the stored context and cannot adopt an unrelated newer presentation baseline.",
557
559
  dryRun: CLI_BINARY_NAME + " theme push --dry-run reads the site, lists the JSON paths at which each settings file "
558
560
  + "differs from it, and says whether the recorded baseline is still current or a pending save of the same "
559
561
  + "change set would be replayed; it writes nothing.",
@@ -566,7 +568,11 @@ export function getAppearanceReference() {
566
568
  + " pull to refresh the baseline, re-apply the edits, and push again. A Taproot without the atomic save "
567
569
  + "refuses with theme.server_unsupported; theme push never falls back to sequential writes.",
568
570
  footerBoundary:
569
- "theme push changes only five colors per footer scheme. Use footer push for prose, links, layout, and imagery.",
571
+ "theme push owns header and footer contexts and logo variants. Use footer push for prose, links, layout, logos, images, fade and padding.",
572
+ surfaceContexts:
573
+ "Set site-header.context and footerSettings.context to a name declared by both themes, or empty to follow the page. Deleting either key clears it on theme push. Invalid names fail settings.context_unknown; dropping a context a surface still uses fails theme.context_in_use. Repoint the surface and drop the old context in one atomic push.",
574
+ footerColorMigration:
575
+ "Before upgrading a site with custom footer colors, pull and record its five values per scheme. In each theme declare a context: the background is layer2, text is ink.color, headings are ink.heading, links are accent.text and hover is accent.hover. Add named color anchors for literal values and bind those roles to the anchors. For a semantic background such as --esp-color-layer-1, copy that token's source/lightness mapping into the context's semanticMappings.layer2. Set footerSettings.context to the shared name, remove backgroundColor/textColor/headingColor/linkColor/linkHoverColor from both footer schemes, then theme push. Retired keys fail appearance.retired_footer_color; images, fade and padding remain footer content.",
570
576
  footerContentGuard: "theme push refuses while settings.footerSettings carries unpushed content edits: "
571
577
  + "theme.unpushed_footer_content names " + CLI_BINARY_NAME + " footer push to save them "
572
578
  + "(" + CLI_BINARY_NAME + " pull discards them). A workspace pulled before this baseline "
@@ -576,9 +582,59 @@ export function getAppearanceReference() {
576
582
  }
577
583
 
578
584
  const FOOTER_FIELD_DETAILS = Object.freeze({
585
+ "FooterSettings.logoVariant": { type: "enum", values: LOGO_VARIANTS, default: "", description: "Theme-owned artwork choice: empty matches the scheme, light or dark forces that effective footer artwork. Footer push strips it and retains the local choice; auto is refused." },
586
+ "FooterSettings.context": {
587
+ type: "theme-context",
588
+ default: "",
589
+ description:
590
+ "Theme-owned Colors choice; declare the name in both schemes and save it with theme push. Footer push preserves local presentation edits and never sends this field.",
591
+ },
579
592
  "FooterSettings.enabled": { type: "boolean", default: false },
580
593
  "FooterSettings.showBrand": { type: "boolean", default: true },
581
594
  "FooterSettings.showBrandText": { type: "boolean", default: true },
595
+ "FooterSettings.brandSpan": { type: "integer", default: 1, minimum: 1, maximum: FOOTER_LIMITS.brandSpanMax },
596
+ "FooterSettings.asideSpan": { type: "integer", default: 1, minimum: 1, maximum: FOOTER_LIMITS.asideSpanMax },
597
+ "FooterSettings.brandSize": {
598
+ type: "enum",
599
+ default: "standard",
600
+ values: ["standard", "large"],
601
+ description: "Brand text size; logoScale independently sets the logo size.",
602
+ },
603
+ "FooterSettings.logoScale": {
604
+ type: "decimal-string",
605
+ default: "1.0",
606
+ ...FOOTER_LOGO_SCALE_LIMITS,
607
+ description:
608
+ "Logo size from 1.0 through 5.0 in 0.1 steps. Empty and 1 normalize to 1.0. An old absent or null value migrates to 1.5 for large brand text, otherwise 1.0; pull and footer push materialize it. Whitespace, exponents, numeric JSON values and extra decimal places are refused.",
609
+ },
610
+ "FooterSettings.logoBox": {
611
+ type: "enum",
612
+ default: "fixed",
613
+ values: ["fixed", "natural"],
614
+ description:
615
+ "Fixed keeps scaled logo height, including unused image-box space. Natural fits the constrained artwork dimensions without cropping alpha padding. Omitted, null or empty is fixed.",
616
+ },
617
+ ...Object.fromEntries(["alignment", "brandAlignment", "asideAlignment"].map(name => [
618
+ `FooterSettings.${name}`,
619
+ { type: "FooterResponsiveAlignment|null", inheritedWhenOmitted: true },
620
+ ])),
621
+ "FooterSettings.bottomAlignment": { type: "FooterResponsiveInlineAlignment|null", inheritedWhenOmitted: true },
622
+ ...Object.fromEntries(
623
+ ["FooterResponsiveAlignment", "FooterResponsiveInlineAlignment"].flatMap(type =>
624
+ FOOTER_ALIGNMENT_LAYOUTS.map(layout => [
625
+ `${type}.${layout}`,
626
+ {
627
+ type: type === "FooterResponsiveAlignment" ? "FooterAlignment|null" : "FooterInlineAlignment|null",
628
+ inheritedWhenOmitted: true,
629
+ },
630
+ ])
631
+ ),
632
+ ),
633
+ ...Object.fromEntries(["FooterAlignment", "FooterInlineAlignment"].flatMap(type => [
634
+ [`${type}.horizontal`, { type: "enum", values: ["", ...FOOTER_POSITION_VALUES], inheritedWhenOmitted: true }],
635
+ [`${type}.textAlign`, { type: "enum", values: ["", ...FOOTER_TEXT_ALIGN_VALUES], inheritedWhenOmitted: true }],
636
+ ])),
637
+ "FooterAlignment.vertical": { type: "enum", values: ["", ...FOOTER_POSITION_VALUES], inheritedWhenOmitted: true },
582
638
  "FooterSettings.linkColumns": { type: "FooterLinkColumn[]", default: [], maximumItems: FOOTER_LIMITS.linkColumns },
583
639
  "FooterSettings.asideHeadingContent": {
584
640
  type: "FooterRichText",
@@ -609,6 +665,8 @@ const FOOTER_FIELD_DETAILS = Object.freeze({
609
665
  "FooterSettings.dark": { type: "FooterSchemeSettings", default: "scheme defaults" },
610
666
  "FooterSettings.featureImage": { type: "FooterFeatureImageSettings|null", default: null },
611
667
  "FooterLinkColumn.id": { type: "canonical-lowercase-uuid", required: true },
668
+ "FooterLinkColumn.span": { type: "integer", default: 1, minimum: 1, maximum: FOOTER_LIMITS.columnSpanMax },
669
+ "FooterLinkColumn.alignment": { type: "FooterResponsiveAlignment|null", inheritedWhenOmitted: true },
612
670
  "FooterLinkColumn.groups": { type: "FooterLinkGroup[]", default: [], maximumItems: FOOTER_LIMITS.groupsPerColumn },
613
671
  "FooterLinkGroup.id": { type: "canonical-lowercase-uuid", required: true },
614
672
  "FooterLinkGroup.heading": {
@@ -646,31 +704,13 @@ const FOOTER_FIELD_DETAILS = Object.freeze({
646
704
  exclusiveWith: "pageResourceId",
647
705
  maximumLength: FOOTER_LIMITS.externalUrlLength,
648
706
  },
649
- "FooterSchemeSettings.backgroundColor": {
650
- type: "appearance-color",
651
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "backgroundColor")),
652
- default: "",
653
- },
654
- "FooterSchemeSettings.textColor": {
655
- type: "appearance-color",
656
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "textColor")),
657
- default: "",
658
- },
659
- "FooterSchemeSettings.headingColor": {
660
- type: "appearance-color",
661
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "headingColor")),
662
- default: "",
663
- },
664
- "FooterSchemeSettings.linkColor": {
665
- type: "appearance-color",
666
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "linkColor")),
667
- default: "",
668
- },
669
- "FooterSchemeSettings.linkHoverColor": {
670
- type: "appearance-color",
671
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "linkHoverColor")),
707
+ "FooterSchemeSettings.logoId": {
708
+ type: "site-owned-png-or-webp-image-uuid",
672
709
  default: "",
710
+ description:
711
+ "An optional footer logo override for this scheme. Empty inherits that scheme's site logo; clearing an override leaves the site logo and media unchanged.",
673
712
  },
713
+ "FooterSchemeSettings.logoUrl": { type: "url", readOnly: true },
674
714
  "FooterSchemeSettings.backgroundImageId": { type: "site-owned-image-uuid", default: "" },
675
715
  "FooterSchemeSettings.backgroundImageUrl": { type: "url", readOnly: true },
676
716
  "FooterSchemeSettings.backgroundImageOpacity": { type: "number", default: 1, minimum: 0, maximum: 1 },
@@ -732,16 +772,42 @@ export function getFooterReference() {
732
772
  + "with accented or non-English letters are not supported here; use a bottom link for that site. "
733
773
  + "The row renders between the bottom content and the bottom links.",
734
774
  imageRule:
735
- "Image ids come from pull or media upload. Feature images require alt text; background art is decorative.",
775
+ "Image ids come from pull or media upload. Each scheme's logoId is an optional site-owned PNG/WebP override; "
776
+ + "an empty id inherits the site's logo for that scheme independently. logoUrl is response-only metadata. "
777
+ + "Feature images require alt text; background art is decorative.",
778
+ layoutRule: "Brand, link columns and aside share equal tracks; each span adds tracks, with no total limit. "
779
+ + "The brand gets its own row at tablet width, and all regions stack on phones. brandSize changes only brand text; "
780
+ + `logoScale independently scales the logo's normal ${FOOTER_LOGO_BOX.heightRem}rem height and ${FOOTER_LOGO_BOX.maxWidthRem}rem maximum width at every width. `
781
+ + "The available width still constrains it.",
782
+ alignmentRule: "Save sparse wide, wrapped (Brand row) and stacked profiles on alignment (whole-footer default), "
783
+ + "brandAlignment, asideAlignment and each column's alignment. bottomAlignment has horizontal and textAlign only. "
784
+ + "For each axis, search from the active layout toward wider layouts, trying the region then whole-footer choice "
785
+ + "at each layout. Empty or omitted axes inherit; null or empty profiles disappear on pull. Explicit start stays "
786
+ + "authored intent. Horizontal and vertical accept start, center and end; start/end are logical and reverse "
787
+ + "physical sides in RTL. Text also accepts auto and justify. Auto follows current horizontal alignment and can "
788
+ + "reset inherited justification. Justify affects prose with a normal last line; headings, brand, menus and CTA "
789
+ + "labels follow horizontal placement. Invalid, whitespace-padded, non-string and wrong-axis values are refused.",
790
+ logoSpaceRule: "logoBox fixed preserves scaled image height; start moves spare height below the artwork. "
791
+ + "Natural fits the width-constrained artwork, including its loading reservation, without changing scale or "
792
+ + "cropping transparent padding. Absent, null or empty logoBox is fixed. Header geometry is unchanged.",
793
+ fitCheck:
794
+ "validate reports footer.word_breaks at five widths: desktop, small desktop, tablet, phone and Small phone (320px); footer push "
795
+ + "prints the same warnings before saving. At most 12 are shown, with the true count and any remainder. "
796
+ + "Estimates use generated default-font advances, the default type scale and gaps; custom fonts or scale may differ. "
797
+ + "Supported whitespace, hyphen and zero-width break opportunities are estimated; contextual shaping is bounded, "
798
+ + "and Han, Kana or Thai fragments are skipped. When local upload dimensions are unavailable the CLI assumes a maximum "
799
+ + "4:1 logo ratio, so it can over-report brand words beside a narrow logo. Known dimensions follow the footer's own forced artwork. Warnings never refuse a save. "
800
+ + "The deployment check covers standard and profile sites; managed Docs sites use validate and the Footer tab.",
736
801
  readOnlyProjections: FOOTER_READ_ONLY_FIELDS,
737
802
  concurrency:
738
- "pull records expectedDraftHash. A conflict returns footer.concurrent_modification; pull, reconcile, and retry.",
803
+ "pull records the footer-draft-v8 expectedDraftHash, including effective logoScale, logoBox, all sparse profiles "
804
+ + "and both logo ids, but no context, logoVariant, retired colors, response URLs or effective inherited choices. Old v7 baselines are refused; upgrade and pull again. A conflict returns "
805
+ + "footer.concurrent_modification; pull, reconcile, and retry.",
739
806
  themeInteraction:
740
- "theme push overlays its ten scheme colors onto the site's current footer document inside its atomic save and "
741
- + "rewrites this file from the saved result. It refuses while unpushed footer-content edits exist "
742
- + "(theme.unpushed_footer_content); run " + CLI_BINARY_NAME + " footer push first, or " + CLI_BINARY_NAME
743
- + " pull to discard the local edit. A footer push that changed a scheme color advances the presentation "
744
- + "baseline theme push is fenced by.",
807
+ "theme push saves the footer context and logoVariant atomically with the themes and rewrites the file from the saved result. "
808
+ + "It refuses while unpushed footer-content edits exist (theme.unpushed_footer_content); run " + CLI_BINARY_NAME
809
+ + " footer push first, or pull to discard the edit. Footer push strips the context and logoVariant from its request and restores "
810
+ + "the local choice after projecting the response, so presentation edits not yet sent by theme push are preserved.",
745
811
  workflow: [
746
812
  CLI_BINARY_NAME + " pull",
747
813
  "edit settings/site-publishing-preferences.json at settings.footerSettings",
@@ -850,6 +916,8 @@ export function formatPresentationReference(reference) {
850
916
  + "\nHeader width: " + reference.headerWidthContract
851
917
  + "\nBlock spacing: " + reference.blockSpacingContract
852
918
  + "\nMobile menu and menu font: " + reference.menuContract
919
+ + "\nSurface contexts: " + reference.surfaceContexts
920
+ + "\nRetired footer color recipe: " + reference.footerColorMigration
853
921
  + "\nFooter: " + reference.footerBoundary
854
922
  + "\nFooter content guard: " + reference.footerContentGuard + "\n\nAtomic change set (one transaction):\n"
855
923
  + reference.changeSet.map((step, index) => " " + (index + 1) + ". " + step).join("\n")
@@ -862,12 +930,17 @@ export function formatPresentationReference(reference) {
862
930
  if (reference.referenceKind === "footer") {
863
931
  const messages = reference.messages.map((message) =>
864
932
  message.name + " (unlisted fields rejected)\n"
865
- + message.fields.map((field) => " " + field.name.padEnd(30) + fieldConstraint(field)).join("\n")
933
+ + message.fields.map((field) =>
934
+ " " + field.name.padEnd(30) + fieldConstraint(field)
935
+ + (field.description ? "; " + field.description : "")
936
+ ).join("\n")
866
937
  ).join("\n\n");
867
938
  return reference.title + "\nUsage: " + reference.usage + "\nWorkspace: "
868
939
  + reference.workspaceFile + " :: " + reference.workspacePath + "\n\nClosed schema:\n"
869
940
  + messages + "\n\nTargets: " + reference.targetRule + "\nSocial links: " + reference.socialLinkRule
870
941
  + "\nImages: " + reference.imageRule
942
+ + "\nLayout: " + reference.layoutRule + "\nAlignment: " + reference.alignmentRule
943
+ + "\nLogo space: " + reference.logoSpaceRule + "\nFit check: " + reference.fitCheck
871
944
  + "\nConcurrency: " + reference.concurrency
872
945
  + "\nTheme interaction: " + reference.themeInteraction + "\nRead-only projections: "
873
946
  + reference.readOnlyProjections.join(", ") + "\n\nWorkflow:\n"
@@ -95,7 +95,7 @@ import {
95
95
 
96
96
  export { getAppearanceReference, getFooterReference, getSettingsReference, getThemeReference };
97
97
 
98
- export const REFERENCE_VERSION = 59;
98
+ export const REFERENCE_VERSION = 61;
99
99
 
100
100
  // The date-limit examples `help forms` prints; tests run them through the form validator.
101
101
  export const FORM_DATE_WINDOW_FIELD = Object.freeze({
@@ -640,7 +640,7 @@ const WORKFLOW_REFERENCES = Object.freeze({
640
640
  + "(and brand.faviconId) from the image ids .taproot-site-media.json records for those files, so each scheme carries the artwork that reads on its header. "
641
641
  + "Optional lightCompactLogoId and darkCompactLogoId in the same styles file provide alternate artwork when a Fixed header above 1.0 starts shrinking. "
642
642
  + "Its visible height follows scroll distance down to the minimum height (1.0 by default) and expands again when scrolling back to the top; "
643
- + "the compact logo switches at the first actual shrink. "
643
+ + "the compact logo switches at the first actual shrink. Choose logoVariant independently in site-header.json and footerSettings: empty matches the scheme, light or dark forces that surface's effective artwork. Theme push owns those choices; footer push preserves them. validate can warn about a logo on the opposite surface brightness. "
644
644
  + "Set headerHeightMultiplier and optional headerMinHeightMultiplier as strings in site-header.json; for example, 3.8 expanded and 1.9 minimum. See help appearance for the range and fallback rules.",
645
645
  `See the compiled colors: ${CLI_BINARY_NAME} theme resolve prints, offline, every semantic color Espalier compiles `
646
646
  + "from the pair for each scheme and context, whether each is compiled from the roles or pinned, and the contrast "
@@ -658,7 +658,7 @@ const WORKFLOW_REFERENCES = Object.freeze({
658
658
  + "nothing to do.",
659
659
  `Push: ${CLI_BINARY_NAME} theme push --dry-run first: it reads the site and lists the JSON paths at which each `
660
660
  + "settings file differs from it, and says whether the baseline pull recorded is still current. Then "
661
- + `${CLI_BINARY_NAME} theme push saves both themes, the appearance scalars and the ten footer scheme colours in `
661
+ + `${CLI_BINARY_NAME} theme push saves both themes, the appearance scalars, header/footer contexts and logo variants in `
662
662
  + "one transaction fenced by that baseline: a concurrent change to any of those fields refuses the whole push "
663
663
  + "(theme.concurrent_modification) and nothing is written; keep copies of the edited files, pull, re-apply, "
664
664
  + "and push again. A lost response is safe to retry — the site answers applied=false when it already holds "
@@ -1,4 +1,4 @@
1
- import { APPEARANCE_FOOTER_COLOR_FIELDS, APPEARANCE_SCALAR_FIELDS } from "./appearance-contract.js";
1
+ import { APPEARANCE_SCALAR_FIELDS } from "./appearance-contract.js";
2
2
  import {
3
3
  SETTINGS_GROUPS,
4
4
  SETTINGS_TYPE_BRAND,
@@ -160,6 +160,18 @@ const BRAND_ENTRIES = {
160
160
  };
161
161
 
162
162
  const HEADER_ENTRIES = {
163
+ logoVariant: entry(
164
+ `${HEADER} > Logo`,
165
+ "Which artwork the header uses: empty matches the color scheme, light chooses light-background artwork, and dark chooses dark-background artwork.",
166
+ "The header's regular and eligible compact logos; footer and legal PDF choices remain independent.",
167
+ "",
168
+ ),
169
+ context: entry(
170
+ `${HEADER} > Colors`,
171
+ "The header's theme context, declared by both schemes; empty uses the page colors.",
172
+ "Everything in the header, including navigation and its drawer.",
173
+ "",
174
+ ),
163
175
  headerLayout: entry(
164
176
  `${HEADER} > Layout`,
165
177
  "How the brand, menu and buttons are arranged: standard (one row), centered-brand, minimal (the menu stays in "
@@ -361,7 +373,7 @@ const PREFERENCES_ENTRIES = {
361
373
  ),
362
374
  footerSettings: entry(
363
375
  "Footer",
364
- "The whole footer: link columns, aside and bottom text, brand, feature image and per-scheme colors and background.",
376
+ "The whole footer: link columns, aside and bottom text, brand, feature image, theme context and per-scheme background art.",
365
377
  "The footer of every published page, but only once footerSettings.enabled is true. help footer has the closed "
366
378
  + "schema.",
367
379
  { enabled: false },
@@ -385,13 +397,12 @@ export function describeSettingField(settingsType, name) {
385
397
  const WRITABLE_SCALARS = new Set(
386
398
  APPEARANCE_SCALAR_FIELDS.map((field) => `${field.settingsType}:${field.name}`),
387
399
  );
388
- const THEME_FOOTER_COLORS = APPEARANCE_FOOTER_COLOR_FIELDS.length;
389
400
 
390
401
  /** How the CLI changes a field: the verb that writes it, or that it is read-only here. */
391
402
  function writeVerb(group, field) {
392
403
  if (field.wireType === "theme" || WRITABLE_SCALARS.has(`${group.settingsType}:${field.name}`)) return "theme push";
393
404
  if (field.name === "footerSettings") {
394
- return `footer push (content); theme push (the ${THEME_FOOTER_COLORS} scheme colors)`;
405
+ return "footer push (content); theme push (context and logoVariant)";
395
406
  }
396
407
  if (field.name.endsWith("Url")) return "read-only projection of the matching id; never authored";
397
408
  return "read-only: pull records it, change it in the app";
@@ -2,7 +2,7 @@ import { parseTheme } from "@taprootio/espalier/shared/theme";
2
2
 
3
3
  import { SiteAuthoringError } from "./errors.js";
4
4
  import { projectFooterSettingsForWorkspace } from "./footer-contract.js";
5
- import { parseHeaderHeightMultiplier } from "./header-presentation.js";
5
+ import { parseHeaderHeightMultiplier, resolveLogoVariant } from "./header-presentation.js";
6
6
  import { projectPulledTheme } from "./theme-projection.js";
7
7
 
8
8
  /**
@@ -25,8 +25,8 @@ import { projectPulledTheme } from "./theme-projection.js";
25
25
  * projected to the complete effective theme (`theme-projection.js`). Theme
26
26
  * push validates and re-encodes them only at the wire boundary.
27
27
  * - `footerSettings` is snapshotted as its structured document. Theme push
28
- * overlays only its scheme colors onto a fresh server read before using the
29
- * optimistic-concurrency footer endpoint.
28
+ * owns its context through the atomic presentation save; footer push owns
29
+ * its content through the optimistic-concurrency footer endpoint.
30
30
  * - `membershipsEnabled` is excluded. It appears in the publishing-preferences
31
31
  * message but not in the group's settable field set: it is a plan-derived
32
32
  * flag the server computes, not site configuration a workspace owns.
@@ -104,6 +104,8 @@ export const SETTINGS_GROUPS = Object.freeze([
104
104
  "headerMinHeightMultiplier",
105
105
  "lightBrandColor",
106
106
  "darkBrandColor",
107
+ "context",
108
+ "logoVariant",
107
109
  ),
108
110
  { name: "showThemeToggle", wireType: "boolean" },
109
111
  { name: "showBrandText", wireType: "boolean" },
@@ -210,6 +212,11 @@ export function projectSettingsGroup(group, response) {
210
212
  const source = message !== null && typeof message === "object" && !Array.isArray(message) ? message : {};
211
213
  const projected = {};
212
214
  for (const field of group.fields) {
215
+ if (field.name === "logoVariant") {
216
+ const variant = resolveLogoVariant(source[field.name]);
217
+ if (variant !== "") projected[field.name] = variant;
218
+ continue;
219
+ }
213
220
  if (field.name === "headerHeightMultiplier" || field.name === "headerMinHeightMultiplier") {
214
221
  const height = parseHeaderHeightMultiplier(source[field.name]);
215
222
  if (!height) {