frameboard 0.37.0 → 0.38.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/dist/cli.js CHANGED
@@ -9084,32 +9084,68 @@ function datetime(params) {
9084
9084
  return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
9085
9085
  }
9086
9086
  // src/shared/frame-device.ts
9087
- /** The devices the board can draw around a frame. */
9088
- const DEVICES = ["phone", "tablet"];
9087
+ /** The devices the board can draw around a frame, the frame's width picking one. */
9088
+ const DEVICES = [
9089
+ "phone",
9090
+ "tablet",
9091
+ "laptop"
9092
+ ];
9093
+ /** The laptop lid's chin below the screen, past the border its sides hold. */
9094
+ const LAPTOP_CHIN = 28;
9095
+ /** The laptop's base below the chin, reaching past the lid on each side by its share of the lid's width. */
9096
+ const LAPTOP_BASE = {
9097
+ height: 14,
9098
+ reach: .06,
9099
+ radius: 10
9100
+ };
9089
9101
  /**
9090
9102
  * The phone's border is a current Pro's body less its display, 71.9 mm
9091
9103
  * across holding 1206 pixels at 460 ppi, which is 16 points a side. The
9092
9104
  * tablet's is a 13-inch Pro's, 215.5 mm across holding 2064 pixels at 264
9093
9105
  * ppi, which is 44. The tablet's screen radius is a guess no source backs.
9106
+ * The laptop's lid, chin, and base are scaled off the picked mock rather
9107
+ * than any maker's, and its screen rounds its top corners alone.
9094
9108
  */
9095
9109
  const BEZELS = {
9096
9110
  phone: {
9097
9111
  border: 16,
9112
+ bottom: 16,
9098
9113
  screenRadius: 62,
9099
9114
  bodyRadius: 78
9100
9115
  },
9101
9116
  tablet: {
9102
9117
  border: 44,
9118
+ bottom: 44,
9103
9119
  screenRadius: 18,
9104
9120
  bodyRadius: 62
9121
+ },
9122
+ laptop: {
9123
+ border: 20,
9124
+ bottom: LAPTOP_CHIN + LAPTOP_BASE.height,
9125
+ screenRadius: 10,
9126
+ bodyRadius: 30
9105
9127
  }
9106
9128
  };
9107
9129
  /**
9130
+ * The narrowest width each device draws around, widest first, so a frame
9131
+ * takes the first one it reaches. Under the phone's width no device fits.
9132
+ */
9133
+ const DEVICE_WIDTHS = [
9134
+ ["laptop", 1024],
9135
+ ["tablet", 480],
9136
+ ["phone", 320]
9137
+ ];
9138
+ /** The device a frame this wide draws inside, null under 320 where none fits. */
9139
+ function deviceForWidth(width) {
9140
+ return DEVICE_WIDTHS.find(([, least]) => width >= least)?.[0] ?? null;
9141
+ }
9142
+ /**
9108
9143
  * The body's colors, fixed in both themes, since the board draws hardware
9109
9144
  * rather than chrome: the body, the hairline around it, and the island.
9110
9145
  */
