@taprootio/site-authoring 0.55.0 → 0.56.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.
@@ -67,7 +67,9 @@ import {
67
67
  PAGE_TEMPLATES,
68
68
  requireTemplateName,
69
69
  RETIRED_GENERATED_PAGE_KINDS,
70
+ sentDisplayAuthor,
70
71
  sentDisplayDate,
72
+ sentShowOnProfile,
71
73
  TEMPLATE_FREE_FORM,
72
74
  TEMPLATE_GENERATED,
73
75
  templateFrontMatterFault,
@@ -118,6 +120,7 @@ import {
118
120
  workspacePageSourceBodyHash,
119
121
  writeManifest,
120
122
  writeWorkspaceJson,
123
+ mediaReferenceCandidates,
121
124
  } from "../workspace.js";
122
125
 
123
126
  /**
@@ -199,6 +202,7 @@ const RESOLUTION_METADATA_CODES = new Set([
199
202
  "pages.front_matter_invalid",
200
203
  "pages.front_matter_unknown",
201
204
  "pages.front_matter_duplicate",
205
+ "pages.display_author_invalid",
202
206
  "pages.metadata_missing",
203
207
  "pages.path_missing",
204
208
  "pages.path_unsupported",
@@ -271,6 +275,17 @@ export function parseFrontMatter(source, file) {
271
275
  ));
272
276
  continue;
273
277
  }
278
+ // A bare `displayAuthor:` reads as empty, and empty clears the pen name. Only a quoted empty value may
279
+ // do that, so an unfinished line cannot put the member's own byline back on the page (TR01402).
280
+ if (key === "displayAuthor" && rawValue.trim() === "") {
281
+ record(documentError(
282
+ "pages.display_author_invalid",
283
+ `'${file}' declares displayAuthor with no value. Write displayAuthor: "" to clear the display author, `
284
+ + "or a site author's handle.",
285
+ key,
286
+ ));
287
+ continue;
288
+ }
274
289
  const seen = values.get(key);
275
290
  if (seen === undefined) {
276
291
  if (key === "tags") tagsLine = index + 1;
@@ -368,21 +383,6 @@ function unwrapProseMirrorDocument(parsed, file) {
368
383
  );
369
384
  }
370
385
 
371
- /**
372
- * The candidate keys a Markdown image reference could match in the media
373
- * manifest. Authors write `./media/hero.png`, `media/hero.png`, or
374
- * `/media/hero.png` for the same file, and a resolver that accepted only one
375
- * spelling would refuse content that is plainly correct.
376
- */
377
- function mediaReferenceCandidates(reference) {
378
- if (typeof reference !== "string" || reference === "") return [];
379
- const withoutQuery = reference.split("#")[0].split("?")[0];
380
- const stripped = withoutQuery.replace(/^\.\//u, "").replace(/^\/+/u, "");
381
- const candidates = new Set([reference, withoutQuery, stripped]);
382
- if (!stripped.includes("/")) candidates.add(`media/${stripped}`);
383
- return [...candidates];
384
- }
385
-
386
386
  function makeResolveImage(mediaManifest, file) {
387
387
  return async (reference) => {
388
388
  for (const candidate of mediaReferenceCandidates(reference)) {
@@ -679,29 +679,33 @@ export function requireReconciledRevision({ file, pagePath, target, entry, obser
679
679
  }
680
680
 
681
681
  /**
682
- * The same guard for a typed page's display date, which the revision does not
683
- * cover. It refuses only when this push would change a date that moved on the
684
- * site since the workspace last saw it: an unset date is left alone by the
685
- * update, and a pull that showed the operator a conflict has already handed
686
- * them the site's version.
682
+ * The same guard for a typed page's display date, display author and showOnProfile, which the
683
+ * revision does not cover. It refuses only when this push would change a value
684
+ * that moved on the site since the workspace last saw it: an unset value is
685
+ * left alone by the update, and a pull that showed the operator a conflict has
686
+ * already handed them the site's version. `key` names the value in the
687
+ * document, the target, the baseline and the observed record, and `label` the
688
+ * value in the refusal (TR01402).
687
689
  */
688
- function requireReconciledDisplayDate({ file, pagePath, target, entry, document_, observed }) {
689
- const sent = documentTemplate(document_) === TEMPLATE_FREE_FORM ? undefined : document_.displayDate;
690
- const recorded = entry?.baseline?.displayDate;
691
- const live = target.displayDate;
690
+ function requireReconciledPageValue(key, label, { file, pagePath, target, entry, document_, observed }) {
691
+ const sent = documentTemplate(document_) === TEMPLATE_FREE_FORM ? undefined : document_[key];
692
+ const recorded = entry?.baseline?.[key];
693
+ const live = target[key];
692
694
  if (sent === undefined || recorded === undefined) return;
693
- // A refused pull records the date it showed. Only that date is overridable: a
694
- // page whose date moved again since is refused again, like a moved revision.
695
- // A record from a pull that named no date still counts as having shown it.
696
- if (observed !== undefined && (observed.displayDate === undefined || observed.displayDate === live)) return;
697
- if (typeof recorded !== "string" || live === recorded || live === sent) return;
695
+ // A refused pull records the value it showed. Only that value is overridable: a
696
+ // page whose value moved again since is refused again, like a moved revision.
697
+ // A record from a pull that named no value still counts as having shown it.
698
+ if (observed !== undefined && (observed[key] === undefined || observed[key] === live)) return;
699
+ if (live === recorded || live === sent) return;
700
+ // A flag reads as true or false. An empty text value reads as "not set": "none" is a handle a site may use.
701
+ const shown = (value) => typeof value === "boolean" ? String(value) : value ? `'${value}'` : "not set";
698
702
  throw new SiteAuthoringError(
699
703
  "pages.push_conflict",
700
- `Page '${pagePath || "/"}' has a different display date on the site (${live || "none"}) than the one this `
701
- + `workspace last reconciled with (${recorded || "none"}), and '${file}' would replace it with `
702
- + `${sent || "none"}. No page was pushed. Run 'taproot-site pull' to adopt the site's date, or delete `
704
+ `Page '${pagePath || "/"}' has a different ${label} on the site (${shown(live)}) than the one this `
705
+ + `workspace last reconciled with (${shown(recorded)}), and '${file}' would replace it with `
706
+ + `${shown(sent)}. No page was pushed. Run 'taproot-site pull' to adopt the site's ${label}, or delete `
703
707
  + `'${file}' and pull again.`,
704
- { field: file, alternatives: [recorded, live] },
708
+ { field: file, alternatives: [String(recorded), String(live)] },
705
709
  );
706
710
  }
707
711
 
@@ -815,6 +819,12 @@ async function convertedWorkspacePageSource({ source, mediaManifest, content: in
815
819
  if (parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, "tags")) {
816
820
  throw documentError("pages.tags_unsupported", `'${file}' declares tags, which the free-form template does not accept.`, "tags");
817
821
  }
822
+ // Dropping one of these silently would publish the page under the member's own byline (TR01402, TR01403).
823
+ for (const key of ["displayAuthor", "showOnProfile"]) {
824
+ if (parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, key)) {
825
+ throw documentError("pages.document_shape", `'${file}' declares ${key}, which the free-form template does not accept.`, key);
826
+ }
827
+ }
818
828
  return { document: normalizeColumnsBody(unwrapProseMirrorDocument(parsed, file)).body };
819
829
  }
820
830
 
@@ -1073,6 +1083,11 @@ export function liveAuthorsRefresher({ client, workspaceDir, siteId, write, onPr
1073
1083
  };
1074
1084
  }
1075
1085
 
1086
+ /** The display author a write left on the page: what the site reports, else what was declared. */
1087
+ function displayAuthorAfterWrite(page, summary) {
1088
+ return summary.displayAuthor || page.document.displayAuthor || "";
1089
+ }
1090
+
1076
1091
  /**
1077
1092
  * Decides what a page says about its author before anything is sent
1078
1093
  * (TR01196). `declared` is what the source (or, for a `.pm.json` page, its
@@ -1139,6 +1154,30 @@ async function resolvePageAuthor({ file, pagePath, declared, recorded, markdown,
1139
1154
  return { author: reference.value, sendAuthor: true, unverified };
1140
1155
  }
1141
1156
 
1157
+ /**
1158
+ * Checks a declared display author against the site's authors (TR01402), as
1159
+ * `resolvePageAuthor` checks a new author: `authors.json` first, then, online,
1160
+ * the site's own list once, refusing only a handle the site really lacks. An
1161
+ * offline run cannot ask, so it flags the handle as unverified. The empty value
1162
+ * clears the display author and a value the site already holds needs no check.
1163
+ */
1164
+ async function checkDisplayAuthor({ file, declared, held, knownAuthors, refreshAuthors }) {
1165
+ if (declared === undefined || declared === "" || declared === held) return {};
1166
+ let known = authorKnown(await knownAuthors(), declared);
1167
+ if (known === true) return {};
1168
+ if (refreshAuthors === undefined) return known === false ? { unverified: true } : {};
1169
+ known = authorKnown(await refreshAuthors(), declared);
1170
+ if (known === false) {
1171
+ throw documentError(
1172
+ "pages.display_author_unknown",
1173
+ `'${file}' names displayAuthor '${declared}', who is not one of the site's authors. Run 'taproot-site authors `
1174
+ + "list' to see the handles, or 'taproot-site authors add' to create a site author.",
1175
+ file,
1176
+ );
1177
+ }
1178
+ return {};
1179
+ }
1180
+
1142
1181
  /**
1143
1182
  * Phase one over the workspace's page sources (TR01002): resolve which file is
1144
1183
  * each page's one source, convert and validate it, and decide create, update,
@@ -1516,7 +1555,9 @@ export async function planPages({
1516
1555
  if (sourceTemplate === TEMPLATE_LEGAL) legalRevisionGuard = guard;
1517
1556
  else {
1518
1557
  if (tagIntent === undefined) requireReconciledRevision(guard);
1519
- requireReconciledDisplayDate({ ...guard, document_, observed });
1558
+ requireReconciledPageValue("displayDate", "display date", { ...guard, document_, observed });
1559
+ requireReconciledPageValue("displayAuthor", "display author", { ...guard, document_, observed });
1560
+ requireReconciledPageValue("showOnProfile", "showOnProfile setting", { ...guard, document_, observed });
1520
1561
  }
1521
1562
  }
1522
1563
  }
@@ -1569,6 +1610,15 @@ export async function planPages({
1569
1610
  knownAuthors: getRecordedAuthors,
1570
1611
  refreshAuthors: getLiveAuthors,
1571
1612
  });
1613
+ const displayAuthor = generated
1614
+ ? {}
1615
+ : await checkDisplayAuthor({
1616
+ file,
1617
+ declared: document_.displayAuthor,
1618
+ held: online && target !== undefined ? target.displayAuthor : baseline?.displayAuthor,
1619
+ knownAuthors: getRecordedAuthors,
1620
+ refreshAuthors: getLiveAuthors,
1621
+ });
1572
1622
  contentKey = contentKeyFor(authorship.author);
1573
1623
  // An author the site no longer holds is a change to send, however the
1574
1624
  // source compares with the record.
@@ -1604,8 +1654,15 @@ export async function planPages({
1604
1654
  file,
1605
1655
  );
1606
1656
  }
1657
+ // The byline the page will have after this push (TR01402): the declared
1658
+ // display author, none after an explicit clear, else the site's value.
1659
+ const declaredDisplayAuthor = document_.displayAuthor;
1660
+ const siteDisplayAuthor = (online && target !== undefined ? target.displayAuthor : baseline?.displayAuthor) ?? "";
1607
1661
  const reviewAuthorMissing = documentTemplate(document_) === TEMPLATE_PLACE_REVIEW
1608
1662
  && authorship.author === ""
1663
+ && (declaredDisplayAuthor ?? siteDisplayAuthor) === ""
1664
+ // The site's own flag decides for a page it already has, so a display author cleared by this
1665
+ // push shows its warning on the next run, once the site reports the page without a credit.
1609
1666
  && (online && target !== undefined
1610
1667
  ? target.reviewAuthorMissing === true
1611
1668
  : targetEntry?.pageId === undefined || targetEntry.reviewAuthorMissing === true);
@@ -1623,6 +1680,7 @@ export async function planPages({
1623
1680
  sendAuthor: authorship.sendAuthor,
1624
1681
  reviewAuthorMissing,
1625
1682
  ...(authorship.unverified === true ? { authorUnverified: true } : {}),
1683
+ ...(displayAuthor.unverified === true ? { displayAuthorUnverified: true } : {}),
1626
1684
  document: document_,
1627
1685
  sourceFormat: source.sourceFormat,
1628
1686
  sourceHash: source.sourceHash,
@@ -1940,6 +1998,7 @@ export async function pagesPush(invocation) {
1940
1998
  action: page.action,
1941
1999
  status: summary.status,
1942
2000
  ...(page.author === "" ? {} : { author: page.author }),
2001
+ ...(displayAuthorAfterWrite(page, summary) === "" ? {} : { displayAuthor: displayAuthorAfterWrite(page, summary) }),
1943
2002
  });
1944
2003
  // `entry?.` because a hand-edited manifest can hold a null in the list,
1945
2004
  // and a raw TypeError here would collapse to an opaque `site.failed`
@@ -1992,6 +2051,11 @@ export async function pagesPush(invocation) {
1992
2051
  // Recorded for the pages whose push sends a date, so the next push
1993
2052
  // can tell a date the site changed from one it already holds.
1994
2053
  ...(sentDisplayDate(page.templateType) ? { displayDate: summary.displayDate } : {}),
2054
+ // Recorded from the handle the write's answer returns, so a second
2055
+ // push with no pull between compares with what the site holds now.
2056
+ ...(sentDisplayAuthor(page.templateType) ? { displayAuthor: summary.displayAuthor } : {}),
2057
+ // The value the write's answer returns, in the workspace's sense (TR01403).
2058
+ ...(sentShowOnProfile(page.templateType) ? { showOnProfile: summary.showOnProfile } : {}),
1995
2059
  ...(heldAuthor === "" ? {} : { author: heldAuthor }),
1996
2060
  },
1997
2061
  pendingApproval: true,
@@ -2077,7 +2141,8 @@ export async function pagesPush(invocation) {
2077
2141
 
2078
2142
  // Pages are authorless unless a source names an author, and an owner
2079
2143
  // otherwise finds the missing byline only after publishing (TR01196).
2080
- const authorless = applied.filter((entry) => entry.action === "created" && entry.author === undefined);
2144
+ const authorless = applied.filter((entry) =>
2145
+ entry.action === "created" && entry.author === undefined && entry.displayAuthor === undefined);
2081
2146
  if (authorless.length > 0) {
2082
2147
  onProgress(
2083
2148
  `${authorless.length} page(s) were created without an author, so they publish with no byline. To credit one, `
package/src/verbs/pull.js CHANGED
@@ -25,7 +25,12 @@ import {
25
25
  } from "../constants.js";
26
26
  import { tagDestinationCatalogSlugs } from "../appearance-contract.js";
27
27
  import { validateAuthoredTagNames } from "../authored-tag-names.js";
28
- import { AUTHORS_FILE_NAME, parseAuthorReference, projectAuthorsForWorkspace } from "../authors-contract.js";
28
+ import {
29
+ AUTHORS_FILE_NAME,
30
+ normalizeAuthorHandle,
31
+ parseAuthorReference,
32
+ projectAuthorsForWorkspace,
33
+ } from "../authors-contract.js";
29
34
  import { isCanonicalUuid, sanitizeDiagnostic, SiteAuthoringError } from "../errors.js";
30
35
  import { appearanceManifestEntry, footerManifestEntry, presentationManifestEntry } from "../footer-workspace.js";
31
36
  import { describeJsonDifferences, reportableDifferencePaths } from "../json-path-diff.js";
@@ -53,7 +58,9 @@ import {
53
58
  isAuthorableTemplateType,
54
59
  isGeneratedTemplateType,
55
60
  projectAuthoredTagSnapshot,
61
+ sentDisplayAuthor,
56
62
  sentDisplayDate,
63
+ sentShowOnProfile,
57
64
  supportsAuthoredTagWireType,
58
65
  TEMPLATE_LEGAL,
59
66
  workspaceDocumentFromPage,
@@ -689,6 +696,17 @@ function trackedDisplayDate(page, templateType) {
689
696
  return sentDisplayDate(templateType) ? (typeof page.displayDate === "string" ? page.displayDate : "") : undefined;
690
697
  }
691
698
 
699
+ /** The display author a read reports for a page whose push sends one ("" for none), or `undefined` for other pages. */
700
+ function trackedDisplayAuthor(page, templateType) {
701
+ if (!sentDisplayAuthor(templateType)) return undefined;
702
+ return typeof page.displayAuthor === "string" ? normalizeAuthorHandle(page.displayAuthor) ?? "" : "";
703
+ }
704
+
705
+ /** Whether a read says the page may be on its author's profile, or `undefined` for pages that carry no such setting. */
706
+ function trackedShowOnProfile(page, templateType) {
707
+ return sentShowOnProfile(templateType) ? page.showOnProfile !== false : undefined;
708
+ }
709
+
692
710
  function notThisSite(message, field) {
693
711
  // One code for one situation: "this workspace is not provably this site's."
694
712
  // The remedy is the same for every branch below — a fresh directory — and an
@@ -840,6 +858,8 @@ export async function pull(invocation) {
840
858
  const sourceBodyHash = supportsAuthoredTagWireType(summary.templateType) ? remoteHash : undefined;
841
859
  const revision = normalizePageBodyRevision(page.bodyRevision);
842
860
  const displayDate = trackedDisplayDate(page, summary.templateType);
861
+ const displayAuthor = trackedDisplayAuthor(page, summary.templateType);
862
+ const showOnProfile = trackedShowOnProfile(page, summary.templateType);
843
863
  return {
844
864
  source,
845
865
  entry: {
@@ -859,6 +879,8 @@ export async function pull(invocation) {
859
879
  ...(sourceBodyHash === undefined ? {} : { sourceBodyHash }),
860
880
  ...(revision === undefined ? {} : { revision }),
861
881
  ...(displayDate === undefined ? {} : { displayDate }),
882
+ ...(displayAuthor === undefined ? {} : { displayAuthor }),
883
+ ...(showOnProfile === undefined ? {} : { showOnProfile }),
862
884
  ...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
863
885
  ...(confirmedTags === undefined ? {} : {
864
886
  authoredTagRevision: confirmedTags.revision,
@@ -1202,7 +1224,18 @@ export async function pull(invocation) {
1202
1224
  const dateChanged = remoteDisplayDate !== undefined
1203
1225
  && source.baseline?.displayDate !== undefined
1204
1226
  && source.baseline.displayDate !== remoteDisplayDate;
1205
- const remoteChanged = revisionChanged || dateChanged;
1227
+ // The display author is page content like the date and is compared the
1228
+ // same way (TR01402). A baseline written before it counts as not having
1229
+ // seen the value, so such a workspace pulls without a conflict.
1230
+ const remoteDisplayAuthor = trackedDisplayAuthor(page, summary.templateType);
1231
+ const displayAuthorChanged = remoteDisplayAuthor !== undefined
1232
+ && source.baseline?.displayAuthor !== undefined
1233
+ && source.baseline.displayAuthor !== remoteDisplayAuthor;
1234
+ const remoteShowOnProfile = trackedShowOnProfile(page, summary.templateType);
1235
+ const showOnProfileChanged = remoteShowOnProfile !== undefined
1236
+ && source.baseline?.showOnProfile !== undefined
1237
+ && source.baseline.showOnProfile !== remoteShowOnProfile;
1238
+ const remoteChanged = revisionChanged || dateChanged || displayAuthorChanged || showOnProfileChanged;
1206
1239
  // Markdown is one-way, so a Markdown source can never be rewritten from
1207
1240
  // the site's document and is always kept. A ProseMirror source can be
1208
1241
  // refreshed — but only over content the author has not edited since the
@@ -1338,6 +1371,8 @@ export async function pull(invocation) {
1338
1371
  ...reconciled.baseline,
1339
1372
  ...(revision === undefined ? {} : { revision }),
1340
1373
  ...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
1374
+ ...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
1375
+ ...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
1341
1376
  ...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
1342
1377
  }
1343
1378
  : {
@@ -1353,6 +1388,8 @@ export async function pull(invocation) {
1353
1388
  ...reconciled.baseline,
1354
1389
  ...(revision === undefined ? {} : { revision }),
1355
1390
  ...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
1391
+ ...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
1392
+ ...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
1356
1393
  ...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
1357
1394
  },
1358
1395
  // A conflict preserves the site's version whatever kept the source: the
@@ -1383,6 +1420,10 @@ export async function pull(invocation) {
1383
1420
  // the record showed must match too or its differences are stale.
1384
1421
  const alreadyShown = observed !== undefined
1385
1422
  && observed.displayDate === remoteDisplayDate
1423
+ && (remoteDisplayAuthor === undefined || observed.displayAuthor === undefined
1424
+ || observed.displayAuthor === remoteDisplayAuthor)
1425
+ && (remoteShowOnProfile === undefined || observed.showOnProfile === undefined
1426
+ || observed.showOnProfile === remoteShowOnProfile)
1386
1427
  && (revision === undefined
1387
1428
  ? observed.revision === undefined && observed.remoteHash === remoteHash
1388
1429
  : observed.revision === revision);
@@ -1421,6 +1462,8 @@ export async function pull(invocation) {
1421
1462
  observedRevision: revision,
1422
1463
  observedRemoteHash: remoteHash,
1423
1464
  observedDisplayDate: remoteDisplayDate,
1465
+ observedDisplayAuthor: remoteDisplayAuthor,
1466
+ observedShowOnProfile: remoteShowOnProfile,
1424
1467
  observedRevisionFile: internalPageObservedRevisionFile(summary.pageId),
1425
1468
  });
1426
1469
  }
@@ -1488,6 +1531,8 @@ export async function pull(invocation) {
1488
1531
  ? { remoteHash: conflict.observedRemoteHash }
1489
1532
  : { revision: conflict.observedRevision }),
1490
1533
  ...(conflict.observedDisplayDate === undefined ? {} : { displayDate: conflict.observedDisplayDate }),
1534
+ ...(conflict.observedDisplayAuthor === undefined ? {} : { displayAuthor: conflict.observedDisplayAuthor }),
1535
+ ...(conflict.observedShowOnProfile === undefined ? {} : { showOnProfile: conflict.observedShowOnProfile }),
1491
1536
  ...(conflict.differences === undefined ? {} : { differences: conflict.differences }),
1492
1537
  });
1493
1538
  }
package/src/workspace.js CHANGED
@@ -5,7 +5,7 @@ import path from "node:path";
5
5
 
6
6
  import { atomicWriteFile } from "./atomic-file.js";
7
7
  import { AUTHORED_TAG_SLUG, MAX_AUTHORED_TAG_NAME_SCALARS, MAX_AUTHORED_TAGS } from "./authored-tag-names.js";
8
- import { parseAuthorReference } from "./authors-contract.js";
8
+ import { normalizeAuthorHandle, parseAuthorReference } from "./authors-contract.js";
9
9
  import { LIMITS } from "./constants.js";
10
10
  import { hasAsciiControl, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
11
11
  import { isSystemPageTypeTag } from "./page-type-tags.js";
@@ -264,6 +264,8 @@ export async function readObservedPageRecord(workspaceDir, pageId) {
264
264
  // The date the refusal showed, for a typed page. A date edit does not move
265
265
  // the revision, so the record has to name it to say what was seen.
266
266
  displayDate: normalizeBaselineDisplayDate(parsed.displayDate),
267
+ displayAuthor: normalizeBaselineDisplayAuthor(parsed.displayAuthor),
268
+ showOnProfile: normalizeBaselineShowOnProfile(parsed.showOnProfile),
267
269
  differences: normalizeObservedDifferences(parsed.differences),
268
270
  };
269
271
  }
@@ -421,6 +423,19 @@ function normalizeBaselineDisplayDate(value) {
421
423
  return typeof value === "string" && (value === "" || /^\d{4}-\d{2}-\d{2}$/u.test(value)) ? value : undefined;
422
424
  }
423
425
 
426
+ // A site author's handle or "" (no display author). Anything else is a damaged
427
+ // baseline member, and a baseline written before TR01402 has none: it counts as
428
+ // not having seen the value.
429
+ function normalizeBaselineDisplayAuthor(value) {
430
+ return value === "" || (typeof value === "string" && normalizeAuthorHandle(value) === value) ? value : undefined;
431
+ }
432
+
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) {
436
+ return typeof value === "boolean" ? value : undefined;
437
+ }
438
+
424
439
  /**
425
440
  * Whether a manifest entry names a file `walkWorkspaceFiles` could have
426
441
  * produced: under `pages/`, bounded, and every segment in the workspace
@@ -492,10 +507,13 @@ export function pageSourceRegistry(manifest) {
492
507
  const contentKey = normalizeBaselineHash(declared?.contentKey);
493
508
  const revision = normalizePageBodyRevision(declared?.revision);
494
509
  const displayDate = normalizeBaselineDisplayDate(declared?.displayDate);
510
+ const displayAuthor = normalizeBaselineDisplayAuthor(declared?.displayAuthor);
511
+ const showOnProfile = normalizeBaselineShowOnProfile(declared?.showOnProfile);
495
512
  const author = normalizeAuthorValue(declared?.author);
496
513
  const tagBaseline = normalizeAuthoredTagBaseline(declared);
497
514
  const baseline =
498
515
  remoteHash === undefined && sourceHash === undefined && revision === undefined && displayDate === undefined
516
+ && displayAuthor === undefined && showOnProfile === undefined
499
517
  && sourceBodyHash === undefined && contentKey === undefined && author === undefined && tagBaseline === undefined
500
518
  ? undefined
501
519
  : {
@@ -505,6 +523,8 @@ export function pageSourceRegistry(manifest) {
505
523
  ...(contentKey === undefined ? {} : { contentKey }),
506
524
  ...(revision === undefined ? {} : { revision }),
507
525
  ...(displayDate === undefined ? {} : { displayDate }),
526
+ ...(displayAuthor === undefined ? {} : { displayAuthor }),
527
+ ...(showOnProfile === undefined ? {} : { showOnProfile }),
508
528
  // The author the site held for the page when this workspace last
509
529
  // reconciled with it: what a page's own author reference is
510
530
  // compared with before anything is sent (TR01196).
@@ -1459,6 +1479,21 @@ export async function readMediaManifest(workspaceDir, expectedSiteId) {
1459
1479
  };
1460
1480
  }
1461
1481
 
1482
+ /**
1483
+ * The candidate keys a Markdown image reference could match in the media
1484
+ * manifest. Authors write `./media/hero.png`, `media/hero.png`, or
1485
+ * `/media/hero.png` for the same file, and a resolver that accepted only one
1486
+ * spelling would refuse content that is plainly correct.
1487
+ */
1488
+ export function mediaReferenceCandidates(reference) {
1489
+ if (typeof reference !== "string" || reference === "") return [];
1490
+ const withoutQuery = reference.split("#")[0].split("?")[0];
1491
+ const stripped = withoutQuery.replace(/^\.\//u, "").replace(/^\/+/u, "");
1492
+ const candidates = new Set([reference, withoutQuery, stripped]);
1493
+ if (!stripped.includes("/")) candidates.add(`media/${stripped}`);
1494
+ return [...candidates];
1495
+ }
1496
+
1462
1497
  /** The alt text a media record keeps when its file is uploaded again: the author's own, or none. */
1463
1498
  export function recordedAlt(entry) {
1464
1499
  return typeof entry?.alt === "string" ? entry.alt : "";