@taprootio/site-authoring 0.42.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +110 -12
  2. package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
  3. package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
  4. package/package.json +4 -3
  5. package/src/api.js +242 -23
  6. package/src/appearance-contract.js +264 -3
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/authors-contract.js +71 -3
  9. package/src/block-flow.js +103 -1
  10. package/src/brand-color.js +22 -0
  11. package/src/breadcrumb-artwork.js +234 -0
  12. package/src/breadcrumb-separators.js +11 -0
  13. package/src/changelog.json +160 -0
  14. package/src/chrome-features.js +6 -2
  15. package/src/chrome-input.js +1 -0
  16. package/src/chrome-paint-catalog-taproot.json +3 -3
  17. package/src/chrome-report.js +91 -12
  18. package/src/cli.js +136 -38
  19. package/src/constants.js +1 -0
  20. package/src/content/components.js +27 -4
  21. package/src/content/external-link.js +2 -1
  22. package/src/content/markdown.js +271 -101
  23. package/src/content/tiptap-prosemirror.ts +125 -43
  24. package/src/content/validate-document.js +4 -1
  25. package/src/content-inset.js +48 -0
  26. package/src/errors.js +1 -0
  27. package/src/espalier-shared.js +26 -0
  28. package/src/field-suggestions.js +40 -0
  29. package/src/fixture-init.js +22 -5
  30. package/src/font-catalog.js +11 -1
  31. package/src/footer-brand-inputs.js +22 -3
  32. package/src/footer-content.js +1 -0
  33. package/src/footer-contract.js +11 -0
  34. package/src/footer-cta-styles.js +6 -0
  35. package/src/footer-draft-hash.js +4 -2
  36. package/src/footer-fit.js +62 -15
  37. package/src/footer-workspace.js +44 -7
  38. package/src/latest-posts-tags.js +57 -0
  39. package/src/page-metadata.js +15 -13
  40. package/src/page-structure-checks.js +5 -0
  41. package/src/page-tag-badge-modes.js +6 -0
  42. package/src/page-tag-writes.js +158 -0
  43. package/src/page-type-tags.js +16 -0
  44. package/src/presentation-reference.js +297 -86
  45. package/src/recipe-page-options.js +22 -0
  46. package/src/recipe-step-contract.js +164 -0
  47. package/src/recipe-step-contract.json +65 -0
  48. package/src/reference-help.js +182 -79
  49. package/src/session.js +39 -24
  50. package/src/setting-reference.js +239 -48
  51. package/src/settings-catalog.js +63 -0
  52. package/src/site-check-findings.js +23 -5
  53. package/src/site-check-rules.json +1 -0
  54. package/src/site-health-findings.js +13 -13
  55. package/src/styling-fixed-values.js +71 -0
  56. package/src/tag-destination-warnings.js +35 -0
  57. package/src/template-token-reach.json +242 -0
  58. package/src/theme-proposals.js +18 -27
  59. package/src/theme-resolve.js +265 -23
  60. package/src/theme-validation.js +118 -7
  61. package/src/token-reach.js +222 -0
  62. package/src/typed-page-reference.js +94 -16
  63. package/src/typed-pages.js +233 -74
  64. package/src/verbs/authors.js +198 -33
  65. package/src/verbs/deploy.js +6 -0
  66. package/src/verbs/footer-push.js +30 -5
  67. package/src/verbs/forms-push.js +11 -3
  68. package/src/verbs/index.js +4 -2
  69. package/src/verbs/pages-delete.js +19 -10
  70. package/src/verbs/pages-push.js +225 -71
  71. package/src/verbs/plan.js +10 -4
  72. package/src/verbs/pull.js +324 -69
  73. package/src/verbs/staging-review.js +27 -1
  74. package/src/verbs/status.js +22 -0
  75. package/src/verbs/theme-push.js +93 -25
  76. package/src/verbs/theme-resolve.js +189 -55
  77. package/src/verbs/validate.js +6 -5
  78. package/src/workspace-check.js +35 -3
  79. package/src/workspace.js +73 -2
  80. package/test/fixtures/default-site-theme.json +516 -0
@@ -6,11 +6,15 @@ import {
6
6
  mergeTheme,
7
7
  parseTheme,
8
8
  SEMANTIC_COLOR_NAMES,
9
+ validateComponentProperties,
9
10
  validateThemePair,
10
11
  } from "@taprootio/espalier/shared/theme";
11
12
 
