@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
@@ -1,20 +1,42 @@
1
- import { getSitePresentation, withRefusalGuidance } from "../api.js";
2
- import { LIMITS, VERB_THEME_RESOLVE } from "../constants.js";
1
+ import { AA_LARGE_RATIO, AA_TEXT_RATIO, SEMANTIC_COLOR_NAMES } from "@taprootio/espalier/shared/theme";
2
+
3
+ import { getNavigation, getSitePresentation, withRefusalGuidance } from "../api.js";
4
+ import { appearanceImageIds, footerPresentationOverlay, validateAppearanceScalarGroup } from "../appearance-contract.js";
5
+ import { BREADCRUMB_ARTWORK_FIELDS } from "../breadcrumb-artwork.js";
6
+ import { CAPABILITY_CONTENT } from "../capabilities.js";
7
+ import { captureChromeResources } from "../chrome-input.js";
8
+ import { displayChromeContext, displayChromeRatio, indexChromePaint } from "../chrome-output.js";
9
+ import { completeChromeReport, RECIPE_TAG_ICON_CONTRAST } from "../chrome-report.js";
10
+ import { LIMITS, SURFACE_DOCS_PRESENTATION, SURFACE_STANDARD, VERB_THEME_RESOLVE } from "../constants.js";
3
11
  import { SiteAuthoringError } from "../errors.js";
4
- import { CHECK_AREA, collectProblems, refuseProblems, withinByteBudget } from "../problems.js";
12
+ import { footerImageIds, validateFooterDocument } from "../footer-contract.js";
13
+ import { appearanceResourceIds } from "../footer-workspace.js";
14
+ import { CHECK_AREA, collectProblems, refuseProblems } from "../problems.js";
5
15
  import { boundedByBytes, openAnonymousSession, openSession, successResult } from "../session.js";
6
- import { projectSettingsGroup, SETTINGS_GROUPS, SETTINGS_TYPE_TAPROOT_STYLES } from "../settings-catalog.js";
7
- import { AA_LARGE_RATIO, AA_TEXT_RATIO, resolveThemePair, THEME_STYLES_FILE } from "../theme-resolve.js";
8
- import { missingThemeSettings, readSettingsDocument, requireNoMissingSettings } from "./theme-push.js";
9
-
10
- // A result must fit LIMITS.githubOutputBytes (64 KiB), and a theme may declare 128 contexts a scheme. The lists that
11
- // grow with the theme are bounded first, each by its own share; surfaces then take what is left, and the ones past
12
- // it are named in omittedSurfaces to be fetched with --scheme and --context.
13
- const RESULT_ENVELOPE_BYTES = 4 * 1024;
16
+ import {
17
+ projectSettingsGroup,
18
+ SETTINGS_GROUPS,
19
+ SETTINGS_TYPE_SITE_HEADER,
20
+ SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES,
21
+ SETTINGS_TYPE_TAPROOT_STYLES,
22
+ } from "../settings-catalog.js";
23
+ import { resolveThemePair, THEME_STYLES_FILE } from "../theme-resolve.js";
24
+ import { abbreviateThemeContext } from "../theme-validation.js";
25
+ import { buildTokenPaintCatalog } from "../token-reach.js";
26
+ import { readManifest, readMediaManifest } from "../workspace.js";
27
+ import { validateNavigationWorkspaceDocument } from "./nav-push.js";
28
+ import { missingThemeSettings, readBoundSettingsDocument, readSettingsDocument, requireNoMissingSettings } from "./theme-push.js";
29
+
30
+ // Bound variable diagnostics before budgeting complete surfaces against the real result.
14
31
  const FLAG_BYTE_BUDGET = 10 * 1024;
15
32
  const NAME_LIST_BYTE_BUDGET = 6 * 1024;
33
+ // The chrome catalog contract keeps the maximal fixture within this ceiling.
34
+ // Resolve charges each command for the cards it actually returns.
35
+ export const CHROME_BYTE_BUDGET = 13 * 1024;
16
36
 
17
37
  const STYLES_GROUP = SETTINGS_GROUPS.find((group) => group.settingsType === SETTINGS_TYPE_TAPROOT_STYLES);
38
+ const HEADER_GROUP = SETTINGS_GROUPS.find((group) => group.settingsType === SETTINGS_TYPE_SITE_HEADER);
39
+ const PUBLISHING_GROUP = SETTINGS_GROUPS.find((group) => group.settingsType === SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES);
18
40
 
19
41
  /** The workspace's pair, read the way theme push reads it; or the site's, projected the way pull writes it. */
