@taprootio/site-authoring 0.34.1 → 0.36.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.
@@ -2,6 +2,7 @@ import { getSitePresentation, saveSitePresentation, withRefusalGuidance } from "
2
2
  import {
3
3
  APPEARANCE_FOOTER_COLOR_FIELDS,
4
4
  APPEARANCE_SCALAR_FIELDS,
5
+ appearanceScalarInput,
5
6
  buildAppearanceScalarOperations,
6
7
  footerColorOverlay,
7
8
  } from "../appearance-contract.js";
@@ -149,7 +150,7 @@ export async function validateThemeWorkspace(workspaceDir, siteId, knownImageIds
149
150
  // leaves retain their existing empty-color fallback.
150
151
  const missing = missingThemeSettings(style);
151
152
  for (const definition of APPEARANCE_SCALAR_FIELDS) {
152
- if (!Object.hasOwn(documents[definition.settingsType], definition.name)) {
153
+ if (!definition.optional && !Object.hasOwn(documents[definition.settingsType], definition.name)) {
153
154
  missing.push(definition.path);
154
155
  }
155
156
  }
@@ -246,10 +247,17 @@ function ownedDocuments(validated, presentation) {
246
247
  for (const group of SETTINGS_GROUPS) {
247
248
  projected[group.settingsType] = projectSettingsGroup(group, presentation);
248
249
  }
250
+ const fieldDefinitions = new Map(
251
+ APPEARANCE_SCALAR_FIELDS.map(field => [`${field.settingsType}:${field.name}`, field]),
252
+ );
253
+ const valueOf = (settingsType, document, name) => {
254
+ const definition = fieldDefinitions.get(`${settingsType}:${name}`);
255
+ return definition ? appearanceScalarInput(definition, document[name]) : document[name];
256
+ };
249
257
  const owned = (settingsType, local, remote, names) => ({
250
258
  file: `${SETTINGS_DIRECTORY}/${SETTINGS_FILES[settingsType]}`,
251
- local: Object.fromEntries(names.map((name) => [name, local[name]])),
252
- remote: Object.fromEntries(names.map((name) => [name, remote[name]])),
259
+ local: Object.fromEntries(names.map((name) => [name, valueOf(settingsType, local, name)])),
260
+ remote: Object.fromEntries(names.map((name) => [name, valueOf(settingsType, remote, name)])),
253
261
  });
254
262
  const scalarNames = (settingsType) =>
255
263
  APPEARANCE_SCALAR_FIELDS.filter((field) => field.settingsType === settingsType).map((field) => field.name);
@@ -314,7 +322,10 @@ export function presentationMovedRefusal({ baseline, current, differences }) {
314
322
  + `${current.revision}), so nothing was written. Keep copies of the edited settings files, run `
315
323
  + "'taproot-site pull' to refresh the baseline, re-apply the edits, and push again; the paths below name "
316
324
  + "where the workspace and the site now differ.",
317
- { field: "revision", alternatives: differences.filter((entry) => entry.paths.length > 0).map((entry) => entry.file) },
325
+ {
326
+ field: "revision",
327
+ alternatives: differences.filter((entry) => entry.paths.length > 0).map((entry) => entry.file),
328
+ },
318
329
  ).withDifferences(differences.flatMap((entry) => entry.paths.map((path) => `${entry.file}:${path}`)));
319
330
  }
320
331
 
@@ -386,7 +397,9 @@ export async function themePush(invocation) {
386
397
  for (const warning of themes.warnings) onProgress(`Espalier warning: ${warning}`);
387
398
  if (themes.warningsTruncated) {
388
399
  const hidden = themes.warningCount - themes.warnings.length;
389
- onProgress(`${hidden} more Espalier warning(s) not shown; resolve the ones above and run theme push --dry-run to see them.`);
400
+ onProgress(
401
+ `${hidden} more Espalier warning(s) not shown; resolve the ones above and run theme push --dry-run to see them.`,
402
+ );
390
403
  }
391
404
  const warnings = {
392
405
  items: themes.warnings,
@@ -397,8 +410,11 @@ export async function themePush(invocation) {
397
410
  // The fresh read serves both modes: the dry run compares against it, and
398
411
  // the push takes the footer document's draft token from it. Nothing before
399
412
  // this point, and nothing in a dry run after it, writes to the site.
400
- const comparison = await withRefusalGuidance(onProgress, "theme push", async () =>
401
- await comparePresentation(client, siteId, validated, appearanceContext.manifest));
413
+ const comparison = await withRefusalGuidance(
414
+ onProgress,
415
+ "theme push",
416
+ async () => await comparePresentation(client, siteId, validated, appearanceContext.manifest),
417
+ );
402
418
  const { current, stale, changeSet, changeSetHash, pending, replayable, replaying, differences, changed } = comparison;
403
419
 
404
420
  if (dryRun) {
@@ -408,7 +424,9 @@ export async function themePush(invocation) {
408
424
  }
409
425
  if (!changed) onProgress("The workspace's presentation matches the site; a push would change nothing.");
410
426
  if (baseline === undefined) {
411
- onProgress("The pull manifest records no presentation baseline; a push would refuse until the workspace is re-pulled.");
427
+ onProgress(
428
+ "The pull manifest records no presentation baseline; a push would refuse until the workspace is re-pulled.",
429
+ );
412
430
  } else if (replaying) {
413
431
  onProgress(
414
432
  `The site's presentation revision moved since this workspace was pulled (${baseline.revision} → `
@@ -500,7 +518,9 @@ export async function themePush(invocation) {
500
518
  // so an error answered after that commit has moved the revision, and the
501
519
  // record is what lets the next run of the same change set be answered as
502
520
  // already current instead of refused as someone else's edit.
503
- if (error instanceof ApiError && (error.hasField("ExpectedRevision") || error.hasField("ExpectedFooterDraftHash"))) {
521
+ if (
522
+ error instanceof ApiError && (error.hasField("ExpectedRevision") || error.hasField("ExpectedFooterDraftHash"))
523
+ ) {
504
524
  await clearPendingPresentationSave(config.workspaceDir, siteId);
505
525
  } else {
506
526
  onProgress(
package/src/workspace.js CHANGED
@@ -5,6 +5,7 @@ import path from "node:path";
5
5
 
6
6
  import { atomicWriteFile } from "./atomic-file.js";
7
7
  import { parseAuthorReference } from "./authors-contract.js";
8
+ import { LIMITS } from "./constants.js";
8
9
  import { hasAsciiControl, sanitizeDiagnostic, SiteAuthoringError } from "./errors.js";
9
10
  import {
10
11
  noteEntry,
@@ -274,7 +275,7 @@ export const MEDIA_MANIFEST_VERSION = 2;
274
275
  export const WORKSPACE_LIMITS = Object.freeze({
275
276
  // One authored page: a Markdown source or a ProseMirror document.
276
277
  documentBytes: 2 * 1024 * 1024,
277
- navigationBytes: 1024 * 1024,
278
+ navigationBytes: LIMITS.navigationWorkspaceBytes,
278
279
  // The redirect map: sized from the contract's own bounds (entries, path
279
280
  // and target bytes, pretty-printed JSON overhead) rather than borrowed from
280
281
  // the navigation tree, so the site's own pulled map always reads back.