@taprootio/site-authoring 0.55.0 → 0.59.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 +91 -22
- package/package.json +2 -2
- package/src/api.js +90 -17
- package/src/authors-contract.js +71 -3
- package/src/block-flow.js +4 -2
- package/src/changelog.json +104 -0
- package/src/chrome-additions.js +106 -0
- package/src/chrome-features.js +43 -10
- package/src/chrome-input.js +137 -30
- package/src/chrome-report.js +4 -2
- package/src/cli.js +144 -38
- package/src/constants.js +1 -0
- package/src/content/button-styles.js +27 -0
- package/src/content/components.js +76 -10
- package/src/content/free-form-section-registry.json +9 -0
- package/src/content/free-form-sections.js +55 -16
- package/src/content/markdown.js +133 -56
- package/src/content/media-presentation.js +37 -0
- package/src/content/tiptap-prosemirror.ts +26 -10
- package/src/credentials.js +2 -1
- package/src/delivery-check.js +10 -2
- package/src/font-catalog.js +9 -6
- package/src/footer-content.js +1 -1
- package/src/footer-contract.js +3 -0
- package/src/footer-draft-hash.js +1 -0
- package/src/heading-outline.js +94 -6
- package/src/image-description-contract.js +5 -3
- package/src/image-description-write.js +26 -0
- package/src/index.js +1 -0
- package/src/output.js +2 -1
- package/src/page-metadata.js +15 -13
- package/src/page-structure-checks.js +14 -25
- package/src/placed-image-ids.js +42 -17
- package/src/presentation-reference.js +63 -18
- package/src/problems.js +147 -4
- package/src/reference-help.js +122 -60
- package/src/site-check-findings.js +2 -3
- package/src/site-check-rules.json +0 -1
- package/src/site-health-findings.js +7 -9
- package/src/site-health-image-checks.js +4 -1
- package/src/site-health-precheck.js +23 -6
- package/src/site-navigation-groups.js +16 -0
- package/src/status-warning-paints.js +175 -0
- package/src/template-token-reach.json +13 -18
- package/src/theme-proposals.js +143 -55
- package/src/theme-resolve.js +14 -1
- package/src/theme-validation.js +70 -38
- package/src/token-reach.js +20 -0
- package/src/typed-page-reference.js +25 -3
- package/src/typed-pages.js +73 -14
- package/src/verbs/authors.js +198 -33
- package/src/verbs/changelog.js +23 -2
- package/src/verbs/delivery-check.js +43 -9
- package/src/verbs/index.js +4 -2
- package/src/verbs/media-images.js +4 -4
- package/src/verbs/pages-push.js +138 -67
- package/src/verbs/plan.js +28 -20
- package/src/verbs/pull.js +226 -26
- package/src/verbs/theme-push.js +59 -15
- package/src/verbs/theme-resolve.js +109 -11
- package/src/verbs/validate.js +97 -16
- package/src/workspace-check.js +4 -4
- package/src/workspace-context-usage.js +180 -0
- package/src/workspace.js +48 -1
- package/test/fixtures/default-site-theme.json +1 -1
package/src/heading-outline.js
CHANGED
|
@@ -64,13 +64,101 @@ export function bannerOpensPage(state, data) {
|
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* The level of the heading a hero or CTA component fixes on the page, or
|
|
67
|
-
* undefined when the component carries none
|
|
68
|
-
*
|
|
67
|
+
* undefined when the component carries none (a blank title or heading renders
|
|
68
|
+
* no element and claims nothing). A CTA heading is an h2. A hero title is the
|
|
69
|
+
* page's h1 unless an earlier element already claimed it, then an h2 (TR01424);
|
|
70
|
+
* with no outline to ask, it is the h1.
|
|
69
71
|
*/
|
|
70
|
-
export function componentFixedHeadingLevel(type, data) {
|
|
71
|
-
if (type === "hero-section" && data.title)
|
|
72
|
-
return 1;
|
|
73
|
-
if (type === "cta" && data.heading)
|
|
72
|
+
export function componentFixedHeadingLevel(type, data, state) {
|
|
73
|
+
if (type === "hero-section" && nonBlank(data.title))
|
|
74
|
+
return state?.titleClaimed ? 2 : 1;
|
|
75
|
+
if (type === "cta" && nonBlank(data.heading))
|
|
74
76
|
return 2;
|
|
75
77
|
return undefined;
|
|
76
78
|
}
|
|
79
|
+
function nonBlank(value) {
|
|
80
|
+
return typeof value === "string" && value.trim() !== "";
|
|
81
|
+
}
|
|
82
|
+
// Elements whose content is text, not markup, so a tag inside is not a real tag.
|
|
83
|
+
const RAW_TEXT = new Set([
|
|
84
|
+
"script",
|
|
85
|
+
"style",
|
|
86
|
+
"textarea",
|
|
87
|
+
"title",
|
|
88
|
+
"noscript",
|
|
89
|
+
"iframe",
|
|
90
|
+
"xmp",
|
|
91
|
+
"noembed",
|
|
92
|
+
"noframes",
|
|
93
|
+
"plaintext",
|
|
94
|
+
]);
|
|
95
|
+
/**
|
|
96
|
+
* Whether markup holds a real `<h1>` opening tag. The scan is quote-aware, so
|
|
97
|
+
* `<h1>` inside an attribute value (a `title="<h1>"`), a comment or a script is
|
|
98
|
+
* not one (TR01424). The publisher and the page-structure checks both use it to
|
|
99
|
+
* decide whether an adopted fragment claims the page title.
|
|
100
|
+
*/
|
|
101
|
+
export function htmlOpensH1(html) {
|
|
102
|
+
let cursor = 0;
|
|
103
|
+
// A declarative shadow template's content is not light DOM, so an h1 in it
|
|
104
|
+
// does not claim the page title. Templates nest, so count them.
|
|
105
|
+
let templateDepth = 0;
|
|
106
|
+
while (cursor < html.length) {
|
|
107
|
+
const open = html.indexOf("<", cursor);
|
|
108
|
+
if (open < 0)
|
|
109
|
+
return false;
|
|
110
|
+
if (html.startsWith("<!--", open)) {
|
|
111
|
+
const end = html.indexOf("-->", open + 4);
|
|
112
|
+
if (end < 0)
|
|
113
|
+
return false;
|
|
114
|
+
cursor = end + 3;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const closing = html[open + 1] === "/";
|
|
118
|
+
const nameStart = open + (closing ? 2 : 1);
|
|
119
|
+
// A tag name ends at whitespace, "/", ">" or the end of the input, so
|
|
120
|
+
// `<h1_x>` and `<h1:x>` are other elements, not an h1.
|
|
121
|
+
const name = /^[a-z][^\s/>]*/iu.exec(html.slice(nameStart, nameStart + 64))?.[0]?.toLowerCase();
|
|
122
|
+
if (!name) {
|
|
123
|
+
cursor = open + 1;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
// Find the tag's end outside quoted attribute values.
|
|
127
|
+
let end = nameStart + name.length;
|
|
128
|
+
let quote = "";
|
|
129
|
+
for (; end < html.length; end++) {
|
|
130
|
+
const character = html[end];
|
|
131
|
+
if (quote) {
|
|
132
|
+
if (character === quote)
|
|
133
|
+
quote = "";
|
|
134
|
+
}
|
|
135
|
+
else if (character === "\"" || character === "'")
|
|
136
|
+
quote = character;
|
|
137
|
+
else if (character === ">")
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
cursor = end + 1;
|
|
141
|
+
if (closing) {
|
|
142
|
+
if (name === "template" && templateDepth > 0)
|
|
143
|
+
templateDepth--;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (name === "h1" && templateDepth === 0)
|
|
147
|
+
return true;
|
|
148
|
+
if (name === "template")
|
|
149
|
+
templateDepth++;
|
|
150
|
+
else if (RAW_TEXT.has(name)) {
|
|
151
|
+
const close = endTagIndex(html, name, cursor);
|
|
152
|
+
if (close < 0)
|
|
153
|
+
return false;
|
|
154
|
+
cursor = close;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
/** The index of the next `</name` at or after `from`, matched case-insensitively, or -1. */
|
|
160
|
+
function endTagIndex(html, name, from) {
|
|
161
|
+
const pattern = new RegExp(`</${name}`, "giu");
|
|
162
|
+
pattern.lastIndex = from;
|
|
163
|
+
return pattern.exec(html)?.index ?? -1;
|
|
164
|
+
}
|
|
@@ -56,13 +56,15 @@ export function imageDescriptionOptions(invocation = {}) {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
const expectedRevision = normalizeImageDescriptionRevision(invocation.expectedRevision);
|
|
59
|
-
|
|
59
|
+
const onlyIfMissing = invocation.onlyIfMissing === true;
|
|
60
|
+
// --if-missing without a revision reads the image first, so the write still carries the revision it saw.
|
|
61
|
+
if (expectedRevision === undefined && (invocation.expectedRevision !== undefined || !onlyIfMissing)) {
|
|
60
62
|
throw new SiteAuthoringError("media.image_revision_required",
|
|
61
|
-
"Supply --expected-revision from the image's list/get result, as a nonnegative int64 decimal integer
|
|
63
|
+
"Supply --expected-revision from the image's list/get result, as a nonnegative int64 decimal integer, "
|
|
64
|
+
+ "or pass --if-missing alone to write at the revision the CLI reads.", {
|
|
62
65
|
field: "expectedRevision", exitCode: 2,
|
|
63
66
|
});
|
|
64
67
|
}
|
|
65
|
-
const onlyIfMissing = invocation.onlyIfMissing === true;
|
|
66
68
|
if (onlyIfMissing && description.trim() === "") {
|
|
67
69
|
throw new SiteAuthoringError("media.image_condition_clear", "--if-missing cannot clear a description.", {
|
|
68
70
|
field: "onlyIfMissing", exitCode: 2,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getSiteImageDescription, updateSiteImageDescription } from "./api.js";
|
|
2
|
+
import { SiteAuthoringError } from "./errors.js";
|
|
3
|
+
|
|
4
|
+
export function imageDescriptionExistsError(status) {
|
|
5
|
+
return new SiteAuthoringError("media.image_description_exists", "This image already has a default description; nothing changed.", {
|
|
6
|
+
field: "onlyIfMissing",
|
|
7
|
+
...(status === undefined ? {} : { status }),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The one description write (TR01417). A caller that already read the image passes its revision. Without
|
|
13
|
+
* one, the current image is read first: `onlyIfMissing` then refuses text that is already there before any
|
|
14
|
+
* write, and the write carries the revision just read, so a change in between is still refused by the server.
|
|
15
|
+
*/
|
|
16
|
+
export async function writeImageDescription(client, siteId, imageId, { defaultDescription, onlyIfMissing, expectedRevision }) {
|
|
17
|
+
let revision = expectedRevision;
|
|
18
|
+
if (revision === undefined) {
|
|
19
|
+
const current = await getSiteImageDescription(client, siteId, imageId);
|
|
20
|
+
if (onlyIfMissing && typeof current.defaultDescription === "string" && current.defaultDescription.trim() !== "") {
|
|
21
|
+
throw imageDescriptionExistsError();
|
|
22
|
+
}
|
|
23
|
+
revision = current.descriptionRevision;
|
|
24
|
+
}
|
|
25
|
+
return await updateSiteImageDescription(client, siteId, imageId, { defaultDescription, expectedRevision: revision, onlyIfMissing });
|
|
26
|
+
}
|
package/src/index.js
CHANGED
package/src/output.js
CHANGED
|
@@ -198,7 +198,8 @@ export function humanFailure(error) {
|
|
|
198
198
|
? ` refusal=${sanitizeDiagnostic(kind, "unknown")}`
|
|
199
199
|
: "";
|
|
200
200
|
const details = error.details?.map((item) => `${item.field}: ${item.message}`).join("\n");
|
|
201
|
-
|
|
201
|
+
// A lone problem is listed only when it has a source line, since the summary line has no room for the file.
|
|
202
|
+
const problems = error.problems?.length > 1 || error.problems?.[0]?.line !== undefined
|
|
202
203
|
? error.problems.map((problem) => ` ${problemLocation(problem)} [${problem.code}]: ${problem.message}`).join("\n")
|
|
203
204
|
: undefined;
|
|
204
205
|
return `${CLI_BINARY_NAME} failed [${error.code}]${field}${status}${refusal}: ${sanitizeDiagnostic(error.message)}`
|
package/src/page-metadata.js
CHANGED
|
@@ -57,28 +57,30 @@ export function descriptionWarnings(pages, onProgress) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export const PAGE_AUTHOR_UNVERIFIED = "pages.author_unverified";
|
|
60
|
+
export const PAGE_DISPLAY_AUTHOR_UNVERIFIED = "pages.display_author_unverified";
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* Warnings for authors an offline run could not confirm (TR01196). The only
|
|
63
64
|
* evidence offline is `authors.json`, which is as old as the last `pull` or
|
|
64
65
|
* `authors list`, so a name missing from it may simply be newer; it is flagged
|
|
65
|
-
* rather than refused, and an online run settles it against the site.
|
|
66
|
+
* rather than refused, and an online run settles it against the site. A display
|
|
67
|
+
* author's handle (TR01402) is held to the same evidence and has its own code.
|
|
66
68
|
*/
|
|
67
69
|
export function authorWarnings(pages, onProgress) {
|
|
68
70
|
const items = [];
|
|
69
71
|
for (const page of pages ?? []) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
for (const [flag, code, label, name] of [
|
|
73
|
+
[page.authorUnverified, PAGE_AUTHOR_UNVERIFIED, "author", page.author],
|
|
74
|
+
[page.displayAuthorUnverified, PAGE_DISPLAY_AUTHOR_UNVERIFIED, "displayAuthor", page.document?.displayAuthor],
|
|
75
|
+
]) {
|
|
76
|
+
if (flag !== true) continue;
|
|
77
|
+
const item = { code, file: page.file, path: displayPagePath(page.pagePath ?? page.path), author: name };
|
|
78
|
+
onProgress(
|
|
79
|
+
`Warning: ${item.file} names ${label} '${item.author}', who is not in authors.json; it may have been added `
|
|
80
|
+
+ "since. 'taproot-site authors list' refreshes it, and 'pages push' checks the name against the site.",
|
|
81
|
+
);
|
|
82
|
+
items.push(item);
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
const reported = boundedByBytes(items, 8 * 1024);
|
|
84
86
|
return items.length === 0
|
|
@@ -20,10 +20,9 @@
|
|
|
20
20
|
* can carry copies. `node scripts/sync-field-validation.mjs` writes them; edit
|
|
21
21
|
* only this file and re-run it.
|
|
22
22
|
*/
|
|
23
|
-
import { bannerOpensPage, componentFixedHeadingLevel, createHeadingOutlineState, nextHeadingLevel, recordFixedHeading, } from "./heading-outline.js";
|
|
23
|
+
import { bannerOpensPage, componentFixedHeadingLevel, createHeadingOutlineState, htmlOpensH1, nextHeadingLevel, recordFixedHeading, } from "./heading-outline.js";
|
|
24
24
|
export const RULE_H1_MISSING = "seo.h1_missing";
|
|
25
25
|
export const RULE_H1_DEMOTED = "seo.h1_demoted";
|
|
26
|
-
export const RULE_H1_MULTIPLE = "seo.h1_multiple";
|
|
27
26
|
export const RULE_HEADING_RENUMBERED = "seo.heading_renumbered";
|
|
28
27
|
export const RULE_HEADING_BEFORE_TITLE = "seo.heading_before_title";
|
|
29
28
|
// Image completeness is assessed from frozen library defaults during deployment.
|
|
@@ -41,7 +40,6 @@ export const RULE_SOCIAL_IMAGE_FALLBACK = "seo.social_image_fallback";
|
|
|
41
40
|
const RULE_ORDER = [
|
|
42
41
|
RULE_H1_MISSING,
|
|
43
42
|
RULE_H1_DEMOTED,
|
|
44
|
-
RULE_H1_MULTIPLE,
|
|
45
43
|
RULE_HEADING_RENUMBERED,
|
|
46
44
|
RULE_HEADING_BEFORE_TITLE,
|
|
47
45
|
RULE_LINK_TEXT_EMPTY,
|
|
@@ -136,13 +134,10 @@ function walkBody(body) {
|
|
|
136
134
|
const findings = [];
|
|
137
135
|
// Findings about headings wait for the whole walk: whether the page has an h1 is known only at the end.
|
|
138
136
|
const headings = [];
|
|
139
|
-
const extraTitles = [];
|
|
140
137
|
const outline = createHeadingOutlineState({ titleOpen: true });
|
|
141
138
|
let claimant;
|
|
142
139
|
let imageCount = 0;
|
|
143
140
|
let hasContent = false;
|
|
144
|
-
// Adopted integration markup is opaque here; it may hold the page's own h1.
|
|
145
|
-
let opaqueH1 = false;
|
|
146
141
|
const seeContent = () => {
|
|
147
142
|
hasContent = true;
|
|
148
143
|
outline.titleOpen = false;
|
|
@@ -201,7 +196,7 @@ function walkBody(body) {
|
|
|
201
196
|
const data = componentData(node);
|
|
202
197
|
// The banner decides whether it is the title before the page counts it as content.
|
|
203
198
|
const opensPage = type === "image-banner" && bannerOpensPage(outline, data);
|
|
204
|
-
const fixedLevel = componentFixedHeadingLevel(type, data);
|
|
199
|
+
const fixedLevel = componentFixedHeadingLevel(type, data, outline);
|
|
205
200
|
if (type === "image-banner" && imageSource(data.image)) {
|
|
206
201
|
imageCount++;
|
|
207
202
|
}
|
|
@@ -213,13 +208,14 @@ function walkBody(body) {
|
|
|
213
208
|
recordFixedHeading(outline, 1);
|
|
214
209
|
claimant = { kind: "banner", text: clip(String(data.overlayText)) };
|
|
215
210
|
}
|
|
216
|
-
else if (
|
|
211
|
+
else if (type === "hero-section" && fixedLevel !== undefined) {
|
|
212
|
+
// A hero title is the page's h1 unless something already claimed it, then an h2 (TR01424).
|
|
217
213
|
const text = clip(String(data.title));
|
|
218
|
-
if (
|
|
219
|
-
extraTitles.push({ path, text });
|
|
220
|
-
else
|
|
214
|
+
if (fixedLevel === 1)
|
|
221
215
|
claimant = { kind: "hero", text };
|
|
222
|
-
|
|
216
|
+
else
|
|
217
|
+
headings.push({ path, text, authored: 1, level: 2, role: "demoted" });
|
|
218
|
+
recordFixedHeading(outline, fixedLevel);
|
|
223
219
|
}
|
|
224
220
|
else if (fixedLevel !== undefined) {
|
|
225
221
|
recordFixedHeading(outline, fixedLevel);
|
|
@@ -240,12 +236,14 @@ function walkBody(body) {
|
|
|
240
236
|
return;
|
|
241
237
|
case "integrationFragment": {
|
|
242
238
|
// The publisher treats an adopted fragment with markup as content before a banner, and its bytes may
|
|
243
|
-
// carry the page's own `<h1>`, which
|
|
239
|
+
// carry the page's own `<h1>`, which then claims the title (TR01424).
|
|
244
240
|
const html = node.attrs?.html;
|
|
245
241
|
if (nonBlank(html)) {
|
|
246
242
|
seeContent();
|
|
247
|
-
if (
|
|
248
|
-
|
|
243
|
+
if (htmlOpensH1(html)) {
|
|
244
|
+
claimant ??= { kind: "fragment", text: "" };
|
|
245
|
+
outline.titleClaimed = true;
|
|
246
|
+
}
|
|
249
247
|
}
|
|
250
248
|
return;
|
|
251
249
|
}
|
|
@@ -264,7 +262,7 @@ function walkBody(body) {
|
|
|
264
262
|
children(body).forEach((child, index) => visit(child, [index], 1));
|
|
265
263
|
if (claimant === undefined) {
|
|
266
264
|
// A page with nothing on it has nothing to title yet.
|
|
267
|
-
if (hasContent
|
|
265
|
+
if (hasContent) {
|
|
268
266
|
findings.unshift({ ruleId: RULE_H1_MISSING, severity: "warning", subject: "", detail: "" });
|
|
269
267
|
}
|
|
270
268
|
}
|
|
@@ -303,15 +301,6 @@ function walkBody(body) {
|
|
|
303
301
|
});
|
|
304
302
|
}
|
|
305
303
|
}
|
|
306
|
-
for (const title of extraTitles) {
|
|
307
|
-
findings.push({
|
|
308
|
-
ruleId: RULE_H1_MULTIPLE,
|
|
309
|
-
severity: "warning",
|
|
310
|
-
subject: title.text,
|
|
311
|
-
detail: kind,
|
|
312
|
-
path: title.path,
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
304
|
}
|
|
316
305
|
return { findings, imageCount, hasContent };
|
|
317
306
|
}
|
package/src/placed-image-ids.js
CHANGED
|
@@ -17,8 +17,13 @@
|
|
|
17
17
|
* - the `Guid.TryParse` X format (`{0x...}`), and the numeric entities .NET also decodes with a sign or
|
|
18
18
|
* whitespace (`&#+34;`, `&# 34;`).
|
|
19
19
|
*
|
|
20
|
-
* It
|
|
21
|
-
*
|
|
20
|
+
* It also reports which ids are placed only as a section decoration (`decorationOnlyImageIds`): C#'s `Extract` returns ids only, so the roles are a
|
|
21
|
+
* TypeScript-only reading of the same walk, and an image placed only as a section decoration needs no description
|
|
22
|
+
* (TR01421).
|
|
23
|
+
*
|
|
24
|
+
* It is dependency-free so the published site-authoring package can carry a compiled copy. The generator's Site
|
|
25
|
+
* Health and the CLI use it, so `node scripts/sync-field-validation.mjs` writes both copies; edit only this file
|
|
26
|
+
* and re-run it.
|
|
22
27
|
*/
|
|
23
28
|
/** Matches the depth the link extractors use, so a hostile body cannot overflow the stack. */
|
|
24
29
|
const MAXIMUM_DEPTH = 256;
|
|
@@ -83,16 +88,21 @@ function isDictionary(value) {
|
|
|
83
88
|
function own(dictionary, key) {
|
|
84
89
|
return Object.hasOwn(dictionary, key) ? dictionary[key] : undefined;
|
|
85
90
|
}
|
|
86
|
-
function addGuid(
|
|
91
|
+
function addGuid(placements, value, role = "content") {
|
|
87
92
|
const guid = parseGuid(value);
|
|
88
|
-
if (guid
|
|
89
|
-
|
|
93
|
+
if (guid === undefined)
|
|
94
|
+
return;
|
|
95
|
+
const roles = placements.get(guid);
|
|
96
|
+
if (roles === undefined)
|
|
97
|
+
placements.set(guid, new Set([role]));
|
|
98
|
+
else
|
|
99
|
+
roles.add(role);
|
|
90
100
|
}
|
|
91
101
|
/** The id in `parent[property].imageId`, when `parent[property]` is an object. */
|
|
92
|
-
function addProcessedImage(
|
|
102
|
+
function addProcessedImage(placements, parent, property, role = "content") {
|
|
93
103
|
const image = own(parent, property);
|
|
94
104
|
if (isDictionary(image) && typeof own(image, "imageId") === "string")
|
|
95
|
-
addGuid(
|
|
105
|
+
addGuid(placements, own(image, "imageId"), role);
|
|
96
106
|
}
|
|
97
107
|
/** The nodes of one body that name an image: what `AddImageIdsFromProseMirrorJson` reads at each node. */
|
|
98
108
|
function addNodeImages(ids, node) {
|
|
@@ -103,7 +113,7 @@ function addNodeImages(ids, node) {
|
|
|
103
113
|
if (type === "section") {
|
|
104
114
|
const decoration = own(attributes, "decoration");
|
|
105
115
|
if (isDictionary(decoration))
|
|
106
|
-
addProcessedImage(ids, decoration, "image");
|
|
116
|
+
addProcessedImage(ids, decoration, "image", "decoration");
|
|
107
117
|
const background = own(attributes, "background");
|
|
108
118
|
if (isDictionary(background)) {
|
|
109
119
|
addProcessedImage(ids, background, "image");
|
|
@@ -214,14 +224,9 @@ function templateBodies(templateType, data) {
|
|
|
214
224
|
return [];
|
|
215
225
|
}
|
|
216
226
|
}
|
|
217
|
-
/**
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
* other value, including `integration-managed`, returns an empty list. `data` is the wire form's data member (the
|
|
221
|
-
* `[dataKey]` member of `wireTemplate(document)`), never the wrapper. The caller adds the cover image separately.
|
|
222
|
-
*/
|
|
223
|
-
export function placedImageIds(templateType, data) {
|
|
224
|
-
const ids = new Set();
|
|
227
|
+
/** Every placement of a page, by lowercase id, each with the roles it plays. */
|
|
228
|
+
function readPlacements(templateType, data) {
|
|
229
|
+
const ids = new Map();
|
|
225
230
|
try {
|
|
226
231
|
if (isDictionary(data)) {
|
|
227
232
|
for (const body of templateBodies(templateType, data))
|
|
@@ -239,5 +244,25 @@ export function placedImageIds(templateType, data) {
|
|
|
239
244
|
catch {
|
|
240
245
|
// Never throw: an unreadable shape returns what the walk had reached.
|
|
241
246
|
}
|
|
242
|
-
return
|
|
247
|
+
return ids;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The image ids a page places, as a sorted, de-duplicated array of lowercase hyphenated GUIDs. `templateType` is a
|
|
251
|
+
* workspace template name (`free-form`, `article`, `recipe`, `album`, `place-review`, `legal` or `generated`); any
|
|
252
|
+
* other value, including `integration-managed`, returns an empty list. `data` is the wire form's data member (the
|
|
253
|
+
* `[dataKey]` member of `wireTemplate(document)`), never the wrapper. The caller adds the cover image separately.
|
|
254
|
+
*/
|
|
255
|
+
export function placedImageIds(templateType, data) {
|
|
256
|
+
return [...readPlacements(templateType, data).keys()].sort();
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* The ids `placedImageIds` returns that a page places only as a section decoration. An id also placed as content
|
|
260
|
+
* on the same page is not listed. The caller still has to remove an id the page also uses outside its body (the
|
|
261
|
+
* cover, an integration), which this walk cannot see.
|
|
262
|
+
*/
|
|
263
|
+
export function decorationOnlyImageIds(templateType, data) {
|
|
264
|
+
return [...readPlacements(templateType, data)]
|
|
265
|
+
.filter(([, roles]) => !roles.has("content"))
|
|
266
|
+
.map(([imageId]) => imageId)
|
|
267
|
+
.sort();
|
|
243
268
|
}
|
|
@@ -300,8 +300,17 @@ const THEME_GROUPS = Object.freeze([
|
|
|
300
300
|
"How strongly the page background image shows, from 0 (invisible) to 1 (fully opaque).",
|
|
301
301
|
{ minimum: 0, maximum: 1 },
|
|
302
302
|
),
|
|
303
|
-
themeField(
|
|
304
|
-
|
|
303
|
+
themeField(
|
|
304
|
+
"boxBackgroundImage",
|
|
305
|
+
"Optional background image on every box, painted above each box's fill. A component that sets its own box "
|
|
306
|
+
+ "background (--esp-box-background) shows that instead; no Taproot template does. Removing "
|
|
307
|
+
+ "boxBackgroundImage removes the image.",
|
|
308
|
+
),
|
|
309
|
+
themeField(
|
|
310
|
+
"boxBackgroundImageOpacity",
|
|
311
|
+
"How strongly the box background image shows, from 0 (invisible) to 1 (fully opaque), fading it over each box's fill.",
|
|
312
|
+
{ minimum: 0, maximum: 1 },
|
|
313
|
+
),
|
|
305
314
|
themeField("vellumOpacity", "Optional modal-vellum opacity.", { minimum: 0, maximum: 1 }),
|
|
306
315
|
themeField("vellumBackgroundImage", "Optional inherited vellum background image."),
|
|
307
316
|
themeField("vellumBackgroundImageOpacity", "Optional vellum image opacity.", { minimum: 0, maximum: 1 }),
|
|
@@ -368,7 +377,9 @@ export const ROLE_RESOLUTION = Object.freeze({
|
|
|
368
377
|
"Otherwise the Espalier default mapping applies.",
|
|
369
378
|
"A context rebinds roles, lightness, tones and pins for one zone with the same precedence inside that zone. A root "
|
|
370
379
|
+ "pin applies inside every context unless that context pins the token itself. theme resolve shows the inherited "
|
|
371
|
-
+ "pin as inherited_pin."
|
|
380
|
+
+ "pin as inherited_pin. A root layer pin therefore reaches the header and footer contexts and the header drawer "
|
|
381
|
+
+ "(the header bar and footer paint their context's layer2, the drawer and vertical rail paint layer1) unless that "
|
|
382
|
+
+ "context pins the layer itself.",
|
|
372
383
|
]),
|
|
373
384
|
});
|
|
374
385
|
|
|
@@ -413,10 +424,18 @@ function assertExampleContrast(theme, scheme) {
|
|
|
413
424
|
|
|
414
425
|
const HEADING_AND_QUOTE_COLORS = Object.freeze([
|
|
415
426
|
"Per-level colors apply to native h1–h4 under esp-root, including prose, folder, archive, not-found, docs, and profile headings. The published page title uses the h1 color and the recipe card title uses the h2 color. Ingredients and group headings use their own rendered levels.",
|
|
416
|
-
"Light-DOM component headings can inherit those colors, such as a slotted product-grid title. Component shadow headings and locally styled chrome headings keep the semantic headings color.",
|
|
427
|
+
"Light-DOM component headings can inherit those colors, such as a slotted product-grid title. Component shadow headings and locally styled chrome headings keep the semantic headings color. This is guidance about the per-level heading tokens: --esp-footer-heading-color sets the footer heading ink.",
|
|
417
428
|
"The editor and app draft preview color an authored h3 as h3. If publishing normalizes it to h2, the published page uses the h2 color.",
|
|
418
|
-
"Set --esp-blockquote-bar-color for the quote bar and --esp-blockquote-glyph-color for the glyph. The glyph follows the bar when unset. The quote fill
|
|
419
|
-
"Espalier measures heading overrides against the scheme or context background at APCA Lc 60. The recipe card paints on layer1, where the same heading may have lower contrast.",
|
|
429
|
+
"Set --esp-blockquote-bar-color for the quote bar and --esp-blockquote-glyph-color for the glyph. The glyph follows the bar when unset. --esp-blockquote-font-family sets the font of the quote's own paragraphs and lists. The quote fill defaults to layer 1, and --esp-blockquote-surface (layer1, layer2 or background) sets it.",
|
|
430
|
+
"Espalier measures the native --esp-heading-N-color overrides against the scheme or context background at APCA Lc 60. The footer heading color is checked at WCAG 4.5:1 against the footer surface, or against the heading fill when one is set. The recipe card paints on layer1, where the same heading may have lower contrast.",
|
|
431
|
+
]);
|
|
432
|
+
|
|
433
|
+
/** TR01414: one elevation scale; components take a level, never their own geometry. */
|
|
434
|
+
const ELEVATION_RULE = Object.freeze([
|
|
435
|
+
"Shadows have three levels, --esp-shadow-1 to --esp-shadow-3. A scheme root or a context sets each level's offsets and blur with --esp-shadow-N-geometry (an inline offset, a block offset and an optional blur), and every consumer of that level there follows. --esp-button-shadow-color recolors the theme elevation levels used for button rest and hover; other elevations and the focus glow keep the theme's shadow color, and a raw CSS shadow keeps its declared color. An outline button casts the theme shadow only when the theme sets --esp-button-outline-background in componentProperties.",
|
|
436
|
+
"A component that takes a shadow takes a level (none, 1, 2 or 3), never its own geometry: --esp-box-shadow and --esp-button-shadow are examples. Raised and elevated sections, boxes and cards read the same levels.",
|
|
437
|
+
"A card grid with interaction press rests on level 2, moves 0.125rem toward its shadow on hover and shows level 1, and moves 0.25rem with no shadow when pressed. It looks like a press when levels 1 and 2 are hard offsets, so set the geometry to match the steps.",
|
|
438
|
+
'Example componentProperties for a hard-offset look: {"--esp-shadow-1-geometry": "2px 2px 0", "--esp-shadow-2-geometry": "4px 4px 0"}.',
|
|
420
439
|
]);
|
|
421
440
|
|
|
422
441
|
export function getThemeReference() {
|
|
@@ -432,6 +451,7 @@ export function getThemeReference() {
|
|
|
432
451
|
groups: THEME_GROUPS,
|
|
433
452
|
componentProperties: structuredClone(getSettableComponentProperties()),
|
|
434
453
|
headingAndQuoteColors: HEADING_AND_QUOTE_COLORS,
|
|
454
|
+
elevationRule: ELEVATION_RULE,
|
|
435
455
|
vocabulary: {
|
|
436
456
|
roles: ROLE_NAMES,
|
|
437
457
|
colorSources: COLOR_SOURCES,
|
|
@@ -452,9 +472,27 @@ export function getThemeReference() {
|
|
|
452
472
|
"Add named contexts for whole zones, including inverted zones, and rebind lightness when the zone changes brightness. A context that declares its own action needs its own actionBackground pin: without one it compiles at the engine's mid-band stop, and where the root is pinned it carries the root's pin instead, whatever action colour the context declares.",
|
|
453
473
|
"Tune typography, type/space ratios, radii, and viewport interpolation as one layout system.",
|
|
454
474
|
"Typography is per scheme on purpose: light and dark set their own moods, so a heading, body, or brand face that differs between them is a design choice, and theme push never warns about it.",
|
|
455
|
-
"Retune danger/success/warning/info through intents without changing their meanings; design data palettes separately."
|
|
475
|
+
"Retune danger/success/warning/info through intents without changing their meanings; design data palettes separately. "
|
|
476
|
+
+ "Espalier compares the four statuses and the action color as action fills: each is re-rendered at the action color's lightness stop and "
|
|
477
|
+
+ "the actionBackground chroma band, and two that land closer than 0.045 apart in OKLab (ΔE-OK) raise a 'Status colors' warning. "
|
|
478
|
+
+ "Intents are set once per scheme and every context inherits them; a context cannot set its own, so a warning that starts with "
|
|
479
|
+
+ "'contexts.<name>:' and involves action is fixed by that context's action color (the advice names the field), or left alone; one "
|
|
480
|
+
+ "between two statuses is retuned through root intents and applies to every zone. A context that "
|
|
481
|
+
+ "renders no status UI, such as a decorative band, can keep its warning: it is advisory, and each status warning lists the "
|
|
482
|
+
+ "components that paint that color in statusWarningPaints (statusWarningPaintsOmitted counts warnings left out). A proposal keeps a status within 16 degrees of its hue; when none "
|
|
483
|
+
+ "clears the warning it says so and names the action lightness stop, the chroma band and the other family as the levers.",
|
|
484
|
+
"A status warning for a named context also says what in the workspace uses that context. usedBy counts the header, "
|
|
485
|
+
+ "the footer, and the sections and calls to action that name it (usedBy: null means nothing was found). The first record of "
|
|
486
|
+
+ "each warning adds usedIn: { items: [{ file, kind, position }], total, truncated }, where kind is section or cta and position is "
|
|
487
|
+
+ "the 1-based ordinal among all of the page's sections (or calls to action), with or without a context, in document order. "
|
|
488
|
+
+ "items holds at most 20 rows, in page-walk order, and total is the full count. A page counts only when it reads, converts and passes "
|
|
489
|
+
+ "the same content checks validate runs, against the theme being evaluated; any other page is listed in contextUsageSkipped: "
|
|
490
|
+
+ "{ items: [{ file, code }], total, truncated }, also at most 20, and the text output adds a 'Not counted' line. When the pages "
|
|
491
|
+
+ "folder cannot be listed, no usage is claimed and the text says why. theme push and theme resolve add these fields last, "
|
|
492
|
+
+ "from the bytes the result has left, so a full result can omit usedIn or contextUsageSkipped (the text still reports the total). "
|
|
493
|
+
+ "validate prints the skipped sources in its progress text and returns its error envelope without contextUsageSkipped.",
|
|
456
494
|
"Use semanticMappings only for meanings roles and contexts cannot express; scattered pins shadow the coherent model. pull keeps only authored pins there and lists them in explicitMappingTokens; a mapping the marker does not name is never applied, so a hand-added pin at the root needs its token added to the marker or theme push reports it as inert. A pin inside a context needs no marker.",
|
|
457
|
-
"Run theme push --dry-run and clear its warnings, fit lints included; then run theme push and verify text, actions, focus states, and both schemes in authoring previews.",
|
|
495
|
+
"Run theme push --dry-run and clear its warnings, fit lints included (a status-color warning in a context that renders no status UI may stay); then run theme push and verify text, actions, focus states, and both schemes in authoring previews.",
|
|
458
496
|
],
|
|
459
497
|
example: THEME_EXAMPLE,
|
|
460
498
|
};
|
|
@@ -558,6 +596,9 @@ export function getAppearanceReference() {
|
|
|
558
596
|
+ "base colors they use in both schemes. Text needs 4.5:1. Icons and focus indicators need 3:1. Inspect "
|
|
559
597
|
+ "background artwork and states outside the audited interactions on staging. "
|
|
560
598
|
+ `Offline reports leave ${CHROME_OFFLINE_PAGE_LIMITATION} unchecked. `
|
|
599
|
+
+ "Approved pages count as links, as staging renders them. A draft page, a page the inventory lacks, or a page "
|
|
600
|
+
+ "with no usable path is left out and listed in skippedNavigationLinks with the reason draft_page, missing_page "
|
|
601
|
+
+ "or unknown_path. Each item also names its location (header or footer), resourceId and path (null when no known page has that id), so the two copies of one page are told apart. theme resolve --site reads the site's page inventory instead of assuming every page is linked. "
|
|
561
602
|
+ "A staged edit to a live page or a truncated inventory can leave its production path unknown. "
|
|
562
603
|
+ "Settings-only Docs validation lacks the navigation and page inventory for navigation and footer page links. "
|
|
563
604
|
+ CHROME_NAVIGATION_UNAVAILABLE_MESSAGE + " When report-name display eligibility is unknown, only validate "
|
|
@@ -667,8 +708,8 @@ const FOOTER_FIELD_DETAILS = Object.freeze({
|
|
|
667
708
|
"FooterSettings.context": {
|
|
668
709
|
appLabel: "Footer > Colors",
|
|
669
710
|
description:
|
|
670
|
-
"Theme-owned color context. Empty follows the page. Declare the name in both schemes and save it with theme push. Footer push preserves local presentation edits.",
|
|
671
|
-
renders: "The enabled footer's background, text, links and controls.",
|
|
711
|
+
"Theme-owned color context. Empty follows the page. Declare the name in both schemes and save it with theme push. Footer push preserves local presentation edits. The footer base paints the context's layer2, so a layer2 pin in the root theme or in this context sets its background.",
|
|
712
|
+
renders: "The enabled footer's background (the context's layer2), text, links and controls.",
|
|
672
713
|
},
|
|
673
714
|
"FooterSettings.enabled": {
|
|
674
715
|
type: "boolean",
|
|
@@ -700,6 +741,12 @@ const FOOTER_FIELD_DETAILS = Object.freeze({
|
|
|
700
741
|
description: "Choose a regular link, bold link or a compact button. An empty value selects link.",
|
|
701
742
|
renders: "The call to action in the enabled footer's aside region.",
|
|
702
743
|
},
|
|
744
|
+
"FooterSettings.brandHoverGrow": {
|
|
745
|
+
type: "boolean",
|
|
746
|
+
description:
|
|
747
|
+
"Grows the footer brand slightly on hover, by the same fixed scale as the header's brandHoverGrow. Save it with footer push.",
|
|
748
|
+
renders: "Footer logo and brand text on hover",
|
|
749
|
+
},
|
|
703
750
|
"FooterSettings.brandSize": {
|
|
704
751
|
type: "enum",
|
|
705
752
|
values: ["standard", "large"],
|
|
@@ -934,19 +981,16 @@ export function getFooterReference() {
|
|
|
934
981
|
referenceKind: "footer",
|
|
935
982
|
usage: CLI_BINARY_NAME + " footer push [--dry-run]",
|
|
936
983
|
fixedValues: structuredClone(FOOTER_FIXED_VALUES),
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
"--esp-footer-link-underline-offset",
|
|
940
|
-
"--esp-footer-link-underline-thickness",
|
|
941
|
-
"--esp-footer-heading-size",
|
|
942
|
-
].includes(name))),
|
|
984
|
+
// The manifest owns which properties the footer has, so a new one shows up here without an edit.
|
|
985
|
+
componentProperties: structuredClone(getSettableComponentProperties().filter(({ component }) => component === "esp-footer")),
|
|
943
986
|
linkDefaults: structuredClone(FOOTER_LINK_DEFAULTS),
|
|
944
987
|
footerStyleRule:
|
|
945
988
|
"Both footer headings default to the normal text size. The link properties cover column, bottom and brand links, "
|
|
946
989
|
+ "links in the aside and bottom rich text, and the link and bold-link aside actions. Set resting decoration, "
|
|
947
990
|
+ "offset and thickness in the scheme or footer context. Offset is in em. Divide the target pixels by the "
|
|
948
991
|
+ "rendered link font size in pixels, for example 4 px at 16 px is 0.25em. Covered links underline on hover. Social icons keep "
|
|
949
|
-
+ "their own decoration and the button uses the footer action colors."
|
|
992
|
+
+ "their own decoration and the button uses the footer action colors. Heading marks (the --esp-heading-N-mark-* "
|
|
993
|
+
+ "properties) do not reach footer headings; set --esp-footer-heading-background to fill behind them.",
|
|
950
994
|
workspaceFile: APPEARANCE_FILES[SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES],
|
|
951
995
|
workspacePath: "settings.footerSettings",
|
|
952
996
|
messages: footerMessages(),
|
|
@@ -990,7 +1034,7 @@ export function getFooterReference() {
|
|
|
990
1034
|
+ "The deployment check covers standard and profile sites; managed Docs sites use validate and the Footer tab.",
|
|
991
1035
|
readOnlyProjections: FOOTER_READ_ONLY_FIELDS,
|
|
992
1036
|
concurrency:
|
|
993
|
-
`pull records the ${FOOTER_DRAFT_VERSION} expectedDraftHash, including asideCtaStyle, effective logoScale, logoBox, all sparse profiles `
|
|
1037
|
+
`pull records the ${FOOTER_DRAFT_VERSION} expectedDraftHash, including asideCtaStyle, brandHoverGrow, effective logoScale, logoBox, all sparse profiles `
|
|
994
1038
|
+ "and both logo ids, but no context, logoVariant, retired colors, response URLs or effective inherited choices. Earlier draft hash versions are refused. Upgrade and pull again. A conflict returns "
|
|
995
1039
|
+ "footer.concurrent_modification; pull, reconcile, and retry.",
|
|
996
1040
|
themeInteraction:
|
|
@@ -1106,6 +1150,7 @@ export function formatPresentationReference(reference) {
|
|
|
1106
1150
|
+ "\n\nPrecedence:\n"
|
|
1107
1151
|
+ reference.roleResolution.precedence.map((line, index) => " " + (index + 1) + ". " + line).join("\n")
|
|
1108
1152
|
+ "\n\nTheme groups:\n" + groups + "\n\n" + formatComponentProperties(reference.componentProperties)
|
|
1153
|
+
+ "\n\nElevation\n" + reference.elevationRule.map((line) => " " + line).join("\n")
|
|
1109
1154
|
+ "\n\nHeading and quote colors\n" + reference.headingAndQuoteColors.map((line) => " " + line).join("\n")
|
|
1110
1155
|
+ "\n\nValid complete pair (both schemes resolved and contrast-checked):\n"
|
|
1111
1156
|
+ JSON.stringify(reference.example, null, 2) + "\n";
|