13
+ import { LIMITS } from "./constants.js";
12
14
  import { hasControlCharacter, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
13
- import { loadEspalierShared } from "./espalier-shared.js";
15
+ import { getSettableComponentProperties, loadEspalierShared } from "./espalier-shared.js";
16
+ import { closeFieldMatch, unknownFieldHint } from "./field-suggestions.js";
17
+ import { withinByteBudget } from "./problems.js";
14
18
  import { sharedDeclaredThemeContextNames, sharedEncodedThemeContextNames } from "./theme-contexts.js";
15
19
  import { proposePassingValues, refuseUnavailableFontWeights } from "./theme-proposals.js";
16
20
 
@@ -19,6 +23,8 @@ export const MAXIMUM_THEME_WARNINGS = 32;
19
23
  // missed its floor before the remedy, and a surface that fails across the
20
24
  // board runs past 900 scalars. Truncating it would cut the remedy off.
21
25
  export const MAXIMUM_THEME_WARNING_SCALARS = 2048;
26
+ // Leave room for change paths and save evidence in the CLI result.
27
+ const MAXIMUM_THEME_WARNING_BYTES = LIMITS.githubOutputBytes / 2;
22
28
  export const MAXIMUM_THEME_OPEN_MAP_ENTRIES = 128;
23
29
  export const MAXIMUM_THEME_OPEN_MAP_KEY_SCALARS = 64;
24
30
 
@@ -62,6 +68,21 @@ export const REQUIRED_THEME_PROPERTIES = Object.freeze([
62
68
  "fontWeightMenu",
63
69
  ]);
64
70
 
71
+ export const OPTIONAL_THEME_FIELDS = Object.freeze([
72
+ "explicitMappingTokens",
73
+ "boxBackgroundImage",
74
+ "boxBackgroundImageOpacity",
75
+ "vellumOpacity",
76
+ "vellumBackgroundImage",
77
+ "vellumBackgroundImageOpacity",
78
+ "componentProperties",
79
+ ]);
80
+
81
+ export const THEME_FIELD_NAMES = Object.freeze([
82
+ ...REQUIRED_THEME_PROPERTIES,
83
+ ...OPTIONAL_THEME_FIELDS,
84
+ ]);
85
+
65
86
  const REQUIRED_ANGLE_LEAVES = Object.freeze([
66
87
  "analogous",
67
88
  "complementary",
@@ -300,6 +321,19 @@ function requireCompleteTheme(theme, scheme) {
300
321
  }
301
322
  }
302
323
 
324
+ function requireKnownThemeFields(theme, scheme) {
325
+ const key = Object.keys(theme).find((name) => !THEME_FIELD_NAMES.includes(name));
326
+ if (key === undefined) return;
327
+
328
+ const nearest = closeFieldMatch(key, THEME_FIELD_NAMES);
329
+ const field = `${scheme}Theme.${key}`;
330
+ throw new SiteAuthoringError(
331
+ "theme.field_unknown",
332
+ `Unknown theme field '${field}'.${unknownFieldHint(nearest)}`,
333
+ { field, alternatives: nearest === undefined ? undefined : [nearest] },
334
+ );
335
+ }
336
+
303
337
  function refuseAgentStylesheets(theme, scheme) {
304
338
  // Espalier keeps this array in its complete theme document, but an external
305
339
  // stylesheet is mutable code outside the frozen authoring-preview inventory.
@@ -475,14 +509,63 @@ async function fitLints(light, dark) {
475
509
  return { fit, items };
476
510
  }
477
511
 
512
+ function effectiveComponentProperty(theme, context, { name, default: fallback }) {
513
+ return (context === null ? undefined : theme.contexts[context]?.componentProperties?.[name])
514
+ ?? theme.componentProperties?.[name]
515
+ ?? fallback;
516
+ }
517
+
518
+ function comparableComponentProperty(value, unit) {
519
+ if (unit === undefined) return value;
520
+ if (value === "0") return 0;
521
+ return value.endsWith(unit) ? Number(value.slice(0, -unit.length)) : value;
522
+ }
523
+
524
+ function displayComponentProperty(authored, comparable, unit) {
525
+ if (typeof comparable !== "number") return authored;
526
+ const compact = comparable === 0 ? "0" : `${comparable}${unit}`;
527
+ return compact.length < authored.length ? compact : authored;
528
+ }
529
+
530
+ export function abbreviateThemeContext(context, maximumLength, position) {
531
+ if (context.length <= maximumLength) return context;
532
+ const ending = `…${context.slice(-40)} [context ${position}]`;
533
+ return context.slice(0, maximumLength - ending.length) + ending;
534
+ }
535
+
536
+ function componentPropertyReflowWarnings(lightTheme, darkTheme) {
537
+ const properties = getSettableComponentProperties().filter(({ syntax }) => syntax !== "color");
538
+ const contexts = sharedDeclaredThemeContextNames(lightTheme, darkTheme);
539
+ const prefix = "theme.component_property_scheme_differs: ";
540
+ const warnings = [];
541
+ for (const [position, context] of [null, ...contexts].entries()) {
542
+ for (const property of properties) {
543
+ const light = effectiveComponentProperty(lightTheme, context, property);
544
+ const dark = effectiveComponentProperty(darkTheme, context, property);
545
+ const lightComparable = comparableComponentProperty(light, property.unit);
546
+ const darkComparable = comparableComponentProperty(dark, property.unit);
547
+ if (lightComparable === darkComparable) continue;
548
+ const lightValue = displayComponentProperty(light, lightComparable, property.unit);
549
+ const darkValue = displayComponentProperty(dark, darkComparable, property.unit);
550
+ const details = ` ${property.name} is ${lightValue} in light and ${darkValue} in dark.`;
551
+ const nameBudget = Math.min(LIMITS.diagnosticScalars, MAXIMUM_THEME_WARNING_SCALARS)
552
+ - prefix.length - "contexts.".length - details.length;
553
+ const surface = context === null ? "root" : `contexts.${abbreviateThemeContext(context, nameBudget, position)}`;
554
+ warnings.push(prefix + surface + details);
555
+ }
556
+ }
557
+ return warnings;
558
+ }
559
+
478
560
  function boundedThemeWarnings(allWarnings) {
479
- const warnings = allWarnings
561
+ const candidates = allWarnings
480
562
  .slice(0, MAXIMUM_THEME_WARNINGS)
481
563
  .map((warning) =>
482
564
  [...sanitizeDiagnostic(warning, "Theme validation warning.")]
483
565
  .slice(0, MAXIMUM_THEME_WARNING_SCALARS)
484
566
  .join("")
485
567
  );
568
+ const warnings = withinByteBudget(candidates, MAXIMUM_THEME_WARNING_BYTES);
486
569
  return {
487
570
  warnings,
488
571
  warningCount: allWarnings.length,
@@ -515,21 +598,24 @@ export async function validateAndLintThemePair(lightTheme, darkTheme) {
515
598
  fit,
516
599
  });
517
600
  const unbuilt = items.filter((item) => item.lint === undefined).map((item) => item.text);
518
- const warningGroups = { validation: proposed.warnings, unbuilt, lints: proposed.lints, inert };
601
+ const reflow = componentPropertyReflowWarnings(lightTheme, darkTheme);
602
+ const warningGroups = { validation: proposed.warnings, reflow, unbuilt, lints: proposed.lints, inert };
519
603
  const themes = Object.defineProperty({ light, dark }, "warningGroups", { value: warningGroups });
520
604
  return withChromeWarnings(themes, []);
521
605
  }
522
606
 
523
607
  /** Finish warning publication from the complete groups, before the shared cap. */
524
608
  export function withChromeWarnings(themes, chromeWarnings) {
525
- const { validation, unbuilt, lints, inert } = themes.warningGroups;
526
- const bounded = boundedThemeWarnings([...validation, ...unbuilt, ...lints, ...chromeWarnings, ...inert]);
609
+ const { validation, reflow, unbuilt, lints, inert } = themes.warningGroups;
610
+ const bounded = boundedThemeWarnings([...validation, ...reflow, ...unbuilt, ...lints, ...chromeWarnings, ...inert]);
527
611
  return Object.defineProperty({ ...themes, ...bounded }, "warningGroups", { value: themes.warningGroups });
528
612
  }
529
613
 
530
614
  function checkThemePair(lightTheme, darkTheme) {
531
615
  requireCompleteTheme(lightTheme, "light");
532
616
  requireCompleteTheme(darkTheme, "dark");
617
+ requireKnownThemeFields(lightTheme, "light");
618
+ requireKnownThemeFields(darkTheme, "dark");
533
619
 
534
620
  let light;
535
621
  let dark;
@@ -545,8 +631,11 @@ function checkThemePair(lightTheme, darkTheme) {
545
631
  }
546
632
 
547
633
  const result = validateThemePair(light, dark);
548
- if (!result.valid) {
549
- const first = result.errors[0] ?? "The theme pair is invalid.";
634
+ // Espalier appends one error per component finding after its ordinary errors.
635
+ const findings = result.valid ? [] : validateComponentProperties(light, dark);
636
+ const componentFinding = findings.length === result.errors.length ? findings[0] : undefined;
637
+ const first = result.errors[0] ?? "The theme pair is invalid.";
638
+ if (!result.valid && componentFinding === undefined) {
550
639
  const field = /^\s*(?:light|dark):\s*Every entry in ([A-Za-z0-9_.-]+)/u.exec(first)?.[1]
551
640
  ?? /^\s*(?:light|dark):\s*([A-Za-z0-9_.-]+)/u.exec(first)?.[1]
552
641
  ?? (/^\s*contexts\b/u.test(first) ? "contexts" : undefined);
@@ -558,6 +647,28 @@ function checkThemePair(lightTheme, darkTheme) {
558
647
  }
559
648
  refuseAgentStylesheets(lightTheme, "light");
560
649
  refuseAgentStylesheets(darkTheme, "dark");
650
+ if (componentFinding !== undefined) {
651
+ const { scheme, context, property, code } = componentFinding;
652
+ const field = [`${scheme}Theme`];
653
+ if (context !== null) field.push("contexts", context);
654
+ field.push("componentProperties");
655
+ if (property !== null) field.push(property);
656
+ // Espalier suggests the nearest settable name even for unrelated inputs.
657
+ const unknownProperty = code === "unknown" && property !== null;
658
+ const nearest = unknownProperty
659
+ ? closeFieldMatch(property.slice("--esp-".length), getSettableComponentProperties().map(({ name }) =>
660
+ name.slice("--esp-".length)))
661
+ : undefined;
662
+ const fullName = nearest === undefined ? undefined : "--esp-" + nearest;
663
+ const message = unknownProperty
664
+ ? `Unknown component property '${property}'.${unknownFieldHint(fullName)}`
665
+ : `Espalier rejected the theme: ${first}`;
666
+ throw new SiteAuthoringError(
667
+ "theme.validation_failed",
668
+ message,
669
+ { field: field.join("."), alternatives: fullName === undefined ? undefined : [fullName] },
670
+ );
671
+ }
561
672
  return {
562
673
  light,
563
674
  dark,
@@ -0,0 +1,222 @@
1
+ import {
2
+ ROLE_DERIVED_INK,
3
+ ROLE_DERIVED_SURFACE,
4
+ ROLE_TOKEN_PLAN,
5
+ SEMANTIC_COLOR_NAMES,
6
+ semanticToCSS,
7
+ } from "@taprootio/espalier/shared/theme";
8
+
9
+ import { BADGE_FOCUS_RING, getEspalierTokenManifest, supportsBadgeFocusRing } from "./espalier-shared.js";
10
+ import templateTokenReach from "./template-token-reach.json" with { type: "json" };
11
+
12
+ const DERIVATIONS = new Map();
13
+ for (const [role, slots] of Object.entries(ROLE_TOKEN_PLAN)) {
14
+ for (const [slot, mappings] of Object.entries(slots)) {
15
+ const key = `${role}.${slot}`;
16
+ const derived = ROLE_DERIVED_INK.has(key) || ROLE_DERIVED_SURFACE.has(key);
17
+ for (const [name, stop] of mappings) {
18
+ DERIVATIONS.set(name, Object.freeze({ role, slot, defaultStop: derived ? "derived per scheme" : stop }));
19
+ }
20
+ }
21
+ }
22
+
23
+ const STATUS_NOTE = "Status color outside the role plan.";
24
+ const BORDER_PAINT_NOTES = [
25
+ {
26
+ token: "--esp-color-border",
27
+ component: "esp-header",
28
+ part: "header",
29
+ state: "default",
30
+ label: "header border value",
31
+ folder: "header",
32
+ text: "The header bottom hairline uses 1px of the context's border token.",
33
+ },
34
+ {
35
+ token: "--esp-color-border",
36
+ component: "esp-footer",
37
+ part: "footer",
38
+ state: "default",
39
+ label: "footer border block start",
40
+ folder: "footer",
41
+ text: "The footer top hairline uses 1px of the context's border token.",
42
+ },
43
+ {
44
+ token: "--esp-color-border",
45
+ component: "esp-root",
46
+ part: "blockquote",
47
+ state: "default",
48
+ label: "quote border-inline-start",
49
+ folder: "shared",
50
+ text: "--esp-blockquote-bar-color overrides the quote bar.",
51
+ },
52
+ {
53
+ token: "--esp-color-border",
54
+ component: "esp-root",
55
+ part: "quote-mark",
56
+ state: "default",
57
+ label: "quote mark background",
58
+ folder: "shared",
59
+ text: "--esp-blockquote-glyph-color overrides the quote glyph. When unset, the glyph follows the bar.",
60
+ },
61
+ ];
62
+ const COMPONENT_PAINT_NOTES = {
63
+ border: BORDER_PAINT_NOTES,
64
+ headings: [1, 2, 3, 4].map((level) => ({
65
+ token: "--esp-color-headings",
66
+ component: "esp-root",
67
+ part: `h${level}`,
68
+ state: "default",
69
+ label: `h${level} ink`,
70
+ folder: "root",
71
+ text: `--esp-heading-${level}-color overrides native h${level} ink.`,
72
+ })),
73
+ };
74
+
75
+ // An alias is optional in a component paint. The owning token is the entry's key.
76
+ const COMPONENT_FIELDS = ["component", "part", "state", "label", "folder", "alias"];
77
+ const TEMPLATE_FIELDS = ["file", "markup", "part", "label"];
78
+ const TEMPLATE_PAINT = -1;
79
+ const CATALOG_FIELDS = [...new Set([...COMPONENT_FIELDS, ...TEMPLATE_FIELDS, "topics"])];
80
+ const PAGE_FIELDS = ["token", ...TEMPLATE_FIELDS, "topics"];
81
+
82
+ let manifestPaintsByCssName;
83
+
84
+ function getComponentPaints(name) {
85
+ if (manifestPaintsByCssName === undefined) {
86
+ manifestPaintsByCssName = new Map(getEspalierTokenManifest().tokens.map(({ name, paints }) => [name, paints]));
87
+ }
88
+ return manifestPaintsByCssName.get(semanticToCSS(name));
89
+ }
90
+
91
+ export function getTokenDerivation(name) {
92
+ return DERIVATIONS.get(name) ?? null;
93
+ }
94
+
95
+ function installedTemplatePaints() {
96
+ return supportsBadgeFocusRing() ? templateTokenReach
97
+ : templateTokenReach.filter(({ token, part }) => token !== BADGE_FOCUS_RING && part !== BADGE_FOCUS_RING);
98
+ }
99
+
100
+ export function getPageTokenReach(type) {
101
+ return structuredClone(installedTemplatePaints().filter(({ topics }) => topics.includes(type)));
102
+ }
103
+
104
+ function paintNotesFor(name, paints) {
105
+ const notes = [];
106
+ for (const { text, ...identity } of COMPONENT_PAINT_NOTES[name] ?? []) {
107
+ const paintIndex = paints.findIndex((paint) =>
108
+ Object.entries(identity).every(([field, value]) => paint[field] === value)
109
+ );
110
+ if (paintIndex === -1) {
111
+ throw new Error(`The installed Espalier manifest is missing the ${name} paint "${identity.label}".`);
112
+ }
113
+ notes.push({ paintIndex, text });
114
+ }
115
+ return notes;
116
+ }
117
+
118
+ function createCatalog(fields) {
119
+ const dictionary = Object.fromEntries(fields.map((field) => [field, []]));
120
+ const indexes = Object.fromEntries(fields.map((field) => [field, new Map()]));
121
+ function intern(field, value) {
122
+ const key = Array.isArray(value) ? JSON.stringify(value) : value;
123
+ const index = indexes[field].get(key);
124
+ if (index !== undefined) return index;
125
+ const items = dictionary[field];
126
+ indexes[field].set(key, items.length);
127
+ items.push(value);
128
+ return items.length - 1;
129
+ }
130
+ return { dictionary, intern };
131
+ }
132
+
133
+ export function encodePageTokenReach(paints) {
134
+ const { dictionary, intern } = createCatalog(PAGE_FIELDS);
135
+ const rows = paints.map((paint) => PAGE_FIELDS.map((field) => intern(field, paint[field])));
136
+ return { dictionary, rows };
137
+ }
138
+
139
+ export function decodePageTokenReach({ dictionary, rows }) {
140
+ return rows.map((row) => Object.fromEntries(
141
+ PAGE_FIELDS.map((field, index) => [field, dictionary[field][row[index]]]),
142
+ ));
143
+ }
144
+
145
+ /** Intern paint fields in first-use order and keep the release's paint row order. */
146
+ export function buildTokenPaintCatalog(names = SEMANTIC_COLOR_NAMES) {
147
+ const { dictionary: paintCatalog, intern } = createCatalog(CATALOG_FIELDS);
148
+ const templateRows = installedTemplatePaints();
149
+
150
+ const tokens = Object.fromEntries([...names].map((name) => {
151
+ const cssName = semanticToCSS(name);
152
+ const componentRows = getComponentPaints(name);
153
+ const componentPaints = componentRows.map((paint) =>
154
+ COMPONENT_FIELDS.filter((field) => Object.hasOwn(paint, field)).map((field) => intern(field, paint[field]))
155
+ );
156
+ const templatePaints = [];
157
+ for (const paint of templateRows) {
158
+ if (paint.token !== cssName) continue;
159
+ templatePaints.push([
160
+ TEMPLATE_PAINT,
161
+ ...TEMPLATE_FIELDS.map((field) => intern(field, paint[field])),
162
+ ...paint.topics.map((topic) => intern("topics", topic)),
163
+ ]);
164
+ }
165
+ const derivation = getTokenDerivation(name);
166
+ const entry = {
167
+ derivation,
168
+ paints: [...componentPaints, ...templatePaints],
169
+ ...(derivation === null ? { note: STATUS_NOTE } : {}),
170
+ };
171
+ const paintNotes = paintNotesFor(name, componentRows);
172
+ if (paintNotes.length > 0) entry.paintNotes = paintNotes;
173
+ return [name, entry];
174
+ }));
175
+ return { tokens, paintCatalog };
176
+ }
177
+
178
+ export function decodeTokenPaint(catalog, name, [first, ...rest]) {
179
+ const token = semanticToCSS(name);
180
+ if (first === TEMPLATE_PAINT) {
181
+ const fields = TEMPLATE_FIELDS.map((field, index) => [field, catalog[field][rest[index]]]);
182
+ return {
183
+ token,
184
+ ...Object.fromEntries(fields),
185
+ topics: rest.slice(TEMPLATE_FIELDS.length).map((index) => catalog.topics[index]),
186
+ };
187
+ }
188
+ const row = [first, ...rest];
189
+ return {
190
+ token,
191
+ ...Object.fromEntries(row.map((index, fieldIndex) => {
192
+ const field = COMPONENT_FIELDS[fieldIndex];
193
+ return [field, catalog[field][index]];
194
+ })),
195
+ };
196
+ }
197
+
198
+ export function formatTokenPaints(tokens, paintCatalog) {
199
+ const groups = new Map();
200
+ for (const [name, entry] of Object.entries(tokens)) {
201
+ const notes = new Map(entry.paintNotes?.map(({ paintIndex, text }) => [paintIndex, text]));
202
+ for (const [index, row] of entry.paints.entries()) {
203
+ const paint = decodeTokenPaint(paintCatalog, name, row);
204
+ const group = paint.component ?? paint.file;
205
+ if (!groups.has(group)) groups.set(group, []);
206
+ const lines = groups.get(group);
207
+ const details = [paint.markup, paint.part, paint.state, paint.alias].filter(Boolean).join(", ");
208
+ lines.push(` ${name} — ${paint.label} (${details})`);
209
+ if (notes.has(index)) lines.push(` ${notes.get(index)}`);
210
+ }
211
+ }
212
+ return [...groups].flatMap(([group, lines]) => [` ${group}`, ...lines]);
213
+ }
214
+
215
+ export function describeChromeToken(name, role) {
216
+ const paints = getComponentPaints(name) ?? [];
217
+ const folders = role === "header" ? ["menu", "header"] : ["footer"];
218
+ const labels = new Set(folders.flatMap((folder) =>
219
+ paints.filter((paint) => paint.folder === folder).map(({ label }) => label)
220
+ ));
221
+ return labels.size === 0 ? name : `${name} (${[...labels].slice(0, 4).join(", ")})`;
222
+ }
@@ -1,7 +1,9 @@
1
1
  import { CLI_BINARY_NAME } from "./constants.js";
2
+ import { RECIPE_STEP_CONTRACT } from "./recipe-step-contract.js";
2
3
  import {
3
4
  frontMatterKeysFor,
4
5
  PLACE_REVIEW_RATINGS,
6
+ RECIPE_STEP_UNSUPPORTED,
5
7
  TEMPLATE_ALBUM,
6
8
  TEMPLATE_ARTICLE,
7
9
  TEMPLATE_GENERATED,
@@ -44,6 +46,14 @@ const FIELD_HELP = Object.freeze({
44
46
  + "address. Pages are authorless unless you name one, and an author already on the page is never replaced. "
45
47
  + "'authors list' shows who can be named; 'authors add' creates a site author without an account.",
46
48
  },
49
+ tags: {
50
+ type: "JSON array of names",
51
+ required: false,
52
+ description:
53
+ 'Set topic tags with a list such as ["Trail running", "PNW"]. Omit tags to preserve the site\'s assignment. '
54
+ + "An unchanged pulled list is also omitted from the save. Set [] to clear topic tags. "
55
+ + "To replace a list on an existing page, pull first and use a key with site.tags.manage.",
56
+ },
47
57
  displayDate: {
48
58
  type: "YYYY-MM-DD",
49
59
  required: false,
@@ -51,12 +61,33 @@ const FIELD_HELP = Object.freeze({
51
61
  "The date the page is about or was originally published. Set it to preserve an imported date; omit it to use the "
52
62
  + "first publication date. An empty value clears it.",
53
63
  },
64
+ displayAuthor: {
65
+ type: "site author handle",
66
+ required: false,
67
+ description:
68
+ "The site author the byline shows instead of the member who wrote the page, such as jane-doe. Every handle "
69
+ + "names an author, including none; a member's email address is refused. A page with a display author carries no "
70
+ + "trace of the member and stays off their Taproot profile. Omit it to leave the site's value alone; a quoted "
71
+ + "empty value (\"\") clears it and a bare key is refused. It can be changed at any time, but a page that must be kept apart from the member needs it "
72
+ + "before the page is first published: a page already published under the member's name was public with it. "
73
+ + "An unknown handle is refused (pages.display_author_unknown); offline validate only warns "
74
+ + "(pages.display_author_unverified) about one authors.json lacks.",
75
+ },
76
+ showOnProfile: {
77
+ type: "true or false",
78
+ required: false,
79
+ description:
80
+ "false keeps a member's page (one with no display author) off that member's Taproot profile; it keeps its byline "
81
+ + "and profile link. Omit it to leave "
82
+ + "the site's setting alone. Only true and false are accepted (pages.show_on_profile_invalid). The profile "
83
+ + "changes after the page is published and its release goes live. A displayAuthor keeps a page apart entirely.",
84
+ },
54
85
  coverImage: {
55
86
  type: "media reference",
56
87
  required: false,
57
88
  description:
58
89
  "A file recorded by 'media upload', e.g. media/cover.jpg. The site requires the cover to be one of the page's own "
59
- + "images, so the same file must also appear in the body, introduction, steps or album images "
90
+ + "images, so the same file must also appear in the body, introduction or album images "
60
91
  + "(pages.cover_image_unused). Omit it for automatic selection; an empty value clears it.",
61
92
  },
62
93
  prepTimeMinutes: { type: "whole number", required: false, description: "Preparation time in minutes." },
@@ -123,6 +154,8 @@ cookingMethod: Baking
123
154
 
124
155
  Tart, sweet, and easy to double.
125
156
 
157
+ > Let the crust cool before slicing. Add longer notes or photos here.
158
+
126
159
  ## Ingredients
127
160
 
128
161
  ### Crust
@@ -137,10 +170,11 @@ Tart, sweet, and easy to double.
137
170
 
138
171
  ## Instructions
139
172
 
140
- 1. Press the crust into a pan and bake for 20 minutes.
141
- 2. Whisk the filling and pour it over the warm crust.
173
+ 1. Press the **crust** into a pan and bake for 20 minutes.
174
+ 2. Whisk the filling and pour it over the *warm* crust.\\
175
+ Check it after 15 minutes.
142
176
 
143
- Bake until set.
177
+ Bake until set. See the [baking temperature guide](/baking){title="Baking temperatures"}.
144
178
  `;
145
179
 
146
180
  const ALBUM_EXAMPLE = `---
@@ -196,12 +230,18 @@ const TYPE_DETAILS = Object.freeze({
196
230
  displayName: "Recipe",
197
231
  summary: "Structured ingredients and steps with times, servings and category, published with recipe markup.",
198
232
  body:
199
- "Text before '## Ingredients' is the introduction (optional). '## Ingredients' holds '- ' bullets, optionally split "
200
- + "by '### Group name' headings. '## Instructions' holds numbered or bulleted steps, optionally split by "
201
- + "'### Section name' headings; indent a step's later paragraphs by two spaces. Those two headings are the only "
202
- + "level-2 headings allowed, and both are required: text that does not fit is refused, never dropped. The "
203
- + "introduction and each step take paragraphs, headings, lists, quotes, code, images, tables and components, but "
204
- + "not sections or inline facts, which the site rejects there (pages.node_unsupported_for_template).",
233
+ "Text before '## Ingredients' is the optional introduction. It accepts paragraphs, headings, lists, quotes, "
234
+ + "code, images, tables and components. Sections and inline facts are refused (pages.node_unsupported_for_template). "
235
+ + "'## Ingredients' holds text bullets, optionally grouped by '### Group name'. '## Instructions' holds a list "
236
+ + "whose items are steps, optionally grouped by '### Section name'. Use plain text for group and section names. "
237
+ + "Indent later paragraphs to the start of the step text. Use both level-2 headings in that order.",
238
+ stepContract: Object.freeze({
239
+ ...RECIPE_STEP_CONTRACT,
240
+ errorCode: RECIPE_STEP_UNSUPPORTED,
241
+ guidance: "Use paragraphs and line breaks. Put notes, tips, quotes and photos in the introduction. "
242
+ + "Unsupported blocks, marks and attributes are refused by validate and pages push. "
243
+ + "The CLI reports the file, section and step, plus the source line for Markdown.",
244
+ }),
205
245
  markdownExample: RECIPE_EXAMPLE,
206
246
  documentExample: documentExample(
207
247
  TEMPLATE_RECIPE,
@@ -212,7 +252,27 @@ const TYPE_DETAILS = Object.freeze({
212
252
  name: "Crust",
213
253
  ingredients: [{ rawText: "2 cups flour", quantity: "", unit: "", name: "", parsed: false }],
214
254
  }],
215
- instructionSections: [{ name: "", stepBodies: [PARAGRAPH("Press the crust into a pan and bake.")] }],
255
+ instructionSections: [{
256
+ name: "",
257
+ stepBodies: [{
258
+ type: "doc",
259
+ content: [{
260
+ type: "paragraph",
261
+ content: [
262
+ { type: "text", text: "Press the crust into a pan.", marks: [{ type: "bold" }] },
263
+ { type: "hardBreak" },
264
+ { type: "text", text: "Bake until set.", marks: [{ type: "underline" }] },
265
+ ],
266
+ }, {
267
+ type: "paragraph",
268
+ content: [{
269
+ type: "text",
270
+ text: "Read the baking temperature guide.",
271
+ marks: [{ type: "link", attrs: { href: "/baking", title: "Baking temperatures" } }],
272
+ }],
273
+ }],
274
+ }],
275
+ }],
216
276
  prepTimeMinutes: 15,
217
277
  cookTimeMinutes: 35,
218
278
  servings: 16,
@@ -224,12 +284,17 @@ const TYPE_DETAILS = Object.freeze({
224
284
  dataFields: [
225
285
  "introductionBody: ProseMirror document (optional)",
226
286
  "ingredientGroups: [{ name, ingredients: [{ rawText, quantity, unit, name, parsed }] }]; at least one ingredient",
227
- "instructionSections: [{ name, stepBodies: [ProseMirror document] }]; at least one step",
287
+ "instructionSections: [{ name, stepBodies: [ProseMirror document] }]. Include at least one step. Every step must contain text.",
228
288
  "prepTimeMinutes, cookTimeMinutes, servings: whole numbers; recipeCategory, recipeCuisine, cookingMethod: strings",
229
289
  ],
230
290
  note:
231
291
  "A Markdown source supplies each ingredient as text only, so it publishes as written. A .pm.json source may also "
232
- + "carry quantity, unit and name with parsed: true.",
292
+ + "carry quantity, unit and name with parsed: true. The site-wide recipeJumpControl sets the Jump to recipe "
293
+ + "control beside the date in the public recipe byline. recipeTagsContent chooses the bar contents and recipeTagsIcon sets its icon. "
294
+ + "See help settings for these choices, the bar colors and metadata destinations. A default-height sticky header can cover the top of the card after a jump to "
295
+ + "#recipe. Member-only recipes have no jump control. Opening a URL with #recipe before the card decrypts can "
296
+ + "leave the reader at the top of the page. Public recipes publish recipe markup with ingredients and steps "
297
+ + "even without an author. Google recommends a credited author for recipe rich results.",
233
298
  },
234
299
  [TEMPLATE_ALBUM]: {
235
300
  displayName: "Album",
@@ -280,6 +345,10 @@ const TYPE_DETAILS = Object.freeze({
280
345
  `rating: ${Object.keys(PLACE_REVIEW_RATINGS).join(" | ")}`,
281
346
  "body: ProseMirror document (required, not empty)",
282
347
  ],
348
+ note:
349
+ "Google review snippets require a valid reviewer name under 100 characters, a supported place type, and a rating. "
350
+ + "A public review with missing or ineligible review data still publishes article markup. For public reviews "
351
+ + "without a credited reviewer, validate and deploy --staging report an advisory. Pull first to refresh a tracked page.",
283
352
  },
284
353
  [TEMPLATE_GENERATED]: {
285
354
  displayName: "Generated page",
@@ -459,13 +528,17 @@ function typedReference(type) {
459
528
  purpose: generated
460
529
  ? "The pulled form, and the only one: { template, data }. Path comes from the manifest; title and description "
461
530
  + "are the custom ones in data."
462
- : "The pulled form: { template, displayDate?, coverImageId?, data }. Title, path and description come from the manifest.",
531
+ : "The pulled form: { template, displayDate?, displayAuthor?, showOnProfile?, coverImageId?, data }. Title, path and description come from the manifest.",
463
532
  dataFields: Object.freeze(details.dataFields),
464
533
  }),
465
534
  ]),
466
535
  }),
467
536
  ...(generated ? {} : { markdown: Object.freeze({ body: details.body, example: details.markdownExample }) }),
468
- document: Object.freeze({ example: details.documentExample, ...(details.note ? { note: details.note } : {}) }),
537
+ document: Object.freeze({
538
+ example: details.documentExample,
539
+ ...(details.stepContract === undefined ? {} : { stepContract: details.stepContract }),
540
+ ...(details.note ? { note: details.note } : {}),
541
+ }),
469
542
  workflow: Object.freeze([
470
543
  ...(generated
471
544
  ? [Object.freeze({
@@ -514,12 +587,17 @@ export function formatTypedPageReference(page) {
514
587
  if (page.type === LEGAL_PAGE_TYPE) return formatLegalReference(page);
515
588
  const markdown = page.workspace.formats.find((format) => format.extension === ".md");
516
589
  const json = page.workspace.formats.find((format) => format.extension === ".pm.json");
590
+ const contract = page.document.stepContract;
591
+ const stepHelp = contract === undefined ? "" : `\nRecipe step contract\n ${contract.guidance}\n`
592
+ + ` Inline formatting includes ${Object.keys(contract.marks).join(", ")}.\n`
593
+ + ` A link can carry ${contract.marks.link.join(", ")}. Use .pm.json for underline. In Markdown put title in a link's attribute braces.\n`
594
+ + ` Refusal code ${contract.errorCode}.\n`;
517
595
  const markdownSection = markdown === undefined
518
596
  ? ""
519
597
  : `Markdown front matter:\n${markdown.metadata.map(formatField).join("\n")}\n\nMarkdown body: ${page.markdown.body}\n\nMarkdown example:\n${page.markdown.example}\n`;
520
598
  return `${page.displayName} (${page.type})\n${page.summary}\n\nWorkspace (${page.workspace.directory}):\n source rule ${page.workspace.sourceRule}\n pull ${page.workspace.pull}\n\n${markdownSection}.pm.json (${json.purpose})\n data:\n${
521
599
  json.dataFields.map((field) => ` ${field}`).join("\n")
522
- }\n${page.document.note === undefined ? "" : ` ${page.document.note}\n`}\n.pm.json example:\n${
600
+ }\n${page.document.note === undefined ? "" : ` ${page.document.note}\n`}${stepHelp}\n.pm.json example:\n${
523
601
  JSON.stringify(page.document.example, null, 2)
524
602
  }\n\nWorkflow:\n${
525
603
  page.workflow.map((step) => ` ${step.command}: ${step.result}`).join("\n")