20
42
  async function readThemes(invocation) {
@@ -23,7 +45,7 @@ async function readThemes(invocation) {
23
45
  const presentation = await withRefusalGuidance(session.onProgress, "theme resolve", async () =>
24
46
  await getSitePresentation(session.client, session.siteId));
25
47
  const projected = projectSettingsGroup(STYLES_GROUP, presentation);
26
- return { siteId: session.siteId, source: "site", themes: [projected.lightTheme, projected.darkTheme] };
48
+ return { siteId: session.siteId, source: "site", style: projected, session, presentation };
27
49
  }
28
50
  const { config } = await openAnonymousSession({ ...invocation, client: null });
29
51
  if (config === undefined) {
@@ -38,10 +60,221 @@ async function readThemes(invocation) {
38
60
  "No site is selected. Run 'taproot-site use <site>' to choose one, or set siteId in taproot-site.json.",
39
61
  );
40
62
  }
41
- const style = await readSettingsDocument(config.workspaceDir, config.siteId, SETTINGS_TYPE_TAPROOT_STYLES);
63
+ const { settings } = await readBoundSettingsDocument(config.workspaceDir, config.siteId, SETTINGS_TYPE_TAPROOT_STYLES);
64
+ const style = { ...settings };
65
+ // Artwork does not affect the colors or chrome this report measures.
66
+ for (const field of BREADCRUMB_ARTWORK_FIELDS) delete style[field];
42
67
  // The same preflight push and validate run, so a stale workspace gets the same code and the full path list.
43
68
  requireNoMissingSettings(missingThemeSettings(style));
44
- return { siteId: config.siteId, source: "workspace", themes: [style.lightTheme, style.darkTheme] };
69
+ return { siteId: config.siteId, source: "workspace", style, config };
70
+ }
71
+
72
+ async function optionalEvidence(read) {
73
+ try {
74
+ return await read();
75
+ } catch {
76
+ return undefined;
77
+ }
78
+ }
79
+
80
+ async function siteNavigation(session) {
81
+ const capabilities = session.exchanged?.capabilities;
82
+ if (session.surface !== SURFACE_STANDARD || !Array.isArray(capabilities) || !capabilities.includes(CAPABILITY_CONTENT)) {
83
+ return undefined;
84
+ }
85
+ return await optionalEvidence(async () => {
86
+ const { navItems } = await getNavigation(session.client, session.siteId, { requireEvidence: true });
87
+ return validateNavigationWorkspaceDocument({ siteId: session.siteId, navItems }, session.siteId);
88
+ });
89
+ }
90
+
91
+ async function readReportEvidence({ siteId, style, config, session, presentation }) {
92
+ let header;
93
+ let publishing;
94
+ let resources;
95
+ if (session) {
96
+ const [navigation, projectedHeader, projectedPublishing] = await Promise.all([
97
+ siteNavigation(session),
98
+ optionalEvidence(() => presentation.headerSettings === undefined ? undefined : projectSettingsGroup(HEADER_GROUP, presentation)),
99
+ optionalEvidence(() => presentation.sitePublishingPreferences === undefined
100
+ ? undefined
101
+ : projectSettingsGroup(PUBLISHING_GROUP, presentation)),
102
+ ]);
103
+ header = projectedHeader;
104
+ publishing = projectedPublishing;
105
+ resources = {
106
+ source: "site",
107
+ presentation,
108
+ navigation,
109
+ settingsOnly: session.surface === SURFACE_DOCS_PRESENTATION,
110
+ knownImageIds: new Set([
111
+ ...appearanceImageIds({ [SETTINGS_TYPE_TAPROOT_STYLES]: style }),
112
+ ...footerImageIds(publishing?.footerSettings),
113
+ ]),
114
+ };
115
+ } else {
116
+ const { workspaceDir } = config;
117
+ const [manifest, mediaManifest, authoredHeader, authoredPublishing] = await Promise.all([
118
+ optionalEvidence(() => readManifest(workspaceDir, siteId, { required: false })),
119
+ optionalEvidence(() => readMediaManifest(workspaceDir, siteId)),
120
+ optionalEvidence(() => readSettingsDocument(workspaceDir, siteId, SETTINGS_TYPE_SITE_HEADER)),
121
+ optionalEvidence(() => readSettingsDocument(workspaceDir, siteId, SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES)),
122
+ ]);
123
+ header = authoredHeader;
124
+ publishing = authoredPublishing;
125
+ resources = await captureChromeResources({
126
+ workspaceDir,
127
+ siteId,
128
+ manifest,
129
+ mediaManifest,
130
+ settingsOnly: config.authoringSurface === SURFACE_DOCS_PRESENTATION,
131
+ ...appearanceResourceIds(manifest, mediaManifest),
132
+ });
133
+ }
134
+
135
+ const acceptedHeader = header === undefined ? undefined : await optionalEvidence(() =>
136
+ validateAppearanceScalarGroup(SETTINGS_TYPE_SITE_HEADER, header, resources.knownImageIds));
137
+ const acceptedStyle = await optionalEvidence(() =>
138
+ validateAppearanceScalarGroup(SETTINGS_TYPE_TAPROOT_STYLES, style, resources.knownImageIds));
139
+ const footerSettings = await optionalEvidence(() => {
140
+ footerPresentationOverlay(publishing?.footerSettings);
141
+ return validateFooterDocument(publishing.footerSettings, resources);
142
+ });
143
+ return {
144
+ appearance: {
145
+ style: acceptedStyle ?? { lightTheme: style.lightTheme, darkTheme: style.darkTheme },
146
+ header: acceptedHeader,
147
+ publishing,
148
+ },
149
+ resources: { ...resources, footerSettings },
150
+ };
151
+ }
152
+
153
+ function selectChrome(report, { themeScheme, themeContext }) {
154
+ const matchesContext = (entry) => themeContext === undefined || entry.context === themeContext;
155
+ const entries = Object.fromEntries(Object.entries(report.entries)
156
+ .filter(([scheme]) => themeScheme === undefined || themeScheme === scheme)
157
+ .map(([scheme, surfaces]) => [scheme, surfaces.filter(matchesContext)]));
158
+ const flags = report.flags.filter((flag) => Object.hasOwn(entries, flag.scheme) && matchesContext(flag));
159
+ const badgePairs = Object.keys(entries).flatMap(scheme => report.badges[scheme].filter(matchesContext).flatMap(({ pairs }) => pairs.filter(({ kind }) => kind === "ring")));
160
+ return {
161
+ ...indexChromePaint(entries),
162
+ unavailable: report.unavailable,
163
+ navigationUnavailable: report.navigationUnavailable,
164
+ flags: flags.map((flag) => ({ ...flag, context: displayChromeContext(flag.context).context })),
165
+ contrast: { pairs: Object.values(entries).flat().reduce((count, entry) => count + entry.pairs.length, badgePairs.length), belowAa: flags.filter(({ code }) => code !== RECIPE_TAG_ICON_CONTRAST).length },
166
+ };
167
+ }
168
+
169
+ function footerLinkOnLayer2(report, scheme, surface) {
170
+ return surface.footerInks === undefined && surface.tokens.some(({ token, adjusted }) => token === "link" && adjusted)
171
+ && report.entries[scheme]?.some(({ role, context, pairs }) =>
172
+ role === "footer" && context === surface.context && pairs.some(({ element, state, foreground, background }) =>
173
+ element === "footer-link" && state === "rest" && foreground === "link" && background === "layer2"
174
+ )
175
+ );
176
+ }
177
+
178
+ function resultBytes(result) {
179
+ return Buffer.byteLength(JSON.stringify(result), "utf8");
180
+ }
181
+
182
+ function reportEnvelope(siteId, source, contexts, entries, semanticFlags, chrome) {
183
+ const allFlags = [...semanticFlags, ...chrome.flags];
184
+ const flags = { ...boundedByBytes(allFlags, FLAG_BYTE_BUDGET), count: allFlags.length };
185
+ const contrast = { pairs: chrome.contrast.pairs, belowAa: chrome.contrast.belowAa, belowApca: 0 };
186
+ for (const { surface } of entries) {
187
+ for (const pair of surface.pairs) {
188
+ contrast.pairs += 1;
189
+ contrast.belowAa += Number(!pair.aa);
190
+ contrast.belowApca += Number(!pair.apcaMet);
191
+ }
192
+ for (const ink of surface.footerInks ?? []) contrast.belowApca += Number(ink.resolvedLc < ink.targetLc);
193
+ }
194
+ return successResult(VERB_THEME_RESOLVE, siteId, {
195
+ source,
196
+ thresholds: { textRatio: AA_TEXT_RATIO, largeRatio: AA_LARGE_RATIO },
197
+ contexts,
198
+ chrome: chrome.chrome,
199
+ chromeCatalog: chrome.chromeCatalog,
200
+ ...(chrome.unavailable ? { chromeUnavailable: true } : {}),
201
+ ...(chrome.navigationUnavailable ? { chromeNavigationUnavailable: true } : {}),
202
+ contrast,
203
+ flags,
204
+ });
205
+ }
206
+
207
+ function tokenCandidates(entries) {
208
+ const selected = new Set();
209
+ for (const { surface } of entries) {
210
+ for (const { token, origin, adjusted } of surface.tokens) {
211
+ if (origin !== "compiled" || adjusted) selected.add(token);
212
+ }
213
+ }
214
+ return SEMANTIC_COLOR_NAMES.filter((name) => selected.has(name));
215
+ }
216
+
217
+ function paintsForReport(candidates, shown = []) {
218
+ const omittedTokens = candidates.filter((name) => !shown.includes(name));
219
+ return {
220
+ ...(shown.length > 0 ? buildTokenPaintCatalog(shown) : { tokens: {} }),
221
+ ...(omittedTokens.length > 0 ? { omittedTokens, omittedTokensHelp: "taproot-site help tokens" } : {}),
222
+ };
223
+ }
224
+
225
+ function assembleReport(envelope, entries, omissions, paints) {
226
+ const byScheme = new Map();
227
+ for (const { scheme, surface, footerLinkOnLayer2, badgePaint } of entries) {
228
+ if (!byScheme.has(scheme)) byScheme.set(scheme, []);
229
+ byScheme.get(scheme).push({
230
+ ...surface,
231
+ ...(footerLinkOnLayer2 ? { footerLinkOnLayer2 } : {}),
232
+ ...(badgePaint?.length ? { badgePaint } : {}),
233
+ });
234
+ }
235
+ const schemes = [...byScheme].map(([scheme, surfaces]) => ({ scheme, surfaces }));
236
+ const oversizedCount = omissions.filter(({ reason }) => reason === "surface_too_large").length;
237
+ const retryRootSchemes = omissions.filter(({ context, reason }) => context === null && reason === undefined)
238
+ .map(({ scheme }) => scheme);
239
+ return {
240
+ ...envelope,
241
+ schemes,
242
+ ...paints,
243
+ ...(omissions.length > 0 ? {
244
+ omittedSurfaces: {
245
+ ...boundedByBytes(omissions, NAME_LIST_BYTE_BUDGET),
246
+ count: omissions.length,
247
+ ...(oversizedCount > 0 ? { oversizedCount } : {}),
248
+ ...(retryRootSchemes.length > 0 ? { retryRootSchemes } : {}),
249
+ },
250
+ } : {}),
251
+ };
252
+ }
253
+
254
+ function omission(entry, contextPositions, tooLarge) {
255
+ const { scheme, surface: { context } } = entry;
256
+ const label = context === null ? null : abbreviateThemeContext(context, LIMITS.diagnosticScalars, contextPositions.get(context));
257
+ return { scheme, context: label, ...(tooLarge ? { reason: "surface_too_large" } : {}) };
258
+ }
259
+
260
+ function canShowAfterNarrowing(entry, { resolution, entries, contexts, chromeReport, contextPositions, siteId, source, oversized }) {
261
+ const { scheme, surface } = entry;
262
+ // Root retry keeps the named contexts and chrome in the same scheme.
263
+ const context = surface.context ?? undefined;
264
+ const matches = (row, rowContext) => row.scheme === scheme && (context === undefined || rowContext === context);
265
+ const narrowed = entries.filter((row) => matches(row, row.surface.context));
266
+ const flags = resolution.flags.filter((flag) => matches(flag, flag.context));
267
+ const chrome = selectChrome(chromeReport, { themeScheme: scheme, themeContext: context });
268
+ const envelope = reportEnvelope(siteId, source, contexts, narrowed, flags, chrome);
269
+ const paints = paintsForReport(tokenCandidates(narrowed));
270
+ const otherOmissions = narrowed.filter((row) => row !== entry)
271
+ .map((row) => omission(row, contextPositions, oversized.has(row)));
272
+ const bytes = (candidate) =>
273
+ resultBytes(assembleReport(envelope, [{ ...entry, surface: candidate }], otherOmissions, paints));
274
+ const unexpanded = bytes(surface);
275
+ if (unexpanded > LIMITS.githubOutputBytes) return false;
276
+ if (unexpanded + resolution.passingStopByteBound(surface) <= LIMITS.githubOutputBytes) return true;
277
+ return bytes(resolution.enrichSurface(scheme, surface)) <= LIMITS.githubOutputBytes;
45
278
  }
