@taprootio/site-authoring 0.61.0 → 0.64.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 (71) hide show
  1. package/README.md +97 -23
  2. package/package.json +2 -2
  3. package/src/api.js +149 -21
  4. package/src/appearance-contract.js +27 -0
  5. package/src/article-appearance.js +19 -0
  6. package/src/article-appearance.json +9 -0
  7. package/src/article-end-settings.js +295 -0
  8. package/src/changelog.json +49 -0
  9. package/src/chrome-input.js +1 -1
  10. package/src/cli.js +110 -26
  11. package/src/constants.js +7 -0
  12. package/src/content/components.js +130 -14
  13. package/src/content/cta-decoration-paint.js +321 -0
  14. package/src/content/form-placement-presentation.js +91 -0
  15. package/src/content/form-placement-presentation.json +6 -0
  16. package/src/content/free-form-section-registry.json +19 -1
  17. package/src/content/free-form-sections.js +64 -55
  18. package/src/content/markdown.js +13 -0
  19. package/src/content/tiptap-prosemirror.ts +72 -59
  20. package/src/content/validate-document.js +2 -0
  21. package/src/cta-artwork-warnings.js +164 -0
  22. package/src/errors.js +6 -0
  23. package/src/field-schema.json +6 -2
  24. package/src/field-validation.js +14 -5
  25. package/src/footer-workspace.js +7 -3
  26. package/src/form-references.js +71 -9
  27. package/src/forms-contract.js +3 -5
  28. package/src/heading-outline.js +7 -0
  29. package/src/output.js +2 -0
  30. package/src/page-article-end.js +66 -0
  31. package/src/page-block-catalog.js +54 -0
  32. package/src/page-form-presentation.js +104 -0
  33. package/src/page-structure-checks.js +7 -1
  34. package/src/placed-image-ids.js +15 -18
  35. package/src/presentation-reference.js +31 -53
  36. package/src/reference-help.js +97 -27
  37. package/src/reusable-blocks.js +429 -0
  38. package/src/reusable-placements.js +271 -0
  39. package/src/setting-reference.js +57 -1
  40. package/src/settings-catalog.js +3 -0
  41. package/src/site-check-findings.js +30 -2
  42. package/src/site-check-rules.json +1 -0
  43. package/src/site-checks.js +26 -2
  44. package/src/site-health-findings.js +25 -3
  45. package/src/site-health-image-checks.js +1 -1
  46. package/src/staging-check.js +108 -21
  47. package/src/staging-served.js +5 -49
  48. package/src/status-warning-paints.js +17 -0
  49. package/src/template-token-reach.json +20 -2
  50. package/src/theme-resolve.js +27 -0
  51. package/src/transport.js +41 -5
  52. package/src/typed-page-reference.js +55 -5
  53. package/src/typed-pages.js +27 -4
  54. package/src/verbs/approve.js +2 -1
  55. package/src/verbs/deploy.js +93 -15
  56. package/src/verbs/footer-push.js +4 -2
  57. package/src/verbs/forms-push.js +9 -0
  58. package/src/verbs/health.js +11 -6
  59. package/src/verbs/index.js +3 -0
  60. package/src/verbs/pages-blocks-pull.js +22 -0
  61. package/src/verbs/pages-push.js +89 -34
  62. package/src/verbs/plan.js +34 -5
  63. package/src/verbs/pull.js +213 -124
  64. package/src/verbs/status.js +20 -2
  65. package/src/verbs/theme-push.js +170 -20
  66. package/src/verbs/theme-resolve.js +114 -40
  67. package/src/verbs/validate.js +49 -18
  68. package/src/workspace-check.js +42 -5
  69. package/src/workspace-context-usage.js +54 -1
  70. package/src/workspace.js +37 -7
  71. package/test/fixtures/default-site-theme.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { compactFormEvidence } from "../form-references.js";
1
2
  import { footerLinkWarnings } from "./footer-push.js";
2
3
  import { lstat, realpath } from "node:fs/promises";
3
4
  import path from "node:path";
@@ -10,6 +11,7 @@ import {
10
11
  selectNameReportEligibility,
11
12
  } from "../chrome-input.js";
12
13
  import { completeChromeReport } from "../chrome-report.js";
14
+ import { ctaArtworkWarnings } from "../cta-artwork-warnings.js";
13
15
  import { addUsageFields, fitChromeAdditions } from "../chrome-additions.js";