9111
9146
  const BEZEL_COLORS = {
9112
9147
  body: "#17181b",
9148
+ base: "#2c2e33",
9113
9149
  edge: "#45484f",
9114
9150
  island: "#050506",
9115
9151
  homeBar: "rgba(128, 128, 128, 0.6)"
@@ -9129,6 +9165,33 @@ const HOME_BAR = {
9129
9165
  bottom: 8
9130
9166
  };
9131
9167
  /**
9168
+ * The laptop's chin and base, each a box from the frame's top left, which
9169
+ * the board and the PNG draw as positioned boxes, since one spread around
9170
+ * the screen cannot draw a body wider below than above.
9171
+ */
9172
+ function laptopParts({ width, height }) {
9173
+ const { border } = BEZELS.laptop;
9174
+ const lid = width + 2 * border;
9175
+ const reach = baseReach(width);
9176
+ return {
9177
+ chin: {
9178
+ x: -border,
9179
+ y: height,
9180
+ width: lid,
9181
+ height: LAPTOP_CHIN
9182
+ },
9183
+ base: {
9184
+ x: -border - reach,
9185
+ y: height + LAPTOP_CHIN,
9186
+ width: lid + 2 * reach,
9187
+ height: LAPTOP_BASE.height
9188
+ }
9189
+ };
9190
+ }
9191
+ function baseReach(width) {
9192
+ return Math.round((width + 2 * BEZELS.laptop.border) * LAPTOP_BASE.reach);
9193
+ }
9194
+ /**
9132
9195
  * The CSS `box-shadow` drawing a device's body: a spread the border wide
9133
9196
  * around a box rounded to the screen radius, which also covers the frame's
9134
9197
  * corners past that radius, so the body's outer radius is the screen's plus
@@ -9147,21 +9210,19 @@ function bezelShadow(device, { board = true } = {}) {
9147
9210
  ].join(", ");
9148
9211
  }
9149
9212
  /**
9150
- * A layout entry's `device` value, or null for anything but a known device,
9151
- * so a value no reader understands reads as a frame with no device.
9213
+ * The box a device's body covers around a frame's box, the box itself with
9214
+ * none. A laptop's base reaches past its lid, so its sides grow by more
9215
+ * than its top.
9152
9216
  */
9153
- function deviceOf(value) {
9154
- return DEVICES.find((device) => device === value) ?? null;
9155
- }
9156
- /** The box a device's body covers around a frame's box, the box itself with none. */
9157
9217
  function bezelBox(box, device) {
9158
9218
  if (!device) return { ...box };
9159
- const { border } = BEZELS[device];
9219
+ const { border, bottom } = BEZELS[device];
9220
+ const side = device === "laptop" ? border + baseReach(box.width) : border;
9160
9221
  return {
9161
- x: box.x - border,
9222
+ x: box.x - side,
9162
9223
  y: box.y - border,
9163
- width: box.width + 2 * border,
9164
- height: box.height + 2 * border
9224
+ width: box.width + 2 * side,
9225
+ height: box.height + border + bottom
9165
9226
  };
9166
9227
  }
9167
9228
  // src/shared/frame-sizes.ts
@@ -9374,10 +9435,14 @@ function isSize(value) {
9374
9435
  /**
9375
9436
  * Where each linked width draws: in a row at the frame's `y`, the first
9376
9437
  * `FRAME_GAP` past the frame's right edge and each next one past the last.
9438
+ * A laptop's base reaches past its lid below the screen, where a linked width
9439
+ * taller than the frame would meet it, so the row moves out by that reach.
9377
9440
  */
9378
- function linkedBoxes(box, widths) {
9441
+ function linkedBoxes(box, widths, device) {
9379
9442
  const boxes = [];
9380
- let x = box.x + box.width;
9443
+ const body = bezelBox(box, device);
9444
+ const lid = device ? BEZELS[device].border : 0;
9445
+ let x = body.x + body.width - lid;
9381
9446
  for (const { width, height } of widths) {
9382
9447
  x += 80;
9383
9448
  boxes.push({
@@ -9395,7 +9460,7 @@ function linkedBoxes(box, widths) {
9395
9460
  * width it draws, the frame's own with neither. Linked widths draw no device.
9396
9461
  */
9397
9462
  function drawnExtent(box, widths, device) {
9398
- const boxes = [bezelBox(box, device), ...linkedBoxes(box, widths)];
9463
+ const boxes = [bezelBox(box, device), ...linkedBoxes(box, widths, device)];
9399
9464
  const left = Math.min(...boxes.map(({ x }) => x));
9400
9465
  const top = Math.min(...boxes.map(({ y }) => y));
9401
9466
  const right = Math.max(...boxes.map(({ x, width }) => x + width));
@@ -9565,7 +9630,8 @@ const projectFileSchema = looseObject({
9565
9630
  createdAt: union([datetime(), unknown()]).optional(),
9566
9631
  checks: union([projectChecksSchema, unknown()]).optional(),
9567
9632
  group: union([string$1(), unknown()]).optional(),
9568
- archived: union([boolean$1(), unknown()]).optional()
9633
+ archived: union([boolean$1(), unknown()]).optional(),
9634
+ title: union([string$1(), unknown()]).optional()
9569
9635
  });
9570
9636
  const layoutEntrySchema = looseObject({
9571
9637
  x: int$1(),
@@ -9582,6 +9648,7 @@ const layoutEntrySchema = looseObject({
9582
9648
  width: int$1().min(1),
9583
9649
  height: int$1().min(1)
9584
9650
  })), unknown()]).optional(),
9651
+ showDevice: unknown().optional(),
9585
9652
  device: unknown().optional(),
9586
9653
  transition: unknown().optional()
9587
9654
  });
@@ -23975,6 +24042,38 @@ function attributeLocation(element, name) {
23975
24042
  function sheetBase(sheet) {
23976
24043
  return dirname(sheet.path);
23977
24044
  }
24045
+ /**
24046
+ * A script's inline text, or its `src` file's when the file sits in the
24047
+ * board. A remote, outside, or unreadable `src` reads as null, since the
24048
+ * write hook never reports a read as failed.
24049
+ */
24050
+ function scriptSource(element, source) {
24051
+ const src = element.attribs.src;
24052
+ if (src === void 0) return {
24053
+ text: textOf$1(element),
24054
+ path: source.path,
24055
+ offset: element.children[0]?.startIndex ?? 0
24056
+ };
24057
+ const file = localTarget(src, source.pageDir);
24058
+ if (!file || !isInside(source.root, file)) return null;
24059
+ try {
24060
+ return {
24061
+ text: readFileSync(file, "utf8"),
24062
+ path: file,
24063
+ offset: 0
24064
+ };
24065
+ } catch {
24066
+ return null;
24067
+ }
24068
+ }
24069
+ /** A script's code as `scriptSource` reads it, empty where that reads none. */
24070
+ function scriptText(element, source) {
24071
+ return scriptSource(element, source)?.text ?? "";
24072
+ }
24073
+ /** An element's own text, joined from its text children. */
24074
+ function textOf$1(element) {
24075
+ return element.children.map((node) => "data" in node ? node.data : "").join("");
24076
+ }
23978
24077
  // src/server/checks/rule.ts
23979
24078
  /**
23980
24079
  * Builds findings for the rules `docs` declares, each at the level its doc
@@ -24019,7 +24118,7 @@ const TRANSITION_FILE_RULES = [{
24019
24118
  severity: "error",
24020
24119
  description: `A stylesheet under ${ASSETS_FOLDER}/${TRANSITIONS_FOLDER}/ is named in lowercase kebab case and holds @keyframes enter, optionally @keyframes leave, and nothing else, with no url(), quoted string, or escape. The board refuses a file breaking it whole, whether or not the rule is on`
24021
24120
  }];
24022
- const finding$12 = findingFor(TRANSITION_FILE_RULES);
24121
+ const finding$13 = findingFor(TRANSITION_FILE_RULES);
24023
24122
  /** A keyframe step: `from`, `to`, or a percentage, alone or in a comma list. */
24024
24123
  const STEP = /^(?:from|to|\d+(?:\.\d+)?%)(?:\s*,\s*(?:from|to|\d+(?:\.\d+)?%))*$/i;
24025
24124
  /**
@@ -24164,7 +24263,7 @@ function transitionPath(project, name) {
24164
24263
  function checkTransitionSheet({ project, name }, css) {
24165
24264
  const reading = readTransitionSheet(name, css);
24166
24265
  if (reading.ok) return [];
24167
- return reading.problems.map(({ message, location }) => finding$12("transition-file", {
24266
+ return reading.problems.map(({ message, location }) => finding$13("transition-file", {
24168
24267
  frame: null,
24169
24268
  path: transitionPath(project, name),
24170
24269
  message,
@@ -24269,7 +24368,7 @@ async function listFrames(pageDir) {
24269
24368
  /**
24270
24369
  * The page order a reader shows: listed pages that exist in that order, then
24271
24370
  * unlisted ones by name. A file that fails to read orders every page by name.
24272
- * The creation time, folder, archive flag, and turned-off rules come from the
24371
+ * The creation time, title, folder, archive flag, and turned-off rules come from the
24273
24372
  * same read, each read as absent when the file holds none or holds one of
24274
24373
  * another type.
24275
24374
  */
@@ -24287,6 +24386,7 @@ async function readPageOrder(projectDir) {
24287
24386
  return {
24288
24387
  pages: folders,
24289
24388
  createdAt: null,
24389
+ title: null,
24290
24390
  group: null,
24291
24391
  archived: false,
24292
24392
  checksOff: [],
@@ -24299,6 +24399,7 @@ async function readPageOrder(projectDir) {
24299
24399
  return {
24300
24400
  pages: orderPages(file.pages, folders),
24301
24401
  createdAt: isTime(file.createdAt) ? file.createdAt : null,
24402
+ title: titleOf(file.title),
24302
24403
  group: groupOf$1(file.group),
24303
24404
  archived: file.archived === true,
24304
24405
  checksOff: checksOffOf(file.checks),
@@ -24317,6 +24418,13 @@ function checksOffOf(checks) {
24317
24418
  }
24318
24419
  /** A folder name as home shows it, trimmed, null for a blank or a non-string. */
24319
24420
  function groupOf$1(value) {
24421
+ return trimmedOf(value);
24422
+ }
24423
+ /** A project's title as readers show it, trimmed, null for a blank or a non-string. */
24424
+ function titleOf(value) {
24425
+ return trimmedOf(value);
24426
+ }
24427
+ function trimmedOf(value) {
24320
24428
  if (typeof value !== "string") return null;
24321
24429
  const trimmed = value.trim();
24322
24430
  return trimmed === "" ? null : trimmed;
@@ -24352,15 +24460,17 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
24352
24460
  continue;
24353
24461
  }
24354
24462
  const scroll = entry.scroll ?? false;
24355
- const device = deviceOf(entry.device);
24463
+ const box = {
24464
+ x: entry.x,
24465
+ y: entry.y,
24466
+ width: entry.width,
24467
+ height: entry.height
24468
+ };
24469
+ const shown = showsDevice(entry);
24470
+ const device = shown ? deviceForWidth(box.width) : null;
24356
24471
  const transition = readTransition(entry.transition);
24357
24472
  placements.set(name, {
24358
- box: {
24359
- x: entry.x,
24360
- y: entry.y,
24361
- width: entry.width,
24362
- height: entry.height
24363
- },
24473
+ box,
24364
24474
  order: entry.order,
24365
24475
  hidden: entry.hidden ?? false,
24366
24476
  locked: entry.locked ?? false,
@@ -24368,6 +24478,7 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
24368
24478
  hugHeight: !scroll && (entry.hugHeight ?? false),
24369
24479
  scroll,
24370
24480
  widths: widthsOf(entry.widths),
24481
+ ...shown ? { showDevice: true } : {},
24371
24482
  ...device ? { device } : {},
24372
24483
  ...transition ? { transition } : {},
24373
24484
  placed: true
@@ -24381,6 +24492,10 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
24381
24492
  }
24382
24493
  return placements;
24383
24494
  }
24495
+ /** Whether an entry shows its device, through its own key or the device name written before it. */
24496
+ function showsDevice(entry) {
24497
+ return entry?.showDevice === true || typeof entry?.device === "string";
24498
+ }
24384
24499
  /**
24385
24500
  * Where a frame with no layout entry sits: desktop size at `y` 0, 80 past the
24386
24501
  * right edge of every frame already placed and the linked widths it draws, on top of all of them. The board
@@ -24422,7 +24537,7 @@ async function scanBoard(root, { project } = {}) {
24422
24537
  }
24423
24538
  async function scanProject(root, name) {
24424
24539
  const path = join(root, name);
24425
- const { pages: order, createdAt, group, archived, checksOff, error } = await readPageOrder(path);
24540
+ const { pages: order, createdAt, title, group, archived, checksOff, error } = await readPageOrder(path);
24426
24541
  const transitions = await listTransitionNames(path);
24427
24542
  const pages = await Promise.all(order.map((page, index) => scanPage(root, name, page, index, transitions)));
24428
24543
  const times = await Promise.all([
@@ -24432,6 +24547,7 @@ async function scanProject(root, name) {
24432
24547
  ]);
24433
24548
  return {
24434
24549
  name,
24550
+ title,
24435
24551
  path,
24436
24552
  modifiedAt: new Date(Math.max(...times)).toISOString(),
24437
24553
  createdAt,
@@ -24594,7 +24710,7 @@ async function isDirectory(path) {
24594
24710
  }
24595
24711
  }
24596
24712
  // package.json
24597
- var version$1 = "0.37.0";
24713
+ var version$1 = "0.38.0";
24598
24714
  var dependencies = { "playwright-core": "1.65.0" };
24599
24715
  var peerDependencies = { "oxfmt": "0.78.0" };
24600
24716
  // src/shared/version.ts
@@ -24723,6 +24839,32 @@ function nextFreeName(base, taken) {
24723
24839
  if (!lowered.has(candidate.toLowerCase())) return candidate;
24724
24840
  }
24725
24841
  }
24842
+ /**
24843
+ * The folder a project in `current` lands in once titled `title`: the name
24844
+ * made from the title, the next free one when another of `taken` holds it,
24845
+ * and `current` itself when the title names no folder or names the one it
24846
+ * is in. A taken name near the length limit is cut back until a free one
24847
+ * fits, its suffix included, so the folder always stays a valid name.
24848
+ */
24849
+ function titledFolder(current, title, taken) {
24850
+ const folder = folderName(title);
24851
+ if (folder === "" || namesCollide(folder, current)) return current;
24852
+ const others = [...taken].filter((name) => name !== current);
24853
+ for (let cut = folder.length; cut > 0; cut--) {
24854
+ const base = folder.slice(0, cut).replace(/-+$/, "");
24855
+ const free = nextFreeName(base, others);
24856
+ if (base !== "" && free.length <= 64) return free;
24857
+ }
24858
+ return current;
24859
+ }
24860
+ /**
24861
+ * A typed title as the folder it names, lower case with each run of
24862
+ * characters a name may not hold turned into one dash, so `Acme mobile`
24863
+ * becomes `acme-mobile`. Empty when the title holds nothing a name may.
24864
+ */
24865
+ function folderName(typed) {
24866
+ return typed.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
24867
+ }
24726
24868
  // src/shared/records/claims.ts
24727
24869
  /**
24728
24870
  * Where a reserved frame will land, and which axes take their size from the
@@ -25110,7 +25252,7 @@ async function addFrame(root, ref, options) {
25110
25252
  ...hugs,
25111
25253
  scroll,
25112
25254
  widths,
25113
- ...options.device ? { device: options.device } : {}
25255
+ ...options.showDevice ? { showDevice: true } : {}
25114
25256
  });
25115
25257
  layout.renumber();
25116
25258
  }, journal);
@@ -25553,16 +25695,16 @@ async function setFrameFlag(root, ref, flag, { on, ...options }) {
25553
25695
  }));
25554
25696
  }
25555
25697
  /**
25556
- * Sets the device the board draws around a frame, or clears it with null.
25557
- * The frame's file and box are left as they stand, since the bezel wraps
25558
- * whatever size the frame is.
25698
+ * Shows or hides the device the board draws around a frame, which the
25699
+ * frame's width picks. The frame's file and box are left as they stand,
25700
+ * since the body wraps whatever size the frame is.
25559
25701
  */
25560
- async function setFrameDevice(root, ref, device, options) {
25702
+ async function setFrameDevice(root, ref, show, options) {
25561
25703
  return updatePlacement(root, ref, options, (placement) => {
25562
- const { device: _held, ...rest } = placement;
25563
- return device ? {
25704
+ const { showDevice: _held, device: _device, ...rest } = placement;
25705
+ return show ? {
25564
25706
  ...rest,
25565
- device
25707
+ showDevice: true
25566
25708
  } : rest;
25567
25709
  });
25568
25710
  }
@@ -25676,10 +25818,11 @@ var PageLayout = class {
25676
25818
  * is written once it is on or when the entry holds it, so an entry from
25677
25819
  * before the flags gains no key, and a scroll entry writes both hug flags
25678
25820
  * false, since it fixes both axes. `scroll` follows the same rule. `widths`,
25679
- * `device`, and `transition` are written while the frame holds one and
25821
+ * `showDevice`, and `transition` are written while the frame holds one and
25680
25822
  * removed once cleared, leaving a held value no reader understands as is.
25823
+ * A `device` name from before `showDevice` is replaced by it on any write.
25681
25824
  */
25682
- set(name, { box, order, hidden, locked, scroll, widths, device, transition, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
25825
+ set(name, { box, order, hidden, locked, scroll, widths, showDevice, transition, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
25683
25826
  const hugWidth = hugsWidth && !scroll;
25684
25827
  const hugHeight = hugsHeight && !scroll;
25685
25828
  const held = this.file.frames[name];
@@ -25699,11 +25842,12 @@ var PageLayout = class {
25699
25842
  width,
25700
25843
  height
25701
25844
  })) } : {},
25702
- ...device ? { device } : {},
25845
+ ...showDevice ? { showDevice } : {},
25703
25846
  ...transition ? { transition: { ...transition } } : {}
25704
25847
  };
25705
25848
  if (widths.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
25706
- if (!device && deviceOf(held?.device)) delete entry.device;
25849
+ if (!showDevice && held?.showDevice === true) delete entry.showDevice;
25850
+ if (typeof held?.device === "string") delete entry.device;
25707
25851
  if (!transition && storedTransitionOf(held?.transition)) delete entry.transition;
25708
25852
  this.file.frames[name] = entry;
25709
25853
  this.changed = true;
@@ -30007,7 +30151,7 @@ const THEME_RULES = [{
30007
30151
  severity: "error",
30008
30152
  description: "A frame setting literal colors defines the other theme too, through a [data-theme] selector, a prefers-color-scheme query, or light-dark()"
30009
30153
  }];
30010
- const finding$11 = findingFor(THEME_RULES);
30154
+ const finding$12 = findingFor(THEME_RULES);
30011
30155
  const COLOR_PROPERTIES$2 = /^(color|background(-color|-image)?|border(-(top|right|bottom|left|block|inline)(-(start|end))?)?(-color)?|outline(-color)?|fill|stroke|box-shadow|text-shadow|caret-color|accent-color|text-decoration(-color)?|column-rule(-color)?)$/i;
30012
30156
  const COLOR_FUNCTION = /\b(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(/i;
30013
30157
  const HEX_COLOR = /#[0-9a-f]{3,8}\b/i;
@@ -30017,7 +30161,7 @@ function checkTheme(source) {
30017
30161
  const { firstColor, bothThemes } = readThemeColors(source);
30018
30162
  if (!firstColor || bothThemes) return [];
30019
30163
  const { path, location } = firstColor;
30020
- return [finding$11("theme", {
30164
+ return [finding$12("theme", {
30021
30165
  frame: source.ref,
30022
30166
  path,
30023
30167
  message: "The frame sets its own colors for one theme alone. Define the other through [data-theme] or prefers-color-scheme, or take the colors from token variables.",
@@ -37044,12 +37188,12 @@ function changesOnlyTarget(before, after, index, change) {
37044
37188
  }
37045
37189
  return serialize$1(before.document) === serialize$1(after.document);
37046
37190
  }
37047
- function textOf$1(element) {
37191
+ function textOf(element) {
37048
37192
  return element.childNodes.map((node) => "value" in node && node.nodeName === "#text" ? node.value : "").join("");
37049
37193
  }
37050
37194
  /** Whether the target holds the value the change asked for. */
37051
37195
  function holdsValue(element, change) {
37052
- if (change.kind === "text") return textOf$1(element) === change.value;
37196
+ if (change.kind === "text") return textOf(element) === change.value;
37053
37197
  if (change.kind === "attribute") {
37054
37198
  const stated = element.attrs.find((attribute) => isNamed(attribute, change.name));
37055
37199
  return "remove" in change ? stated === void 0 : stated?.value === change.value;
@@ -39008,6 +39152,45 @@ async function renameProject(root, name, newName, { journal } = {}) {
39008
39152
  return scanProject(root, newName);
39009
39153
  }
39010
39154
  /**
39155
+ * Sets the name a person reads for the project, which may hold any
39156
+ * characters, and moves the folder to the name made from it, the next free
39157
+ * one when another project holds it. A title naming no folder, such as one in
39158
+ * a script a name cannot hold, or one naming the folder it is in, keeps the
39159
+ * folder. A blank title takes the key out, so readers show the folder again.
39160
+ * The title goes in first under the old folder and the move follows, which
39161
+ * the board's undo reverses in turn. The times are put back as a filing's
39162
+ * are, since a title draws nothing.
39163
+ */
39164
+ async function retitleProject(root, name, title, { journal } = {}) {
39165
+ const project = await resolveProject(root, name);
39166
+ const path = join(project.path, PROJECT_FILE);
39167
+ const trimmed = title.trim();
39168
+ if (trimmed.length > 256) throw new FrameboardError("invalid-name", `A project title holds at most 256 characters.`, { title: trimmed });
39169
+ await keepingTimes([path], (keep) => withLocks([path], async () => {
39170
+ const file = await readRecord(path, {
39171
+ ...projectSpec,
39172
+ empty: emptyProject
39173
+ });
39174
+ const { title: _title, ...rest } = file;
39175
+ const next = trimmed === "" ? rest : {
39176
+ ...rest,
39177
+ title: trimmed
39178
+ };
39179
+ const before = filingOf(file);
39180
+ const after = filingOf(next);
39181
+ if (isSameFiling(before, after)) return;
39182
+ await keep(path);
39183
+ await writeRecord(path, next);
39184
+ journal?.project(path, before, after);
39185
+ }));
39186
+ const moved = titledFolder(project.name, trimmed, await listProjects(root));
39187
+ if (moved === project.name) return scanProject(root, project.name);
39188
+ const target = join(root, moved);
39189
+ if (journal) await journal.moved(project.path, target);
39190
+ else await rename(project.path, target);
39191
+ return scanProject(root, moved);
39192
+ }
39193
+ /**
39011
39194
  * A copy of the project under the next free name, without its notes, and
39012
39195
  * stamped as made `now`.
39013
39196
  */
@@ -39093,11 +39276,12 @@ function filingOf(file) {
39093
39276
  return {
39094
39277
  ...file.group === void 0 ? {} : { group: file.group },
39095
39278
  ...file.archived === void 0 ? {} : { archived: file.archived },
39279
+ ...file.title === void 0 ? {} : { title: file.title },
39096
39280
  ...off === void 0 ? {} : { off }
39097
39281
  };
39098
39282
  }
39099
39283
  function isSameFiling(a, b) {
39100
- return a.group === b.group && a.archived === b.archived && isDeepStrictEqual(a.off, b.off);
39284
+ return a.group === b.group && a.archived === b.archived && a.title === b.title && isDeepStrictEqual(a.off, b.off);
39101
39285
  }
39102
39286
  /**
39103
39287
  * Turns one check rule off for the project, or back on, by adding or removing
@@ -39162,13 +39346,14 @@ function isRecord$3(value) {
39162
39346
  /**
39163
39347
  * Runs `run`, a section holding the lock of each project file it writes, and
39164
39348
  * puts back the times that file and its folder held, which the scanner reads
39165
- * as the project's last edit. `run` calls `keep` under the lock before each
39349
+ * as the project's last edit. `land` names where a file stands once `run`
39350
+ * is done, for a run that moves its folder, and the times go back there. `run` calls `keep` under the lock before each
39166
39351
  * write, so the file's time is read after any writer that held the lock first.
39167
39352
  * The folder's time is read before the lock, since taking and dropping the
39168
39353
  * lock moves it, and goes back only where the file kept its time until `keep`,
39169
39354
  * so a writer that ran in between keeps the Edited time it earned.
39170
39355
  */
39171
- async function keepingTimes(files, run) {
39356
+ async function keepingTimes(files, run, land = (file) => file) {
39172
39357
  const before = new Map(await Promise.all(files.map(async (file) => [file, {
39173
39358
  file: await stat(file).catch(() => void 0),
39174
39359
  folder: await stat(dirname(file)).catch(() => void 0)
@@ -39183,9 +39368,10 @@ async function keepingTimes(files, run) {
39183
39368
  return await run(keep);
39184
39369
  } finally {
39185
39370
  await Promise.all([...kept].map(async ([file, time]) => {
39186
- await put(file, time);
39371
+ const at = land(file);
39372
+ await put(at, time);
39187
39373
  const { file: was, folder } = before.get(file) ?? {};
39188
- if (folder && was?.mtimeMs === time.mtimeMs) await put(dirname(file), folder);
39374
+ if (folder && was?.mtimeMs === time.mtimeMs) await put(dirname(at), folder);
39189
39375
  }));
39190
39376
  }
39191
39377
  }
@@ -39565,7 +39751,7 @@ async function restore(change, side) {
39565
39751
  return;
39566
39752
  }
39567
39753
  case "project": {
39568
- const { group: _group, archived: _archived, ...rest } = await readRecord(change.file, projectSpec);
39754
+ const { group: _group, archived: _archived, title: _title, ...rest } = await readRecord(change.file, projectSpec);
39569
39755
  const { off, ...filing } = change[side];
39570
39756
  await writeRecord(change.file, withOff({
39571
39757
  ...rest,
@@ -39957,19 +40143,26 @@ var History = class {
39957
40143
  const step = from.pop();
39958
40144
  if (!step) throw empty();
39959
40145
  const was = to === "before" ? "after" : "before";
40146
+ const standing = step.changes.map((change, index) => standingAt(change, step.changes.slice(index + 1), was));
39960
40147
  const hashes = {};
39961
- const locks = step.changes.flatMap(lockPaths).filter((path) => existsSync(dirname(path)));
39962
- const timed = step.changes.flatMap((change) => change.kind === "project" ? [change.file] : []);
40148
+ const moves = step.changes.flatMap((change) => change.kind === "moved" ? [change.from, change.to] : []);
40149
+ const locks = standing.flatMap(lockPaths).filter((path) => existsSync(dirname(path))).filter((path) => !moves.some((folder) => path.startsWith(folder + sep)));
40150
+ const landing = new Map(standing.flatMap((change, index) => change.kind === "project" ? [[change.file, standingAt(step.changes[index] ?? change, step.changes.slice(index + 1), to)]] : []));
40151
+ const timed = [...landing.keys()];
40152
+ const landed = (file) => {
40153
+ const change = landing.get(file);
40154
+ return change?.kind === "project" ? change.file : file;
40155
+ };
39963
40156
  try {
39964
40157
  await keepingTimes(timed, (keep) => withLocks(locks, async () => {
39965
- for (const change of step.changes) if (!await holds(change, was)) throw new FrameboardError("undo-overtaken", `An agent changed ${nameOf(change)} after your edit, so that step was dropped.`, { change: change.kind });
40158
+ for (const change of standing) if (!await holds(change, was)) throw new FrameboardError("undo-overtaken", `An agent changed ${nameOf(change)} after your edit, so that step was dropped.`, { change: change.kind });
39966
40159
  for (const file of timed) await keep(file);
39967
40160
  const ordered = to === "before" ? [...step.changes].reverse() : step.changes;
39968
40161
  for (const change of ordered) {
39969
40162
  const hash = await restore(change, to);
39970
40163
  if (hash !== void 0 && "ref" in change) hashes[change.ref] = hash;
39971
40164
  }
39972
- }));
40165
+ }), landed);
39973
40166
  } catch (error) {
39974
40167
  if (!(error instanceof FrameboardError && error.code === "undo-overtaken")) from.push(step);
39975
40168
  this.onChange(this.counts());
@@ -39993,6 +40186,24 @@ var History = class {
39993
40186
  return run;
39994
40187
  }
39995
40188
  };
40189
+ /**
40190
+ * The change as the board stands at `side`, reading a project file where the
40191
+ * moves `later` in its step left it on the after side, since a retitle writes
40192
+ * the file under the old folder and then moves the folder. Restoring keeps the
40193
+ * recorded path, since the moves are undone first and redone last.
40194
+ */
40195
+ function standingAt(change, later, side) {
40196
+ if (side === "before" || change.kind !== "project") return change;
40197
+ let file = change.file;
40198
+ for (const each of later) {
40199
+ if (each.kind !== "moved") continue;
40200
+ if (file.startsWith(each.from + sep)) file = each.to + file.slice(each.from.length);
40201
+ }
40202
+ return file === change.file ? change : {
40203
+ ...change,
40204
+ file
40205
+ };
40206
+ }
39996
40207
  /** What a refusal names as overtaken, being a frame, a section, a page, the slide transition, the page order, or a filed project. */
39997
40208
  function nameOf(change) {
39998
40209
  if (change.kind === "entry") return change.frame;
@@ -42478,6 +42689,74 @@ async function sectionRecord(root, page, name) {
42478
42689
  if (!section) throw new Error(`Section ${name} vanished from ${page.name}.`);
42479
42690
  return section;
42480
42691
  }
42692
+ // src/server/checks/board-routes.ts
42693
+ const BOARD_ROUTE_RULES = [{
42694
+ id: "board-route",
42695
+ tier: "exact",
42696
+ severity: "error",
42697
+ description: "A frame's scripts and event handlers name no path under /api/, which on the board's origin reaches the board's own server"
42698
+ }];
42699
+ const finding$11 = findingFor(BOARD_ROUTE_RULES);
42700
+ /**
42701
+ * A quoted string or template literal opening on `/api/`, bare or after a
42702
+ * scheme and host, so a URL in code matches and prose in a comment does not.
42703
+ * A path the script builds at runtime, such as `'/ap' + 'i/'`, passes, since
42704
+ * the rule catches a mistake rather than a deliberate call.
42705
+ */
42706
+ const BOARD_ROUTE = /(['"`])((?:(?:[a-z][a-z0-9+.-]*:)?\/\/[^/'"`\s]*)?\/api\/[^'"`\n]*)\1/gi;
42707
+ /**
42708
+ * `board-route`, one finding per string naming a board route in a frame's
42709
+ * scripts, inline or local, and in its `on*` event handler attributes.
42710
+ */
42711
+ function checkBoardRoutes(source) {
42712
+ return frameCode(source).flatMap((code) => [...code.text.matchAll(BOARD_ROUTE)].map((match) => {
42713
+ const start = code.offset === null ? null : code.offset + match.index;
42714
+ return finding$11("board-route", {
42715
+ frame: source.ref,
42716
+ path: boardPath(source.root, code.path),
42717
+ message: `${code.via} names ${match[2]}, a route of the board's own server, which a frame on the board's origin reaches. Mock an app's calls with data kept in the script, or list board-route in the project's checks.off if its frames mean to call /api/.`,
42718
+ location: start === null ? code.at : locate$1(code.file, start, start + match[0].length)
42719
+ });
42720
+ }));
42721
+ }
42722
+ /**
42723
+ * Whether a browser runs the script, as it does for no `type`, `module`, or a
42724
+ * JavaScript type. A JSON, import map, or template block is data, which the
42725
+ * rule's own message names as the way to mock an app's calls.
42726
+ */
42727
+ function runs(element) {
42728
+ const type = (element.attribs.type ?? "").trim().toLowerCase();
42729
+ return type === "" || type === "module" || /^(?:application|text)\/(?:x-)?(?:java|ecma)script$/.test(type);
42730
+ }
42731
+ function frameCode(source) {
42732
+ const code = [];
42733
+ for (const element of source.elements) {
42734
+ if (element.name === "script" && runs(element)) {
42735
+ const script = scriptSource(element, source);
42736
+ if (script) {
42737
+ const inline = element.attribs.src === void 0;
42738
+ code.push({
42739
+ ...script,
42740
+ file: inline ? source.html : script.text,
42741
+ at: null,
42742
+ via: inline ? "A <script>" : `The script ${element.attribs.src}`
42743
+ });
42744
+ }
42745
+ }
42746
+ for (const [name, value] of Object.entries(element.attribs)) {
42747
+ if (!name.startsWith("on")) continue;
42748
+ code.push({
42749
+ text: value,
42750
+ path: source.path,
42751
+ offset: null,
42752
+ file: source.html,
42753
+ at: attributeLocation(element, name),
42754
+ via: `The ${name} handler on <${element.name}>`
42755
+ });
42756
+ }
42757
+ }
42758
+ return code;
42759
+ }
42481
42760
  // src/server/checks/browser/contrast.ts
42482
42761
  const CONTRAST_RULES = [{
42483
42762
  id: "min-contrast",
@@ -43508,12 +43787,13 @@ async function shootElement(page, ref, index, scale) {
43508
43787
  * page the size of the body, so the PNG holds the body and nothing past it.
43509
43788
  */
43510
43789
  async function drawBezel(browser, shot, box, device, scale) {
43511
- const { border, screenRadius } = BEZELS[device];
43790
+ const { screenRadius } = BEZELS[device];
43512
43791
  const outer = bezelBox({
43513
43792
  x: 0,
43514
43793
  y: 0,
43515
43794
  ...box
43516
43795
  }, device);
43796
+ const laptop = device === "laptop";
43517
43797
  const context = await browser.newContext({
43518
43798
  viewport: {
43519
43799
  width: outer.width,
@@ -43523,8 +43803,9 @@ async function drawBezel(browser, shot, box, device, scale) {
43523
43803
  });
43524
43804
  try {
43525
43805
  const page = await context.newPage();
43526
- const marks = device === "phone" ? `<span style="${pill(PHONE_ISLAND.width, PHONE_ISLAND.height, BEZEL_COLORS.island)}top:${PHONE_ISLAND.top}px"></span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>` : "";
43527
- await page.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${border}px;top:${border}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="display:block;width:100%;height:100%"><div style="position:absolute;inset:0;border-radius:${screenRadius}px;box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
43806
+ const marks = device === "phone" ? `<span style="${pill(PHONE_ISLAND.width, PHONE_ISLAND.height, BEZEL_COLORS.island)}top:${PHONE_ISLAND.top}px"></span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>` : laptop ? laptopMarks(box) : "";
43807
+ const radius = laptop ? `${screenRadius}px ${screenRadius}px 0 0` : `${screenRadius}px`;
43808
+ await page.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="display:block;width:100%;height:100%"><div style="position:absolute;inset:0;border-radius:${radius};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
43528
43809
  return await page.screenshot({
43529
43810
  omitBackground: true,
43530
43811
  caret: "hide"
@@ -43533,6 +43814,15 @@ async function drawBezel(browser, shot, box, device, scale) {
43533
43814
  await context.close();
43534
43815
  }
43535
43816
  }
43817
+ /**
43818
+ * The laptop's chin and base as the board draws them, past the screen's
43819
+ * bottom, with the body's edge as its last pixel rather than past it.
43820
+ */
43821
+ function laptopMarks(box) {
43822
+ const { chin, base } = laptopParts(box);
43823
+ const edge = `1px solid ${BEZEL_COLORS.edge}`;
43824
+ return `<span style="position:absolute;box-sizing:border-box;left:${chin.x}px;top:${chin.y}px;width:${chin.width}px;height:${chin.height}px;background:${BEZEL_COLORS.body};border-left:${edge};border-right:${edge}"></span><span style="position:absolute;box-sizing:border-box;left:${base.x}px;top:${base.y}px;width:${base.width}px;height:${base.height}px;background:${BEZEL_COLORS.base};border:${edge};border-radius:0 0 ${LAPTOP_BASE.radius}px ${LAPTOP_BASE.radius}px"></span>`;
43825
+ }
43536
43826
  function pill(width, height, color) {
43537
43827
  return `position:absolute;left:50%;transform:translateX(-50%);width:${width}px;height:${height}px;border-radius:${height / 2}px;background:${color};`;
43538
43828
  }
@@ -44174,25 +44464,6 @@ function bareVars(value) {
44174
44464
  function scriptWrites(text) {
44175
44465
  return SCRIPT_WRITES.flatMap((pattern) => [...text.matchAll(pattern)].map((match) => match.at(-1) ?? ""));
44176
44466
  }
44177
- /**
44178
- * A script's inline text, or its `src` file's when the file sits in the
44179
- * board. A remote, outside, or unreadable `src` reads as empty, since the
44180
- * write hook never reports a read as failed.
44181
- */
44182
- function scriptText(element, source) {
44183
- const src = element.attribs.src;
44184
- if (src === void 0) return textOf(element);
44185
- const file = localTarget(src, source.pageDir);
44186
- if (!file || !isInside(source.root, file)) return "";
44187
- try {
44188
- return readFileSync(file, "utf8");
44189
- } catch {
44190
- return "";
44191
- }
44192
- }
44193
- function textOf(element) {
44194
- return element.children.map((node) => "data" in node ? node.data : "").join("");
44195
- }
44196
44467
  function parseOrNull(css) {
44197
44468
  try {
44198
44469
  return postcss_default.parse(css);
@@ -44730,6 +45001,7 @@ function checkFrameIn(target, { config, tokens }) {
44730
45001
  ...checkMalformedTags(source),
44731
45002
  ...checkNesting(source),
44732
45003
  ...checkLinks(source),
45004
+ ...checkBoardRoutes(source),
44733
45005
  ...checkFonts(source, cascade, config),
44734
45006
  ...checkTheme(source),
44735
45007
  ...checkUnknownTokens(source, tokens),
@@ -44989,6 +45261,7 @@ function overlaps(a, b) {
44989
45261
  const RULES = [
44990
45262
  ...STRUCTURE_RULES,
44991
45263
  ...LINK_RULES,
45264
+ ...BOARD_ROUTE_RULES,
44992
45265
  ...FONT_RULES,
44993
45266
  ...THEME_RULES,
44994
45267
  ...CUSTOM_PROPERTY_RULES,
@@ -45093,6 +45366,11 @@ const renameSchema = object$1({
45093
45366
  ref,
45094
45367
  name
45095
45368
  });
45369
+ /** Any characters, since the folder takes a valid name made from it, and the verb refuses a title past its limit. */
45370
+ const retitleSchema = object$1({
45371
+ ref,
45372
+ title: string$1().max(1024)
45373
+ });
45096
45374
  const moveSchema = object$1({
45097
45375
  ref,
45098
45376
  index
@@ -45143,7 +45421,7 @@ const pasteSchema = object$1({
45143
45421
  });
45144
45422
  const frameDeviceSchema = object$1({
45145
45423
  refs,
45146
- device: _enum$1(DEVICES).nullable()
45424
+ show: boolean$1()
45147
45425
  });
45148
45426
  /** More widths than any device list offers, so a body cannot grow without bound. */
45149
45427
  const widthList = array$1(int$1().min(1)).max(64);
@@ -45514,10 +45792,10 @@ function structureRoutes(root, access, history, measure, tokens = null) {
45514
45792
  data: frames
45515
45793
  });
45516
45794
  });
45517
- /** Sets or clears the device drawn around each frame, in one step, leaving every frame file alone. */
45795
+ /** Shows or hides the device each frame's width names, in one step, leaving every frame file alone. */
45518
45796
  app.post("/api/frame/device", async (c) => {
45519
45797
  const body = await parseBody$1(c.req.raw, frameDeviceSchema);
45520
- const frames = await eachFrame(body.refs, (frame, journal) => setFrameDevice(root, frame, body.device, {
45798
+ const frames = await eachFrame(body.refs, (frame, journal) => setFrameDevice(root, frame, body.show, {
45521
45799
  cwd,
45522
45800
  journal
45523
45801
  }), (records) => records.map((record) => record.ref));
@@ -45743,6 +46021,22 @@ function structureRoutes(root, access, history, measure, tokens = null) {
45743
46021
  data: project
45744
46022
  });
45745
46023
  });
46024
+ app.post("/api/project/title", async (c) => {
46025
+ const body = await parseBody$1(c.req.raw, retitleSchema);
46026
+ const source = await resolveProject(root, body.ref);
46027
+ await refuseHeld([source.name]);
46028
+ const project = await recorded((journal) => retitleProject(root, body.ref, body.title, { journal }), async (retitled) => ({
46029
+ ...await onHome(),
46030
+ ...retitled.name === source.name ? {} : { renamed: {
46031
+ before: source.name,
46032
+ after: retitled.name
46033
+ } }
46034
+ }));
46035
+ return c.json({
46036
+ ok: true,
46037
+ data: project
46038
+ });
46039
+ });
45746
46040
  app.post("/api/project/duplicate", async (c) => {
45747
46041
  const body = await parseBody$1(c.req.raw, projectSchema);
45748
46042
  const project = await recorded((journal) => duplicateProject(root, body.ref, /* @__PURE__ */ new Date(), { journal }), onHome);
@@ -46292,7 +46586,7 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
46292
46586
  for (const theme of themes) {
46293
46587
  const tiles = [];
46294
46588
  const videos = /* @__PURE__ */ new Map();
46295
- for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths)]) {
46589
+ for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths, frame.device)]) {
46296
46590
  const { bytes, videos: unloaded } = await renderFrame(browser, baseUrl, frame, box, theme, scale);
46297
46591
  for (const video of inFrame(frame.ref, unloaded)) videos.set(`${video.ref} ${video.index}`, video);
46298
46592
  tiles.push(`<img src="data:image/png;base64,${bytes.toString("base64")}" style="position:absolute;left:${box.x + bounds.dx}px;top:${box.y + bounds.dy}px;width:${box.width}px;height:${box.height}px">`);
@@ -46886,7 +47180,9 @@ const frameRecordSchema = object$1({
46886
47180
  width: number(),
46887
47181
  height: number()
46888
47182
  })),
46889
- /** The device the board draws around the frame, absent when it has none. */
47183
+ /** Whether the board draws the frame inside a device, absent when it does not. */
47184
+ showDevice: boolean$1().optional(),
47185
+ /** The device the frame's width names while it shows one, absent when off or under 320 wide. */
46890
47186
  device: _enum$1(DEVICES).optional(),
46891
47187
  /** The transition the frame arrives with in present mode, over its page's, absent when it holds none. */
46892
47188
  transition: transitionRecordSchema.optional(),
@@ -46919,7 +47215,10 @@ const pageRecordSchema = object$1({
46919
47215
  sections: array$1(sectionRecordSchema)
46920
47216
  });
46921
47217
  const projectRecordSchema = object$1({
47218
+ /** The folder, which every ref, URL, and CLI argument names the project by. */
46922
47219
  name: string$1(),
47220
+ /** The name a person reads, null when `project.json` holds none, where readers show `name`. */
47221
+ title: string$1().nullable(),
46923
47222
  path: string$1(),
46924
47223
  modifiedAt: string$1(),
46925
47224
  /** When the project was made, null for one made before the time was recorded. */
@@ -47444,7 +47743,7 @@ function contentFormat() {
47444
47743
  "hidden, locked, hugWidth, hugHeight, and scroll read as false when absent, and an axis whose hug flag is false holds the size its entry states.",
47445
47744
  `scroll marks a frame that holds a fixed screen height and scrolls past it, such as a page with a sticky section. It fixes both axes, so either hug flag beside it reads as false, frame fit refuses it, and serve never measures it. frame add --scroll sets it, taking the height given or else the preset height of the width (${FRAME_SIZES.desktop.height} px at ${FRAME_SIZES.desktop.width}). frame resize --scroll sets it on a placed frame, dropping a hugging height to that preset height unless a height is given and keeping a fixed height as it stands, so resize a frame fixed past a screen with --height too. frame resize --no-scroll clears it, keeping the box.`,
47446
47745
  `widths lists the extra widths one frame file also shows at, as { width, height } objects, each drawn 80 px past the last in a row beside the frame at its y, so a responsive page is one file rather than a copy per width. Each width follows the frame's own height mode: it hugs its content at that width while hugHeight is on, and otherwise holds its height, the preset height of its width when first set and on frame resize --scroll. A value of any other shape reads as none. frame add --widths 834,390 and frame resize --widths set it, refusing a repeated width, the frame's own width, or a frame hugging its width, and frame resize --no-widths clears it. capture writes <frame>@<width>.<theme>.png beside <frame>.<theme>.png, check reports a browser finding at a linked width with that width and prints it as <path>@<width>, and a frames.json value of <project>/<page>/<frame>@<width> syncs that width's images.`,
47447
- `device names the device the board draws around the frame, phone or tablet, as a body ${BEZELS.phone.border} or ${BEZELS.tablet.border} px past the box on every side. It never changes the frame file or its size, the body wraps whatever box the frame holds, and a frame placed beside one lands 80 px past the body. Linked widths draw no device. Any other value reads as none and is kept on write. frame add --device and frame device <frame-ref> <phone|tablet|none> set it, and none clears it.`,
47746
+ `showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side and the tablet's ${BEZELS.tablet.border}, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file or its size, and a frame placed beside one lands 80 px past the body. Linked widths draw no device. Any other value of showDevice reads as off and is kept on write. A device string from before showDevice reads as on, and the entry's next write replaces it with showDevice. frame add --device on and frame device <frame-ref> <on|off> set it, taking phone and tablet as on and none as off.`,
47448
47747
  `An axis that hugs takes its size from the frame's content: a running serve measures it after each write to the frame file and when frame add places a file already written, its width at most ${FRAME_SIZES.desktop.width} px, and writes width and height alone, never a flag. Content sized off the viewport keeps the box it has.`,
47449
47748
  "frame add with no size hugs both axes, --size or --width fixes the width and hugs the height, and --height fixes the height alone, its box standing in until serve measures. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
47450
47749
  "Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
@@ -47821,7 +48120,29 @@ function transitionFrom(name, { ms, direction }) {
47821
48120
  // src/cli/commands/frame.ts
47822
48121
  const FRAME_REF = "a frame ref, <page>/<frame> or <project>/<page>/<frame>, or a path to its .html file";
47823
48122
  const ANY_INTEGER = parseInteger(Number.MIN_SAFE_INTEGER);
47824
- const DEVICE_HELP = "the device the board draws around the frame, leaving the frame file and its size as they are";
48123
+ const DEVICE_HELP = "on to draw the frame inside the phone, tablet, or laptop its width names, leaving the frame file and its size as they are, with phone and tablet taken as on";
48124
+ /**
48125
+ * What `frame device` takes, on or off, with the device names it took before
48126
+ * the width picked the body kept as aliases, so no agent's call breaks.
48127
+ */
48128
+ const DEVICE_SWITCH = {
48129
+ on: true,
48130
+ off: false,
48131
+ phone: true,
48132
+ tablet: true,
48133
+ none: false
48134
+ };
48135
+ const DEVICE_ON = [
48136
+ "on",
48137
+ "phone",
48138
+ "tablet"
48139
+ ];
48140
+ /** What `frame device` did, naming the device the frame's width gave it. */
48141
+ function deviceHeadline({ ref, box, showDevice, device }) {
48142
+ if (!showDevice) return `Hid the device on ${ref}`;
48143
+ if (!device) return `Showed the device on ${ref}, though no device fits its ${box.width} px width`;
48144
+ return `Showed the ${device} on ${ref}`;
48145
+ }
47825
48146
  const WIDTHS_HELP = "the extra widths the frame also shows at, a comma list such as 834,390, each drawn beside it and hugging or holding its height as the frame does";
47826
48147
  const POSITIVE = parseInteger(1);
47827
48148
  /** A comma list of positive integers, each checked as `--width` checks one. */
@@ -47844,8 +48165,9 @@ function registerFrame(program, context) {
47844
48165
  data: record,
47845
48166
  human: `${what} ${record.ref}`
47846
48167
  });
47847
- act(withPosition(withSize(verb("add", "Place a frame past every frame, as written when its file exists and with a skeleton file only when none does, so write the file first to show no empty box. Each axis no size names hugs its content, so a preset or --width fixes the width and the height hugs.").option("--scroll", SCROLL_HELP).option("--widths <list>", WIDTHS_HELP, parseWidths).addOption(new Option("--device <device>", DEVICE_HELP).choices(DEVICES)))), context, async ([ref = ""], options) => done(await addFrame(await boardOf(options, io), ref, {
48168
+ act(withPosition(withSize(verb("add", "Place a frame past every frame, as written when its file exists and with a skeleton file only when none does, so write the file first to show no empty box. Each axis no size names hugs its content, so a preset or --width fixes the width and the height hugs.").option("--scroll", SCROLL_HELP).option("--widths <list>", WIDTHS_HELP, parseWidths).addOption(new Option("--device <on>", DEVICE_HELP).choices(DEVICE_ON)))), context, async ([ref = ""], { device, ...options }) => done(await addFrame(await boardOf(options, io), ref, {
47848
48169
  ...options,
48170
+ ...device ? { showDevice: true } : {},
47849
48171
  cwd: io.cwd
47850
48172
  }), "Added"));
47851
48173
  act(verb("duplicate", "Copy a frame file byte for byte, on top").option("--to <page-ref>", "the page to copy into, defaulting to its own").option("--name <new>", "name of the copy, defaulting to the next free -2, -3"), context, async ([ref = ""], options) => done(await duplicateFrame(await boardOf(options, io), ref, {
@@ -47901,12 +48223,16 @@ function registerFrame(program, context) {
47901
48223
  human: `Deleted frame ${result.deleted}`
47902
48224
  };
47903
48225
  });
47904
- act(verb("device", "Set the device the board draws around a frame, or clear it with none, leaving the frame file and its size as they are").addArgument(new Argument("<device>", "the device, or none to clear it").choices([...DEVICES, "none"])), context, async ([ref = "", device = ""], options) => {
47905
- const record = await setFrameDevice(await boardOf(options, io), ref, deviceOf(device), {
48226
+ act(verb("device", "Show or hide the device the board draws around a frame, the phone, tablet, or laptop its width names, leaving the frame file and its size as they are").addArgument(new Argument("<on|off>", "on to show the device, off to hide it, with phone and tablet taken as on and none as off").choices(Object.keys(DEVICE_SWITCH))), context, async ([ref = "", value = ""], options) => {
48227
+ const show = Object.hasOwn(DEVICE_SWITCH, value) ? DEVICE_SWITCH[value] : false;
48228
+ const record = await setFrameDevice(await boardOf(options, io), ref, show, {
47906
48229
  ...options,
47907
48230
  cwd: io.cwd
47908
48231
  });
47909
- return done(record, record.device ? `Set ${record.device} on` : "Cleared the device on");
48232
+ return {
48233
+ data: record,
48234
+ human: deviceHeadline(record)
48235
+ };
47910
48236
  });
47911
48237
  act(withTransitionFlags(verb("transition", "Set the transition present mode draws as this slide arrives, over its page’s, or clear it with page so it takes the page’s, writing only layout.json").addArgument(new Argument("<transition>", transitionHelp(`${SAME_AS_PAGE_WORD} to take the page’s`)))), context, async ([ref = "", name = ""], options) => {
47912
48238
  const record = await setFrameTransition(await boardOf(options, io), ref, transitionOrPage(name, options), {
@@ -52397,6 +52723,13 @@ function registerProject(program, context) {
52397
52723
  human: `Renamed project ${name} to ${record.name}`
52398
52724
  };
52399
52725
  });
52726
+ act(addVerb(project, "title", "Set the name a person reads for a project, which may hold any characters, and move its folder to the name made from it").argument("<name>", "the project folder").argument("<title>", "its title, a blank one taking the title out"), context, async ([name = "", title = ""], options) => {
52727
+ const record = await retitleProject(await boardOf(options, io), name, title);
52728
+ return {
52729
+ data: record,
52730
+ human: record.title === null ? `Took the title off project ${record.name}` : record.name === name ? `Titled project ${name} '${record.title}'` : `Titled project ${name} '${record.title}' and moved it to ${record.name}`
52731
+ };
52732
+ });
52400
52733
  act(addVerb(project, "delete", "Delete a project and everything in it").argument("<name>", "the project"), context, async ([name = ""], options) => {
52401
52734
  const result = await deleteProject(await boardOf(options, io), name);
52402
52735
  return {
@@ -56467,6 +56800,26 @@ function isIgnored(root, path) {
56467
56800
  * Only frames in `board` are named, in board order.
56468
56801
  */
56469
56802
  function reloadRefs(root, paths, board, tokens = null) {
56803
+ const { refs, everyFrame } = reloadCauses(root, paths, tokens);
56804
+ const named = [];
56805
+ for (const project of board.projects) for (const page of project.pages) for (const frame of page.frames) if (everyFrame || refs.has(frame.ref) || refs.has(`${page.ref}/*`) || refs.has(`${project.name}/*`)) named.push(frame.ref);
56806
+ return named;
56807
+ }
56808
+ /**
56809
+ * The frames `reloadRefs` names through their own file alone, with no token
56810
+ * sheet, asset, or other page-folder file in the batch reaching them, in
56811
+ * board order. Only these reload into bytes a hash of that one file names.
56812
+ */
56813
+ function ownReloadRefs(root, paths, board, tokens = null) {
56814
+ const { refs, everyFrame } = reloadCauses(root, paths, tokens);
56815
+ if (everyFrame) return [];
56816
+ return board.projects.flatMap((project) => refs.has(`${project.name}/*`) ? [] : project.pages.flatMap((page) => refs.has(`${page.ref}/*`) ? [] : page.frames.filter((frame) => refs.has(frame.ref)).map((frame) => frame.ref)));
56817
+ }
56818
+ /**
56819
+ * What a batch's paths reach: frame refs, `<page>/*` and `<project>/*`
56820
+ * wildcards, and whether a board-wide sheet reaches every frame.
56821
+ */
56822
+ function reloadCauses(root, paths, tokens) {
56470
56823
  const refs = /* @__PURE__ */ new Set();
56471
56824
  let everyFrame = false;
56472
56825
  for (const path of paths) {
@@ -56488,9 +56841,10 @@ function reloadRefs(root, paths, board, tokens = null) {
56488
56841
  refs.add(frame === null ? `${project}/${folder}/*` : `${project}/${folder}/${frame}`);
56489
56842
  }
56490
56843
  }
56491
- const named = [];
56492
- for (const project of board.projects) for (const page of project.pages) for (const frame of page.frames) if (everyFrame || refs.has(frame.ref) || refs.has(`${page.ref}/*`) || refs.has(`${project.name}/*`)) named.push(frame.ref);
56493
- return named;
56844
+ return {
56845
+ refs,
56846
+ everyFrame
56847
+ };
56494
56848
  }
56495
56849
  /**
56496
56850
  * `refs` less each frame that only moved with a folder the board renamed,
@@ -57774,10 +58128,14 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
57774
58128
  hug.later(board, [.../* @__PURE__ */ new Set([...refs, ...relisted])].filter((ref) => !own.includes(ref) && !placed.includes(ref)));
57775
58129
  if (refs.length > 0) {
57776
58130
  const reloads = unmovedRefs(refs, board, moved(), last);
57777
- if (reloads.length > 0) hub.broadcast({
57778
- type: "reload",
57779
- refs: reloads
57780
- });
58131
+ if (reloads.length > 0) {
58132
+ const hashes = await ownFileHashes(board, ownReloadRefs(root, paths, board, tokens).filter((ref) => reloads.includes(ref)));
58133
+ hub.broadcast({
58134
+ type: "reload",
58135
+ refs: reloads,
58136
+ ...Object.keys(hashes).length > 0 ? { hashes } : {}
58137
+ });
58138
+ }
57781
58139
  thumbnails.invalidate(refs);
57782
58140
  const stale = Object.fromEntries(refs.map((ref) => [ref, null]));
57783
58141
  for (const theme of THEMES) hub.broadcast({
@@ -57797,6 +58155,23 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
57797
58155
  await pushNotes(root, paths, hub, delivery);
57798
58156
  }
57799
58157
  /**
58158
+ * The content hash of each named frame's file as it stands now, which is
58159
+ * what its reload will render. A file that cannot be read is left out, so
58160
+ * its frame reloads.
58161
+ */
58162
+ async function ownFileHashes(board, refs) {
58163
+ const named = new Set(refs);
58164
+ const frames = board.projects.flatMap((project) => project.pages).flatMap((page) => page.frames).filter((frame) => named.has(frame.ref));
58165
+ const read = await Promise.all(frames.map(async (frame) => {
58166
+ try {
58167
+ return [[frame.ref, contentHash(await readFile(frame.path))]];
58168
+ } catch {
58169
+ return [];
58170
+ }
58171
+ }));
58172
+ return Object.fromEntries(read.flat());
58173
+ }
58174
+ /**
57800
58175
  * Runs `outranked` over each settled agent write against the bytes it
57801
58176
  * replaced, holding the result in place of the frame's previous write's, and
57802
58177
  * returns the merged lists to send. A write raising nothing keeps a held