46
279
 
47
280
  /**
@@ -50,49 +283,79 @@ async function readThemes(invocation) {
50
283
  * each ink-on-surface pairing. Offline from the pulled workspace by default;
51
284
  * `--site` reads the site's own theme instead (and needs a credential).
52
285
  */
53
- export async function themeResolve(invocation) {
54
- const { siteId, source, themes: [lightTheme, darkTheme] } = await readThemes(invocation);
286
+ export async function themeResolve(invocation, chromeDependencies) {
287
+ const input = await readThemes(invocation);
288
+ const { siteId, source, style: { lightTheme, darkTheme } } = input;
55
289
  const problems = [];
290
+ const evidence = await readReportEvidence(input);
291
+ const footer = evidence.resources.footerSettings;
56
292
  const resolution = await collectProblems(
57
293
  problems,
58
294
  { area: CHECK_AREA.presentation, file: THEME_STYLES_FILE },
59
295
  async () => await resolveThemePair(lightTheme, darkTheme, {
60
296
  scheme: invocation.themeScheme,
61
297
  context: invocation.themeContext,
298
+ footerContext: footer?.enabled === true ? footer.context || null : undefined,
299
+ deferPassingStops: true,
62
300
  }),
63
301
  );
64
302
  refuseProblems(problems, "theme resolve");
65
303
 
66
- const flags = { ...boundedByBytes(resolution.flags, FLAG_BYTE_BUDGET), count: resolution.flags.length };
304
+ const chromeReport = await completeChromeReport({ ...evidence, themes: resolution.encoded }, chromeDependencies);
305
+ const chrome = selectChrome(chromeReport, invocation);
67
306
  const contexts = { ...boundedByBytes(resolution.contexts, NAME_LIST_BYTE_BUDGET), count: resolution.contexts.length };
68
- const surfaceBudget = LIMITS.githubOutputBytes - RESULT_ENVELOPE_BYTES - NAME_LIST_BYTE_BUDGET
69
- - Buffer.byteLength(JSON.stringify({ flags, contexts }), "utf8");
70
- const entries = resolution.schemes.flatMap(({ scheme, surfaces }) => surfaces.map((surface) => ({ scheme, surface })));
71
- const shown = withinByteBudget(entries, surfaceBudget);
72
- const omitted = entries.slice(shown.length);
73
- const schemes = resolution.schemes
74
- .map(({ scheme }) => ({
75
- scheme,
76
- surfaces: shown.filter((entry) => entry.scheme === scheme).map((entry) => entry.surface),
77
- }))
78
- .filter((entry) => entry.surfaces.length > 0);
79
- return successResult(VERB_THEME_RESOLVE, siteId, {
80
- source,
81
- thresholds: { textRatio: AA_TEXT_RATIO, largeRatio: AA_LARGE_RATIO },
82
- contexts,
83
- schemes,
84
- contrast: resolution.contrast,
85
- flags,
86
- ...(omitted.length === 0
87
- ? {}
88
- : {
89
- omittedSurfaces: {
90
- ...boundedByBytes(
91
- omitted.map((entry) => ({ scheme: entry.scheme, context: entry.surface.context })),
92
- NAME_LIST_BYTE_BUDGET,
93
- ),
94
- count: omitted.length,
95
- },
96
- }),
97
- });
307
+ const contextPositions = new Map(resolution.contexts.map((name, index) => [name, index + 1]));
308
+ const entries = resolution.schemes.flatMap(({ scheme, surfaces }) => surfaces.map((surface) => ({
309
+ scheme,
310
+ surface,
311
+ footerLinkOnLayer2: footerLinkOnLayer2(chromeReport, scheme, surface),
312
+ badgePaint: chromeReport.badges[scheme].find(entry => entry.context === surface.context)?.pairs
313
+ .map(({ ratio, required, ...pair }) => ({ ...pair, ratio: displayChromeRatio(ratio, required), required })),
314
+ })));
315
+ const candidates = tokenCandidates(entries);
316
+ const emptyPaints = paintsForReport(candidates);
317
+ const envelope = reportEnvelope(siteId, source, contexts, entries, resolution.flags, chrome);
318
+ const oversized = new Set();
319
+ const narrowingInputs = { resolution, entries, contexts, chromeReport, contextPositions, siteId, source, oversized };
320
+ // A scheme-only root retry includes omissions for that scheme's named contexts.
321
+ const named = entries.filter(({ surface }) => surface.context !== null);
322
+ const roots = entries.filter(({ surface }) => surface.context === null);
323
+ for (const entry of [...named, ...roots]) {
324
+ if (!canShowAfterNarrowing(entry, narrowingInputs)) oversized.add(entry);
325
+ }
326
+ const possibleOmissions = entries.map((entry) => omission(entry, contextPositions, oversized.has(entry)));
327
+ const shown = [];
328
+ const omitted = [];
329
+ for (const [index, entry] of entries.entries()) {
330
+ const labels = [...omitted, ...possibleOmissions.slice(index + 1)];
331
+ const bytes = (candidate) => resultBytes(assembleReport(envelope, [...shown, candidate], labels, emptyPaints));
332
+ if (bytes(entry) <= LIMITS.githubOutputBytes) {
333
+ const surface = resolution.enrichSurface(entry.scheme, entry.surface);
334
+ const expanded = { ...entry, surface };
335
+ if (bytes(expanded) <= LIMITS.githubOutputBytes) {
336
+ shown.push(expanded);
337
+ continue;
338
+ }
339
+ }
340
+ omitted.push(possibleOmissions[index]);
341
+ }
342
+ if (shown.length === 0 && omitted.length > 0 && omitted.every(({ reason }) => reason === "surface_too_large")) {
343
+ const [{ scheme, context }] = omitted;
344
+ const field = context === null ? `${scheme}Theme` : `${scheme}Theme.contexts.${context}`;
345
+ throw new SiteAuthoringError(
346
+ "theme.resolve_surface_too_large",
347
+ "The selected theme report exceeds the output budget. Shorten long component property values or context names for the affected surfaces, then run theme resolve again.",
348
+ { field },
349
+ );
350
+ }
351
+ let result = assembleReport(envelope, shown, omitted, emptyPaints);
352
+ const paintNames = [];
353
+ for (const name of candidates) {
354
+ const trial = assembleReport(envelope, shown, omitted, paintsForReport(candidates, [...paintNames, name]));
355
+ if (resultBytes(trial) <= LIMITS.githubOutputBytes) {
356
+ paintNames.push(name);
357
+ result = trial;
358
+ }
359
+ }
360
+ return result;
98
361
  }
@@ -2,6 +2,8 @@ import { lstat, realpath } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
 
4
4
  import { NAVIGATION_MAXIMUM_DEPTH, withRefusalGuidance } from "../api.js";
5
+ import { CHROME_OFFLINE_PAGE_LIMITATION, CHROME_REPORT_NAME_RULE, selectNameReportEligibility } from "../chrome-input.js";
6
+ import { completeChromeReport } from "../chrome-report.js";
5
7
  import { loadSiteConfig } from "../config.js";
6
8
  import { SURFACE_DOCS_PRESENTATION, VERB_VALIDATE } from "../constants.js";
7
9
  import { freeFormRootPresentation } from "../content/free-form-sections.js";
@@ -18,8 +20,7 @@ import {
18
20
  import { initializeFixture } from "../fixture-init.js";
19
21
  import { evaluateLogoSurfaceChecks } from "../logo-surface-checks.js";
20
22
  import { loadThemeEngines } from "../theme-resolve.js";
21
- import { readFooterBrandInputs } from "../footer-brand-inputs.js";
22
- import { buildFooterFitInput } from "../footer-fit.js";
23
+ import { footerFitInputFromSettings } from "../footer-brand-inputs.js";
23
24
  import { appearanceManifestEntry, footerManifestEntry } from "../footer-workspace.js";
24
25
  import { FORMS_DIRECTORY } from "../forms-contract.js";
25
26
  import { authorWarnings, descriptionWarnings } from "../page-metadata.js";
@@ -41,6 +42,7 @@ import {
41
42
  readImageRecords,
42
43
  } from "../site-health-precheck.js";
43
44
  import { SETTINGS_GROUPS } from "../settings-catalog.js";
45
+ import { withChromeWarnings } from "../theme-validation.js";
44
46
  import { checkWorkspace } from "../workspace-check.js";
45
47
  import {
46
48
  displayPagePath,
@@ -73,6 +75,7 @@ const SITE_CHECKS_NOT_PROVEN =
73
75
  + "applies, or siteChecks.checkedInEditor, which only the page editor evaluates (a cover, a description field, or a "
74
76
  + "description's length); images an integration places, or a video poster a push copies, which the stored report "
75
77
  + "after staging covers";
78
+ const DOCS_CHROME_NOT_PROVEN = "navigation or footer-page-link contrast, because the settings-only workspace has no local navigation or page inventory";
76
79
  const FIXTURE_ROOT_KEYS = new Set(FIXTURE_ROOT_FIELDS);
77
80
  const FIXTURE_METADATA_KEYS = new Set(FIXTURE_METADATA_FIELDS);
78
81
 
@@ -687,10 +690,17 @@ function pageHints(checked, onProgress) {
687
690
  * The offline site checks (TR01085) over the planned pages: the rules the shared
688
691
  * catalogue lists for `validate`, with the rest named as checked by the site.
689
692
  */
690
- async function offlineSiteChecks(checked, manifest, onProgress, imageCheck, workspaceDir, loadLogoEngines) {
691
- const footerInput = checked.footer === undefined
693
+ async function offlineSiteChecks(checked, manifest, mediaManifest, onProgress, imageCheck, options) {
694
+ const { reportChrome, nameReportEnabled, loadLogoEngines } = options;
695
+ const footer = checked.footer?.footerSettings;
696
+ const footerInput = footer === undefined
692
697
  ? undefined
693
- : buildFooterFitInput(checked.footer.footerSettings, await readFooterBrandInputs(workspaceDir, checked.footer.footerSettings));
698
+ : footerFitInputFromSettings(
699
+ checked.presentation?.header,
700
+ checked.presentation?.style,
701
+ mediaManifest.media,
702
+ footer,
703
+ );
694
704
  const evaluated = evaluateOfflineSiteChecks({
695
705
  planned: checked.settingsOnly ? [] : checked.pages?.planned,
696
706
  footerInput,
@@ -704,10 +714,42 @@ async function offlineSiteChecks(checked, manifest, onProgress, imageCheck, work
704
714
  const logos = await evaluateLogoSurfaceChecks({
705
715
  styles: checked.presentation?.style,
706
716
  header: checked.presentation?.header,
707
- footer: checked.footer?.footerSettings,
717
+ footer,
708
718
  onProgress,
709
719
  }, { loadEngines: loadLogoEngines });
710
- return mergeOfflineSiteChecks(evaluated, logos);
720
+ const merged = mergeOfflineSiteChecks(evaluated, logos);
721
+ if (!reportChrome) {
722
+ merged.siteChecks.ranOffline = merged.siteChecks.ranOffline.filter((id) => id !== CHROME_REPORT_NAME_RULE);
723
+ return merged;
724
+ }
725
+
726
+ return mergeOfflineSiteChecks(merged, {
727
+ findings: { total: 0, errors: 0, warnings: 0, items: [] },
728
+ siteChecks: {
729
+ ...(checked.settingsOnly ? { ranOffline: [CHROME_REPORT_NAME_RULE] } : {}),
730
+ ...(nameReportEnabled === undefined ? { skipped: [CHROME_REPORT_NAME_RULE] } : {}),
731
+ },
732
+ });
733
+ }
734
+
735
+ async function completeValidationWarnings(checked, resources, options, onProgress) {
736
+ if (options.reportChrome && resources.valid) {
737
+ const appearance = checked.presentation;
738
+ const { warnings } = await completeChromeReport({
739
+ themes: appearance.themes,
740
+ appearance,
741
+ resources: {
742
+ manifest: resources.manifest,
743
+ mediaManifest: resources.mediaManifest,
744
+ footerSettings: checked.footer?.footerSettings,
745
+ navigation: checked.navigation,
746
+ settingsOnly: checked.settingsOnly,
747
+ },
748
+ nameReportEnabled: options.nameReportEnabled,
749
+ }, { loadFit: options.loadChromeFit });
750
+ appearance.themes = withChromeWarnings(appearance.themes, warnings);
751
+ }
752
+ reportThemeWarnings(checked.presentation, onProgress);
711
753
  }
712
754
 
713
755
  /**
@@ -752,12 +794,19 @@ function emptyBlock(pages) {
752
794
  };
753
795
  }
754
796
 
755
- export async function validateFixture(invocation = {}, { loadLogoEngines = loadThemeEngines } = {}) {
797
+ export async function validateFixture(invocation = {}, {
798
+ loadLogoEngines = loadThemeEngines,
799
+ loadChromeFit,
800
+ reportChrome = true,
801
+ } = {}) {
756
802
  // Refused before any file is read: a directory, or a fixture to export, has no site to read.
757
803
  if (invocation.fromSite === true && (invocation.init || invocation.fixturePath !== undefined)) {
758
804
  throw siteNeedsWorkspaceError(Boolean(invocation.init));
759
805
  }
760
- if (invocation.init) return await initializeFixture(invocation, next => validateFixture(next, { loadLogoEngines }));
806
+ if (invocation.init) {
807
+ return await initializeFixture(invocation, next => validateFixture(next, { loadLogoEngines, reportChrome: false }));
808
+ }
809
+ const reporting = { loadLogoEngines, loadChromeFit, reportChrome };
761
810
  const onProgress = typeof invocation.onProgress === "function" ? invocation.onProgress : () => {};
762
811
  const cwd = invocation.cwd ?? process.cwd();
763
812
  if (invocation.fixturePath === undefined) {
@@ -769,7 +818,7 @@ export async function validateFixture(invocation = {}, { loadLogoEngines = loadT
769
818
  "siteId",
770
819
  );
771
820
  }
772
- return await validatePulledWorkspace(config.workspaceDir, config.siteId, invocation, onProgress, { config, loadLogoEngines });
821
+ return await validatePulledWorkspace(config.workspaceDir, config.siteId, invocation, onProgress, { config, ...reporting });
773
822
  }
774
823
  const fixtureRoot = await resolveFixtureRoot(cwd, invocation.fixturePath);
775
824
  if (
@@ -780,7 +829,7 @@ export async function validateFixture(invocation = {}, { loadLogoEngines = loadT
780
829
  if (!isCanonicalUuid(siteId)) {
781
830
  fail("workspace.manifest_invalid", `${MANIFEST_FILE_NAME} does not record a canonical site id.`, "siteId");
782
831
  }
783
- return await validatePulledWorkspace(fixtureRoot, siteId, invocation, onProgress, { directoryArgument: true, loadLogoEngines });
832
+ return await validatePulledWorkspace(fixtureRoot, siteId, invocation, onProgress, { directoryArgument: true, ...reporting });
784
833
  }
785
834
 
786
835
  onProgress(`Reading ${FIXTURE_MANIFEST_FILE_NAME}.`);
@@ -814,12 +863,11 @@ export async function validateFixture(invocation = {}, { loadLogoEngines = loadT
814
863
  siteId: manifest.siteId,
815
864
  manifest,
816
865
  mediaManifest,
817
- binding: { knownImageIds: imageIds, settingsEntityIds: contract.settingsEntityIds, pageIds, resourceIds },
866
+ binding: { fixture: true, knownImageIds: imageIds, settingsEntityIds: contract.settingsEntityIds, pageIds, resourceIds },
818
867
  content: invocation.content,
819
868
  onProgress,
820
869
  });
821
870
  problems.push(...checked.problems);
822
- reportThemeWarnings(checked.presentation, onProgress);
823
871
 
824
872
  const manifestByFile = new Map(manifest.pages.map((entry) => [entry.file, entry]));
825
873
  const validatedPages = [];
@@ -837,6 +885,8 @@ export async function validateFixture(invocation = {}, { loadLogoEngines = loadT
837
885
  // A forms folder that failed to read is already its own problem.
838
886
  if (checked.forms !== undefined) requireFixtureFormsBound(manifest.forms, checked.forms);
839
887
  });
888
+ const options = { ...reporting, nameReportEnabled: selectNameReportEligibility({ manifest }) };
889
+ await completeValidationWarnings(checked, { manifest, mediaManifest, valid: problems.length === 0 }, options, onProgress);
840
890
  refuseProblems(problems, "validate found problems in the fixture");
841
891
 
842
892
  const hints = pageHints(checked, onProgress);
@@ -844,7 +894,7 @@ export async function validateFixture(invocation = {}, { loadLogoEngines = loadT
844
894
  ...autolinkWarnings(checked.pages?.planned, onProgress),
845
895
  ...descriptionWarnings(checked.pages?.planned, onProgress),
846
896
  ...authorWarnings(checked.pages?.planned, onProgress),
847
- ...await offlineSiteChecks(checked, manifest, onProgress, imageCheckSkipped(IMAGE_CHECK_DIRECTORY_ARGUMENT), fixtureRoot, loadLogoEngines),
897
+ ...await offlineSiteChecks(checked, manifest, mediaManifest, onProgress, imageCheckSkipped(IMAGE_CHECK_DIRECTORY_ARGUMENT), options),
848
898
  };
849
899
  onProgress(
850
900
  `Validated ${validatedPages.length} page(s), ${checked.navigation.items} navigation item(s), two themes, appearance, and footer without credentials or mutation.`,
@@ -886,7 +936,7 @@ export async function validateFixture(invocation = {}, { loadLogoEngines = loadT
886
936
  * runs before it sends anything, for every page and setting at once, against
887
937
  * what the manifests recorded at the pull — no credential and no request.
888
938
  */
889
- async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgress, { config, directoryArgument = false, loadLogoEngines }) {
939
+ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgress, { config, directoryArgument = false, ...reporting }) {
890
940
  onProgress(`Reading ${MANIFEST_FILE_NAME}.`);
891
941
  const manifest = await readManifest(workspaceDir, siteId);
892
942
  const mediaManifest = await readMediaManifest(workspaceDir, siteId);
@@ -898,7 +948,8 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
898
948
  content: invocation.content,
899
949
  onProgress,
900
950
  });
901
- reportThemeWarnings(checked.presentation, onProgress);
951
+ const options = { ...reporting, nameReportEnabled: selectNameReportEligibility({ manifest }) };
952
+ await completeValidationWarnings(checked, { manifest, mediaManifest, valid: checked.problems.length === 0 }, options, onProgress);
902
953
  refuseProblems(checked.problems, "validate found problems in the workspace");
903
954
 
904
955
  // Only --site reads the site; without it the image rule is skipped with the reason (TR01371).
@@ -915,9 +966,11 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
915
966
  ...descriptionWarnings(checked.pages.planned, onProgress),
916
967
  ...authorWarnings(checked.pages.planned, onProgress),
917
968
  }),
918
- ...await offlineSiteChecks(checked, manifest, onProgress, site.imageCheck, workspaceDir, loadLogoEngines),
969
+ ...await offlineSiteChecks(checked, manifest, mediaManifest, onProgress, site.imageCheck, options),
919
970
  };
920
971
  // The Docs settings checks do not own the skipped image reason reported by --site.
972
+ if (checked.latestPostsWarnings?.count > 0) warnings.latestPostsWarnings = checked.latestPostsWarnings;
973
+ if (checked.tagDestinationWarnings !== undefined) warnings.tagDestinationWarnings = checked.tagDestinationWarnings;
921
974
  const docsReason = checked.settingsOnly && invocation.fromSite === true
922
975
  ? {
923
976
  imageCheckReason: {
@@ -961,6 +1014,7 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
961
1014
  doesNotProve: [
962
1015
  "credential authorization or live site ownership",
963
1016
  "pages, revisions, or videos that changed on the site since the pull",
1017
+ checked.settingsOnly ? DOCS_CHROME_NOT_PROVEN : CHROME_OFFLINE_PAGE_LIMITATION,
964
1018
  "server normalization and pull round trips",
965
1019
  SITE_CHECKS_NOT_PROVEN,
966
1020
  "preview or published rendering",