14
16
  import { buildContextUsage } from "../workspace-context-usage.js";
15
17
  import {
@@ -43,6 +45,8 @@ import { footerFitInputFromSettings } from "../footer-brand-inputs.js";
43
45
  import { appearanceManifestEntry, footerManifestEntry } from "../footer-workspace.js";
44
46
  import { FORMS_DIRECTORY } from "../forms-contract.js";
45
47
  import { authorWarnings, descriptionWarnings } from "../page-metadata.js";
48
+ import { appendReusablePlacementReport, REUSABLE_CATALOG_UNAVAILABLE } from "../reusable-placements.js";
49
+ import { appendReusableBlockReport } from "../reusable-blocks.js";
46
50
  import { CHECK_AREA, appendAll, collectProblems, omittedFileCodes, refuseProblems } from "../problems.js";
47
51
  import { isRedirectMapRevision, REDIRECT_KIND_GONE, REDIRECTS_FILE_NAME } from "../redirects-contract.js";
48
52
  import { boundedList, openSession, storedPlatformLegalSite, successResult } from "../session.js";
@@ -730,12 +734,13 @@ async function offlineSiteChecks(checked, manifest, mediaManifest, onProgress, i
730
734
  footer,
731
735
  );
732
736
  const evaluated = evaluateOfflineSiteChecks({
733
- planned: checked.settingsOnly ? [] : checked.pages?.planned,
737
+ planned: checked.settingsOnly ? [] : checked.reusablePlacements?.checkedPages ?? checked.pages?.planned,
734
738
  footerInput,
735
739
  footerOnly: checked.settingsOnly,
736
740
  pagePaths: checked.settingsOnly ? [] : manifest.pages.map((entry) => normalizePagePath(entry?.path)).filter((value) => value !== undefined),
737
741
  pagesComplete: manifest.pagesTruncated !== true,
738
742
  formKeysChecked: checked.formKeysChecked === true,
743
+ formEvidence: compactFormEvidence(manifest, checked.forms),
739
744
  imageCheck,
740
745
  onProgress,
741
746
  });
@@ -812,6 +817,9 @@ export function pageContextUsage(checked, problems) {
812
817
  for (const dropped of omittedFileCodes(problems)) {
813
818
  if (dropped.area === CHECK_AREA.pages && !codes.has(dropped.file)) codes.set(dropped.file, dropped.code);
814
819
  }
820
+ for (const file of checked.reusablePlacements?.unavailableFiles ?? []) {
821
+ if (!codes.has(file)) codes.set(file, REUSABLE_CATALOG_UNAVAILABLE);
822
+ }
815
823
  for (const file of checked.pages?.conflictedFiles ?? []) codes.set(file, "pages.path_conflict");
816
824
  // A walk that failed leaves no planning result, and its problem names no file.
817
825
  const walkFailure = checked.pages === undefined
@@ -822,7 +830,7 @@ export function pageContextUsage(checked, problems) {
822
830
  footerSettings: checked.footer?.footerSettings,
823
831
  listingCardContext: checked.presentation.publishing?.listingCardContext,
824
832
  contexts: contextScopedNames(checked.presentation.themes.warnings),
825
- pages: (checked.pages?.planned ?? []).filter((page) => !codes.has(page.file)),
833
+ pages: (checked.reusablePlacements?.checkedPages ?? checked.pages?.planned ?? []).filter((page) => !codes.has(page.file)),
826
834
  skipped: [...codes].map(([file, code]) => ({ file, code })),
827
835
  ...(walkFailure === undefined ? {} : {
828
836
  unavailable: { code: walkFailure.code, ...(walkFailure.field === undefined ? {} : { field: walkFailure.field }) },
@@ -830,9 +838,26 @@ export function pageContextUsage(checked, problems) {
830
838
  });
831
839
  }
832
840
 
833
- /** The context-usage fields, added to a finished result from the bytes it has left. */
834
- function withContextUsage(result, checked) {
835
- return addUsageFields(result, { usedIn: usedInOf(checked.statusWarningPaints), skipped: checked.contextUsage?.skipped });
841
+ async function finishValidationResult(result, checked, onProgress, { loadLogoEngines }) {
842
+ const withUsage = appendReusableBlockReport(
843
+ appendReusablePlacementReport(
844
+ addUsageFields(result, { usedIn: usedInOf(checked.statusWarningPaints), skipped: checked.contextUsage?.skipped }),
845
+ checked.reusablePlacements?.report,
846
+ onProgress,
847
+ ),
848
+ checked.reusableBlocks,
849
+ onProgress,
850
+ );
851
+ const warnings = await ctaArtworkWarnings(
852
+ checked.reusablePlacements?.checkedPages ?? checked.pages?.planned, checked.presentation?.style, onProgress, loadLogoEngines,
853
+ );
854
+ if (warnings.ctaArtworkWarnings === undefined) return withUsage;
855
+
856
+ // Artwork advice uses the room left after every other field, including context usage and any site findings.
857
+ const fitted = { ...withUsage, ...fitPrecheckToBudget(withUsage, warnings, ["ctaArtworkWarnings"]) };
858
+ if (Buffer.byteLength(JSON.stringify(fitted), "utf8") <= LIMITS.githubOutputBytes) return fitted;
859
+ onProgress(`Warning: ${warnings.ctaArtworkWarnings.total} CTA artwork contrast finding(s). The JSON result has no room for their summary.`);
860
+ return withUsage;
836
861
  }
837
862
 
838
863
  /**
@@ -982,7 +1007,7 @@ export async function validateFixture(invocation = {}, {
982
1007
  onProgress(
983
1008
  `Validated ${validatedPages.length} page(s), ${checked.navigation.items} navigation item(s), two themes, appearance, and footer without credentials or mutation.`,
984
1009
  );
985
- return withContextUsage(fitChromeAdditions(successResult(VERB_VALIDATE, manifest.siteId, {
1010
+ return finishValidationResult(fitChromeAdditions(successResult(VERB_VALIDATE, manifest.siteId, {
986
1011
  offline: true,
987
1012
  fixture: {
988
1013
  contractVersion: FIXTURE_CONTRACT_VERSION,
@@ -1011,7 +1036,7 @@ export async function validateFixture(invocation = {}, {
1011
1036
  "preview or published rendering",
1012
1037
  ],
1013
1038
  nextStep: "Run a real pull and authorized preview before approval or deployment.",
1014
- })), checked);
1039
+ })), checked, onProgress, options);
1015
1040
  }
1016
1041
 
1017
1042
  /**
@@ -1038,7 +1063,9 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
1038
1063
 
1039
1064
  // Only --site reads the site; without it the image rule is skipped with the reason (TR01371).
1040
1065
  const site = invocation.fromSite === true
1041
- ? await readSiteImages(checked, invocation, onProgress, config)
1066
+ ? manifest.settingsOnly === true
1067
+ ? { imageCheck: { ran: false, code: "settings_only_workspace", message: "Run a full pull to record the site's page inventory." } }
1068
+ : await readSiteImages(checked, invocation, onProgress, config)
1042
1069
  : { imageCheck: imageCheckSkipped(directoryArgument ? IMAGE_CHECK_DIRECTORY_ARGUMENT : IMAGE_CHECK_NOT_REQUESTED) };
1043
1070
  const pages = checked.settingsOnly
1044
1071
  ? []
@@ -1055,7 +1082,7 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
1055
1082
  // The Docs settings checks do not own the skipped image reason reported by --site.
1056
1083
  if (checked.latestPostsWarnings?.count > 0) warnings.latestPostsWarnings = checked.latestPostsWarnings;
1057
1084
  if (checked.tagDestinationWarnings !== undefined) warnings.tagDestinationWarnings = checked.tagDestinationWarnings;
1058
- const docsReason = checked.settingsOnly && invocation.fromSite === true
1085
+ const settingsOnlyReason = checked.settingsOnly && invocation.fromSite === true
1059
1086
  ? {
1060
1087
  imageCheckReason: {
1061
1088
  code: site.imageCheck.code,
@@ -1081,14 +1108,16 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
1081
1108
  ...validatedSummary(checked, pages),
1082
1109
  hints,
1083
1110
  ...warnings,
1084
- ...docsReason,
1111
+ ...settingsOnlyReason,
1085
1112
  proves: [
1086
- "every page source: metadata, Markdown conversion, media references, content vocabulary, and section contexts",
1087
- "page paths, templates, and system pages against the pages the pull recorded",
1088
- "navigation shape and page references the pull recorded",
1089
- "redirect-map shape, normalization, chains, loops, and workspace page paths",
1113
+ ...(manifest.settingsOnly === true ? [] : [
1114
+ "every page source: metadata, Markdown conversion, media references, content vocabulary, and section contexts",
1115
+ "page paths, templates, and system pages against the pages the pull recorded",
1116
+ "navigation shape and page references the pull recorded",
1117
+ "redirect-map shape, normalization, chains, loops, and workspace page paths",
1118
+ ]),
1090
1119
  "complete theme, appearance, header, brand, and footer semantics",
1091
- "form files against the shared field schema",
1120
+ ...(manifest.settingsOnly === true ? [] : ["form files against the shared field schema"]),
1092
1121
  ...(site.block === undefined ? [] : [
1093
1122
  site.imageCheck.ran
1094
1123
  ? "which placed images have no default description, from the site's own image records (imageFindings)"
@@ -1103,7 +1132,9 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
1103
1132
  SITE_CHECKS_NOT_PROVEN,
1104
1133
  "preview or published rendering",
1105
1134
  ],
1106
- nextStep: "Run 'taproot-site plan' to check the workspace against the live site and see the ordered apply.",
1135
+ nextStep: manifest.settingsOnly === true
1136
+ ? "Run 'taproot-site theme push --dry-run' to compare the presentation with the live site."
1137
+ : "Run 'taproot-site plan' to check the workspace against the live site and see the ordered apply.",
1107
1138
  }));
1108
1139
  // Footer links outside the release, fitted into the bytes the result has left (TR01433).
1109
1140
  const withFooterLinks = checked.footer?.footerSettings === undefined ? base : {
@@ -1111,11 +1142,11 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
1111
1142
  ...footerLinkWarnings(manifest.pages, checked.footer.footerSettings, onProgress,
1112
1143
  LIMITS.githubOutputBytes - Buffer.byteLength(JSON.stringify(base), "utf8") - 2048 - 256),
1113
1144
  };
1114
- if (site.block === undefined) return withContextUsage(withFooterLinks, checked);
1145
+ if (site.block === undefined) return finishValidationResult(withFooterLinks, checked, onProgress, options);
1115
1146
  const fitted = fitPrecheckToBudget(
1116
1147
  withFooterLinks,
1117
1148
  { imageFindings: site.block.imageFindings, notInSiteLibrary: site.block.notInSiteLibrary },
1118
1149
  ["notInSiteLibrary", "imageFindings"],
1119
1150
  );
1120
- return withContextUsage({ ...withFooterLinks, ...fitted }, checked);
1151
+ return finishValidationResult({ ...withFooterLinks, ...fitted }, checked, onProgress, options);
1121
1152
  }
@@ -1,4 +1,5 @@
1
1
  import { checkTagDestinationTargets } from "./appearance-contract.js";
2
+ import { ARTICLE_END_FILE, resolveArticleEndWorkspace } from "./article-end-settings.js";
2
3
  import { sharedThemeContextNames } from "./content/free-form-sections.js";
3
4
  import { readAppearanceWorkspaceContext, FOOTER_SETTINGS_FILE } from "./footer-workspace.js";
4
5
  import { placedFormKeys } from "./form-references.js";
@@ -8,6 +9,13 @@ import { readWorkspaceForms } from "./forms-workspace.js";
8
9
  import { describeSiteFinding } from "./site-check-findings.js";
9
10
  import { unknownFormKeyFindings } from "./site-checks.js";
10
11
  import { CHECK_AREA, appendAll, collectProblems, problemsOf } from "./problems.js";
12
+ import {
13
+ checkReusableWorkspaceTargets,
14
+ resolveReusableWorkspace,
15
+ reusableWorkspaceReport,
16
+ REUSABLE_BLOCKS_FILE,
17
+ } from "./reusable-blocks.js";
18
+ import { assessReusablePlacements } from "./reusable-placements.js";
11
19
  import { normalizeRedirectPath, REDIRECTS_FILE_NAME, validateRedirectsDocument } from "./redirects-contract.js";
12
20
  import { boundedByBytes } from "./session.js";
13
21
  import { SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES } from "./settings-catalog.js";
@@ -56,12 +64,13 @@ export async function checkWorkspace({
56
64
  binding = {},
57
65
  content,
58
66
  areas = ALL_AREAS,
67
+ deferReusableTargets = false,
59
68
  platformLegalSite = false,
60
69
  onProgress = () => {},
61
70
  }) {
62
71
  const problems = [];
63
72
  // A managed Docs site's workspace holds its settings only (TR00790).
64
- const settingsOnly = manifest.authoringSurface !== undefined;
73
+ const settingsOnly = manifest.authoringSurface !== undefined || manifest.settingsOnly === true;
65
74
  const pageIds = binding.pageIds
66
75
  ?? new Set(manifest.pages.map((entry) => entry?.pageId).filter((value) => typeof value === "string"));
67
76
  const resourceIds = binding.resourceIds
@@ -78,7 +87,9 @@ export async function checkWorkspace({
78
87
  const presentation = knownImageIds === undefined
79
88
  ? undefined
80
89
  : await collectProblems(problems, { area: CHECK_AREA.presentation }, async () => {
81
- const validated = await validateThemeWorkspace(workspaceDir, siteId, knownImageIds, binding.settingsEntityIds);
90
+ const validated = await validateThemeWorkspace(
91
+ workspaceDir, siteId, knownImageIds, binding.settingsEntityIds, { authoringSurface: manifest.authoringSurface, mediaManifest },
92
+ );
82
93
  if (validated.publishing.tagDestinations !== undefined) {
83
94
  // A fixture declares its own tag names and has no live tag catalog.
84
95
  const fixtureTagSlugs = binding.fixture ? Object.keys(validated.publishing.tagDestinations) : undefined;
@@ -93,6 +104,14 @@ export async function checkWorkspace({
93
104
  manifest, undefined, undefined, true,
94
105
  );
95
106
  }
107
+ if (validated.articleEnd !== undefined) {
108
+ await collectProblems(problems, { area: CHECK_AREA.presentation, file: ARTICLE_END_FILE }, async () =>
109
+ resolveArticleEndWorkspace(validated.articleEnd, {
110
+ definitions: validated.reusableBlocks,
111
+ tags: Array.isArray(manifest.articleEndTags) ? manifest.articleEndTags : undefined,
112
+ onProgress,
113
+ }));
114
+ }
96
115
  return validated;
97
116
  });
98
117
  const tagDestinationWarnings = reportTagDestinationWarnings(
@@ -109,12 +128,23 @@ export async function checkWorkspace({
109
128
  siteId,
110
129
  {
111
130
  expectedEntityId: binding.settingsEntityIds?.get(SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES),
112
- knownPageResourceIds: resourceIds,
131
+ knownPageResourceIds: manifest.settingsOnly === true ? undefined : resourceIds,
113
132
  knownImageIds,
114
133
  },
115
134
  ));
116
135
 
117
- if (settingsOnly) return { problems, settingsOnly, presentation, footer };
136
+ const checkReusable = async (plannedPages) => {
137
+ if (presentation?.reusableBlocks === undefined) return undefined;
138
+ return await collectProblems(problems, { area: CHECK_AREA.presentation, file: REUSABLE_BLOCKS_FILE }, async () => {
139
+ resolveReusableWorkspace(presentation.reusableBlocks, manifest.reusableBlocks);
140
+ if (deferReusableTargets) return undefined;
141
+ const targets = checkReusableWorkspaceTargets(presentation.reusableBlocks, manifest, plannedPages);
142
+ return await reusableWorkspaceReport(presentation.reusableBlocks, presentation.style, targets, onProgress);
143
+ });
144
+ };
145
+ if (settingsOnly) {
146
+ return { problems, settingsOnly, presentation, footer, reusableBlocks: await checkReusable() };
147
+ }
118
148
 
119
149
  onProgress("Validating navigation shape and its page targets.");
120
150
  const navigation = await collectProblems(problems, { area: CHECK_AREA.navigation, file: NAVIGATION_FILE_NAME }, async () =>
@@ -150,6 +180,13 @@ export async function checkWorkspace({
150
180
  onProgress,
151
181
  }));
152
182
  if (pages !== undefined) appendAll(problems, pages.problems);
183
+ const reusablePlacements = pages === undefined ? undefined : assessReusablePlacements(pages.planned, {
184
+ catalog: manifest.pageBlockCatalog,
185
+ workspaceDefinitions: presentation?.reusableBlocks,
186
+ manifest,
187
+ onProgress,
188
+ });
189
+ if (reusablePlacements !== undefined) appendAll(problems, reusablePlacements.problems);
153
190
  const listingTagProblems = pages === undefined ? [] : latestPostsTagProblems(pages.planned, manifest);
154
191
  const latestPostsWarnings = { count: listingTagProblems.length, ...boundedByBytes(listingTagProblems, 8 * 1024) };
155
192
  for (const { message } of latestPostsWarnings.items) onProgress("Warning: " + message);
@@ -195,7 +232,7 @@ export async function checkWorkspace({
195
232
 
196
233
  return {
197
234
  problems, settingsOnly, presentation, footer, navigation, pages, redirects, forms, formKeysChecked,
198
- tagDestinationWarnings, latestPostsWarnings,
235
+ tagDestinationWarnings, latestPostsWarnings, reusablePlacements, reusableBlocks: await checkReusable(pages?.planned),
199
236
  };
200
237
  }
201
238
 
@@ -1,4 +1,6 @@
1
+ import { assessReusablePlacements, REUSABLE_CATALOG_UNAVAILABLE } from "./reusable-placements.js";
1
2
  import { FREE_FORM_SECTION_REGISTRY, namedContext } from "./content/free-form-sections.js";
3
+ import { isPlainObject } from "./content/vocabulary.js";
2
4
  import { SiteAuthoringError } from "./errors.js";
3
5
  import { problemsOf } from "./problems.js";
4
6
  import { contentDocuments } from "./typed-pages.js";
@@ -103,6 +105,50 @@ function skippedReport(skipped) {
103
105
  };
104
106
  }
105
107
 
108
+ function contextSetting(settings, field, declaredContexts) {
109
+ if (!isPlainObject(settings)) return null;
110
+ const value = settings[field] === undefined ? "" : settings[field];
111
+ return typeof value === "string" && (value === "" || declaredContexts.has(value)) ? value : null;
112
+ }
113
+
114
+ /** Read only the fields needed for usage so an unrelated invalid setting cannot hide a context. */
115
+ export function contextUsageSettings({ header, publishing }, declaredContexts) {
116
+ const footer = publishing?.footerSettings;
117
+ const footerContext = contextSetting(footer, "context", declaredContexts);
118
+ const enabled = footer?.enabled === undefined ? false : footer.enabled;
119
+ return {
120
+ header: contextSetting(header, "context", declaredContexts),
121
+ footer: footerContext === null || typeof enabled !== "boolean" ? null : enabled ? footerContext : "",
122
+ listingCards: contextSetting(publishing, "listingCardContext", declaredContexts),
123
+ };
124
+ }
125
+
126
+ /** Project the inventory for every selected context, including those with no uses or warnings. */
127
+ export function projectContextUsage({ scope, contexts, settings, usage, skipped, reason, settingsOnly = false }) {
128
+ if (contexts.size === 0) return undefined;
129
+ const available = scope === "workspace" && !settingsOnly && reason === undefined;
130
+ const usedBySetting = (name, context) => name === null ? null : name === context;
131
+ return {
132
+ scope,
133
+ status: !available ? "unavailable" : skipped === undefined ? "complete" : "partial",
134
+ contexts: [...contexts].map((context) => {
135
+ const used = usage?.get(context);
136
+ return {
137
+ context,
138
+ usedBy: {
139
+ header: usedBySetting(settings.header, context),
140
+ footer: usedBySetting(settings.footer, context),
141
+ listingCards: usedBySetting(settings.listingCards, context),
142
+ sections: available ? used?.sections ?? 0 : null,
143
+ ctas: available ? used?.ctas ?? 0 : null,
144
+ },
145
+ };
146
+ }),
147
+ omitted: 0,
148
+ ...(reason === undefined ? {} : { reason }),
149
+ };
150
+ }
151
+
106
152
  /**
107
153
  * The one builder of the context usage every verb reports: the counts and positions, the pages that could not be
108
154
  * counted with their first problem code, and, when the page inventory itself could not be read, why (TR01426).
@@ -148,6 +194,7 @@ export async function readWorkspaceContextUsage({
148
194
  content,
149
195
  contexts,
150
196
  themeContexts,
197
+ reusableDefinitions,
151
198
  }) {
152
199
  const counter = createContextUsageCounter({ header, footerSettings, listingCardContext, contexts });
153
200
  const manifestByFile = new Map(
@@ -178,7 +225,13 @@ export async function readWorkspaceContextUsage({
178
225
  content,
179
226
  getSharedThemeContexts: async () => themeContexts,
180
227
  });
181
- counter.add(document, file);
228
+ const evaluated = assessReusablePlacements([{ file, document }], {
229
+ catalog: manifest?.pageBlockCatalog, workspaceDefinitions: reusableDefinitions,
230
+ });
231
+ const code = evaluated.problems[0]?.code
232
+ ?? (evaluated.unavailableFiles.length > 0 ? REUSABLE_CATALOG_UNAVAILABLE : undefined);
233
+ if (code === undefined) counter.add(evaluated.checkedPages[0].document, file);
234
+ else skipped.push({ file, code });
182
235
  } catch (error) {
183
236
  skipped.push({ file, code: firstProblemCode(error) });
184
237
  }
package/src/workspace.js CHANGED
@@ -265,7 +265,11 @@ export async function readObservedPageRecord(workspaceDir, pageId) {
265
265
  // the revision, so the record has to name it to say what was seen.
266
266
  displayDate: normalizeBaselineDisplayDate(parsed.displayDate),
267
267
  displayAuthor: normalizeBaselineDisplayAuthor(parsed.displayAuthor),
268
- showOnProfile: normalizeBaselineShowOnProfile(parsed.showOnProfile),
268
+ showOnProfile: normalizeBaselineBoolean(parsed.showOnProfile),
269
+ ...(typeof parsed.articleEnd === "boolean" ? { articleEnd: parsed.articleEnd } : {}),
270
+ ...(parsed.formPresentationHash === null ||
271
+ (typeof parsed.formPresentationHash === "string" && WORKSPACE_CONTENT_HASH.test(parsed.formPresentationHash))
272
+ ? { formPresentationHash: parsed.formPresentationHash } : {}),
269
273
  differences: normalizeObservedDifferences(parsed.differences),
270
274
  };
271
275
  }
@@ -430,9 +434,8 @@ function normalizeBaselineDisplayAuthor(value) {
430
434
  return value === "" || (typeof value === "string" && normalizeAuthorHandle(value) === value) ? value : undefined;
431
435
  }
432
436
 
433
- // A boolean (TR01403). A baseline written before showOnProfile existed has
434
- // none: it counts as not having seen the value.
435
- function normalizeBaselineShowOnProfile(value) {
437
+ // A missing optional flag means the workspace has no evidence of that preference.
438
+ function normalizeBaselineBoolean(value) {
436
439
  return typeof value === "boolean" ? value : undefined;
437
440
  }
438
441
 
@@ -508,13 +511,16 @@ export function pageSourceRegistry(manifest) {
508
511
  const revision = normalizePageBodyRevision(declared?.revision);
509
512
  const displayDate = normalizeBaselineDisplayDate(declared?.displayDate);
510
513
  const displayAuthor = normalizeBaselineDisplayAuthor(declared?.displayAuthor);
511
- const showOnProfile = normalizeBaselineShowOnProfile(declared?.showOnProfile);
514
+ const showOnProfile = normalizeBaselineBoolean(declared?.showOnProfile);
515
+ const articleEnd = normalizeBaselineBoolean(declared?.articleEnd);
516
+ const formPresentationHash = normalizeBaselineHash(declared?.formPresentationHash);
512
517
  const author = normalizeAuthorValue(declared?.author);
513
518
  const tagBaseline = normalizeAuthoredTagBaseline(declared);
514
519
  const baseline =
515
520
  remoteHash === undefined && sourceHash === undefined && revision === undefined && displayDate === undefined
516
- && displayAuthor === undefined && showOnProfile === undefined
521
+ && displayAuthor === undefined && showOnProfile === undefined && articleEnd === undefined
517
522
  && sourceBodyHash === undefined && contentKey === undefined && author === undefined && tagBaseline === undefined
523
+ && formPresentationHash === undefined
518
524
  ? undefined
519
525
  : {
520
526
  ...(remoteHash === undefined ? {} : { remoteHash }),
@@ -525,6 +531,8 @@ export function pageSourceRegistry(manifest) {
525
531
  ...(displayDate === undefined ? {} : { displayDate }),
526
532
  ...(displayAuthor === undefined ? {} : { displayAuthor }),
527
533
  ...(showOnProfile === undefined ? {} : { showOnProfile }),
534
+ ...(articleEnd === undefined ? {} : { articleEnd }),
535
+ ...(formPresentationHash === undefined ? {} : { formPresentationHash }),
528
536
  // The author the site held for the page when this workspace last
529
537
  // reconciled with it: what a page's own author reference is
530
538
  // compared with before anything is sent (TR01196).
@@ -1432,8 +1440,20 @@ export async function readManifest(workspaceDir, expectedSiteId, { required = tr
1432
1440
  return parsed;
1433
1441
  }
1434
1442
 
1443
+ export function serializeManifest(manifest) {
1444
+ const contents = `${JSON.stringify(manifest, undefined, 2)}\n`;
1445
+ if (Buffer.byteLength(contents, "utf8") > WORKSPACE_LIMITS.manifestBytes) {
1446
+ throw new SiteAuthoringError(
1447
+ "workspace.file_too_large",
1448
+ `The pull manifest would exceed ${WORKSPACE_LIMITS.manifestBytes} bytes.`,
1449
+ { field: MANIFEST_FILE_NAME },
1450
+ );
1451
+ }
1452
+ return contents;
1453
+ }
1454
+
1435
1455
  export async function writeManifest(workspaceDir, manifest) {
1436
- return await writeWorkspaceJson(workspaceDir, MANIFEST_FILE_NAME, manifest);
1456
+ return await writeWorkspaceFile(workspaceDir, MANIFEST_FILE_NAME, serializeManifest(manifest));
1437
1457
  }
1438
1458
 
1439
1459
  /**
@@ -1506,6 +1526,16 @@ export function mediaReferenceCandidates(reference) {
1506
1526
  return [...candidates];
1507
1527
  }
1508
1528
 
1529
+ export function workspaceImageFromReference(mediaManifest, reference) {
1530
+ for (const candidate of mediaReferenceCandidates(reference)) {
1531
+ const entry = mediaManifest?.media?.[candidate];
1532
+ if (entry !== null && typeof entry === "object" && typeof entry.imageId === "string" && entry.imageId !== "") {
1533
+ return entry;
1534
+ }
1535
+ }
1536
+ return undefined;
1537
+ }
1538
+
1509
1539
  /** The alt text a media record keeps when its file is uploaded again: the author's own, or none. */
1510
1540
  export function recordedAlt(entry) {
1511
1541
  return typeof entry?.alt === "string" ? entry.alt : "";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$generated": "Generated by scripts/build-default-site-theme.mjs from @taprootio/espalier. Do not edit by hand — run `npm run theme:build`.",
3
- "espalierVersion": "7.10.0",
3
+ "espalierVersion": "7.12.0",
4
4
  "light": {
5
5
  "encoded": "eyJzZWVkQ29sb3IiOiJva2xjaCguMDcgMC4xNSAyMTYpIiwiZm9udEJvZHkiOiJcIk5vdG8gU2Fuc1wiLCBzYW5zLXNlcmlmIiwiZm9udEhlYWRpbmdzIjoiXCJJbmlrYVwiLCBzZXJpZiIsImZvbnRCcmFuZCI6IlwiSW5pa2FcIiwgc2VyaWYiLCJmb250TWVudSI6IiIsImZvbnRNb25vc3BhY2UiOiJcIkpldEJyYWlucyBNb25vXCIsIG1vbm9zcGFjZSIsImZvbnRXZWlnaHRCb2R5Ijoibm9ybWFsIiwiZm9udFdlaWdodEhlYWRpbmdzIjoibm9ybWFsIiwiZm9udFdlaWdodEJyYW5kIjoibm9ybWFsIiwiZm9udFdlaWdodE1lbnUiOiJib2xkIiwiZm9udFdlaWdodE1vbm9zcGFjZSI6Im5vcm1hbCIsInN0eWxlc2hlZXRzIjpbXSwicm9vdEZvbnRTaXplIjoxNiwidHlwZVJhdGlvIjoxLjI1LCJzcGFjZVJhdGlvIjoxLjYxOCwiYm9yZGVyUmFkaXVzIjowLjEsInZpZXdwb3J0TWluIjozMjAsInZpZXdwb3J0TWF4IjoxMjAwLCJhbmdsZXMiOnsiYW5hbG9nb3VzIjozMCwiY29tcGxlbWVudGFyeSI6MTgwLCJzcGxpdENvbXBsZW1lbnRhcnkiOjMwLCJ0cmlhZGljIjoxMjB9LCJzZW1hbnRpY0h1ZXMiOnsiZGFuZ2VyIjoyNywic3VjY2VzcyI6MTUwLCJ3YXJuaW5nIjo5MCwiaW5mbyI6MjQ0fSwidmFyaWFudENocm9tYSI6e30sImludGVudHMiOnt9LCJ0b25lcyI6e30sImN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