@taprootio/site-authoring 0.38.1 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -17
- package/examples/riverbend-wellness/manifest.fixture.json +1 -1
- package/examples/riverbend-wellness/settings/site-publishing-preferences.json +29 -14
- package/package.json +2 -2
- package/src/api.js +4 -5
- package/src/appearance-contract.js +64 -55
- package/src/atomic-file.js +2 -1
- package/src/changelog.json +37 -0
- package/src/cli.js +2 -2
- package/src/content/free-form-sections.js +2 -3
- package/src/display-scale.js +17 -0
- package/src/footer-alignment.js +97 -0
- package/src/footer-brand-inputs.js +33 -0
- package/src/footer-branding.js +44 -0
- package/src/footer-content.js +10 -0
- package/src/footer-contract.js +167 -43
- package/src/footer-draft-hash.js +26 -27
- package/src/footer-fit-widths.js +10 -0
- package/src/footer-fit.js +328 -0
- package/src/footer-font-metrics.js +8345 -0
- package/src/footer-workspace.js +4 -6
- package/src/header-presentation.js +17 -15
- package/src/logo-inputs.js +38 -0
- package/src/logo-surface-checks.js +67 -0
- package/src/presentation-reference.js +119 -46
- package/src/reference-help.js +3 -3
- package/src/setting-reference.js +15 -4
- package/src/settings-catalog.js +10 -3
- package/src/site-check-findings.js +73 -11
- package/src/site-check-rules.json +4 -2
- package/src/theme-contexts.js +82 -0
- package/src/theme-resolve.js +2 -2
- package/src/theme-validation.js +30 -13
- package/src/verbs/footer-push.js +20 -9
- package/src/verbs/plan.js +2 -2
- package/src/verbs/theme-push.js +46 -41
- package/src/verbs/validate.js +33 -17
- package/src/workspace-check.js +1 -1
- package/src/workspace.js +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FOOTER_FIT_WIDTH_LABELS, footerFitFindings } from "./footer-fit.js";
|
|
2
|
+
import { FOOTER_SETTINGS_FILE } from "./footer-workspace.js";
|
|
1
3
|
import { sanitizeDiagnostic } from "./errors.js";
|
|
2
4
|
import { boundedByBytes } from "./session.js";
|
|
3
5
|
import rules from "./site-check-rules.json" with { type: "json" };
|
|
@@ -15,6 +17,7 @@ import { displayPagePath } from "./workspace.js";
|
|
|
15
17
|
* words below are this surface's own.
|
|
16
18
|
*/
|
|
17
19
|
export const SITE_CHECK_RULES = Object.freeze(rules.rules);
|
|
20
|
+
export const SITE_FINDINGS_MAX_BYTES = 8 * 1024;
|
|
18
21
|
|
|
19
22
|
/** Why `validate` did not run the image description rule, which needs the site's image records (TR01371). */
|
|
20
23
|
export const IMAGE_CHECK_NOT_REQUESTED = "not_requested";
|
|
@@ -79,6 +82,12 @@ export const SITE_CHECK_WORDING = Object.freeze({
|
|
|
79
82
|
"seo.description_short": (finding) => `has a description of ${finding.detail} characters; consider adding useful detail (guidance: ${DESCRIPTION_MINIMUM_LENGTH}–${DESCRIPTION_WARN_LENGTH})`,
|
|
80
83
|
"seo.description_long": (finding) => `has a description of ${finding.detail} characters; consider shortening it (guidance: ${DESCRIPTION_MINIMUM_LENGTH}–${DESCRIPTION_WARN_LENGTH})`,
|
|
81
84
|
"seo.description_matches_title": () => "has a description that repeats its title; explain what readers will find",
|
|
85
|
+
"footer.word_breaks": (finding) => footerFindingWords(finding),
|
|
86
|
+
"brand.logo_on_surface": finding => {
|
|
87
|
+
const [scheme, second, third] = String(finding.detail ?? "").split(":");
|
|
88
|
+
const artwork = third ?? second;
|
|
89
|
+
return `the ${finding.subject === "footer" ? "footer" : "header"} shows ${artwork === "dark" ? "dark" : "light"}-background ${second === "compact" ? "compact " : ""}artwork against the opposite surface brightness in the ${scheme === "dark" ? "dark" : "light"} scheme; choose its other Logo variant or adjust its Colors context`;
|
|
90
|
+
},
|
|
82
91
|
"seo.social_image_fallback": (finding) =>
|
|
83
92
|
finding.detail === "first_image"
|
|
84
93
|
? "has no cover image; link previews use the page's first image only when it is public and at least 1200 pixels wide"
|
|
@@ -92,6 +101,8 @@ export const SITE_CHECK_WORDING = Object.freeze({
|
|
|
92
101
|
export const AFTER_PAGE_FIX =
|
|
93
102
|
"then, for a page edit, run taproot-site pages push and taproot-site approve, and run taproot-site deploy --staging to refresh the report";
|
|
94
103
|
export const SITE_CHECK_REMEDIES = Object.freeze({
|
|
104
|
+
"brand.logo_on_surface": "Choose a readable header or footer logoVariant in the settings files, run taproot-site theme push, and inspect both schemes on staging. This brightness heuristic does not inspect image pixels or footer background art.",
|
|
105
|
+
"footer.word_breaks": "Widen the named footer region or shorten its text in settings/site-publishing-preferences.json, run taproot-site footer push, then taproot-site deploy --staging to refresh the report.",
|
|
95
106
|
"link.page_missing": `Change the link to a page this site has, or create that page, ${AFTER_PAGE_FIX}.`,
|
|
96
107
|
"image.missing": `Remove the image from the page or replace it with one from the site's library, ${AFTER_PAGE_FIX}.`,
|
|
97
108
|
// Built for each image, because the command carries the image's own revision and text.
|
|
@@ -127,6 +138,21 @@ const H1_CLAIMANT = Object.freeze({
|
|
|
127
138
|
hero: "the hero title",
|
|
128
139
|
});
|
|
129
140
|
|
|
141
|
+
const FOOTER_REGION_ADVICE = Object.freeze({
|
|
142
|
+
column: "Widen its column or shorten the label",
|
|
143
|
+
aside: "Widen the aside or shorten the text",
|
|
144
|
+
brand: "Widen the brand or shorten its text",
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
function footerFindingWords(finding) {
|
|
148
|
+
const [width, region] = String(finding.detail ?? "").split(":");
|
|
149
|
+
const widthName = Object.hasOwn(FOOTER_FIT_WIDTH_LABELS, width)
|
|
150
|
+
? FOOTER_FIT_WIDTH_LABELS[width].toLowerCase()
|
|
151
|
+
: undefined;
|
|
152
|
+
const advice = FOOTER_REGION_ADVICE[region] ?? "Widen the region or shorten the text";
|
|
153
|
+
return `'${finding.subject}' may break mid-word ${widthName === undefined ? "at this width" : `at ${widthName} width`}. ${advice}`;
|
|
154
|
+
}
|
|
155
|
+
|
|
130
156
|
/** The sentence for a finding, falling back to the rule id for a rule this release has no words for. */
|
|
131
157
|
export function describeSiteFinding(finding) {
|
|
132
158
|
const words = Object.hasOwn(SITE_CHECK_WORDING, finding.ruleId) ? SITE_CHECK_WORDING[finding.ruleId] : undefined;
|
|
@@ -164,7 +190,8 @@ function structureFindingsFor(page) {
|
|
|
164
190
|
}
|
|
165
191
|
|
|
166
192
|
/**
|
|
167
|
-
* Evaluates
|
|
193
|
+
* Evaluates offline page and footer rules. `footerOnly` checks settings workspaces without claiming page coverage.
|
|
194
|
+
* `pagePaths` is every
|
|
168
195
|
* page path the workspace knows, and `pagesComplete` says whether that list is
|
|
169
196
|
* the whole site: a truncated manifest cannot say a link is broken.
|
|
170
197
|
*/
|
|
@@ -173,19 +200,24 @@ export function evaluateOfflineSiteChecks({
|
|
|
173
200
|
pagePaths,
|
|
174
201
|
pagesComplete = true,
|
|
175
202
|
formKeysChecked = true,
|
|
203
|
+
footerInput,
|
|
204
|
+
footerOnly = false,
|
|
176
205
|
// Whether `validate --site` ran the image description rule (TR01371), or why it did not.
|
|
177
206
|
imageCheck = imageCheckSkipped(IMAGE_CHECK_NOT_REQUESTED),
|
|
178
207
|
onProgress = () => {},
|
|
179
208
|
}) {
|
|
180
209
|
const known = normalizedPathSet([...pagePaths, ...(planned ?? []).map((page) => page.pagePath)]);
|
|
210
|
+
const footer = footerInput === undefined ? { findings: [], total: 0 } : footerFitFindings(footerInput);
|
|
211
|
+
const hiddenFooter = footer.total - footer.findings.length;
|
|
181
212
|
|
|
182
213
|
const found = [];
|
|
183
|
-
for (const page of planned ?? []) {
|
|
214
|
+
for (const page of footerOnly ? [] : planned ?? []) {
|
|
184
215
|
if (page.document === null || typeof page.document !== "object") continue;
|
|
185
216
|
// The link rule needs every page path; the structure rules read only the page itself.
|
|
186
217
|
const linkFindings = pagesComplete ? missingPageLinkFindings(page.document, page.pagePath ?? "", known) : [];
|
|
187
218
|
for (const finding of [...linkFindings, ...structureFindingsFor(page)]) found.push({ page, finding });
|
|
188
219
|
}
|
|
220
|
+
for (const finding of footer.findings) found.push({ finding });
|
|
189
221
|
// Errors first, then in catalogue order, so the bounded list and the progress lines keep the rules that
|
|
190
222
|
// matter most when a large site raises a frequent one (a missing description) on every page.
|
|
191
223
|
const catalogueOrder = (ruleId) => SITE_CHECK_RULES.findIndex((rule) => rule.id === ruleId);
|
|
@@ -201,8 +233,8 @@ export function evaluateOfflineSiteChecks({
|
|
|
201
233
|
const item = {
|
|
202
234
|
rule: finding.ruleId,
|
|
203
235
|
severity: finding.severity,
|
|
204
|
-
file: page.file,
|
|
205
|
-
path: displayPagePath(page.pagePath),
|
|
236
|
+
file: page === undefined ? FOOTER_SETTINGS_FILE : page.file,
|
|
237
|
+
...(page === undefined ? {} : { path: displayPagePath(page.pagePath) }),
|
|
206
238
|
subject,
|
|
207
239
|
...(finding.detail === "" ? {} : { detail: finding.detail }),
|
|
208
240
|
};
|
|
@@ -214,17 +246,23 @@ export function evaluateOfflineSiteChecks({
|
|
|
214
246
|
if (items.length > MAXIMUM_PROGRESS_LINES) {
|
|
215
247
|
onProgress(`Warning: ${items.length - MAXIMUM_PROGRESS_LINES} more site check finding(s); see findings.`);
|
|
216
248
|
}
|
|
217
|
-
|
|
249
|
+
if (hiddenFooter > 0) onProgress(`Warning: and ${hiddenFooter} more footer fit finding(s); widen or shorten the footer text and run validate again.`);
|
|
250
|
+
const reported = boundedByBytes(items, SITE_FINDINGS_MAX_BYTES);
|
|
251
|
+
const total = items.length + hiddenFooter;
|
|
252
|
+
const footerSkipped = footerInput !== undefined && footerInput.enabled !== true ? ["footer.word_breaks"] : [];
|
|
218
253
|
const errors = items.filter((item) => item.severity === "error").length;
|
|
219
254
|
return {
|
|
220
255
|
findings: {
|
|
221
|
-
total
|
|
256
|
+
total,
|
|
222
257
|
errors,
|
|
223
|
-
warnings:
|
|
258
|
+
warnings: total - errors,
|
|
224
259
|
items: reported.items,
|
|
225
|
-
...(reported.truncated ? { truncated: true } : {}),
|
|
260
|
+
...(reported.truncated || hiddenFooter > 0 ? { truncated: true } : {}),
|
|
226
261
|
},
|
|
227
|
-
siteChecks: {
|
|
262
|
+
siteChecks: footerOnly ? {
|
|
263
|
+
ranOffline: footerInput === undefined ? [] : ["footer.word_breaks"],
|
|
264
|
+
...(footerSkipped.length === 0 ? {} : { skipped: footerSkipped }),
|
|
265
|
+
} : {
|
|
228
266
|
ranOffline: rulesRunningAt("validate"),
|
|
229
267
|
// Local values are checked above; only a deployment knows every effective fallback.
|
|
230
268
|
deferredToDeployment: [...METADATA_RULE_IDS],
|
|
@@ -241,14 +279,15 @@ export function evaluateOfflineSiteChecks({
|
|
|
241
279
|
&& rule.runsAt.includes("edit")
|
|
242
280
|
).map((rule) => rule.id),
|
|
243
281
|
// A rule that had nothing to read: a truncated page manifest, no site read for the images, or a workspace
|
|
244
|
-
// with no form files. In catalogue order.
|
|
245
|
-
...(pagesComplete && formKeysChecked && imageCheck.ran
|
|
282
|
+
// with no form files, or a disabled footer. In catalogue order.
|
|
283
|
+
...(pagesComplete && formKeysChecked && imageCheck.ran && footerSkipped.length === 0
|
|
246
284
|
? {}
|
|
247
285
|
: {
|
|
248
286
|
skipped: [
|
|
249
287
|
...(pagesComplete ? [] : ["link.page_missing"]),
|
|
250
288
|
...(imageCheck.ran ? [] : [RULE_IMAGE_DEFAULT_MISSING]),
|
|
251
289
|
...(formKeysChecked ? [] : ["form.key_unknown"]),
|
|
290
|
+
...footerSkipped,
|
|
252
291
|
],
|
|
253
292
|
}),
|
|
254
293
|
...(imageCheck.ran
|
|
@@ -257,3 +296,26 @@ export function evaluateOfflineSiteChecks({
|
|
|
257
296
|
},
|
|
258
297
|
};
|
|
259
298
|
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
/** Add one offline step without losing the evaluator's findings or coverage metadata. */
|
|
302
|
+
export function mergeOfflineSiteChecks(primary, secondary) {
|
|
303
|
+
const reported = boundedByBytes([...primary.findings.items, ...secondary.findings.items], SITE_FINDINGS_MAX_BYTES);
|
|
304
|
+
const union = name => [...new Set([...(primary.siteChecks[name] ?? []), ...(secondary.siteChecks[name] ?? [])])];
|
|
305
|
+
const skipped = union("skipped");
|
|
306
|
+
return {
|
|
307
|
+
...primary,
|
|
308
|
+
findings: {
|
|
309
|
+
total: primary.findings.total + secondary.findings.total,
|
|
310
|
+
errors: primary.findings.errors + secondary.findings.errors,
|
|
311
|
+
warnings: primary.findings.warnings + secondary.findings.warnings,
|
|
312
|
+
items: reported.items,
|
|
313
|
+
...(primary.findings.truncated || secondary.findings.truncated || reported.truncated ? { truncated: true } : {}),
|
|
314
|
+
},
|
|
315
|
+
siteChecks: {
|
|
316
|
+
...primary.siteChecks,
|
|
317
|
+
ranOffline: union("ranOffline"),
|
|
318
|
+
...(skipped.length === 0 ? {} : { skipped }),
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 2,
|
|
3
|
-
"about": "The catalogue of site checks (TR01085, TR00947). Severity: 'error' blocks a deploy, 'warning' informs. Scope: 'page' rules read one page body plus cheap site lookups, 'site' rules read the site's own records, 'document' rules read only one document and its metadata, so the editor and the CLI evaluate them from shared/page-structure-checks.ts and the generator compiles deployment advice from the same pure evaluator. runsAt names the run points that evaluate the rule: save, validate (the CLI, offline unless --site), deploy, health, edit (the editor, over the open
|
|
3
|
+
"about": "The catalogue of site checks (TR01085, TR00947). Severity: 'error' blocks a deploy, 'warning' informs. Scope: 'page' rules read one page body plus cheap site lookups, 'site' rules read the site's own records, 'document' rules read only one document and its metadata, so the editor and the CLI evaluate them from shared/page-structure-checks.ts and the generator compiles deployment advice from the same pure evaluator. runsAt names the run points that evaluate the rule: save, validate (the CLI, offline unless --site), deploy, health, edit (the page or Footer editor, over the open design in the browser). appliesTo, when present, limits a rule to those page types. subject and detail say what a finding's two values hold. The footer.word_breaks deploy check covers standard and profile sites; managed Docs sites are checked in the Footer editor and CLI. The typed registry in Taproot.Domain/SiteChecks/SiteCheckRules.cs must list the same rules; SiteCheckTests fails on a difference.",
|
|
4
4
|
"runPoints": ["save", "validate", "deploy", "health", "edit"],
|
|
5
5
|
"rules": [
|
|
6
6
|
{ "id": "link.page_missing", "severity": "warning", "scope": "page", "runsAt": ["save", "validate", "health"], "subject": "page_path", "detail": "none" },
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
{ "id": "seo.description_short", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "character_count" },
|
|
34
34
|
{ "id": "seo.description_long", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "character_count" },
|
|
35
35
|
{ "id": "seo.description_matches_title", "severity": "warning", "scope": "document", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "none", "detail": "none" },
|
|
36
|
-
{ "id": "seo.social_image_fallback", "severity": "warning", "scope": "document", "appliesTo": ["free_form"], "runsAt": ["edit"], "subject": "none", "detail": "social_image_source" }
|
|
36
|
+
{ "id": "seo.social_image_fallback", "severity": "warning", "scope": "document", "appliesTo": ["free_form"], "runsAt": ["edit"], "subject": "none", "detail": "social_image_source" },
|
|
37
|
+
{ "id": "footer.word_breaks", "severity": "warning", "scope": "site", "runsAt": ["validate", "edit", "deploy", "health"], "subject": "footer_word", "detail": "width_and_region" },
|
|
38
|
+
{ "id": "brand.logo_on_surface", "severity": "warning", "scope": "site", "runsAt": ["validate"], "subject": "surface", "detail": "scheme_and_variant" }
|
|
37
39
|
]
|
|
38
40
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Generated from shared/theme-contexts.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
/** Keep the decoded-name contract aligned with DefaultSiteTheme and the shared vectors. */
|
|
3
|
+
export const MAX_ENCODED_THEME_LENGTH = 1024 * 1024;
|
|
4
|
+
const MAX_JSON_DEPTH = 64;
|
|
5
|
+
const CONTEXT_NAME = /^[a-z][a-z0-9-]*$/u;
|
|
6
|
+
const UNSAFE_NAMES = new Set(["__proto__", "constructor", "prototype"]);
|
|
7
|
+
const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/u;
|
|
8
|
+
function isObject(value) {
|
|
9
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
/** Only declarations Espalier retains can be selected by a published surface. */
|
|
12
|
+
export function declaredThemeContextNames(theme) {
|
|
13
|
+
if (!isObject(theme) || !Object.prototype.hasOwnProperty.call(theme, "contexts") || !isObject(theme.contexts)) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const contexts = theme.contexts;
|
|
17
|
+
return Object.keys(contexts)
|
|
18
|
+
.filter(name => CONTEXT_NAME.test(name) && !UNSAFE_NAMES.has(name) && isObject(contexts[name]))
|
|
19
|
+
.sort();
|
|
20
|
+
}
|
|
21
|
+
/** Count source nesting so even an overwritten duplicate property keeps the API's limit. */
|
|
22
|
+
function withinJsonDepth(json) {
|
|
23
|
+
let depth = 0;
|
|
24
|
+
let inString = false;
|
|
25
|
+
let escaped = false;
|
|
26
|
+
for (const character of json) {
|
|
27
|
+
if (inString) {
|
|
28
|
+
if (escaped)
|
|
29
|
+
escaped = false;
|
|
30
|
+
else if (character === "\\")
|
|
31
|
+
escaped = true;
|
|
32
|
+
else if (character === "\"")
|
|
33
|
+
inString = false;
|
|
34
|
+
}
|
|
35
|
+
else if (character === "\"")
|
|
36
|
+
inString = true;
|
|
37
|
+
else if (character === "{" || character === "[") {
|
|
38
|
+
if (++depth > MAX_JSON_DEPTH)
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
else if (character === "}" || character === "]")
|
|
42
|
+
depth -= 1;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
/** The API's strict wire decoder wins over Espalier's lenient legacy decoder for declarations. */
|
|
47
|
+
function decodeContextTheme(encoded) {
|
|
48
|
+
if (typeof encoded !== "string" || encoded.length > MAX_ENCODED_THEME_LENGTH)
|
|
49
|
+
return undefined;
|
|
50
|
+
const compact = encoded.replace(/[ \t\r\n]/gu, "");
|
|
51
|
+
if (compact.length % 4 !== 0 || !BASE64.test(compact))
|
|
52
|
+
return undefined;
|
|
53
|
+
try {
|
|
54
|
+
const binary = atob(compact);
|
|
55
|
+
const bytes = Uint8Array.from(binary, character => character.charCodeAt(0));
|
|
56
|
+
const marked = bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf;
|
|
57
|
+
const payload = marked ? bytes.subarray(3) : bytes;
|
|
58
|
+
const hasNonAscii = payload.some(value => value > 0x7f);
|
|
59
|
+
if (marked !== hasNonAscii)
|
|
60
|
+
return undefined;
|
|
61
|
+
const json = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(payload);
|
|
62
|
+
return withinJsonDepth(json) ? JSON.parse(json) : undefined;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function declaredEncodedThemeContextNames(encoded) {
|
|
69
|
+
return declaredThemeContextNames(decodeContextTheme(encoded));
|
|
70
|
+
}
|
|
71
|
+
function intersection(light, dark) {
|
|
72
|
+
const other = new Set(dark);
|
|
73
|
+
return light.filter(name => other.has(name));
|
|
74
|
+
}
|
|
75
|
+
/** Workspace themes are JSON objects until the canonical encoder sends them. */
|
|
76
|
+
export function sharedDeclaredThemeContextNames(light, dark) {
|
|
77
|
+
return intersection(declaredThemeContextNames(light), declaredThemeContextNames(dark));
|
|
78
|
+
}
|
|
79
|
+
/** Stored themes share the API's decoder and declaration rules in previews and publishing. */
|
|
80
|
+
export function sharedEncodedThemeContextNames(light, dark) {
|
|
81
|
+
return intersection(declaredEncodedThemeContextNames(light), declaredEncodedThemeContextNames(dark));
|
|
82
|
+
}
|
package/src/theme-resolve.js
CHANGED
|
@@ -31,7 +31,7 @@ const THEME_SCHEMES = Object.freeze(["light", "dark"]);
|
|
|
31
31
|
let engines;
|
|
32
32
|
|
|
33
33
|
/** The fit report and color engine are Espalier modules beside the exported theme module (see espalier-shared.js). */
|
|
34
|
-
function
|
|
34
|
+
export function loadThemeEngines() {
|
|
35
35
|
engines ??= Promise.all([
|
|
36
36
|
loadEspalierShared("theme-fit-report.js"),
|
|
37
37
|
loadEspalierShared("color-engine.js"),
|
|
@@ -156,7 +156,7 @@ function describeSurface(color, report, scheme, rootSurface) {
|
|
|
156
156
|
*/
|
|
157
157
|
export async function resolveThemePair(lightTheme, darkTheme, { scheme, context } = {}) {
|
|
158
158
|
const { light, dark } = validateAndEncodeThemePair(lightTheme, darkTheme);
|
|
159
|
-
const { fit, color } = await
|
|
159
|
+
const { fit, color } = await loadThemeEngines();
|
|
160
160
|
// The stored pair is encoded and parsed back, as theme push's fit lints do, so this is what the page resolves.
|
|
161
161
|
const suite = fit.themeFitReportSuite(parseTheme(light) ?? {}, parseTheme(dark) ?? {});
|
|
162
162
|
const contexts = suite.surfaces.filter((surface) => surface !== fit.ROOT_SURFACE);
|
package/src/theme-validation.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { hasControlCharacter, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
|
|
13
13
|
import { loadEspalierShared } from "./espalier-shared.js";
|
|
14
|
+
import { sharedDeclaredThemeContextNames, sharedEncodedThemeContextNames } from "./theme-contexts.js";
|
|
14
15
|
import { proposePassingValues, refuseUnavailableFontWeights } from "./theme-proposals.js";
|
|
15
16
|
|
|
16
17
|
export const MAXIMUM_THEME_WARNINGS = 32;
|
|
@@ -99,19 +100,35 @@ export const HEADER_BRAND_COLOR_TOKENS = Object.freeze(
|
|
|
99
100
|
]),
|
|
100
101
|
);
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
103
|
+
/** Validate the complete post-save state, including an atomic repoint and context removal. */
|
|
104
|
+
export function requireSurfaceContexts({ lightTheme, darkTheme, headerContext = "", footerContext = "" }, current) {
|
|
105
|
+
const declared = new Set(sharedDeclaredThemeContextNames(lightTheme, darkTheme));
|
|
106
|
+
const previous = current === undefined ? new Set() : new Set(sharedEncodedThemeContextNames(
|
|
107
|
+
current.styleSettings?.lightTheme,
|
|
108
|
+
current.styleSettings?.darkTheme,
|
|
109
|
+
));
|
|
110
|
+
for (
|
|
111
|
+
const [surface, field, context, stored] of [
|
|
112
|
+
["header", "site-header.context", headerContext, current?.headerSettings?.context ?? ""],
|
|
113
|
+
[
|
|
114
|
+
"footer",
|
|
115
|
+
"footerSettings.context",
|
|
116
|
+
footerContext,
|
|
117
|
+
current?.sitePublishingPreferences?.footerSettings?.context ?? "",
|
|
118
|
+
],
|
|
119
|
+
]
|
|
120
|
+
) {
|
|
121
|
+
if (context === "" || declared.has(context)) continue;
|
|
122
|
+
const removingUsedContext = context === stored && previous.has(context);
|
|
123
|
+
fail(
|
|
124
|
+
removingUsedContext ? "theme.context_in_use" : "settings.context_unknown",
|
|
125
|
+
removingUsedContext
|
|
126
|
+
? `The ${surface} still uses context '${context}'. Keep it in both themes, or repoint the ${surface} in this same theme push.`
|
|
127
|
+
: `${field} must be empty or name a context declared by both lightTheme and darkTheme.`,
|
|
128
|
+
field,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
115
132
|
|
|
116
133
|
export const APPEARANCE_COLOR_CONSTRAINT = Object.freeze({
|
|
117
134
|
maximumLength: 128,
|
package/src/verbs/footer-push.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { PRESENTATION_REVISION, saveSiteFooterSettings, withRefusalGuidance } from "../api.js";
|
|
2
2
|
import { VERB_FOOTER_PUSH } from "../constants.js";
|
|
3
3
|
import { SiteAuthoringError } from "../errors.js";
|
|
4
|
+
import { FOOTER_PRESENTATION_FIELDS, projectFooterContent } from "../footer-content.js";
|
|
4
5
|
import { projectFooterSettingsForWorkspace, validateFooterDocument } from "../footer-contract.js";
|
|
5
6
|
import { computeFooterDraftHash } from "../footer-draft-hash.js";
|
|
7
|
+
import { readFooterBrandInputs } from "../footer-brand-inputs.js";
|
|
8
|
+
import { buildFooterFitInput } from "../footer-fit.js";
|
|
9
|
+
import { evaluateOfflineSiteChecks } from "../site-check-findings.js";
|
|
6
10
|
import {
|
|
7
11
|
advanceFooterManifest,
|
|
8
12
|
FOOTER_SETTINGS_FILE,
|
|
@@ -78,13 +82,20 @@ export async function footerPush(invocation) {
|
|
|
78
82
|
);
|
|
79
83
|
onProgress("Validated the complete footer document, stable page targets, and site-owned image references locally.");
|
|
80
84
|
|
|
85
|
+
const footerChecks = evaluateOfflineSiteChecks({
|
|
86
|
+
pagePaths: [],
|
|
87
|
+
footerOnly: true,
|
|
88
|
+
footerInput: buildFooterFitInput(footerSettings, await readFooterBrandInputs(config.workspaceDir, footerSettings)),
|
|
89
|
+
onProgress,
|
|
90
|
+
});
|
|
91
|
+
|
|
81
92
|
let response;
|
|
82
93
|
try {
|
|
83
94
|
response = await withRefusalGuidance(onProgress, "footer push", async () =>
|
|
84
95
|
await saveSiteFooterSettings(
|
|
85
96
|
client,
|
|
86
97
|
siteId,
|
|
87
|
-
footerSettings,
|
|
98
|
+
projectFooterContent(footerSettings),
|
|
88
99
|
context.footer.expectedDraftHash,
|
|
89
100
|
));
|
|
90
101
|
} catch (error) {
|
|
@@ -103,6 +114,10 @@ export async function footerPush(invocation) {
|
|
|
103
114
|
let footerDraftHash;
|
|
104
115
|
try {
|
|
105
116
|
saved = projectFooterSettingsForWorkspace(response.footerSettings);
|
|
117
|
+
for (const field of FOOTER_PRESENTATION_FIELDS) {
|
|
118
|
+
if (Object.hasOwn(footerSettings, field)) saved[field] = footerSettings[field];
|
|
119
|
+
else delete saved[field];
|
|
120
|
+
}
|
|
106
121
|
footerDraftHash = computeFooterDraftHash(saved);
|
|
107
122
|
const nextDocument = structuredClone(document_);
|
|
108
123
|
nextDocument.settings.footerSettings = saved;
|
|
@@ -110,14 +125,9 @@ export async function footerPush(invocation) {
|
|
|
110
125
|
// fails, a stale token prevents the next push from overwriting the saved
|
|
111
126
|
// remote footer and the completed-write report tells the caller to pull.
|
|
112
127
|
await writeWorkspaceJson(config.workspaceDir, FOOTER_SETTINGS_FILE, nextDocument);
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
// revision is the one this workspace was pulled at: otherwise the site's
|
|
117
|
-
// appearance moved since the pull, the workspace's appearance files do not
|
|
118
|
-
// reflect it, and a baseline taken from this save would let the next
|
|
119
|
-
// theme push overwrite those edits unseen. A Taproot that predates the
|
|
120
|
-
// fields leaves the recorded baseline alone.
|
|
128
|
+
// Content saves report the stored presentation revision in both fields.
|
|
129
|
+
// An equal revision is a no-op; it cannot adopt newer appearance edits
|
|
130
|
+
// that this workspace has never read. Older servers may omit the fields.
|
|
121
131
|
const baseline = readPresentationBaseline(context.manifest);
|
|
122
132
|
const reported = PRESENTATION_REVISION.test(response.presentationRevision ?? "")
|
|
123
133
|
&& PRESENTATION_REVISION.test(response.previousPresentationRevision ?? "");
|
|
@@ -140,6 +150,7 @@ export async function footerPush(invocation) {
|
|
|
140
150
|
return successResult(VERB_FOOTER_PUSH, siteId, {
|
|
141
151
|
footerFile: FOOTER_SETTINGS_FILE,
|
|
142
152
|
footerDraftHash,
|
|
153
|
+
...footerChecks,
|
|
143
154
|
written: { items: ["footerSettings"], count: 1 },
|
|
144
155
|
});
|
|
145
156
|
}
|
package/src/verbs/plan.js
CHANGED
|
@@ -100,7 +100,7 @@ const STEP_REASONS = Object.freeze({
|
|
|
100
100
|
[PLAN_STEP.media]: "Pages resolve their media references against the uploads this step records.",
|
|
101
101
|
[PLAN_STEP.pages]: "Navigation and the footer can point only at pages the site already holds.",
|
|
102
102
|
[PLAN_STEP.footer]: "theme push refuses while the footer document carries unsaved content.",
|
|
103
|
-
[PLAN_STEP.theme]: "The theme saves the footer
|
|
103
|
+
[PLAN_STEP.theme]: "The theme saves the footer context with the rest of the presentation.",
|
|
104
104
|
[PLAN_STEP.navigation]: "Navigation replaces the whole tree, so it goes last, once its targets exist.",
|
|
105
105
|
});
|
|
106
106
|
const READY = "ready";
|
|
@@ -468,7 +468,7 @@ function planReport(planned) {
|
|
|
468
468
|
checked: [
|
|
469
469
|
"every page source, against the live site's pages, revisions, video library, and the forms it places",
|
|
470
470
|
"media under media/ that pages reference and media upload has not sent",
|
|
471
|
-
"the theme, appearance, and
|
|
471
|
+
"the theme, appearance, and surface contexts, against the site's presentation revision",
|
|
472
472
|
"the footer document, against the site's footer draft and the pages it still holds",
|
|
473
473
|
"every image the theme and footer name, and every recorded upload, against the site's images",
|
|
474
474
|
"navigation shape and page targets, against the live page list and navigation",
|