@taprootio/site-authoring 0.41.1 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +50 -0
  2. package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
  3. package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
  4. package/package.json +4 -3
  5. package/src/api.js +170 -11
  6. package/src/appearance-contract.js +278 -8
  7. package/src/authored-tag-names.js +88 -0
  8. package/src/block-flow.js +103 -1
  9. package/src/brand-color.js +39 -4
  10. package/src/breadcrumb-artwork.js +234 -0
  11. package/src/breadcrumb-separators.js +11 -0
  12. package/src/changelog.json +154 -0
  13. package/src/chrome-features.js +152 -0
  14. package/src/chrome-input.js +147 -0
  15. package/src/chrome-output.js +92 -0
  16. package/src/chrome-paint-catalog-taproot.json +52 -0
  17. package/src/chrome-report.js +173 -0
  18. package/src/cli.js +48 -17
  19. package/src/content/components.js +27 -4
  20. package/src/content/external-link.js +2 -1
  21. package/src/content/markdown.js +271 -101
  22. package/src/content/tiptap-prosemirror.ts +125 -43
  23. package/src/content/validate-document.js +4 -1
  24. package/src/content-inset.js +48 -0
  25. package/src/errors.js +1 -0
  26. package/src/espalier-shared.js +26 -0
  27. package/src/field-suggestions.js +40 -0
  28. package/src/fixture-init.js +22 -5
  29. package/src/font-catalog.js +11 -1
  30. package/src/footer-brand-inputs.js +25 -2
  31. package/src/footer-content.js +38 -0
  32. package/src/footer-contract.js +11 -0
  33. package/src/footer-cta-styles.js +6 -0
  34. package/src/footer-draft-hash.js +4 -2
  35. package/src/footer-fit.js +62 -15
  36. package/src/footer-workspace.js +60 -16
  37. package/src/header-presentation.js +16 -0
  38. package/src/latest-posts-tags.js +57 -0
  39. package/src/page-structure-checks.js +5 -0
  40. package/src/page-tag-badge-modes.js +6 -0
  41. package/src/page-tag-writes.js +158 -0
  42. package/src/page-type-tags.js +16 -0
  43. package/src/presentation-reference.js +312 -86
  44. package/src/recipe-page-options.js +22 -0
  45. package/src/recipe-step-contract.js +164 -0
  46. package/src/recipe-step-contract.json +65 -0
  47. package/src/reference-help.js +164 -78
  48. package/src/session.js +39 -24
  49. package/src/setting-reference.js +239 -48
  50. package/src/settings-catalog.js +63 -0
  51. package/src/site-check-findings.js +25 -5
  52. package/src/site-check-rules.json +3 -1
  53. package/src/site-health-findings.js +13 -13
  54. package/src/site-navigation-groups.js +70 -0
  55. package/src/styling-fixed-values.js +71 -0
  56. package/src/tag-destination-warnings.js +35 -0
  57. package/src/template-token-reach.json +242 -0
  58. package/src/theme-proposals.js +18 -27
  59. package/src/theme-resolve.js +305 -51
  60. package/src/theme-validation.js +126 -6
  61. package/src/token-reach.js +222 -0
  62. package/src/typed-page-reference.js +72 -15
  63. package/src/typed-pages.js +171 -71
  64. package/src/verbs/deploy.js +6 -0
  65. package/src/verbs/footer-push.js +30 -5
  66. package/src/verbs/forms-push.js +11 -3
  67. package/src/verbs/pages-delete.js +19 -10
  68. package/src/verbs/pages-push.js +125 -36
  69. package/src/verbs/plan.js +10 -4
  70. package/src/verbs/pull.js +277 -67
  71. package/src/verbs/staging-review.js +27 -1
  72. package/src/verbs/status.js +22 -0
  73. package/src/verbs/theme-push.js +249 -120
  74. package/src/verbs/theme-resolve.js +310 -47
  75. package/src/verbs/validate.js +71 -17
  76. package/src/workspace-check.js +37 -4
  77. package/src/workspace.js +37 -1
  78. package/test/fixtures/default-site-theme.json +516 -0
@@ -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.
@@ -422,7 +456,7 @@ let fitReport;
422
456
  * actually checked. The exact Espalier pin and this package's tests catch a
423
457
  * release that moves it.
424
458
  */
425
- function loadFitReport() {
459
+ export function loadFitReport() {
426
460
  fitReport ??= loadEspalierShared("theme-fit-report.js");
427
461
  return fitReport;
428
462
  }
@@ -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,12 +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
- return { light, dark, ...boundedThemeWarnings([...proposed.warnings, ...unbuilt, ...proposed.lints, ...inert]) };
601
+ const reflow = componentPropertyReflowWarnings(lightTheme, darkTheme);
602
+ const warningGroups = { validation: proposed.warnings, reflow, unbuilt, lints: proposed.lints, inert };
603
+ const themes = Object.defineProperty({ light, dark }, "warningGroups", { value: warningGroups });
604
+ return withChromeWarnings(themes, []);
605
+ }
606
+
607
+ /** Finish warning publication from the complete groups, before the shared cap. */
608
+ export function withChromeWarnings(themes, chromeWarnings) {
609
+ const { validation, reflow, unbuilt, lints, inert } = themes.warningGroups;
610
+ const bounded = boundedThemeWarnings([...validation, ...reflow, ...unbuilt, ...lints, ...chromeWarnings, ...inert]);
611
+ return Object.defineProperty({ ...themes, ...bounded }, "warningGroups", { value: themes.warningGroups });
519
612
  }
