@taprootio/site-authoring 0.39.0 → 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.
@@ -23,11 +23,12 @@ 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";
31
32
  import { FOOTER_LOGO_BOX, FOOTER_LOGO_SCALE_LIMITS } from "./footer-branding.js";
32
33
  import { FOOTER_ALIGNMENT_LAYOUTS, FOOTER_POSITION_VALUES, FOOTER_TEXT_ALIGN_VALUES } from "./footer-alignment.js";
33
34
  import {
@@ -438,9 +439,6 @@ export function getThemeReference() {
438
439
  };
439
440
  }
440
441
 
441
- // "linkHoverColor" reads "link hover color", so a new footer color token needs no second table.
442
- const footerColorLabel = (name) => name.replace(/([A-Z])/gu, " $1").toLowerCase();
443
-
444
442
  function appearanceColorReference(definition) {
445
443
  return definition.type === "appearance-color"
446
444
  ? {
@@ -483,16 +481,17 @@ export function getAppearanceReference() {
483
481
  type: "complete-espalier-theme",
484
482
  },
485
483
  ...scalarFields,
486
- ...APPEARANCE_FOOTER_COLOR_FIELDS.map((field) => ({
484
+ ...APPEARANCE_FOOTER_FIELDS.map(field => ({
487
485
  file: field.file,
488
486
  path: field.path,
489
- appLabel: "Footer",
490
- description: `The footer's ${
491
- footerColorLabel(field.name)
492
- } in the ${field.scheme} scheme. footer push owns the rest of the footer.`,
493
- 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.",
494
492
  type: field.type,
495
- ...appearanceColorReference(field),
493
+ ...(field.values ? { values: field.values } : {}),
494
+ optional: field.optional,
496
495
  default: field.default,
497
496
  })),
498
497
  ],
@@ -518,7 +517,8 @@ export function getAppearanceReference() {
518
517
  + "Inspect at 16 and 32 pixels in light and dark browser tabs; a deliberate contrasting badge can help a favicon "
519
518
  + "remain recognizable independently of the header theme. Verify the published icon loads, not just the setting.",
520
519
  logoContrastContract:
521
- "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 "
522
522
  + "header at desktop and compact/mobile widths. Transparent pixels provide no contrast: inspect the visible mark, "
523
523
  + "not its canvas bounds. When one asset does not remain distinct in both schemes, supply scheme-specific logo "
524
524
  + "assets rather than relying on a shadow, outline, or header color that has not been previewed.",
@@ -543,7 +543,7 @@ export function getAppearanceReference() {
543
543
  + "are per-scheme theme fields set in settings.lightTheme/darkTheme the same way fontBrand is, and an empty "
544
544
  + "fontMenu falls back to the body font, never to headings.",
545
545
  changeSet: [
546
- "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",
547
547
  "default scheme, assets, favicon, and header scalars",
548
548
  "the complete light theme and the complete dark theme",
549
549
  ],
@@ -555,7 +555,7 @@ export function getAppearanceReference() {
555
555
  + "one transaction or none of it does; a change to any of those fields since the pull refuses the push "
556
556
  + "(theme.concurrent_modification) and nothing is written. Footer prose, links and imagery, and the "
557
557
  + "publishing scalars are outside the revision, so an unrelated concurrent edit is preserved rather than "
558
- + "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.",
559
559
  dryRun: CLI_BINARY_NAME + " theme push --dry-run reads the site, lists the JSON paths at which each settings file "
560
560
  + "differs from it, and says whether the recorded baseline is still current or a pending save of the same "
561
561
  + "change set would be replayed; it writes nothing.",
@@ -568,7 +568,11 @@ export function getAppearanceReference() {
568
568
  + " pull to refresh the baseline, re-apply the edits, and push again. A Taproot without the atomic save "
569
569
  + "refuses with theme.server_unsupported; theme push never falls back to sequential writes.",
570
570
  footerBoundary:
571
- "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.",
572
576
  footerContentGuard: "theme push refuses while settings.footerSettings carries unpushed content edits: "
573
577
  + "theme.unpushed_footer_content names " + CLI_BINARY_NAME + " footer push to save them "
574
578
  + "(" + CLI_BINARY_NAME + " pull discards them). A workspace pulled before this baseline "
@@ -578,30 +582,54 @@ export function getAppearanceReference() {
578
582
  }
579
583
 
580
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
+ },
581
592
  "FooterSettings.enabled": { type: "boolean", default: false },
582
593
  "FooterSettings.showBrand": { type: "boolean", default: true },
583
594
  "FooterSettings.showBrandText": { type: "boolean", default: true },
584
595
  "FooterSettings.brandSpan": { type: "integer", default: 1, minimum: 1, maximum: FOOTER_LIMITS.brandSpanMax },
585
596
  "FooterSettings.asideSpan": { type: "integer", default: 1, minimum: 1, maximum: FOOTER_LIMITS.asideSpanMax },
586
- "FooterSettings.brandSize": { type: "enum", default: "standard", values: ["standard", "large"], description: "Brand text size; logoScale independently sets the logo size." },
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
+ },
587
603
  "FooterSettings.logoScale": {
588
604
  type: "decimal-string",
589
605
  default: "1.0",
590
606
  ...FOOTER_LOGO_SCALE_LIMITS,
591
- description: "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.",
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.",
592
609
  },
593
610
  "FooterSettings.logoBox": {
594
- type: "enum", default: "fixed", values: ["fixed", "natural"],
595
- description: "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.",
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.",
596
616
  },
597
617
  ...Object.fromEntries(["alignment", "brandAlignment", "asideAlignment"].map(name => [
598
- `FooterSettings.${name}`, { type: "FooterResponsiveAlignment|null", inheritedWhenOmitted: true },
618
+ `FooterSettings.${name}`,
619
+ { type: "FooterResponsiveAlignment|null", inheritedWhenOmitted: true },
599
620
  ])),
600
621
  "FooterSettings.bottomAlignment": { type: "FooterResponsiveInlineAlignment|null", inheritedWhenOmitted: true },
601
- ...Object.fromEntries(["FooterResponsiveAlignment", "FooterResponsiveInlineAlignment"].flatMap(type =>
602
- FOOTER_ALIGNMENT_LAYOUTS.map(layout => [
603
- `${type}.${layout}`, { type: type === "FooterResponsiveAlignment" ? "FooterAlignment|null" : "FooterInlineAlignment|null", inheritedWhenOmitted: true },
604
- ]))),
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
+ ),
605
633
  ...Object.fromEntries(["FooterAlignment", "FooterInlineAlignment"].flatMap(type => [
606
634
  [`${type}.horizontal`, { type: "enum", values: ["", ...FOOTER_POSITION_VALUES], inheritedWhenOmitted: true }],
607
635
  [`${type}.textAlign`, { type: "enum", values: ["", ...FOOTER_TEXT_ALIGN_VALUES], inheritedWhenOmitted: true }],
@@ -676,35 +704,11 @@ const FOOTER_FIELD_DETAILS = Object.freeze({
676
704
  exclusiveWith: "pageResourceId",
677
705
  maximumLength: FOOTER_LIMITS.externalUrlLength,
678
706
  },
679
- "FooterSchemeSettings.backgroundColor": {
680
- type: "appearance-color",
681
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "backgroundColor")),
682
- default: "",
683
- },
684
- "FooterSchemeSettings.textColor": {
685
- type: "appearance-color",
686
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "textColor")),
687
- default: "",
688
- },
689
- "FooterSchemeSettings.headingColor": {
690
- type: "appearance-color",
691
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "headingColor")),
692
- default: "",
693
- },
694
- "FooterSchemeSettings.linkColor": {
695
- type: "appearance-color",
696
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "linkColor")),
697
- default: "",
698
- },
699
- "FooterSchemeSettings.linkHoverColor": {
700
- type: "appearance-color",
701
- ...appearanceColorReference(APPEARANCE_FOOTER_COLOR_FIELDS.find((field) => field.name === "linkHoverColor")),
702
- default: "",
703
- },
704
707
  "FooterSchemeSettings.logoId": {
705
708
  type: "site-owned-png-or-webp-image-uuid",
706
709
  default: "",
707
- description: "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.",
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.",
708
712
  },
709
713
  "FooterSchemeSettings.logoUrl": { type: "url", readOnly: true },
710
714
  "FooterSchemeSettings.backgroundImageId": { type: "site-owned-image-uuid", default: "" },
@@ -786,24 +790,24 @@ export function getFooterReference() {
786
790
  logoSpaceRule: "logoBox fixed preserves scaled image height; start moves spare height below the artwork. "
787
791
  + "Natural fits the width-constrained artwork, including its loading reservation, without changing scale or "
788
792
  + "cropping transparent padding. Absent, null or empty logoBox is fixed. Header geometry is unchanged.",
789
- fitCheck: "validate reports footer.word_breaks at five widths: desktop, small desktop, tablet, phone and Small phone (320px); footer push "
793
+ fitCheck:
794
+ "validate reports footer.word_breaks at five widths: desktop, small desktop, tablet, phone and Small phone (320px); footer push "
790
795
  + "prints the same warnings before saving. At most 12 are shown, with the true count and any remainder. "
791
796
  + "Estimates use generated default-font advances, the default type scale and gaps; custom fonts or scale may differ. "
792
797
  + "Supported whitespace, hyphen and zero-width break opportunities are estimated; contextual shaping is bounded, "
793
- + "and Han, Kana or Thai fragments are skipped. The CLI cannot measure logos and assumes their maximum "
794
- + "4:1 ratio, so it can over-report brand words beside a narrow logo. Warnings never refuse a save. "
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. "
795
800
  + "The deployment check covers standard and profile sites; managed Docs sites use validate and the Footer tab.",
796
801
  readOnlyProjections: FOOTER_READ_ONLY_FIELDS,
797
802
  concurrency:
798
- "pull records the footer-draft-v7 expectedDraftHash, including effective logoScale, logoBox, all sparse profiles "
799
- + "and both logo ids, but no response URLs or effective inherited choices. Old v6 baselines are refused; upgrade and pull again. A conflict returns "
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 "
800
805
  + "footer.concurrent_modification; pull, reconcile, and retry.",
801
806
  themeInteraction:
802
- "theme push overlays its ten scheme colors onto the site's current footer document inside its atomic save and "
803
- + "rewrites this file from the saved result. It refuses while unpushed footer-content edits exist "
804
- + "(theme.unpushed_footer_content); run " + CLI_BINARY_NAME + " footer push first, or " + CLI_BINARY_NAME
805
- + " pull to discard the local edit. A footer push that changed a scheme color advances the presentation "
806
- + "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.",
807
811
  workflow: [
808
812
  CLI_BINARY_NAME + " pull",
809
813
  "edit settings/site-publishing-preferences.json at settings.footerSettings",
@@ -912,6 +916,8 @@ export function formatPresentationReference(reference) {
912
916
  + "\nHeader width: " + reference.headerWidthContract
913
917
  + "\nBlock spacing: " + reference.blockSpacingContract
914
918
  + "\nMobile menu and menu font: " + reference.menuContract
919
+ + "\nSurface contexts: " + reference.surfaceContexts
920
+ + "\nRetired footer color recipe: " + reference.footerColorMigration
915
921
  + "\nFooter: " + reference.footerBoundary
916
922
  + "\nFooter content guard: " + reference.footerContentGuard + "\n\nAtomic change set (one transaction):\n"
917
923
  + reference.changeSet.map((step, index) => " " + (index + 1) + ". " + step).join("\n")
@@ -924,8 +930,10 @@ export function formatPresentationReference(reference) {
924
930
  if (reference.referenceKind === "footer") {
925
931
  const messages = reference.messages.map((message) =>
926
932
  message.name + " (unlisted fields rejected)\n"
927
- + message.fields.map((field) => " " + field.name.padEnd(30) + fieldConstraint(field)
928
- + (field.description ? "; " + field.description : "")).join("\n")
933
+ + message.fields.map((field) =>
934
+ " " + field.name.padEnd(30) + fieldConstraint(field)
935
+ + (field.description ? "; " + field.description : "")
936
+ ).join("\n")
929
937
  ).join("\n\n");
930
938
  return reference.title + "\nUsage: " + reference.usage + "\nWorkspace: "
931
939
  + reference.workspaceFile + " :: " + reference.workspacePath + "\n\nClosed schema:\n"
@@ -95,7 +95,7 @@ import {
95
95
 
96
96
  export { getAppearanceReference, getFooterReference, getSettingsReference, getThemeReference };
97
97
 
98
- export const REFERENCE_VERSION = 60;
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) {
@@ -17,6 +17,7 @@ import { displayPagePath } from "./workspace.js";
17
17
  * words below are this surface's own.
18
18
  */
19
19
  export const SITE_CHECK_RULES = Object.freeze(rules.rules);
20
+ export const SITE_FINDINGS_MAX_BYTES = 8 * 1024;
20
21
 
21
22
  /** Why `validate` did not run the image description rule, which needs the site's image records (TR01371). */
22
23
  export const IMAGE_CHECK_NOT_REQUESTED = "not_requested";
@@ -82,6 +83,11 @@ export const SITE_CHECK_WORDING = Object.freeze({
82
83
  "seo.description_long": (finding) => `has a description of ${finding.detail} characters; consider shortening it (guidance: ${DESCRIPTION_MINIMUM_LENGTH}–${DESCRIPTION_WARN_LENGTH})`,
83
84
  "seo.description_matches_title": () => "has a description that repeats its title; explain what readers will find",
84
85
  "footer.word_breaks": (finding) => footerFindingWords(finding),
86
+ "brand.logo_on_surface": finding => {
87
+ const [scheme, second, third] = String(finding.detail ?? "").split(":");
88
+ const artwork = third ?? second;
89
+ return `the ${finding.subject === "footer" ? "footer" : "header"} shows ${artwork === "dark" ? "dark" : "light"}-background ${second === "compact" ? "compact " : ""}artwork against the opposite surface brightness in the ${scheme === "dark" ? "dark" : "light"} scheme; choose its other Logo variant or adjust its Colors context`;
90
+ },
85
91
  "seo.social_image_fallback": (finding) =>
86
92
  finding.detail === "first_image"
87
93
  ? "has no cover image; link previews use the page's first image only when it is public and at least 1200 pixels wide"
@@ -95,6 +101,7 @@ export const SITE_CHECK_WORDING = Object.freeze({
95
101
  export const AFTER_PAGE_FIX =
96
102
  "then, for a page edit, run taproot-site pages push and taproot-site approve, and run taproot-site deploy --staging to refresh the report";
97
103
  export const SITE_CHECK_REMEDIES = Object.freeze({
104
+ "brand.logo_on_surface": "Choose a readable header or footer logoVariant in the settings files, run taproot-site theme push, and inspect both schemes on staging. This brightness heuristic does not inspect image pixels or footer background art.",
98
105
  "footer.word_breaks": "Widen the named footer region or shorten its text in settings/site-publishing-preferences.json, run taproot-site footer push, then taproot-site deploy --staging to refresh the report.",
99
106
  "link.page_missing": `Change the link to a page this site has, or create that page, ${AFTER_PAGE_FIX}.`,
100
107
  "image.missing": `Remove the image from the page or replace it with one from the site's library, ${AFTER_PAGE_FIX}.`,
@@ -240,7 +247,7 @@ export function evaluateOfflineSiteChecks({
240
247
  onProgress(`Warning: ${items.length - MAXIMUM_PROGRESS_LINES} more site check finding(s); see findings.`);
241
248
  }
242
249
  if (hiddenFooter > 0) onProgress(`Warning: and ${hiddenFooter} more footer fit finding(s); widen or shorten the footer text and run validate again.`);
243
- const reported = boundedByBytes(items, 8 * 1024);
250
+ const reported = boundedByBytes(items, SITE_FINDINGS_MAX_BYTES);
244
251
  const total = items.length + hiddenFooter;
245
252
  const footerSkipped = footerInput !== undefined && footerInput.enabled !== true ? ["footer.word_breaks"] : [];
246
253
  const errors = items.filter((item) => item.severity === "error").length;
@@ -289,3 +296,26 @@ export function evaluateOfflineSiteChecks({
289
296
  },
290
297
  };
291
298
  }
299
+
300
+
301
+ /** Add one offline step without losing the evaluator's findings or coverage metadata. */
302
+ export function mergeOfflineSiteChecks(primary, secondary) {
303
+ const reported = boundedByBytes([...primary.findings.items, ...secondary.findings.items], SITE_FINDINGS_MAX_BYTES);
304
+ const union = name => [...new Set([...(primary.siteChecks[name] ?? []), ...(secondary.siteChecks[name] ?? [])])];
305
+ const skipped = union("skipped");
306
+ return {
307
+ ...primary,
308
+ findings: {
309
+ total: primary.findings.total + secondary.findings.total,
310
+ errors: primary.findings.errors + secondary.findings.errors,
311
+ warnings: primary.findings.warnings + secondary.findings.warnings,
312
+ items: reported.items,
313
+ ...(primary.findings.truncated || secondary.findings.truncated || reported.truncated ? { truncated: true } : {}),
314
+ },
315
+ siteChecks: {
316
+ ...primary.siteChecks,
317
+ ranOffline: union("ranOffline"),
318
+ ...(skipped.length === 0 ? {} : { skipped }),
319
+ },
320
+ };
321
+ }
@@ -34,6 +34,7 @@
34
34
  { "id": "seo.description_long", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "character_count" },
35
35
  { "id": "seo.description_matches_title", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "none" },
36
36
  { "id": "seo.social_image_fallback", "severity": "warning", "scope": "document", "appliesTo": ["free_form"], "runsAt": ["edit"], "subject": "none", "detail": "social_image_source" },
37
- { "id": "footer.word_breaks", "severity": "warning", "scope": "site", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "footer_word", "detail": "width_and_region" }
37
+ { "id": "footer.word_breaks", "severity": "warning", "scope": "site", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "footer_word", "detail": "width_and_region" },
38
+ { "id": "brand.logo_on_surface", "severity": "warning", "scope": "site", "runsAt": ["validate"], "subject": "surface", "detail": "scheme_and_variant" }
38
39
  ]
39
40
  }
@@ -0,0 +1,82 @@
1
+ // Generated from shared/theme-contexts.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ /** Keep the decoded-name contract aligned with DefaultSiteTheme and the shared vectors. */
3
+ export const MAX_ENCODED_THEME_LENGTH = 1024 * 1024;
4
+ const MAX_JSON_DEPTH = 64;
5
+ const CONTEXT_NAME = /^[a-z][a-z0-9-]*$/u;
6
+ const UNSAFE_NAMES = new Set(["__proto__", "constructor", "prototype"]);
7
+ const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/u;
8
+ function isObject(value) {
9
+ return value !== null && typeof value === "object" && !Array.isArray(value);
10
+ }
11
+ /** Only declarations Espalier retains can be selected by a published surface. */
12
+ export function declaredThemeContextNames(theme) {
13
+ if (!isObject(theme) || !Object.prototype.hasOwnProperty.call(theme, "contexts") || !isObject(theme.contexts)) {
14
+ return [];
15
+ }
16
+ const contexts = theme.contexts;
17
+ return Object.keys(contexts)
18
+ .filter(name => CONTEXT_NAME.test(name) && !UNSAFE_NAMES.has(name) && isObject(contexts[name]))
19
+ .sort();
20
+ }
21
+ /** Count source nesting so even an overwritten duplicate property keeps the API's limit. */
22
+ function withinJsonDepth(json) {
23
+ let depth = 0;
24
+ let inString = false;
25
+ let escaped = false;
26
+ for (const character of json) {
27
+ if (inString) {
28
+ if (escaped)
29
+ escaped = false;
30
+ else if (character === "\\")
31
+ escaped = true;
32
+ else if (character === "\"")
33
+ inString = false;
34
+ }
35
+ else if (character === "\"")
36
+ inString = true;
37
+ else if (character === "{" || character === "[") {
38
+ if (++depth > MAX_JSON_DEPTH)
39
+ return false;
40
+ }
41
+ else if (character === "}" || character === "]")
42
+ depth -= 1;
43
+ }
44
+ return true;
45
+ }
46
+ /** The API's strict wire decoder wins over Espalier's lenient legacy decoder for declarations. */
47
+ function decodeContextTheme(encoded) {
48
+ if (typeof encoded !== "string" || encoded.length > MAX_ENCODED_THEME_LENGTH)
49
+ return undefined;
50
+ const compact = encoded.replace(/[ \t\r\n]/gu, "");
51
+ if (compact.length % 4 !== 0 || !BASE64.test(compact))
52
+ return undefined;
53
+ try {
54
+ const binary = atob(compact);
55
+ const bytes = Uint8Array.from(binary, character => character.charCodeAt(0));
56
+ const marked = bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf;
57
+ const payload = marked ? bytes.subarray(3) : bytes;
58
+ const hasNonAscii = payload.some(value => value > 0x7f);
59
+ if (marked !== hasNonAscii)
60
+ return undefined;
61
+ const json = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(payload);
62
+ return withinJsonDepth(json) ? JSON.parse(json) : undefined;
63
+ }
64
+ catch {
65
+ return undefined;
66
+ }
67
+ }
68
+ export function declaredEncodedThemeContextNames(encoded) {
69
+ return declaredThemeContextNames(decodeContextTheme(encoded));
70
+ }
71
+ function intersection(light, dark) {
72
+ const other = new Set(dark);
73
+ return light.filter(name => other.has(name));
74
+ }
75
+ /** Workspace themes are JSON objects until the canonical encoder sends them. */
76
+ export function sharedDeclaredThemeContextNames(light, dark) {
77
+ return intersection(declaredThemeContextNames(light), declaredThemeContextNames(dark));
78
+ }
79
+ /** Stored themes share the API's decoder and declaration rules in previews and publishing. */
80
+ export function sharedEncodedThemeContextNames(light, dark) {
81
+ return intersection(declaredEncodedThemeContextNames(light), declaredEncodedThemeContextNames(dark));
82
+ }
@@ -31,7 +31,7 @@ const THEME_SCHEMES = Object.freeze(["light", "dark"]);
31
31
  let engines;
32
32
 
33
33
  /** The fit report and color engine are Espalier modules beside the exported theme module (see espalier-shared.js). */
34
- function loadEngines() {
34
+ export function loadThemeEngines() {
35
35
  engines ??= Promise.all([
36
36
  loadEspalierShared("theme-fit-report.js"),
37
37
  loadEspalierShared("color-engine.js"),
@@ -156,7 +156,7 @@ function describeSurface(color, report, scheme, rootSurface) {
156
156
  */
157
157
  export async function resolveThemePair(lightTheme, darkTheme, { scheme, context } = {}) {
158
158
  const { light, dark } = validateAndEncodeThemePair(lightTheme, darkTheme);
159
- const { fit, color } = await loadEngines();
159
+ const { fit, color } = await loadThemeEngines();
160
160
  // The stored pair is encoded and parsed back, as theme push's fit lints do, so this is what the page resolves.
161
161
  const suite = fit.themeFitReportSuite(parseTheme(light) ?? {}, parseTheme(dark) ?? {});
162
162
  const contexts = suite.surfaces.filter((surface) => surface !== fit.ROOT_SURFACE);
@@ -11,6 +11,7 @@ import {
11
11
 
12
12
  import { hasControlCharacter, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
13
13
  import { loadEspalierShared } from "./espalier-shared.js";
14
+ import { sharedDeclaredThemeContextNames, sharedEncodedThemeContextNames } from "./theme-contexts.js";
14
15
  import { proposePassingValues, refuseUnavailableFontWeights } from "./theme-proposals.js";
15
16
 
16
17
  export const MAXIMUM_THEME_WARNINGS = 32;
@@ -99,19 +100,35 @@ export const HEADER_BRAND_COLOR_TOKENS = Object.freeze(
99
100
  ]),
100
101
  );
101
102
 
102
- export const FOOTER_COLOR_TOKENS = Object.freeze({
103
- backgroundColor: new Set([
104
- "--esp-color-background",
105
- "--esp-color-layer-1",
106
- "--esp-color-layer-2",
107
- "--esp-color-layer-3",
108
- "--esp-color-layer-4",
109
- ]),
110
- textColor: new Set(["--esp-color-text", "--esp-color-headings"]),
111
- headingColor: new Set(["--esp-color-headings", "--esp-color-text"]),
112
- linkColor: new Set(["--esp-color-link", "--esp-color-headings"]),
113
- linkHoverColor: new Set(["--esp-color-link-hover", "--esp-color-link"]),
114
- });
103
+ /** Validate the complete post-save state, including an atomic repoint and context removal. */
104
+ export function requireSurfaceContexts({ lightTheme, darkTheme, headerContext = "", footerContext = "" }, current) {
105
+ const declared = new Set(sharedDeclaredThemeContextNames(lightTheme, darkTheme));
106
+ const previous = current === undefined ? new Set() : new Set(sharedEncodedThemeContextNames(
107
+ current.styleSettings?.lightTheme,
108
+ current.styleSettings?.darkTheme,
109
+ ));
110
+ for (
111
+ const [surface, field, context, stored] of [
112
+ ["header", "site-header.context", headerContext, current?.headerSettings?.context ?? ""],
113
+ [
114
+ "footer",
115
+ "footerSettings.context",
116
+ footerContext,
117
+ current?.sitePublishingPreferences?.footerSettings?.context ?? "",
118
+ ],
119
+ ]
120
+ ) {
121
+ if (context === "" || declared.has(context)) continue;
122
+ const removingUsedContext = context === stored && previous.has(context);
123
+ fail(
124
+ removingUsedContext ? "theme.context_in_use" : "settings.context_unknown",
125
+ removingUsedContext
126
+ ? `The ${surface} still uses context '${context}'. Keep it in both themes, or repoint the ${surface} in this same theme push.`
127
+ : `${field} must be empty or name a context declared by both lightTheme and darkTheme.`,
128
+ field,
129
+ );
130
+ }
131
+ }
115
132
 
116
133
  export const APPEARANCE_COLOR_CONSTRAINT = Object.freeze({
117
134
  maximumLength: 128,