520
613
 
521
614
  function checkThemePair(lightTheme, darkTheme) {
522
615
  requireCompleteTheme(lightTheme, "light");
523
616
  requireCompleteTheme(darkTheme, "dark");
617
+ requireKnownThemeFields(lightTheme, "light");
618
+ requireKnownThemeFields(darkTheme, "dark");
524
619
 
525
620
  let light;
526
621
  let dark;
@@ -536,8 +631,11 @@ function checkThemePair(lightTheme, darkTheme) {
536
631
  }
537
632
 
538
633
  const result = validateThemePair(light, dark);
539
- if (!result.valid) {
540
- 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) {
541
639
  const field = /^\s*(?:light|dark):\s*Every entry in ([A-Za-z0-9_.-]+)/u.exec(first)?.[1]
542
640
  ?? /^\s*(?:light|dark):\s*([A-Za-z0-9_.-]+)/u.exec(first)?.[1]
543
641
  ?? (/^\s*contexts\b/u.test(first) ? "contexts" : undefined);
@@ -549,6 +647,28 @@ function checkThemePair(lightTheme, darkTheme) {
549
647
  }
550
648
  refuseAgentStylesheets(lightTheme, "light");
551
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
+ }
552
672
  return {
553
673
  light,
554
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,
@@ -56,7 +66,7 @@ const FIELD_HELP = Object.freeze({
56
66
  required: false,
57
67
  description:
58
68
  "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 "
69
+ + "images, so the same file must also appear in the body, introduction or album images "
60
70
  + "(pages.cover_image_unused). Omit it for automatic selection; an empty value clears it.",
61
71
  },
62
72
  prepTimeMinutes: { type: "whole number", required: false, description: "Preparation time in minutes." },
@@ -123,6 +133,8 @@ cookingMethod: Baking
123
133
 
124
134
  Tart, sweet, and easy to double.
125
135
 
136
+ > Let the crust cool before slicing. Add longer notes or photos here.
137
+
126
138
  ## Ingredients
127
139
 
128
140
  ### Crust
@@ -137,10 +149,11 @@ Tart, sweet, and easy to double.
137
149
 
138
150
  ## Instructions
139
151
 
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.
152
+ 1. Press the **crust** into a pan and bake for 20 minutes.
153
+ 2. Whisk the filling and pour it over the *warm* crust.\\
154
+ Check it after 15 minutes.
142
155
 
143
- Bake until set.
156
+ Bake until set. See the [baking temperature guide](/baking){title="Baking temperatures"}.
144
157
  `;
145
158
 
146
159
  const ALBUM_EXAMPLE = `---
@@ -196,12 +209,18 @@ const TYPE_DETAILS = Object.freeze({
196
209
  displayName: "Recipe",
197
210
  summary: "Structured ingredients and steps with times, servings and category, published with recipe markup.",
198
211
  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).",
212
+ "Text before '## Ingredients' is the optional introduction. It accepts paragraphs, headings, lists, quotes, "
213
+ + "code, images, tables and components. Sections and inline facts are refused (pages.node_unsupported_for_template). "
214
+ + "'## Ingredients' holds text bullets, optionally grouped by '### Group name'. '## Instructions' holds a list "
215
+ + "whose items are steps, optionally grouped by '### Section name'. Use plain text for group and section names. "
216
+ + "Indent later paragraphs to the start of the step text. Use both level-2 headings in that order.",
217
+ stepContract: Object.freeze({
218
+ ...RECIPE_STEP_CONTRACT,
219
+ errorCode: RECIPE_STEP_UNSUPPORTED,
220
+ guidance: "Use paragraphs and line breaks. Put notes, tips, quotes and photos in the introduction. "
221
+ + "Unsupported blocks, marks and attributes are refused by validate and pages push. "
222
+ + "The CLI reports the file, section and step, plus the source line for Markdown.",
223
+ }),
205
224
  markdownExample: RECIPE_EXAMPLE,
206
225
  documentExample: documentExample(
207
226
  TEMPLATE_RECIPE,
@@ -212,7 +231,27 @@ const TYPE_DETAILS = Object.freeze({
212
231
  name: "Crust",
213
232
  ingredients: [{ rawText: "2 cups flour", quantity: "", unit: "", name: "", parsed: false }],
214
233
  }],
215
- instructionSections: [{ name: "", stepBodies: [PARAGRAPH("Press the crust into a pan and bake.")] }],
234
+ instructionSections: [{
235
+ name: "",
236
+ stepBodies: [{
237
+ type: "doc",
238
+ content: [{
239
+ type: "paragraph",
240
+ content: [
241
+ { type: "text", text: "Press the crust into a pan.", marks: [{ type: "bold" }] },
242
+ { type: "hardBreak" },
243
+ { type: "text", text: "Bake until set.", marks: [{ type: "underline" }] },
244
+ ],
245
+ }, {
246
+ type: "paragraph",
247
+ content: [{
248
+ type: "text",
249
+ text: "Read the baking temperature guide.",
250
+ marks: [{ type: "link", attrs: { href: "/baking", title: "Baking temperatures" } }],
251
+ }],
252
+ }],
253
+ }],
254
+ }],
216
255
  prepTimeMinutes: 15,
217
256
  cookTimeMinutes: 35,
218
257
  servings: 16,
@@ -224,12 +263,17 @@ const TYPE_DETAILS = Object.freeze({
224
263
  dataFields: [
225
264
  "introductionBody: ProseMirror document (optional)",
226
265
  "ingredientGroups: [{ name, ingredients: [{ rawText, quantity, unit, name, parsed }] }]; at least one ingredient",
227
- "instructionSections: [{ name, stepBodies: [ProseMirror document] }]; at least one step",
266
+ "instructionSections: [{ name, stepBodies: [ProseMirror document] }]. Include at least one step. Every step must contain text.",
228
267
  "prepTimeMinutes, cookTimeMinutes, servings: whole numbers; recipeCategory, recipeCuisine, cookingMethod: strings",
229
268
  ],
230
269
  note:
231
270
  "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.",
271
+ + "carry quantity, unit and name with parsed: true. The site-wide recipeJumpControl sets the Jump to recipe "
272
+ + "control beside the date in the public recipe byline. recipeTagsContent chooses the bar contents and recipeTagsIcon sets its icon. "
273
+ + "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 "
274
+ + "#recipe. Member-only recipes have no jump control. Opening a URL with #recipe before the card decrypts can "
275
+ + "leave the reader at the top of the page. Public recipes publish recipe markup with ingredients and steps "
276
+ + "even without an author. Google recommends a credited author for recipe rich results.",
233
277
  },
234
278
  [TEMPLATE_ALBUM]: {
235
279
  displayName: "Album",
@@ -280,6 +324,10 @@ const TYPE_DETAILS = Object.freeze({
280
324
  `rating: ${Object.keys(PLACE_REVIEW_RATINGS).join(" | ")}`,
281
325
  "body: ProseMirror document (required, not empty)",
282
326
  ],
327
+ note:
328
+ "Google review snippets require a valid reviewer name under 100 characters, a supported place type, and a rating. "
329
+ + "A public review with missing or ineligible review data still publishes article markup. For public reviews "
330
+ + "without a credited reviewer, validate and deploy --staging report an advisory. Pull first to refresh a tracked page.",
283
331
  },
284
332
  [TEMPLATE_GENERATED]: {
285
333
  displayName: "Generated page",
@@ -465,7 +513,11 @@ function typedReference(type) {
465
513
  ]),
466
514
  }),
467
515
  ...(generated ? {} : { markdown: Object.freeze({ body: details.body, example: details.markdownExample }) }),
468
- document: Object.freeze({ example: details.documentExample, ...(details.note ? { note: details.note } : {}) }),
516
+ document: Object.freeze({
517
+ example: details.documentExample,
518
+ ...(details.stepContract === undefined ? {} : { stepContract: details.stepContract }),
519
+ ...(details.note ? { note: details.note } : {}),
520
+ }),
469
521
  workflow: Object.freeze([
470
522
  ...(generated
471
523
  ? [Object.freeze({
@@ -514,12 +566,17 @@ export function formatTypedPageReference(page) {
514
566
  if (page.type === LEGAL_PAGE_TYPE) return formatLegalReference(page);
515
567
  const markdown = page.workspace.formats.find((format) => format.extension === ".md");
516
568
  const json = page.workspace.formats.find((format) => format.extension === ".pm.json");
569
+ const contract = page.document.stepContract;
570
+ const stepHelp = contract === undefined ? "" : `\nRecipe step contract\n ${contract.guidance}\n`
571
+ + ` Inline formatting includes ${Object.keys(contract.marks).join(", ")}.\n`
572
+ + ` A link can carry ${contract.marks.link.join(", ")}. Use .pm.json for underline. In Markdown put title in a link's attribute braces.\n`
573
+ + ` Refusal code ${contract.errorCode}.\n`;
517
574
  const markdownSection = markdown === undefined
518
575
  ? ""
519
576
  : `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
577
  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
578
  json.dataFields.map((field) => ` ${field}`).join("\n")
522
- }\n${page.document.note === undefined ? "" : ` ${page.document.note}\n`}\n.pm.json example:\n${
579
+ }\n${page.document.note === undefined ? "" : ` ${page.document.note}\n`}${stepHelp}\n.pm.json example:\n${
523
580
  JSON.stringify(page.document.example, null, 2)
524
581
  }\n\nWorkflow:\n${
525
582
  page.workflow.map((step) => ` ${step.command}: ${step.result}`).join("\n")