frameboard 0.30.0 → 0.31.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
@@ -3033,6 +3033,7 @@ const EXIT_CODES = {
3033
3033
  "browser-not-found": 9,
3034
3034
  "font-missing": 10,
3035
3035
  "fit-unbounded": 10,
3036
+ "fit-scroll": 10,
3036
3037
  "capture-too-large": 10,
3037
3038
  "frame-locked": 11,
3038
3039
  "stale-layout": 11,
@@ -9050,6 +9051,25 @@ const FRAME_SIZES = {
9050
9051
  }
9051
9052
  };
9052
9053
  /**
9054
+ * The widths each preset reads as, inclusive, so a 393 phone is a phone. The
9055
+ * preset's own width is the default a preview takes from outside its range.
9056
+ * They sit apart from `FRAME_SIZES`, whose entries spread into a frame's box.
9057
+ */
9058
+ const PRESET_RANGES = {
9059
+ phone: {
9060
+ min: 320,
9061
+ max: 479
9062
+ },
9063
+ tablet: {
9064
+ min: 480,
9065
+ max: 1023
9066
+ },
9067
+ desktop: {
9068
+ min: 1024,
9069
+ max: Number.POSITIVE_INFINITY
9070
+ }
9071
+ };
9072
+ /**
9053
9073
  * The devices the Frame tool and `--size` offer beside the three presets.
9054
9074
  * The iPad Pro 11 and a 1440 desktop are the tablet and desktop presets, so
9055
9075
  * neither repeats here.
@@ -9159,6 +9179,78 @@ function frameSizeOf(name) {
9159
9179
  height
9160
9180
  };
9161
9181
  }
9182
+ /** The preset whose range holds a width, or none below the phone range. */
9183
+ function presetAt(width) {
9184
+ return Object.keys(PRESET_RANGES).filter(isFrameSizePreset).find((preset) => {
9185
+ const { min, max } = PRESET_RANGES[preset];
9186
+ return width >= min && width <= max;
9187
+ });
9188
+ }
9189
+ /**
9190
+ * The viewport height a frame's content is read at, being the height of the
9191
+ * preset whose range holds the width, or the desktop height below every
9192
+ * range. Reading at the box's own height lets content sized off the viewport
9193
+ * grow by that height on every fit.
9194
+ */
9195
+ function referenceHeight(width) {
9196
+ return FRAME_SIZES[presetAt(width) ?? "desktop"].height;
9197
+ }
9198
+ // src/shared/frame-widths.ts
9199
+ /**
9200
+ * A layout entry's `widths` value as a clean list. Anything but an array of
9201
+ * objects each holding a positive integer `width` and `height`, with no width
9202
+ * repeated, reads as none, so a value no reader understands never refuses the
9203
+ * page's layout.
9204
+ */
9205
+ function widthsOf(value) {
9206
+ if (!Array.isArray(value)) return [];
9207
+ const widths = [];
9208
+ for (const item of value) {
9209
+ if (typeof item !== "object" || item === null) return [];
9210
+ const { width, height } = item;
9211
+ if (!isSize(width) || !isSize(height)) return [];
9212
+ if (widths.some((linked) => linked.width === width)) return [];
9213
+ widths.push({
9214
+ width,
9215
+ height
9216
+ });
9217
+ }
9218
+ return widths;
9219
+ }
9220
+ function isSize(value) {
9221
+ return typeof value === "number" && Number.isInteger(value) && value >= 1;
9222
+ }
9223
+ /**
9224
+ * Where each linked width draws: in a row at the frame's `y`, the first
9225
+ * `FRAME_GAP` past the frame's right edge and each next one past the last.
9226
+ */
9227
+ function linkedBoxes(box, widths) {
9228
+ const boxes = [];
9229
+ let x = box.x + box.width;
9230
+ for (const { width, height } of widths) {
9231
+ x += 80;
9232
+ boxes.push({
9233
+ x,
9234
+ y: box.y,
9235
+ width,
9236
+ height
9237
+ });
9238
+ x += width;
9239
+ }
9240
+ return boxes;
9241
+ }
9242
+ /** The box holding a frame and every linked width it draws, the frame's own with none. */
9243
+ function drawnExtent(box, widths) {
9244
+ const boxes = linkedBoxes(box, widths);
9245
+ const last = boxes.at(-1);
9246
+ if (!last) return { ...box };
9247
+ return {
9248
+ x: box.x,
9249
+ y: box.y,
9250
+ width: last.x + last.width - box.x,
9251
+ height: Math.max(box.height, ...boxes.map(({ height }) => height))
9252
+ };
9253
+ }
9162
9254
  // src/shared/records/board.ts
9163
9255
  const boardFileSchema = looseObject({ version: literal(1) });
9164
9256
  /** A project's own check rules, absent meaning the built-in rules alone. */
@@ -9187,7 +9279,12 @@ const layoutEntrySchema = looseObject({
9187
9279
  hidden: boolean$1().optional(),
9188
9280
  locked: boolean$1().optional(),
9189
9281
  hugWidth: boolean$1().optional(),
9190
- hugHeight: boolean$1().optional()
9282
+ hugHeight: boolean$1().optional(),
9283
+ scroll: boolean$1().optional(),
9284
+ widths: union([array$1(looseObject({
9285
+ width: int$1().min(1),
9286
+ height: int$1().min(1)
9287
+ })), unknown()]).optional()
9191
9288
  });
9192
9289
  /** A named box grouping the frames whose center it holds, which it never lists. */
9193
9290
  const sectionEntrySchema = looseObject({
@@ -9317,6 +9414,7 @@ function placeFrames(frames, names) {
9317
9414
  unplaced.push(name);
9318
9415
  continue;
9319
9416
  }
9417
+ const scroll = entry.scroll ?? false;
9320
9418
  placements.set(name, {
9321
9419
  box: {
9322
9420
  x: entry.x,
@@ -9327,8 +9425,10 @@ function placeFrames(frames, names) {
9327
9425
  order: entry.order,
9328
9426
  hidden: entry.hidden ?? false,
9329
9427
  locked: entry.locked ?? false,
9330
- hugWidth: entry.hugWidth ?? false,
9331
- hugHeight: entry.hugHeight ?? false,
9428
+ hugWidth: !scroll && (entry.hugWidth ?? false),
9429
+ hugHeight: !scroll && (entry.hugHeight ?? false),
9430
+ scroll,
9431
+ widths: widthsOf(entry.widths),
9332
9432
  placed: true
9333
9433
  });
9334
9434
  }
@@ -9342,12 +9442,15 @@ function placeFrames(frames, names) {
9342
9442
  }
9343
9443
  /**
9344
9444
  * Where a frame with no layout entry sits: desktop size at `y` 0, 80 past the
9345
- * right edge of every frame already placed, on top of all of them. The board
9445
+ * right edge of every frame already placed and the linked widths it draws, on top of all of them. The board
9346
9446
  * draws what the scanner returns, and `frame add` persists the same box for
9347
9447
  * the first unplaced file, placing any other past the placed frames alone.
9348
9448
  */
9349
9449
  function placeNext(placed) {
9350
- const right = Math.max(...placed.map(({ box }) => box.x + box.width + 80), 0);
9450
+ const right = Math.max(...placed.map(({ box, widths }) => {
9451
+ const extent = drawnExtent(box, widths);
9452
+ return extent.x + extent.width + 80;
9453
+ }), 0);
9351
9454
  const order = Math.max(...placed.map((placement) => placement.order + 1), 0);
9352
9455
  return {
9353
9456
  box: {
@@ -9360,6 +9463,8 @@ function placeNext(placed) {
9360
9463
  locked: false,
9361
9464
  hugWidth: false,
9362
9465
  hugHeight: false,
9466
+ scroll: false,
9467
+ widths: [],
9363
9468
  placed: false
9364
9469
  };
9365
9470
  }
@@ -9528,7 +9633,7 @@ async function isDirectory(path) {
9528
9633
  }
9529
9634
  }
9530
9635
  // package.json
9531
- var version$1 = "0.30.0";
9636
+ var version$1 = "0.31.0";
9532
9637
  var dependencies = { "playwright-core": "1.65.0" };
9533
9638
  var peerDependencies = { "oxfmt": "0.77.0" };
9534
9639
  // src/shared/version.ts
@@ -9988,7 +10093,8 @@ async function framePathParts(root, ref, cwd) {
9988
10093
  * as `placeNext` puts it, ignoring the page's other unplaced files, unless a
9989
10094
  * size or position is given. Every axis no size names hugs its
9990
10095
  * content, a preset fixing the width alone, and the box stands in until the
9991
- * server measures.
10096
+ * server measures. A scroll frame hugs neither axis, and with no height named
10097
+ * takes the reference height of its width.
9992
10098
  */
9993
10099
  async function addFrame(root, ref, options) {
9994
10100
  const { journal } = options;
@@ -10003,7 +10109,11 @@ async function addFrame(root, ref, options) {
10003
10109
  width: reserved.width,
10004
10110
  height: reserved.height
10005
10111
  } : sizeOf(options);
10006
- const hugs = reserved && !sized ? {
10112
+ const scroll = options.scroll ?? false;
10113
+ const hugs = scroll ? {
10114
+ hugWidth: false,
10115
+ hugHeight: false
10116
+ } : reserved && !sized ? {
10007
10117
  hugWidth: reserved.hugWidth ?? false,
10008
10118
  hugHeight: reserved.hugHeight ?? false
10009
10119
  } : hugsOf(options);
@@ -10015,6 +10125,12 @@ async function addFrame(root, ref, options) {
10015
10125
  const slot = names.filter((name) => name === frame.name || layout.hasEntry(name));
10016
10126
  const computed = placeFrames(layout.file.frames, slot).get(frame.name);
10017
10127
  if (!computed) throw new Error(`No placement computed for ${frame.name}.`);
10128
+ const width = size.width ?? computed.box.width;
10129
+ const widths = linkedWidths(refOf$1(frame), options.widths, {
10130
+ width,
10131
+ hugWidth: hugs.hugWidth,
10132
+ held: []
10133
+ });
10018
10134
  if (!exists) {
10019
10135
  await writeFile(frame.path, skeleton(frame.name), { flag: "wx" });
10020
10136
  await journal?.created(frame.path);
@@ -10025,10 +10141,13 @@ async function addFrame(root, ref, options) {
10025
10141
  box: {
10026
10142
  ...computed.box,
10027
10143
  ...size,
10144
+ ...scroll && size.height === void 0 ? { height: referenceHeight(width) } : {},
10028
10145
  x: options.x ?? reserved?.x ?? computed.box.x,
10029
10146
  y: options.y ?? reserved?.y ?? computed.box.y
10030
10147
  },
10031
- ...hugs
10148
+ ...hugs,
10149
+ scroll,
10150
+ widths
10032
10151
  });
10033
10152
  layout.renumber();
10034
10153
  }, journal);
@@ -10056,7 +10175,7 @@ async function duplicateFrame(root, ref, { to, name, offset, journal, ...options
10056
10175
  y: placement.box.y + offset.y
10057
10176
  } : into === from ? {
10058
10177
  ...placement.box,
10059
- x: placement.box.x + placement.box.width + 80
10178
+ x: pastExtent(placement)
10060
10179
  } : placement.box;
10061
10180
  const copyPath = join(into, `${copyName}${FRAME_EXTENSION}`);
10062
10181
  await copyFile(source.path, copyPath, constants.COPYFILE_EXCL);
@@ -10129,32 +10248,100 @@ async function renameFrame(root, ref, newName, options) {
10129
10248
  name: newName
10130
10249
  });
10131
10250
  }
10251
+ /**
10252
+ * Sets the size each option names and fixes those axes. `scroll` on fixes
10253
+ * both, dropping a hugging height no option names to the reference height of
10254
+ * the width, since a frame kept at its content's full height has nothing to
10255
+ * scroll. `scroll` off clears the key and keeps the box as it stands.
10256
+ */
10132
10257
  async function resizeFrame(root, ref, options) {
10133
10258
  const size = sizeOf(options);
10134
- if (Object.keys(size).length === 0) throw new FrameboardError("usage", "Pass --size, --width, or --height to resize a frame.");
10135
- return updatePlacement(root, ref, options, (placement) => ({
10136
- ...placement,
10137
- box: {
10138
- ...placement.box,
10139
- ...size
10140
- },
10141
- hugWidth: placement.hugWidth && size.width === void 0,
10142
- hugHeight: placement.hugHeight && size.height === void 0
10259
+ if (Object.keys(size).length === 0 && options.scroll === void 0 && options.widths === void 0) throw new FrameboardError("usage", "Pass --size, --width, --height, --scroll, --no-scroll, --widths, or --no-widths to resize a frame.");
10260
+ return updatePlacement(root, ref, options, (placement, frameRef) => {
10261
+ const scroll = options.scroll ?? placement.scroll;
10262
+ const width = size.width ?? placement.box.width;
10263
+ const drops = scroll && placement.hugHeight && size.height === void 0;
10264
+ const hugWidth = !scroll && placement.hugWidth && size.width === void 0;
10265
+ const widths = linkedWidths(frameRef, options.widths ?? placement.widths.map((linked) => linked.width), {
10266
+ width,
10267
+ hugWidth,
10268
+ held: placement.widths
10269
+ });
10270
+ return {
10271
+ ...placement,
10272
+ box: {
10273
+ ...placement.box,
10274
+ ...size,
10275
+ ...drops ? { height: referenceHeight(width) } : {}
10276
+ },
10277
+ hugWidth,
10278
+ hugHeight: !scroll && placement.hugHeight && size.height === void 0,
10279
+ scroll,
10280
+ widths: scroll && placement.hugHeight ? widths.map((linked) => ({
10281
+ ...linked,
10282
+ height: referenceHeight(linked.width)
10283
+ })) : widths
10284
+ };
10285
+ });
10286
+ }
10287
+ /**
10288
+ * The linked widths a verb writes, keeping the height each one already held
10289
+ * and giving a new one the reference height of its width, which a hugging
10290
+ * frame's measure replaces. A repeated width, the frame's own width, or a
10291
+ * frame hugging its width refuses `usage`.
10292
+ */
10293
+ function linkedWidths(ref, requested, { width, hugWidth, held }) {
10294
+ if (!requested || requested.length === 0) return [];
10295
+ if (hugWidth) throw new FrameboardError("usage", `${ref} hugs its width, so it has no width to show beside others. Fix it with --size or --width first.`, {
10296
+ ref,
10297
+ widths: requested
10298
+ });
10299
+ const repeated = requested.find((linked, index) => requested.indexOf(linked) !== index);
10300
+ if (repeated !== void 0) throw new FrameboardError("usage", `--widths lists ${repeated} twice, so pass each width once.`, {
10301
+ ref,
10302
+ widths: requested
10303
+ });
10304
+ if (requested.includes(width)) throw new FrameboardError("usage", `${ref} is ${width} px wide already, so --widths lists the other widths alone.`, {
10305
+ ref,
10306
+ width,
10307
+ widths: requested
10308
+ });
10309
+ return requested.map((linked) => ({
10310
+ width: linked,
10311
+ height: held.find((each) => each.width === linked)?.height ?? referenceHeight(linked)
10143
10312
  }));
10144
10313
  }
10314
+ /** The x a copy placed beside a frame takes, past the row of linked widths it draws. */
10315
+ function pastExtent({ box, widths }) {
10316
+ const extent = drawnExtent(box, widths);
10317
+ return extent.x + extent.width + 80;
10318
+ }
10145
10319
  /**
10146
10320
  * Sets a frame's height to its content's measured height and turns hugging
10147
- * back on for that axis, the inverse of the resize that fixed it.
10321
+ * back on for that axis, the inverse of the resize that fixed it, writing
10322
+ * each linked width's measured height beside it while the entry lists it. A
10323
+ * scroll frame refuses `fit-scroll`, since its height is fixed on purpose.
10148
10324
  */
10149
10325
  async function fitHeight(root, ref, height, options) {
10150
- return updatePlacement(root, ref, options, (placement) => ({
10151
- ...placement,
10152
- box: {
10153
- ...placement.box,
10154
- height
10155
- },
10156
- hugHeight: true
10157
- }));
10326
+ return updatePlacement(root, ref, options, (placement) => {
10327
+ if (placement.scroll) throw fitScrollError(ref);
10328
+ return {
10329
+ ...placement,
10330
+ box: {
10331
+ ...placement.box,
10332
+ height
10333
+ },
10334
+ hugHeight: true,
10335
+ widths: placement.widths.map((linked) => ({
10336
+ ...linked,
10337
+ height: options.widths?.find((each) => each.width === linked.width)?.height ?? linked.height
10338
+ }))
10339
+ };
10340
+ });
10341
+ }
10342
+ /** The refusal a fit of a scroll frame answers, before or after measuring. */
10343
+ function fitScrollError(ref) {
10344
+ return new FrameboardError("fit-scroll", `${ref} holds scroll, which fixes its height so the page scrolls past it, so it has no height to fit. Clear it with frame resize --no-scroll first.`, { ref });
10158
10345
  }
10159
10346
  /**
10160
10347
  * Writes the sizes the server measured, on the axes each frame's stored entry
@@ -10172,13 +10359,18 @@ async function setMeasured(root, pageRef, sizes, options) {
10172
10359
  const placement = layout.placement(name);
10173
10360
  const box = {
10174
10361
  ...placement.box,
10175
- width: placement.hugWidth ? size.width : placement.box.width,
10176
- height: placement.hugHeight ? size.height : placement.box.height
10362
+ width: placement.hugWidth && size.width !== void 0 ? size.width : placement.box.width,
10363
+ height: placement.hugHeight && size.height !== void 0 ? size.height : placement.box.height
10177
10364
  };
10178
- if (sameBox(box, placement.box)) continue;
10365
+ const widths = placement.widths.map((linked) => ({
10366
+ ...linked,
10367
+ height: placement.hugHeight ? size.widths?.find((each) => each.width === linked.width)?.height ?? linked.height : linked.height
10368
+ }));
10369
+ if (sameBox(box, placement.box) && isDeepStrictEqual(widths, placement.widths)) continue;
10179
10370
  layout.set(name, {
10180
10371
  ...placement,
10181
- box
10372
+ box,
10373
+ widths
10182
10374
  });
10183
10375
  written.push(name);
10184
10376
  }
@@ -10255,7 +10447,8 @@ async function setBoxes(root, pageRef, boxes, expected, options) {
10255
10447
  ...kept
10256
10448
  },
10257
10449
  hugWidth: placement.hugWidth && box.width === started.width,
10258
- hugHeight: placement.hugHeight && box.height === started.height
10450
+ hugHeight: placement.hugHeight && box.height === started.height,
10451
+ widths: placement.widths.filter((linked) => linked.width !== (kept.width ?? box.width))
10259
10452
  });
10260
10453
  }
10261
10454
  }, options.journal);
@@ -10322,7 +10515,7 @@ async function updatePlacement(root, ref, options, change) {
10322
10515
  const page = pageDir(frame);
10323
10516
  await withLayouts([page], async (layouts) => {
10324
10517
  const layout = layoutAt(layouts, page);
10325
- layout.set(frame.name, change(layout.placement(frame.name)));
10518
+ layout.set(frame.name, change(layout.placement(frame.name), refOf$1(frame)));
10326
10519
  }, options.journal);
10327
10520
  return frameRecord(root, frame.project, frame.page, frame.name);
10328
10521
  }
@@ -10394,11 +10587,17 @@ var PageLayout = class {
10394
10587
  * Writes the seven fixed keys on the entry it creates or changes, after any
10395
10588
  * key the entry already held, so unknown keys survive in place. A hug flag
10396
10589
  * is written on an entry it creates, once it is on, or when the entry holds
10397
- * it, so a write to an entry from before the flags adds no key.
10398
- */
10399
- set(name, { box, order, hidden, locked, hugWidth, hugHeight }) {
10590
+ * it, so a write to an entry from before the flags adds no key. `scroll` is
10591
+ * written once it is on or when the entry holds it, and a scroll entry
10592
+ * writes both hug flags false, since it fixes both axes. `widths` is
10593
+ * written while it lists one and removed once it lists none, and a held
10594
+ * value no reader understands is left as it stands.
10595
+ */
10596
+ set(name, { box, order, hidden, locked, scroll, widths, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
10597
+ const hugWidth = hugsWidth && !scroll;
10598
+ const hugHeight = hugsHeight && !scroll;
10400
10599
  const held = this.file.frames[name];
10401
- this.file.frames[name] = {
10600
+ const entry = {
10402
10601
  ...held,
10403
10602
  x: box.x,
10404
10603
  y: box.y,
@@ -10408,8 +10607,15 @@ var PageLayout = class {
10408
10607
  hidden,
10409
10608
  locked,
10410
10609
  ...!held || hugWidth || held.hugWidth !== void 0 ? { hugWidth } : {},
10411
- ...!held || hugHeight || held.hugHeight !== void 0 ? { hugHeight } : {}
10412
- };
10610
+ ...!held || hugHeight || held.hugHeight !== void 0 ? { hugHeight } : {},
10611
+ ...scroll || held?.scroll !== void 0 ? { scroll } : {},
10612
+ ...widths.length > 0 ? { widths: widths.map(({ width, height }) => ({
10613
+ width,
10614
+ height
10615
+ })) } : {}
10616
+ };
10617
+ if (widths.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
10618
+ this.file.frames[name] = entry;
10413
10619
  this.changed = true;
10414
10620
  }
10415
10621
  remove(name) {
@@ -29002,9 +29208,13 @@ function findingFor(docs) {
29002
29208
  };
29003
29209
  };
29004
29210
  }
29005
- /** One finding as `path:line:column rule message`, as `check` and the hook print it. */
29211
+ /**
29212
+ * One finding as `path:line:column rule message`, as `check` and the hook
29213
+ * print it, the path taking `@<width>` for one read at a linked width.
29214
+ */
29006
29215
  function formatFinding(finding) {
29007
- return `${finding.location ? `${finding.path}:${finding.location.line}:${finding.location.column}` : finding.path} ${finding.rule} ${finding.message}`;
29216
+ const path = finding.width === void 0 ? finding.path : `${finding.path}@${finding.width}`;
29217
+ return `${finding.location ? `${path}:${finding.location.line}:${finding.location.column}` : path} ${finding.rule} ${finding.message}`;
29008
29218
  }
29009
29219
  // src/server/checks/theme.ts
29010
29220
  const THEME_RULES = [{
@@ -29013,7 +29223,7 @@ const THEME_RULES = [{
29013
29223
  severity: "error",
29014
29224
  description: "A frame setting literal colors defines the other theme too, through a [data-theme] selector, a prefers-color-scheme query, or light-dark()"
29015
29225
  }];
29016
- const finding$10 = findingFor(THEME_RULES);
29226
+ const finding$11 = findingFor(THEME_RULES);
29017
29227
  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;
29018
29228
  const COLOR_FUNCTION = /\b(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(/i;
29019
29229
  const HEX_COLOR = /#[0-9a-f]{3,8}\b/i;
@@ -29023,7 +29233,7 @@ function checkTheme(source) {
29023
29233
  const { firstColor, bothThemes } = readThemeColors(source);
29024
29234
  if (!firstColor || bothThemes) return [];
29025
29235
  const { path, location } = firstColor;
29026
- return [finding$10("theme", {
29236
+ return [finding$11("theme", {
29027
29237
  frame: source.ref,
29028
29238
  path,
29029
29239
  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.",
@@ -29861,6 +30071,7 @@ const STATUS$4 = {
29861
30071
  "layout-invalid": 422,
29862
30072
  "project-file-invalid": 422,
29863
30073
  "fit-unbounded": 422,
30074
+ "fit-scroll": 422,
29864
30075
  "claims-invalid": 422,
29865
30076
  "lock-timeout": 503,
29866
30077
  "browser-not-found": 503
@@ -40158,8 +40369,10 @@ const CONTENT_TYPES$1 = {
40158
40369
  * caller what exists.
40159
40370
  *
40160
40371
  * A frame served from a page gets the faces and the token sheets spliced
40161
- * first into its `head`, in the response alone, and every other file is
40162
- * served byte for byte. A frame path carrying `?at=<hash>` serves the
40372
+ * first into its `head`, in the response alone, and is never cached. Every
40373
+ * other file is served byte for byte under a validator the browser checks on
40374
+ * each use, so an edit shows on the next load and an unchanged file answers
40375
+ * 304 with no body. A frame path carrying `?at=<hash>` serves the
40163
40376
  * version `version` holds under that hash in its place, with the same head,
40164
40377
  * and any other path carrying it answers 404.
40165
40378
  */
@@ -40195,6 +40408,21 @@ function frameRoutes(root, look, version) {
40195
40408
  return c.body(stream, 206, headers);
40196
40409
  }
40197
40410
  }
40411
+ if (!isFrame && at === void 0) {
40412
+ const tag = weakTag(await stat(file, { bigint: true }));
40413
+ const revalidate = {
40414
+ ETag: tag,
40415
+ "Cache-Control": "no-cache"
40416
+ };
40417
+ if (matchesTag(c.req.header("If-None-Match"), tag)) return c.body(null, 304, revalidate);
40418
+ const headers = {
40419
+ "Content-Type": contentType,
40420
+ "Accept-Ranges": "bytes",
40421
+ ...revalidate
40422
+ };
40423
+ if (c.req.method === "HEAD") return c.body(null, 200, headers);
40424
+ return c.body(new Uint8Array(await readFile(file)), 200, headers);
40425
+ }
40198
40426
  let bytes;
40199
40427
  if (at === void 0) bytes = new Uint8Array(await readFile(file));
40200
40428
  else {
@@ -40203,16 +40431,30 @@ function frameRoutes(root, look, version) {
40203
40431
  if (held === null) return c.notFound();
40204
40432
  bytes = new TextEncoder().encode(held);
40205
40433
  }
40206
- const body = isFrame ? injectHead(bytes, frameHead(sheetUrls(project, look.sheets(project)), contentHash(bytes))) : bytes;
40434
+ const body = injectHead(bytes, frameHead(sheetUrls(project, look.sheets(project)), contentHash(bytes)));
40207
40435
  return c.body(body, 200, {
40208
40436
  "Content-Type": contentType,
40209
- "Cache-Control": "no-store",
40210
- ...isFrame ? {} : { "Accept-Ranges": "bytes" }
40437
+ "Cache-Control": "no-store"
40211
40438
  });
40212
40439
  });
40213
40440
  return app;
40214
40441
  }
40215
40442
  /**
40443
+ * A weak validator from a file's size and nanosecond mtime, so a check costs
40444
+ * one stat rather than a read of every byte. A same-size rewrite inside one
40445
+ * timestamp tick keeps its tag, which a coarse mount makes likelier.
40446
+ */
40447
+ function weakTag({ size, mtimeNs }) {
40448
+ return `W/"${size.toString(16)}-${mtimeNs.toString(16)}"`;
40449
+ }
40450
+ /** Whether an `If-None-Match` header names `tag`, compared weakly per RFC 9110. */
40451
+ function matchesTag(header, tag) {
40452
+ if (header === void 0) return false;
40453
+ if (header.trim() === "*") return true;
40454
+ const opaque = tag.replace(/^W\//, "");
40455
+ return header.split(",").some((listed) => listed.trim().replace(/^W\//, "") === opaque);
40456
+ }
40457
+ /**
40216
40458
  * The inclusive bytes a single `bytes=` range names within `size`,
40217
40459
  * `'unsatisfiable'` for a valid range that names none of them, or null for a
40218
40460
  * header to ignore, which RFC 9110 allows for any range a server does not
@@ -40839,7 +41081,7 @@ async function pasteFrames(root, pageRef, held, options) {
40839
41081
  };
40840
41082
  return frame.page === target.path ? {
40841
41083
  ...box,
40842
- x: box.x + box.width + 80
41084
+ x: pastExtent(frame.placement)
40843
41085
  } : box;
40844
41086
  };
40845
41087
  const names = await withLayouts([target.path], async (layouts) => {
@@ -41299,10 +41541,23 @@ function structureRoutes(root, access, history, measure, tokens = null) {
41299
41541
  await refuseHeldFrames([body.ref]);
41300
41542
  if (!measure) throw new FrameboardError("browser-not-found", "Fit height needs the board server's browser, and none runs here.");
41301
41543
  const frame = await readFrame$1(root, body.ref, { cwd });
41544
+ if (frame.scroll) throw fitScrollError(frame.ref);
41302
41545
  const measured = await measure(frame);
41546
+ const widths = [];
41547
+ for (const { width } of frame.widths) {
41548
+ const linked = await measure(frame, {
41549
+ width,
41550
+ height: referenceHeight(width)
41551
+ });
41552
+ widths.push({
41553
+ width,
41554
+ height: linked.height
41555
+ });
41556
+ }
41303
41557
  const fit = await recorded((journal) => fitHeight(root, frame.ref, measured.height, {
41304
41558
  cwd,
41305
- journal
41559
+ journal,
41560
+ widths
41306
41561
  }), (record) => onFrames([record.ref]));
41307
41562
  return c.json({
41308
41563
  ok: true,
@@ -42218,14 +42473,18 @@ const SCREENSHOT = {
42218
42473
  };
42219
42474
  /**
42220
42475
  * The file name of one image, `<name>.<theme>.png` at 1x so a path an agent
42221
- * saved stays true, and `<name>.<theme>@<n>x.png` at any other scale.
42476
+ * saved stays true, and `<name>.<theme>@<n>x.png` at any other scale. A shot
42477
+ * scrolled down takes `.scroll-<px>` after the name, the offset asked for,
42478
+ * and a linked width takes `@<width>` ahead of both.
42222
42479
  */
42223
- function imageName(name, theme, scale) {
42224
- return scale === 1 ? `${name}.${theme}.png` : `${name}.${theme}@${scale}x.png`;
42480
+ function imageName(name, theme, scale, scroll, width) {
42481
+ const named = width === void 0 ? name : `${name}@${width}`;
42482
+ const stem = scroll === void 0 ? named : `${named}.scroll-${scroll}`;
42483
+ return scale === 1 ? `${stem}.${theme}.png` : `${stem}.${theme}@${scale}x.png`;
42225
42484
  }
42226
42485
  /** Where one frame's capture in one theme lands under `out`. */
42227
- function frameImagePath(out, frame, theme, scale = 1) {
42228
- return join(out, frame.project, frame.page, imageName(frame.name, theme, scale));
42486
+ function frameImagePath(out, frame, theme, scale = 1, scroll, width) {
42487
+ return join(out, frame.project, frame.page, imageName(frame.name, theme, scale, scroll, width));
42229
42488
  }
42230
42489
  /** Where a page's composite in one theme lands under `out`. */
42231
42490
  function compositeImagePath(out, page, theme, scale = 1) {
@@ -42234,13 +42493,15 @@ function compositeImagePath(out, page, theme, scale = 1) {
42234
42493
  /**
42235
42494
  * The composite's size and the shift placing each frame in it, so the
42236
42495
  * leftmost and topmost frames sit one margin in and one margin is left past
42237
- * the far edges. Refuses `capture-too-large` past Chromium's screenshot limit.
42496
+ * the far edges, each frame's linked widths included. Refuses
42497
+ * `capture-too-large` past Chromium's screenshot limit.
42238
42498
  */
42239
42499
  function compositeBounds(page, frames, scale = 1) {
42240
- const left = Math.min(...frames.map(({ box }) => box.x));
42241
- const top = Math.min(...frames.map(({ box }) => box.y));
42242
- const right = Math.max(...frames.map(({ box }) => box.x + box.width));
42243
- const bottom = Math.max(...frames.map(({ box }) => box.y + box.height));
42500
+ const extents = frames.map(({ box, widths }) => drawnExtent(box, widths ?? []));
42501
+ const left = Math.min(...extents.map((box) => box.x));
42502
+ const top = Math.min(...extents.map((box) => box.y));
42503
+ const right = Math.max(...extents.map((box) => box.x + box.width));
42504
+ const bottom = Math.max(...extents.map((box) => box.y + box.height));
42244
42505
  const width = right - left + 80;
42245
42506
  const height = bottom - top + 80;
42246
42507
  if (width * scale > 16384 || height * scale > 16384) {
@@ -42261,23 +42522,39 @@ function compositeBounds(page, frames, scale = 1) {
42261
42522
  };
42262
42523
  }
42263
42524
  /**
42264
- * Captures each frame in each theme at its layout size times `scale`, one PNG apiece. Every
42265
- * image renders before any is written, so a refusal on one frame leaves no
42266
- * half-written set an agent could read as current.
42525
+ * Captures each frame in each theme at its layout size times `scale`, one PNG
42526
+ * apiece, and again at each linked width it lists, at the height that width
42527
+ * holds. Every image renders before any is written, so a refusal on one frame
42528
+ * leaves no half-written set an agent could read as current. A `scroll`
42529
+ * offset shoots each view that far down, clamped to the page's end. `width`
42530
+ * shoots each frame at that one width alone, its own or a linked one.
42267
42531
  */
42268
- async function captureFrameImages(browser, { baseUrl, frames, themes, out, scale = 1 }) {
42532
+ async function captureFrameImages(browser, { baseUrl, frames, themes, out, scale = 1, scroll, width }) {
42269
42533
  const rendered = [];
42270
- for (const frame of frames) for (const theme of themes) rendered.push({
42271
- ref: frame.ref,
42272
- theme,
42273
- path: frameImagePath(out, frame, theme, scale),
42274
- width: frame.box.width,
42275
- height: frame.box.height,
42276
- scale,
42277
- bytes: await renderFrame(browser, baseUrl, frame, theme, scale)
42278
- });
42534
+ for (const frame of frames) for (const view of viewsOf(frame, width)) for (const theme of themes) {
42535
+ const shot = await renderFrame(browser, baseUrl, frame, view, theme, scale, scroll);
42536
+ const linked = view.width === frame.box.width ? void 0 : view.width;
42537
+ rendered.push({
42538
+ ref: frame.ref,
42539
+ theme,
42540
+ path: frameImagePath(out, frame, theme, scale, scroll, linked),
42541
+ width: view.width,
42542
+ height: view.height,
42543
+ scale,
42544
+ ...shot.scrollY === void 0 ? {} : { scrollY: shot.scrollY },
42545
+ bytes: shot.bytes
42546
+ });
42547
+ }
42279
42548
  return writeImages(rendered);
42280
42549
  }
42550
+ /** The boxes a frame shows at, its own first, or the one `width` names. */
42551
+ function viewsOf(frame, width) {
42552
+ const views = [{
42553
+ width: frame.box.width,
42554
+ height: frame.box.height
42555
+ }, ...frame.widths];
42556
+ return width === void 0 ? views : views.filter((view) => view.width === width);
42557
+ }
42281
42558
  /**
42282
42559
  * Captures one image of a page per theme, every frame at its layout box on
42283
42560
  * the theme's canvas color. Each frame renders as it does alone, font check
@@ -42288,9 +42565,9 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
42288
42565
  const rendered = [];
42289
42566
  for (const theme of themes) {
42290
42567
  const tiles = [];
42291
- for (const frame of frames) {
42292
- const bytes = await renderFrame(browser, baseUrl, frame, theme, scale);
42293
- tiles.push(`<img src="data:image/png;base64,${bytes.toString("base64")}" style="position:absolute;left:${frame.box.x + bounds.dx}px;top:${frame.box.y + bounds.dy}px;width:${frame.box.width}px;height:${frame.box.height}px">`);
42568
+ for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths)]) {
42569
+ const { bytes } = await renderFrame(browser, baseUrl, frame, box, theme, scale);
42570
+ 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">`);
42294
42571
  }
42295
42572
  rendered.push({
42296
42573
  ref: page.ref,
@@ -42304,10 +42581,10 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
42304
42581
  }
42305
42582
  return writeImages(rendered);
42306
42583
  }
42307
- async function renderFrame(browser, baseUrl, frame, theme, scale) {
42584
+ async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll) {
42308
42585
  const box = {
42309
- width: frame.box.width,
42310
- height: frame.box.height
42586
+ width: view.width,
42587
+ height: view.height
42311
42588
  };
42312
42589
  assertScreenshotFits(frame.ref, box, scale);
42313
42590
  const opened = await openFrame(browser, {
@@ -42318,11 +42595,24 @@ async function renderFrame(browser, baseUrl, frame, theme, scale) {
42318
42595
  scale
42319
42596
  });
42320
42597
  try {
42321
- return await opened.page.screenshot(SCREENSHOT);
42598
+ const scrollY = scroll === void 0 ? void 0 : await opened.page.evaluate(scrollAndSettle, scroll);
42599
+ return {
42600
+ bytes: await opened.page.screenshot(SCREENSHOT),
42601
+ scrollY
42602
+ };
42322
42603
  } finally {
42323
42604
  await opened.close();
42324
42605
  }
42325
42606
  }
42607
+ function scrollAndSettle(top) {
42608
+ window.scrollTo({
42609
+ top,
42610
+ behavior: "instant"
42611
+ });
42612
+ return new Promise((resolve) => {
42613
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve(Math.round(window.scrollY))));
42614
+ });
42615
+ }
42326
42616
  async function renderComposite(browser, { width, height }, theme, tiles, scale) {
42327
42617
  const context = await browser.newContext({
42328
42618
  viewport: {
@@ -42355,9 +42645,10 @@ function registerCapture(program, context) {
42355
42645
  "light",
42356
42646
  "dark",
42357
42647
  "both"
42358
- ]).default("both")).addOption(new Option("--scale <n>", "device pixels per CSS pixel, adding @<n>x to the file name past 1").default(1).argParser(parseScale)).option("--out <dir>", "the folder images land in, defaulting to the board's .run/captures/"), context, async ([ref], options) => {
42648
+ ]).default("both")).addOption(new Option("--scale <n>", "device pixels per CSS pixel, adding @<n>x to the file name past 1").default(1).argParser(parseScale)).option("--scroll <px>", "shoot a scroll frame this far down, clamped to the end of its page, adding .scroll-<px> to the file name", parseInteger(0)).option("--out <dir>", "the folder images land in, defaulting to the board's .run/captures/"), context, async ([ref], options) => {
42359
42649
  if (ref === void 0 === (options.page === void 0)) throw new FrameboardError("usage", "Pass a frame ref or --page <page-ref>, exactly one of the two.");
42360
42650
  if (options.composite && options.page === void 0) throw new FrameboardError("usage", "--composite needs --page.");
42651
+ if (options.scroll !== void 0 && options.page !== void 0) throw new FrameboardError("usage", "--scroll shoots one frame, so pass a frame ref rather than --page.");
42361
42652
  const root = await boardOf(options, io);
42362
42653
  const refOptions = {
42363
42654
  project: options.project,
@@ -42396,10 +42687,11 @@ function registerCapture(program, context) {
42396
42687
  }));
42397
42688
  return {
42398
42689
  data: { images },
42399
- human: describe$6(images)
42690
+ human: describe$7(images)
42400
42691
  };
42401
42692
  }
42402
42693
  const frame = await readFrame$1(root, ref ?? "", refOptions);
42694
+ if (options.scroll !== void 0 && !frame.scroll) throw new FrameboardError("usage", `${frame.ref} holds no scroll key, so it has nothing to scroll. Set it with frame resize --scroll first.`, { ref: frame.ref });
42403
42695
  const out = await outOf();
42404
42696
  const images = await withFrameHost({
42405
42697
  root,
@@ -42409,11 +42701,12 @@ function registerCapture(program, context) {
42409
42701
  frames: [frame],
42410
42702
  themes,
42411
42703
  out,
42412
- scale: options.scale
42704
+ scale: options.scale,
42705
+ scroll: options.scroll
42413
42706
  }));
42414
42707
  return {
42415
42708
  data: { images },
42416
- human: describe$6(images)
42709
+ human: describe$7(images)
42417
42710
  };
42418
42711
  });
42419
42712
  }
@@ -42426,7 +42719,7 @@ async function pageOf(root, ref, options) {
42426
42719
  const { pages } = await readPageOrder(join(root, resolved.project));
42427
42720
  return scanPage(root, resolved.project, resolved.page, pages.indexOf(resolved.page));
42428
42721
  }
42429
- function describe$6(images) {
42722
+ function describe$7(images) {
42430
42723
  return images.map((image) => `Wrote ${image.path}`).join("\n");
42431
42724
  }
42432
42725
  // src/server/checks/custom-properties.ts
@@ -42436,7 +42729,7 @@ const CUSTOM_PROPERTY_RULES = [{
42436
42729
  severity: "warning",
42437
42730
  description: "A var() with no fallback names a custom property no token sheet, frame sheet, style attribute, or script write declares"
42438
42731
  }];
42439
- const finding$9 = findingFor(CUSTOM_PROPERTY_RULES);
42732
+ const finding$10 = findingFor(CUSTOM_PROPERTY_RULES);
42440
42733
  /** A `var()` naming its property, with no fallback after a comma. */
42441
42734
  const BARE_VAR = /var\(\s*(--[\w-]+)\s*\)/g;
42442
42735
  /**
@@ -42495,7 +42788,7 @@ function checkUnknownTokens(source, tokens) {
42495
42788
  if (element.name !== "script") continue;
42496
42789
  for (const name of scriptWrites(scriptText(element, source))) declared.add(name);
42497
42790
  }
42498
- return uses.filter((use) => !declared.has(use.name)).map((use) => finding$9("unknown-token", {
42791
+ return uses.filter((use) => !declared.has(use.name)).map((use) => finding$10("unknown-token", {
42499
42792
  frame: source.ref,
42500
42793
  path: use.path,
42501
42794
  message: `var(${use.name}) names a custom property nothing declares, so the declaration resolves to nothing. Use a token the project's tokens.css declares, or give it a fallback, such as var(${use.name}, red). If a script sets it at runtime under a name the check cannot read, the fallback is the way out.`,
@@ -42569,7 +42862,7 @@ const FONT_RULES = [
42569
42862
  description: "Every text element's first family is one of the project's allowed fonts"
42570
42863
  }
42571
42864
  ];
42572
- const finding$8 = findingFor(FONT_RULES);
42865
+ const finding$9 = findingFor(FONT_RULES);
42573
42866
  const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
42574
42867
  "serif",
42575
42868
  "sans-serif",
@@ -42612,7 +42905,7 @@ function checkFonts(source, cascade, config) {
42612
42905
  else if (allowed && !allowed.includes(family.toLowerCase())) push(unlisted, family, element);
42613
42906
  }
42614
42907
  const path = boardPath(source.root, source.path);
42615
- const at = (rule, elements, message) => finding$8(rule, {
42908
+ const at = (rule, elements, message) => finding$9(rule, {
42616
42909
  frame: source.ref,
42617
42910
  path,
42618
42911
  message: `${message} ${described(elements)}`,
@@ -42662,7 +42955,7 @@ const LINK_RULES = [
42662
42955
  description: "Every local file a frame loads exists"
42663
42956
  }
42664
42957
  ];
42665
- const finding$7 = findingFor(LINK_RULES);
42958
+ const finding$8 = findingFor(LINK_RULES);
42666
42959
  /**
42667
42960
  * The attributes that load a resource, by element. An `a href` navigates
42668
42961
  * rather than loads, so it is left out.
@@ -42738,16 +43031,16 @@ function judge(source, load) {
42738
43031
  path: load.path,
42739
43032
  location: load.location
42740
43033
  };
42741
- if (hasScheme(url)) return [finding$7("network", {
43034
+ if (hasScheme(url)) return [finding$8("network", {
42742
43035
  ...fields,
42743
43036
  message: `${load.via} loads ${url} over the network. Save the file into the page folder or the project's assets/ and link it there.`
42744
43037
  })];
42745
43038
  const target = localTarget(url, load.base);
42746
- if (target === null || !allowed(source, target)) return [finding$7("outside-link", {
43039
+ if (target === null || !allowed(source, target)) return [finding$8("outside-link", {
42747
43040
  ...fields,
42748
43041
  message: `${load.via} loads ${url}, outside this page's folder and the project's assets/. Move the file into one of them.`
42749
43042
  })];
42750
- if (!existsSync(target)) return [finding$7("missing-file", {
43043
+ if (!existsSync(target)) return [finding$8("missing-file", {
42751
43044
  ...fields,
42752
43045
  message: `${load.via} loads ${url}, which does not exist.`
42753
43046
  })];
@@ -42836,7 +43129,7 @@ const STRUCTURE_RULES = [
42836
43129
  description: "The browser rebuilds the tree the file writes, adding an element it never opens, closing one it never closed, or moving one out of a table"
42837
43130
  }
42838
43131
  ];
42839
- const finding$6 = findingFor(STRUCTURE_RULES);
43132
+ const finding$7 = findingFor(STRUCTURE_RULES);
42840
43133
  /**
42841
43134
  * Elements a parser may imply with no start tag in a valid file. A `tbody`
42842
43135
  * is `table-tbody`'s to report.
@@ -42899,12 +43192,12 @@ const MALFORMED = {
42899
43192
  function checkNaming(target, path) {
42900
43193
  const ref = `${target.project}/${target.page}/${target.name}`;
42901
43194
  const findings = [];
42902
- if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$6("naming", {
43195
+ if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$7("naming", {
42903
43196
  frame: ref,
42904
43197
  path,
42905
43198
  message: `Page name ${target.page} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
42906
43199
  }));
42907
- if (!isValidName(target.name)) findings.push(finding$6("naming", {
43200
+ if (!isValidName(target.name)) findings.push(finding$7("naming", {
42908
43201
  frame: ref,
42909
43202
  path,
42910
43203
  message: `Frame name ${target.name} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
@@ -42913,7 +43206,7 @@ function checkNaming(target, path) {
42913
43206
  }
42914
43207
  /** `dot-folder`, over a project's folder names. */
42915
43208
  function checkDotFolders(root, projectDir, folders) {
42916
- return folders.filter((name) => name.startsWith(".")).map((name) => finding$6("dot-folder", {
43209
+ return folders.filter((name) => name.startsWith(".")).map((name) => finding$7("dot-folder", {
42917
43210
  frame: null,
42918
43211
  path: boardPath(root, `${projectDir}/${name}`),
42919
43212
  message: `Folder ${name} opens with a dot, so the board never shows it. Rename it or move it out of the project.`
@@ -42925,13 +43218,13 @@ function checkMarkup(source) {
42925
43218
  const findings = [];
42926
43219
  const head = source.elements.find((element) => element.name === "head");
42927
43220
  const body = source.elements.find((element) => element.name === "body");
42928
- if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$6("head-body", {
43221
+ if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$7("head-body", {
42929
43222
  frame: source.ref,
42930
43223
  path,
42931
43224
  message: "The frame states <head> and no <body>. Wrap the visible content in <body>.",
42932
43225
  location: startTagLocation(head)
42933
43226
  }));
42934
- for (const table of source.elements.filter(isTable)) if (table.children.some((child) => child.type === "tag" && child.name === "tbody" && !child.sourceCodeLocation?.startTag)) findings.push(finding$6("table-tbody", {
43227
+ for (const table of source.elements.filter(isTable)) if (table.children.some((child) => child.type === "tag" && child.name === "tbody" && !child.sourceCodeLocation?.startTag)) findings.push(finding$7("table-tbody", {
42935
43228
  frame: source.ref,
42936
43229
  path,
42937
43230
  message: "This table holds rows with no <tbody>, so the browser adds one the file does not hold. State the <tbody>.",
@@ -42958,7 +43251,7 @@ function checkMalformedTags(source) {
42958
43251
  if (reported.has(tag)) continue;
42959
43252
  reported.add(tag);
42960
43253
  }
42961
- findings.push(finding$6("malformed-tag", {
43254
+ findings.push(finding$7("malformed-tag", {
42962
43255
  frame: source.ref,
42963
43256
  path,
42964
43257
  message: `${tag ? `<${tag.name}> raises ${error.code}` : error.code}. ${message}`,
@@ -42976,7 +43269,7 @@ function checkMalformedTags(source) {
42976
43269
  function checkNesting(source) {
42977
43270
  const path = boardPath(source.root, source.path);
42978
43271
  const findings = [];
42979
- const report = (message, location) => findings.push(finding$6("nesting", {
43272
+ const report = (message, location) => findings.push(finding$7("nesting", {
42980
43273
  frame: source.ref,
42981
43274
  path,
42982
43275
  message,
@@ -43039,14 +43332,14 @@ const UPPERCASE_RULES = [{
43039
43332
  configKey: "noUppercase",
43040
43333
  description: "No text is set in capitals, through text-transform: uppercase or a word of more than three capital letters"
43041
43334
  }];
43042
- const finding$5 = findingFor(UPPERCASE_RULES);
43335
+ const finding$6 = findingFor(UPPERCASE_RULES);
43043
43336
  const CAPITALS = /(?<![\p{L}\p{N}])\p{Lu}{4,}(?![\p{L}\p{N}])/u;
43044
43337
  /** `uppercase`, which runs only when the project sets `noUppercase`. */
43045
43338
  function checkUppercase(source, cascade) {
43046
43339
  const capitalized = textElements(source).filter((element) => cascade.textTransform(element) === "uppercase" || ownText(element).some((text) => CAPITALS.test(text)));
43047
43340
  const first = capitalized[0];
43048
43341
  if (!first) return [];
43049
- return [finding$5("uppercase", {
43342
+ return [finding$6("uppercase", {
43050
43343
  frame: source.ref,
43051
43344
  path: boardPath(source.root, source.path),
43052
43345
  message: `Text is set in capitals, which the project does not allow. Write it in sentence case. ${described(capitalized)}`,
@@ -43127,7 +43420,7 @@ const CONTRAST_RULES = [{
43127
43420
  configKey: "minContrast",
43128
43421
  description: "Text contrasts with the solid color behind it at a lower ratio than the project sets, 4.5 being WCAG's, with large text held to two thirds of it. Text over an image, a gradient, or an effect is not measured."
43129
43422
  }];
43130
- const finding$4 = findingFor(CONTRAST_RULES);
43423
+ const finding$5 = findingFor(CONTRAST_RULES);
43131
43424
  /** WCAG's large text is 18 pt, or 14 pt bold, which hold 3:1 against 4.5:1. */
43132
43425
  const LARGE_SHARE = 2 / 3;
43133
43426
  /**
@@ -43145,7 +43438,7 @@ async function checkContrast(page, target, minContrast) {
43145
43438
  const others = under.length - 1;
43146
43439
  const rest = others === 0 ? "" : `, and ${others} more ${others === 1 ? "element is" : "elements are"} under it`;
43147
43440
  const minimum = worst.large ? `${formatRatio(worst.minimum)}:1 minimum for large text` : `${formatRatio(worst.minimum)}:1 minimum`;
43148
- return [finding$4("min-contrast", {
43441
+ return [finding$5("min-contrast", {
43149
43442
  frame: target.ref,
43150
43443
  path: target.path,
43151
43444
  message: `${target.ref} sets text in <${worst.tag}> at element ${worst.index} at ${floorRatio(worst.ratio)}:1, ${worst.foreground} on ${worst.background}, under the project's ${minimum}${rest}.`
@@ -43318,7 +43611,7 @@ const DECLARATION_RULES = [{
43318
43611
  severity: "warning",
43319
43612
  description: "A declaration the page's own CSS parser drops, being a misspelled property, a value it cannot read, or a sheet that stops parsing"
43320
43613
  }];
43321
- const finding$3 = findingFor(DECLARATION_RULES);
43614
+ const finding$4 = findingFor(DECLARATION_RULES);
43322
43615
  /**
43323
43616
  * At-rules whose blocks hold descriptors rather than properties, which
43324
43617
  * `CSS.supports` cannot answer, and `@supports`, whose block is a
@@ -43343,7 +43636,7 @@ async function checkDeclarations(page, source) {
43343
43636
  const path = boardPath(source.root, sheet.path);
43344
43637
  const text = sheet.origin === "style" ? source.html : sheet.css;
43345
43638
  const { root, errors } = parseSheet$1(sheet.css);
43346
- for (const error of errors) findings.push(finding$3("dropped-declaration", {
43639
+ for (const error of errors) findings.push(finding$4("dropped-declaration", {
43347
43640
  frame: source.ref,
43348
43641
  path,
43349
43642
  message: breakMessage(error),
@@ -43382,7 +43675,7 @@ async function checkDeclarations(page, source) {
43382
43675
  const supported = await page.evaluate((pairs) => pairs.map(([property, value]) => CSS.supports(property, value)), written.map((each) => [each.property, each.value]));
43383
43676
  written.forEach((each, index) => {
43384
43677
  if (supported[index]) return;
43385
- findings.push(finding$3("dropped-declaration", {
43678
+ findings.push(finding$4("dropped-declaration", {
43386
43679
  frame: source.ref,
43387
43680
  path: each.path,
43388
43681
  message: `The browser drops ${each.property}: ${each.value}, since it reads no such property or no such value for it. Check the spelling of both, and the unit of a length, such as 12px.`,
@@ -43422,7 +43715,7 @@ const FONT_SIZE_RULES = [{
43422
43715
  configKey: "minFontSize",
43423
43716
  description: "Text renders smaller than the project sets as its minimum size in pixels"
43424
43717
  }];
43425
- const finding$2 = findingFor(FONT_SIZE_RULES);
43718
+ const finding$3 = findingFor(FONT_SIZE_RULES);
43426
43719
  /**
43427
43720
  * Reports text under `minFontSize` pixels, naming the smallest element and
43428
43721
  * how many more fall under, at most one finding per frame.
@@ -43433,7 +43726,7 @@ async function checkFontSize(page, target, minFontSize) {
43433
43726
  const smallest = under.reduce((least, text) => text.size < least.size ? text : least);
43434
43727
  const others = under.length - 1;
43435
43728
  const rest = others === 0 ? "" : `, and ${others} more ${others === 1 ? "element is" : "elements are"} under it`;
43436
- return [finding$2("min-font-size", {
43729
+ return [finding$3("min-font-size", {
43437
43730
  frame: target.ref,
43438
43731
  path: target.path,
43439
43732
  message: `${target.ref} sets text at ${smallest.size} px in <${smallest.tag}> at element ${smallest.index}, under the project's ${minFontSize} px minimum${rest}.`
@@ -43472,17 +43765,23 @@ const HUG_MAX_WIDTH = FRAME_SIZES.desktop.width;
43472
43765
  * Measures a frame's content the way `frame fit` and the server's hug step
43473
43766
  * both read it, in one page resized between readings. A hugging width takes
43474
43767
  * the content's `fit-content` width up to `HUG_MAX_WIDTH`, and the height is
43475
- * read at that width with a 1 px tall viewport and again at the box's height.
43768
+ * read at that width with a 1 px tall viewport and again at the reference
43769
+ * height of the box's width, never the box's own height, so content sized off
43770
+ * the window height reads one height however tall the frame already is.
43476
43771
  * Readings that differ mean the content sizes itself off the viewport, which
43477
43772
  * has no height of its own to fit, so that refuses `fit-unbounded`. Finite
43478
43773
  * animations finish before the first reading, so an entrance is read at its
43479
43774
  * settled size.
43480
43775
  */
43481
43776
  async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
43777
+ const reference = referenceHeight(box.width);
43482
43778
  const opened = await openFrame(browser, {
43483
43779
  baseUrl,
43484
43780
  ref,
43485
- box,
43781
+ box: {
43782
+ width: box.width,
43783
+ height: reference
43784
+ },
43486
43785
  theme: "light",
43487
43786
  fonts
43488
43787
  });
@@ -43494,8 +43793,9 @@ async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
43494
43793
  if (hugWidth && !empty) {
43495
43794
  await page.setViewportSize({
43496
43795
  width: HUG_MAX_WIDTH,
43497
- height: box.height
43796
+ height: reference
43498
43797
  });
43798
+ await settleResize(page);
43499
43799
  width = Math.min(HUG_MAX_WIDTH, await page.evaluate(readFitWidth));
43500
43800
  }
43501
43801
  const short = await readAt(page, {
@@ -43504,9 +43804,9 @@ async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
43504
43804
  });
43505
43805
  const current = await readAt(page, {
43506
43806
  width,
43507
- height: box.height
43807
+ height: reference
43508
43808
  });
43509
- if (short.height !== current.height) throw new FrameboardError("fit-unbounded", `${ref} grows with the viewport, measuring ${short.height} px in a 1 px viewport and ${current.height} px at its ${box.height} px height, so it has no content height to fit. Size it by hand with frame resize.`, {
43809
+ if (short.height !== current.height) throw new FrameboardError("fit-unbounded", `${ref} grows with the viewport, measuring ${short.height} px in a 1 px viewport and ${current.height} px at its ${reference} px reference height, so it has no content height to fit. Size it by hand with frame resize.`, {
43510
43810
  ref,
43511
43811
  heights: [short.height, current.height]
43512
43812
  });
@@ -43522,7 +43822,9 @@ async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
43522
43822
  }
43523
43823
  /**
43524
43824
  * Sets a frame's height to its content's own height at its layout width and
43525
- * turns its height hugging on. The width is reported, never changed.
43825
+ * turns its height hugging on, measuring each linked width at its own width
43826
+ * and writing its height beside the frame's. The width is reported, never
43827
+ * changed.
43526
43828
  */
43527
43829
  async function fitFrame(browser, { baseUrl, frame, ...options }) {
43528
43830
  const measured = await measureContent(browser, {
@@ -43531,8 +43833,27 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
43531
43833
  box: frame.box,
43532
43834
  hugWidth: false
43533
43835
  });
43836
+ const widths = [];
43837
+ for (const { width } of frame.widths) {
43838
+ const linked = await measureContent(browser, {
43839
+ baseUrl,
43840
+ ref: frame.ref,
43841
+ box: {
43842
+ width,
43843
+ height: referenceHeight(width)
43844
+ },
43845
+ hugWidth: false
43846
+ });
43847
+ widths.push({
43848
+ width,
43849
+ height: linked.height
43850
+ });
43851
+ }
43534
43852
  return {
43535
- frame: await fitHeight(options.root, frame.ref, measured.height, options),
43853
+ frame: await fitHeight(options.root, frame.ref, measured.height, {
43854
+ ...options,
43855
+ widths
43856
+ }),
43536
43857
  contentHeight: measured.height,
43537
43858
  contentWidth: measured.contentWidth,
43538
43859
  tooWide: measured.contentWidth > frame.box.width
@@ -43540,8 +43861,19 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
43540
43861
  }
43541
43862
  async function readAt(page, viewport) {
43542
43863
  await page.setViewportSize(viewport);
43864
+ await settleResize(page);
43543
43865
  return page.evaluate(readContentSize);
43544
43866
  }
43867
+ /**
43868
+ * Waits two animation frames after a viewport resize, so a page's `resize`
43869
+ * listener has run and its layout settled before the next reading. A reading
43870
+ * taken straight after the resize sees the layout from before it.
43871
+ */
43872
+ async function settleResize(page) {
43873
+ await page.evaluate(() => new Promise((resolve) => {
43874
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
43875
+ }));
43876
+ }
43545
43877
  function finishAnimations() {
43546
43878
  for (const animation of document.getAnimations()) {
43547
43879
  const end = animation.effect?.getComputedTiming().endTime;
@@ -43651,7 +43983,7 @@ const LAYOUT_RULES = [
43651
43983
  description: "Content sizes itself off the viewport height rather than holding a height of its own, a warning since a full-height screen does it on purpose"
43652
43984
  }
43653
43985
  ];
43654
- const finding$1 = findingFor(LAYOUT_RULES);
43986
+ const finding$2 = findingFor(LAYOUT_RULES);
43655
43987
  /**
43656
43988
  * The slack a reading takes before it counts, so a subpixel edge rounding up
43657
43989
  * is never a finding. One pixel matches what the groundwork spike measured.
@@ -43660,7 +43992,9 @@ const SLACK_PX = 1;
43660
43992
  /**
43661
43993
  * Runs the three layout rules on a frame open at its own box, at most one
43662
43994
  * finding each. `viewport` reads a second time with the viewport twice as
43663
- * tall, then puts the box back.
43995
+ * tall, then puts the box back. Each resize settles before the next read, so
43996
+ * a script sizing content on `resize` reads as the CSS case does, and the
43997
+ * rules after this one see the page back at its box.
43664
43998
  */
43665
43999
  async function checkLayout(page, target) {
43666
44000
  const { width, height } = target.box;
@@ -43671,18 +44005,20 @@ async function checkLayout(page, target) {
43671
44005
  height: height * 2
43672
44006
  });
43673
44007
  try {
44008
+ await settleResize(page);
43674
44009
  const tall = await page.evaluate(readContentSize);
43675
44010
  const atTall = await page.evaluate(readLayout);
43676
44011
  return [
43677
44012
  clipped(target, atBox),
43678
44013
  scrollbar(target, atBox),
43679
- viewport(target, content.height, tall.height, atBox, atTall)
44014
+ target.scroll ? null : viewport(target, content.height, tall.height, atBox, atTall)
43680
44015
  ].filter((found) => found !== null);
43681
44016
  } finally {
43682
44017
  await page.setViewportSize({
43683
44018
  width,
43684
44019
  height
43685
44020
  });
44021
+ await settleResize(page);
43686
44022
  }
43687
44023
  }
43688
44024
  function clipped(target, read) {
@@ -43690,19 +44026,19 @@ function clipped(target, read) {
43690
44026
  const shown = read.boxes.filter((box) => !box.cropped);
43691
44027
  const bottom = Math.max(read.root.bottom, ...shown.map((box) => box.bottom));
43692
44028
  const right = Math.max(read.root.right, ...shown.map((box) => box.right));
43693
- const tall = bottom > height + SLACK_PX;
44029
+ const tall = !target.scroll && bottom > height + SLACK_PX;
43694
44030
  const wide = right > width + SLACK_PX;
43695
44031
  if (!tall && !wide) return null;
43696
44032
  const past = shown.filter((box) => tall && box.bottom > height + SLACK_PX || wide && box.right > width + SLACK_PX);
43697
44033
  const reach = [tall ? `${bottom} px tall in its ${height} px height` : null, wide ? `${right} px wide in its ${width} px width` : null].filter((part) => part !== null).join(" and ");
43698
- return finding$1("clipped", {
44034
+ return finding$2("clipped", {
43699
44035
  frame: target.ref,
43700
44036
  path: target.path,
43701
44037
  message: `${target.ref} is ${reach}, so the board cuts it off${offenders(past, "past the box")}. ${clippedAdvice(tall, wide, width)}`
43702
44038
  });
43703
44039
  }
43704
44040
  function clippedAdvice(tall, wide, width) {
43705
- if (!wide) return "Run frame fit, or shorten the content.";
44041
+ if (!wide) return "Run frame fit, run frame resize --scroll for a page meant to scroll, or shorten the content.";
43706
44042
  if (!tall) return `Reflow or shorten the content to fit its ${width} px width, since frame fit sets the height alone.`;
43707
44043
  return `Run frame fit for the height, and reflow or shorten the content to fit its ${width} px width.`;
43708
44044
  }
@@ -43711,7 +44047,7 @@ function scrollbar(target, read) {
43711
44047
  const [first] = scrolling;
43712
44048
  if (!first) return null;
43713
44049
  const by = Math.max(first.overflowX, first.overflowY);
43714
- return finding$1("scrollbar", {
44050
+ return finding$2("scrollbar", {
43715
44051
  frame: target.ref,
43716
44052
  path: target.path,
43717
44053
  message: `${target.ref} scrolls inside ${element(first)}, whose content is ${by} px past its box${more(scrolling.length - 1, "scrolls", "scroll")}. Size it to its content, or set overflow to hidden.`
@@ -43721,7 +44057,7 @@ function viewport(target, atBox, atTall, boxRead, tallRead) {
43721
44057
  if (atTall <= atBox + SLACK_PX) return null;
43722
44058
  const before = new Map(boxRead.boxes.map((box) => [box.index, box.height]));
43723
44059
  const grown = tallRead.boxes.filter((box) => box.height > (before.get(box.index) ?? box.height) + SLACK_PX);
43724
- return finding$1("viewport", {
44060
+ return finding$2("viewport", {
43725
44061
  frame: target.ref,
43726
44062
  path: target.path,
43727
44063
  message: `${target.ref} grows with the viewport, measuring ${atBox} px at its ${target.box.height} px height and ${atTall} px at twice that${offenders(grown, "growing")}. Give it a height of its own unless it is a full-height screen on purpose.`
@@ -43846,6 +44182,92 @@ function readLayout() {
43846
44182
  scrollers
43847
44183
  };
43848
44184
  }
44185
+ // src/server/checks/browser/scroll-effect.ts
44186
+ const SCROLL_EFFECT_RULES = [{
44187
+ id: "scroll-effect",
44188
+ tier: "browser",
44189
+ severity: "warning",
44190
+ description: "A frame whose height hugs its content holds an effect driven by scrolling, being position: sticky, a window or document scroll listener, or a scroll or view timeline, which never runs since the frame never scrolls"
44191
+ }];
44192
+ const finding$1 = findingFor(SCROLL_EFFECT_RULES);
44193
+ /**
44194
+ * `scroll-effect`, at most one finding, on a frame that hugs its height and
44195
+ * holds no `scroll` key, naming the first trigger found. A listener counts
44196
+ * only on the window or the document, since those are the objects the
44197
+ * DevTools protocol is asked about, so one on an inner scroll container or an
44198
+ * observer driving the effect goes unseen and costs a hint, never an error.
44199
+ */
44200
+ async function checkScrollEffect(page, target) {
44201
+ if (target.scroll || !target.hugHeight) return [];
44202
+ const trigger = await page.evaluate(readScrollStyles) ?? await readListener(page);
44203
+ if (!trigger) return [];
44204
+ return [finding$1("scroll-effect", {
44205
+ frame: target.ref,
44206
+ path: target.path,
44207
+ message: `${target.ref} ${describe$6(trigger)}, which needs the frame to scroll, but its height hugs the content so it never does. Run frame resize --scroll to hold a screen height and scroll past it.`
44208
+ })];
44209
+ }
44210
+ function describe$6(trigger) {
44211
+ switch (trigger.kind) {
44212
+ case "sticky": return `holds position: sticky on <${trigger.tag}> at element ${trigger.index}`;
44213
+ case "timeline": return `runs an animation on a scroll or view timeline from <${trigger.tag}> at element ${trigger.index}`;
44214
+ case "listener": return `listens for scroll on the ${trigger.target}`;
44215
+ }
44216
+ }
44217
+ async function readListener(page) {
44218
+ const session = await page.context().newCDPSession(page);
44219
+ try {
44220
+ for (const name of ["window", "document"]) {
44221
+ const { result } = await session.send("Runtime.evaluate", { expression: name });
44222
+ if (!result.objectId) continue;
44223
+ const { listeners } = await session.send("DOMDebugger.getEventListeners", { objectId: result.objectId });
44224
+ if (listeners.some((listener) => listener.type === "scroll")) return {
44225
+ kind: "listener",
44226
+ target: name
44227
+ };
44228
+ }
44229
+ return null;
44230
+ } finally {
44231
+ await session.detach();
44232
+ }
44233
+ }
44234
+ function readScrollStyles() {
44235
+ const isScrollTimeline = (timeline) => {
44236
+ const name = timeline?.constructor.name;
44237
+ return name === "ScrollTimeline" || name === "ViewTimeline";
44238
+ };
44239
+ const insideScroller = (element) => {
44240
+ for (let parent = element.parentElement; parent && parent !== document.body && parent !== document.documentElement; parent = parent.parentElement) {
44241
+ const { overflowX, overflowY } = getComputedStyle(parent);
44242
+ if (overflowX !== "visible" || overflowY !== "visible") return true;
44243
+ }
44244
+ return false;
44245
+ };
44246
+ let index = 0;
44247
+ for (const node of document.querySelectorAll("*")) {
44248
+ if (node.closest("[data-frameboard]")) continue;
44249
+ const own = index;
44250
+ index += 1;
44251
+ const style = getComputedStyle(node);
44252
+ const tag = node.tagName.toLowerCase();
44253
+ if (style.position === "sticky" && !insideScroller(node)) return {
44254
+ kind: "sticky",
44255
+ index: own,
44256
+ tag
44257
+ };
44258
+ const timeline = style.getPropertyValue("animation-timeline");
44259
+ if (/\b(scroll|view)\(/.test(timeline)) return {
44260
+ kind: "timeline",
44261
+ index: own,
44262
+ tag
44263
+ };
44264
+ }
44265
+ return document.getAnimations().some((animation) => isScrollTimeline(animation.timeline)) ? {
44266
+ kind: "timeline",
44267
+ index: 0,
44268
+ tag: "html"
44269
+ } : null;
44270
+ }
43849
44271
  // src/server/checks/outranked.ts
43850
44272
  const OUTRANKED_RULES = [{
43851
44273
  id: "outranked",
@@ -44069,7 +44491,8 @@ const RULES = [
44069
44491
  ...LAYOUT_RULES,
44070
44492
  ...FONT_SIZE_RULES,
44071
44493
  ...CONTRAST_RULES,
44072
- ...DECLARATION_RULES
44494
+ ...DECLARATION_RULES,
44495
+ ...SCROLL_EFFECT_RULES
44073
44496
  ];
44074
44497
  /** Checks every frame on one page. */
44075
44498
  async function checkPage(root, project, page) {
@@ -44315,6 +44738,13 @@ const frameRecordSchema = object$1({
44315
44738
  /** Whether each axis takes its size from the content rather than holding it. */
44316
44739
  hugWidth: boolean$1(),
44317
44740
  hugHeight: boolean$1(),
44741
+ /** Whether the frame holds a fixed screen height and scrolls past it, fixing both axes. */
44742
+ scroll: boolean$1(),
44743
+ /** The extra widths the frame also shows at, beside it in a row, none when it lists none. */
44744
+ widths: array$1(object$1({
44745
+ width: number(),
44746
+ height: number()
44747
+ })),
44318
44748
  placed: boolean$1(),
44319
44749
  modifiedAt: string$1()
44320
44750
  });
@@ -44369,7 +44799,9 @@ const captureResultSchema = object$1({ images: array$1(object$1({
44369
44799
  width: int$1().min(1),
44370
44800
  height: int$1().min(1),
44371
44801
  /** Device pixels per CSS pixel, so the file is `width * scale` wide. */
44372
- scale: int$1().min(1).max(3)
44802
+ scale: int$1().min(1).max(3),
44803
+ /** How far down a `--scroll` shot reached, absent on a shot taken at the top. */
44804
+ scrollY: int$1().min(0).optional()
44373
44805
  })) });
44374
44806
  /** What `frame fit` returns: the frame as resized, the height it measured, and its width against the layout's. */
44375
44807
  const fitResultSchema = object$1({
@@ -44537,7 +44969,9 @@ const findingSchema = /* @__PURE__ */ object({
44537
44969
  /** Board-relative, with forward slashes. */
44538
44970
  path: /* @__PURE__ */ string(),
44539
44971
  message: /* @__PURE__ */ string(),
44540
- location: /* @__PURE__ */ nullable(findingLocationSchema)
44972
+ location: /* @__PURE__ */ nullable(findingLocationSchema),
44973
+ /** The linked width a browser finding was read at, absent at the frame's own. */
44974
+ width: /* @__PURE__ */ optional(int().check(/* @__PURE__ */ _gte(1)))
44541
44975
  });
44542
44976
  /**
44543
44977
  * Whether the browser rules ran, so a reader can tell no browser findings
@@ -44806,7 +45240,9 @@ function contentFormat() {
44806
45240
  defaultFrameSize: DEFAULT_FRAME_SIZE,
44807
45241
  layout: [
44808
45242
  "x and y are integers, width and height integers of at least 1, and order an integer of at least 0, where a higher order draws on top.",
44809
- "hidden, locked, hugWidth, and hugHeight read as false when absent, and an axis whose hug flag is false holds the size its entry states.",
45243
+ "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.",
45244
+ `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.`,
45245
+ `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.`,
44810
45246
  `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.`,
44811
45247
  "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.",
44812
45248
  "Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
@@ -45127,11 +45563,11 @@ async function reservationsOf(root, refs, options, cwd, now) {
45127
45563
  }
45128
45564
  return reservations;
45129
45565
  }
45130
- /** Where a new row starts on a frame's page, past its frames and reserved boxes. */
45566
+ /** Where a new row starts on a frame's page, past its frames' drawn rows and reserved boxes. */
45131
45567
  async function rightOf(root, frame, live) {
45132
45568
  const page = await scanPage(root, frame.project, frame.page, 0);
45133
45569
  const prefix = `${frame.project}/${frame.page}/`;
45134
- const boxes = [...page.frames.map((each) => each.box), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [each.box] : [])];
45570
+ const boxes = [...page.frames.map((each) => drawnExtent(each.box, each.widths)), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [each.box] : [])];
45135
45571
  return Math.max(...boxes.map((box) => box.x + box.width + 80), 0);
45136
45572
  }
45137
45573
  function describe$4(claims, now) {
@@ -45145,6 +45581,14 @@ function describe$4(claims, now) {
45145
45581
  // src/cli/commands/frame.ts
45146
45582
  const FRAME_REF = "a frame ref, <page>/<frame> or <project>/<page>/<frame>, or a path to its .html file";
45147
45583
  const ANY_INTEGER = parseInteger(Number.MIN_SAFE_INTEGER);
45584
+ 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";
45585
+ const POSITIVE = parseInteger(1);
45586
+ /** A comma list of positive integers, each checked as `--width` checks one. */
45587
+ function parseWidths(value) {
45588
+ return value.split(",").map((part) => POSITIVE(part.trim()));
45589
+ }
45590
+ const SCROLL_HELP = "hold a fixed screen height and scroll past it, fixing both axes, at the reference height of the width when no height is given";
45591
+ const RESIZE_SCROLL_HELP = "hold a fixed screen height and scroll past it, fixing both axes, dropping a hugging height to the reference height of the width and keeping a fixed one";
45148
45592
  function registerFrame(program, context) {
45149
45593
  const { io } = context;
45150
45594
  const frame = program.command("frame").description("Manage frames");
@@ -45155,7 +45599,7 @@ function registerFrame(program, context) {
45155
45599
  data: record,
45156
45600
  human: `${what} ${record.ref}`
45157
45601
  });
45158
- 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."))), context, async ([ref = ""], options) => done(await addFrame(await boardOf(options, io), ref, {
45602
+ 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))), context, async ([ref = ""], options) => done(await addFrame(await boardOf(options, io), ref, {
45159
45603
  ...options,
45160
45604
  cwd: io.cwd
45161
45605
  }), "Added"));
@@ -45167,7 +45611,7 @@ function registerFrame(program, context) {
45167
45611
  ...options,
45168
45612
  cwd: io.cwd
45169
45613
  }), "Moved to"));
45170
- act(withSize(verb("resize", "Set a frame size, fixing each axis it sets")), context, async ([ref = ""], options) => done(await resizeFrame(await boardOf(options, io), ref, {
45614
+ act(withSize(verb("resize", "Set a frame size, fixing each axis it sets").option("--scroll", RESIZE_SCROLL_HELP).option("--no-scroll", "clear scroll, keeping the box as it stands").option("--widths <list>", WIDTHS_HELP, parseWidths).option("--no-widths", "clear the extra widths")), context, async ([ref = ""], options) => done(await resizeFrame(await boardOf(options, io), ref, {
45171
45615
  ...options,
45172
45616
  cwd: io.cwd
45173
45617
  }), "Resized"));
@@ -45178,6 +45622,7 @@ function registerFrame(program, context) {
45178
45622
  cwd: io.cwd
45179
45623
  };
45180
45624
  const frame = await readFrame$1(root, ref, refOptions);
45625
+ if (frame.scroll) throw fitScrollError(frame.ref);
45181
45626
  const result = await withFrameHost({
45182
45627
  root,
45183
45628
  facesDir: context.facesDir
@@ -49364,7 +49809,7 @@ const OPTIONS = {
49364
49809
  * write and `--check` both build through it, so they compare the same bytes.
49365
49810
  */
49366
49811
  async function toReference(source, reference, folder) {
49367
- const result = await (await importFormat(folder))(`${reference}.html`, withProjectAssets(source), OPTIONS);
49812
+ const result = await (await importFormat(folder))(`${reference}.html`, withProjectAssets(source, reference), OPTIONS);
49368
49813
  const [error] = result.errors;
49369
49814
  if (error) {
49370
49815
  const [reason] = error.message.split("\n");
@@ -49375,14 +49820,17 @@ async function toReference(source, reference, folder) {
49375
49820
  /**
49376
49821
  * Rewrites the frame's text only at the spans its loads occupy, so text naming
49377
49822
  * `../assets/` that loads nothing, such as a `<code>` sample, keeps its bytes.
49823
+ * The link climbs one folder per folder the reference sits in, to the folder's
49824
+ * `assets/`.
49378
49825
  */
49379
- function withProjectAssets(source) {
49826
+ function withProjectAssets(source, reference) {
49827
+ const assets = `${"../".repeat(reference.split("/").length - 1)}assets/${source.project}/`;
49380
49828
  const framePath = boardPath(source.root, source.path);
49381
49829
  const spans = /* @__PURE__ */ new Map();
49382
49830
  for (const { path, location } of frameLoads(source)) if (path === framePath && location) spans.set(location.startOffset, location.endOffset);
49383
49831
  let html = source.html;
49384
49832
  for (const [start, end] of [...spans].sort(([a], [b]) => b - a)) {
49385
- const span = html.slice(start, end).replace(BOARD_ASSETS, `../assets/${source.project}/`);
49833
+ const span = html.slice(start, end).replace(BOARD_ASSETS, assets);
49386
49834
  html = `${html.slice(0, start)}${span}${html.slice(end)}`;
49387
49835
  }
49388
49836
  return html;
@@ -49410,12 +49858,15 @@ async function importFormat(folder) {
49410
49858
  }
49411
49859
  }
49412
49860
  // src/server/references/frame-map.ts
49413
- const REFERENCE = /^[a-z0-9]+(-[a-z0-9]+)*\/[a-z0-9]+(-[a-z0-9]+)*$/;
49414
- const BOARD_REF = /^[^/\s]+\/[^/\s]+\/[^/\s]+$/;
49861
+ const SEGMENT = "[a-z0-9]+(-[a-z0-9]+)*";
49862
+ const REFERENCE = new RegExp(`^${SEGMENT}(/${SEGMENT}){1,2}$`);
49863
+ const BOARD_REF = /^[^/\s]+\/[^/\s]+\/[^/\s@]+(@[1-9]\d*)?$/;
49415
49864
  /**
49416
- * Reads `frames.json`, mapping each reference, `<group>/<name>`, to the
49417
- * board frame `<project>/<page>/<frame>` it is captured from. An entry in
49418
- * any other shape refuses rather than filing into the wrong folder.
49865
+ * Reads `frames.json`, mapping each reference, `<group>/<name>` or
49866
+ * `<group>/<section>/<name>`, to the board frame `<project>/<page>/<frame>`
49867
+ * it is captured from, or `<project>/<page>/<frame>@<width>` to capture it at
49868
+ * one of its widths. An entry in any other shape refuses rather than filing
49869
+ * into the wrong folder.
49419
49870
  */
49420
49871
  function parseFrameMap(json) {
49421
49872
  const parsed = parseJson(json);
@@ -49424,8 +49875,8 @@ function parseFrameMap(json) {
49424
49875
  if (Object.keys(frames).length === 0) throw new FrameboardError("frame-map-invalid", "frames.json maps no frames, so a sync would remove every reference.");
49425
49876
  const map = /* @__PURE__ */ new Map();
49426
49877
  for (const [reference, ref] of Object.entries(frames)) {
49427
- if (!REFERENCE.test(reference)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a kebab-case <group>/<name>.`, { reference });
49428
- if (typeof ref !== "string" || !BOARD_REF.test(ref)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a board frame as <project>/<page>/<frame>.`, { reference });
49878
+ if (!REFERENCE.test(reference)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a kebab-case <group>/<name> or <group>/<section>/<name>.`, { reference });
49879
+ if (typeof ref !== "string" || !BOARD_REF.test(ref)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a board frame as <project>/<page>/<frame> or <project>/<page>/<frame>@<width>.`, { reference });
49429
49880
  map.set(reference, ref);
49430
49881
  }
49431
49882
  return map;
@@ -49437,7 +49888,23 @@ function parseJson(json) {
49437
49888
  throw new FrameboardError("frame-map-invalid", "frames.json does not parse as JSON.", {}, { cause: error });
49438
49889
  }
49439
49890
  }
49440
- /** The mapped board frames the board does not hold. */
49891
+ /** A mapped value as the board frame it names and the width it asks for, if any. */
49892
+ function mappedTarget(value) {
49893
+ const at = value.lastIndexOf("@");
49894
+ if (at === -1) return { ref: value };
49895
+ return {
49896
+ ref: value.slice(0, at),
49897
+ width: Number(value.slice(at + 1))
49898
+ };
49899
+ }
49900
+ /** Every value a map may name for one frame: its ref, and its ref at each width it shows at. */
49901
+ function frameTargets(frame) {
49902
+ return [frame.ref, ...[frame.box, ...frame.widths].map(({ width }) => `${frame.ref}@${width}`)];
49903
+ }
49904
+ /**
49905
+ * The mapped values the board does not hold, being a frame it lacks or a
49906
+ * width the frame does not show at, read against `frameTargets`.
49907
+ */
49441
49908
  function missingFrames(map, board) {
49442
49909
  return [...map.values()].filter((ref) => !board.has(ref));
49443
49910
  }
@@ -49484,8 +49951,8 @@ async function buildOutput({ root, folder, facesDir }) {
49484
49951
  const map = parseFrameMap(await readFile(join(folder, "frames.json"), "utf8"));
49485
49952
  const frames = await mappedFrames(root, map);
49486
49953
  const output = /* @__PURE__ */ new Map();
49487
- await Promise.all([...map].map(async ([reference, ref]) => {
49488
- const { project, page, name } = frameOf(frames, ref);
49954
+ await Promise.all([...map].map(async ([reference, value]) => {
49955
+ const { project, page, name } = frameOf(frames, mappedTarget(value).ref);
49489
49956
  const source = readFrame({
49490
49957
  root,
49491
49958
  project,
@@ -49495,18 +49962,35 @@ async function buildOutput({ root, folder, facesDir }) {
49495
49962
  output.set(`${reference}.html`, await toReference(source, reference, folder));
49496
49963
  for (const asset of frameAssets(source)) output.set(join("assets", project, asset), await readFile(join(assetsDirOf(source), asset)));
49497
49964
  }));
49965
+ const targets = new Map([...map.values()].map((value) => {
49966
+ const { ref, width } = mappedTarget(value);
49967
+ const frame = frameOf(frames, ref);
49968
+ return [`${ref}@${width ?? frame.box.width}`, {
49969
+ frame,
49970
+ width
49971
+ }];
49972
+ }));
49498
49973
  const captures = await mkdtemp(join(tmpdir(), "frameboard-references-"));
49499
49974
  try {
49500
49975
  const images = await withFrameHost({
49501
49976
  root,
49502
49977
  facesDir
49503
- }, "references sync", (browser, baseUrl) => captureFrameImages(browser, {
49504
- baseUrl,
49505
- frames: [...frames.values()],
49506
- themes: THEMES,
49507
- out: captures
49508
- }));
49509
- for (const [reference, ref] of map) for (const image of images.filter((image) => image.ref === ref)) output.set(`${reference}-${image.theme}.png`, await readFile(image.path));
49978
+ }, "references sync", async (browser, baseUrl) => {
49979
+ const shot = [];
49980
+ for (const { frame, width } of targets.values()) shot.push(...await captureFrameImages(browser, {
49981
+ baseUrl,
49982
+ frames: [frame],
49983
+ themes: THEMES,
49984
+ out: captures,
49985
+ width: width ?? frame.box.width
49986
+ }));
49987
+ return shot;
49988
+ });
49989
+ for (const [reference, value] of map) {
49990
+ const { ref, width } = mappedTarget(value);
49991
+ const wanted = width ?? frameOf(frames, ref).box.width;
49992
+ for (const image of images.filter((image) => image.ref === ref && image.width === wanted)) output.set(`${reference}-${image.theme}.png`, await readFile(image.path));
49993
+ }
49510
49994
  } finally {
49511
49995
  await rm(captures, {
49512
49996
  recursive: true,
@@ -49519,9 +50003,12 @@ async function buildOutput({ root, folder, facesDir }) {
49519
50003
  async function mappedFrames(root, map) {
49520
50004
  const { projects } = await scanBoard(root);
49521
50005
  const board = new Map(projects.flatMap((project) => project.pages).flatMap((page) => page.frames).map((frame) => [frame.ref, frame]));
49522
- const missing = missingFrames(map, new Set(board.keys()));
50006
+ const missing = missingFrames(map, new Set([...board.values()].flatMap(frameTargets)));
49523
50007
  if (missing.length > 0) throw new FrameboardError("frame-not-found", `No board frame for: ${missing.join(", ")}. Nothing written.`, { missing });
49524
- return new Map([...map.values()].map((ref) => [ref, frameOf(board, ref)]));
50008
+ return new Map([...map.values()].map((value) => {
50009
+ const { ref } = mappedTarget(value);
50010
+ return [ref, frameOf(board, ref)];
50011
+ }));
49525
50012
  }
49526
50013
  function frameOf(frames, ref) {
49527
50014
  const frame = frames.get(ref);
@@ -49817,7 +50304,8 @@ function createThumbnailStore({ root, run, render, onRendered }) {
49817
50304
  ...LAYOUT_RULES,
49818
50305
  ...FONT_SIZE_RULES,
49819
50306
  ...CONTRAST_RULES,
49820
- ...DECLARATION_RULES
50307
+ ...DECLARATION_RULES,
50308
+ ...SCROLL_EFFECT_RULES
49821
50309
  ];
49822
50310
  /** The rules that read one theme's page and land one finding at most. */
49823
50311
  const THEMED_RULES = [
@@ -49830,7 +50318,8 @@ const THEMED_RULES = [
49830
50318
  * dark, and merges the two. A rule tripping in one theme alone names that
49831
50319
  * theme in its message. A missing face is measured in the fallback the board
49832
50320
  * shows rather than refused, since the board shows it too. The declaration
49833
- * rule reads no theme, so it runs on the first theme's page alone.
50321
+ * and scroll-effect rules read no theme, so they run on the first theme's
50322
+ * page alone.
49834
50323
  */
49835
50324
  async function checkRendered(browser, { baseUrl, root, frame, config }) {
49836
50325
  const [project = "", page = "", name = ""] = frame.ref.split("/");
@@ -49841,7 +50330,7 @@ async function checkRendered(browser, { baseUrl, root, frame, config }) {
49841
50330
  name
49842
50331
  });
49843
50332
  const byTheme = /* @__PURE__ */ new Map();
49844
- let declarations = [];
50333
+ let unthemed = [];
49845
50334
  for (const theme of THEMES) {
49846
50335
  const opened = await openFrame(browser, {
49847
50336
  baseUrl,
@@ -49856,12 +50345,12 @@ async function checkRendered(browser, { baseUrl, root, frame, config }) {
49856
50345
  ...config.minFontSize === void 0 ? [] : await checkFontSize(opened.page, frame, config.minFontSize),
49857
50346
  ...config.minContrast === void 0 ? [] : await checkContrast(opened.page, frame, config.minContrast)
49858
50347
  ]);
49859
- if (theme === THEMES[0]) declarations = await checkDeclarations(opened.page, source);
50348
+ if (theme === THEMES[0]) unthemed = [...await checkDeclarations(opened.page, source), ...await checkScrollEffect(opened.page, frame)];
49860
50349
  } finally {
49861
50350
  await opened.close();
49862
50351
  }
49863
50352
  }
49864
- return [...mergeThemes(byTheme), ...declarations];
50353
+ return [...mergeThemes(byTheme), ...unthemed];
49865
50354
  }
49866
50355
  /**
49867
50356
  * One finding per rule across themes, in rule order. A rule both themes trip
@@ -49934,6 +50423,8 @@ async function landReserved(root, now) {
49934
50423
  locked: false,
49935
50424
  hugWidth: hugWidth ?? false,
49936
50425
  hugHeight: hugHeight ?? false,
50426
+ scroll: false,
50427
+ widths: [],
49937
50428
  placed: true
49938
50429
  });
49939
50430
  layout.renumber();
@@ -53315,6 +53806,23 @@ function placedRefs(previous, next, paths) {
53315
53806
  const before = new Set(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => frame.placed).map((frame) => frame.ref))));
53316
53807
  return next.projects.flatMap((project) => project.pages.filter((page) => !written || written.has(join(page.path, "layout.json"))).flatMap((page) => page.frames.filter((frame) => frame.placed && (frame.hugWidth || frame.hugHeight) && !before.has(frame.ref)).map((frame) => frame.ref)));
53317
53808
  }
53809
+ /**
53810
+ * The frames hugging their height whose list of linked widths differs
53811
+ * between two scans, as a `frame resize --widths` leaves one. That write
53812
+ * touches `layout.json` alone, which reloads nothing, so a width it adds is
53813
+ * measured here or holds its stand-in height until the frame file is next
53814
+ * written. A frame absent from `previous` is `placedRefs`'s to name.
53815
+ */
53816
+ function relistedRefs(previous, next) {
53817
+ const before = new Map(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.map((frame) => [frame.ref, listed(frame)]))));
53818
+ return next.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => {
53819
+ const was = before.get(frame.ref);
53820
+ return frame.placed && frame.hugHeight && frame.widths.length > 0 && was !== void 0 && was !== listed(frame);
53821
+ }).map((frame) => frame.ref)));
53822
+ }
53823
+ function listed(frame) {
53824
+ return frame.widths.map(({ width }) => width).join(",");
53825
+ }
53318
53826
  // src/server/live/findings.ts
53319
53827
  /**
53320
53828
  * The board's check findings, held between batches so a hello needs no
@@ -53568,20 +54076,20 @@ function send(socket, message) {
53568
54076
  function createHug({ root, measure }) {
53569
54077
  let queue = Promise.resolve();
53570
54078
  let closed = false;
53571
- const run = async (board, refs) => {
54079
+ const run = async (board, refs, parts) => {
53572
54080
  const pages = /* @__PURE__ */ new Map();
53573
54081
  let stale = false;
53574
- for (const frame of huggingFrames(board, refs)) {
54082
+ for (const frame of huggingFrames(board, refs, parts)) {
53575
54083
  if (closed) return false;
53576
54084
  let size;
53577
54085
  try {
53578
- size = await measure(frame);
54086
+ size = await measureParts(measure, frame, parts);
53579
54087
  } catch (error) {
53580
54088
  if (error instanceof FrameboardError && error.code === "browser-not-found") break;
53581
54089
  continue;
53582
54090
  }
53583
- if (size.empty) continue;
53584
- stale ||= frame.hugWidth && size.width !== frame.box.width || frame.hugHeight && size.height !== frame.box.height;
54091
+ if (Object.keys(size).length === 0) continue;
54092
+ stale ||= frame.hugWidth && size.width !== void 0 && size.width !== frame.box.width || frame.hugHeight && size.height !== void 0 && size.height !== frame.box.height;
53585
54093
  const page = `${frame.project}/${frame.page}`;
53586
54094
  pages.set(page, [...pages.get(page) ?? [], {
53587
54095
  frame,
@@ -53603,20 +54111,55 @@ function createHug({ root, measure }) {
53603
54111
  }
53604
54112
  return written || stale;
53605
54113
  };
54114
+ const enqueue = (board, refs, parts) => {
54115
+ if (closed || huggingFrames(board, refs, parts).length === 0) return;
54116
+ queue = queue.then(() => run(board, refs, parts)).catch(() => {});
54117
+ };
53606
54118
  return {
53607
- now: (board, refs) => run(board, refs),
53608
- later: (board, refs) => {
53609
- if (closed || huggingFrames(board, refs).length === 0) return;
53610
- queue = queue.then(() => run(board, refs)).catch(() => {});
54119
+ now: async (board, refs) => {
54120
+ const stale = await run(board, refs, "own");
54121
+ enqueue(board, refs, "linked");
54122
+ return stale;
53611
54123
  },
54124
+ later: (board, refs) => enqueue(board, refs, "all"),
53612
54125
  close: () => {
53613
54126
  closed = true;
53614
54127
  }
53615
54128
  };
53616
54129
  }
53617
- function huggingFrames(board, refs) {
54130
+ /**
54131
+ * Reads the parts a run asks for, a linked width only on a frame hugging its
54132
+ * height. An empty body at the frame's own box, or at every linked width,
54133
+ * reads nothing for that part, so the box it stands in for holds.
54134
+ */
54135
+ async function measureParts(measure, frame, parts) {
54136
+ const size = {};
54137
+ if (parts !== "linked") {
54138
+ const own = await measure(frame);
54139
+ if (!own.empty) Object.assign(size, {
54140
+ width: own.width,
54141
+ height: own.height
54142
+ });
54143
+ }
54144
+ if (parts !== "own" && frame.hugHeight && frame.widths.length > 0) {
54145
+ const widths = [];
54146
+ for (const { width } of frame.widths) {
54147
+ const linked = await measure(frame, {
54148
+ width,
54149
+ height: referenceHeight(width)
54150
+ });
54151
+ if (!linked.empty) widths.push({
54152
+ width,
54153
+ height: linked.height
54154
+ });
54155
+ }
54156
+ if (widths.length > 0) size.widths = widths;
54157
+ }
54158
+ return size;
54159
+ }
54160
+ function huggingFrames(board, refs, parts) {
53618
54161
  const wanted = new Set(refs);
53619
- return board.projects.flatMap((project) => project.pages).flatMap((page) => page.frames).filter((frame) => wanted.has(frame.ref) && frame.placed && (frame.hugWidth || frame.hugHeight));
54162
+ return board.projects.flatMap((project) => project.pages).flatMap((page) => page.frames).filter((frame) => wanted.has(frame.ref) && frame.placed && (parts === "linked" ? frame.hugHeight && frame.widths.length > 0 : frame.hugWidth || frame.hugHeight));
53620
54163
  }
53621
54164
  /**
53622
54165
  * The hugging frames whose file was written after their page's `layout.json`,
@@ -53649,6 +54192,41 @@ function ownFileRefs(board, paths) {
53649
54192
  }
53650
54193
  // src/server/live/rendered-findings.ts
53651
54194
  /**
54195
+ * Runs `check` at the frame's own box, then at each linked width it lists,
54196
+ * tagging each finding read at a linked width with that width. A linked
54197
+ * finding the own box already reported, being the same rule and message at
54198
+ * the same place, is left out, since it is no fault of that width. A null
54199
+ * reading at any box answers null for the frame.
54200
+ */
54201
+ async function acrossWidths(frame, check) {
54202
+ const own = await check({
54203
+ width: frame.box.width,
54204
+ height: frame.box.height
54205
+ });
54206
+ if (own === null) return null;
54207
+ const seen = new Set(own.map(sameness));
54208
+ const findings = [...own];
54209
+ for (const { width, height } of frame.widths) {
54210
+ const linked = await check({
54211
+ width,
54212
+ height
54213
+ });
54214
+ if (linked === null) return null;
54215
+ for (const finding of linked) if (!seen.has(sameness(finding))) findings.push({
54216
+ ...finding,
54217
+ width
54218
+ });
54219
+ }
54220
+ return findings;
54221
+ }
54222
+ function sameness(finding) {
54223
+ return JSON.stringify([
54224
+ finding.rule,
54225
+ finding.message,
54226
+ finding.location
54227
+ ]);
54228
+ }
54229
+ /**
53652
54230
  * The server's warm checker. Rechecks run one at a time on their own queue,
53653
54231
  * so a PNG never waits behind them, and a ref queued again before its result
53654
54232
  * lands drops that result, so the board never shows findings from an older
@@ -53718,7 +54296,7 @@ function createRenderedFindings({ check, onResult }) {
53718
54296
  known = frames;
53719
54297
  const due = new Set(refs);
53720
54298
  for (const [ref, frame] of frames) {
53721
- const from = `${frame.box.width}x${frame.box.height}@${frame.modifiedAt}`;
54299
+ const from = `${[frame.box, ...frame.widths].map(({ width, height }) => `${width}x${height}`).join(",")}@${frame.modifiedAt}`;
53722
54300
  if (seen.get(ref) !== from) due.add(ref);
53723
54301
  seen.set(ref, from);
53724
54302
  }
@@ -54065,19 +54643,19 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
54065
54643
  await thumbnails.empty();
54066
54644
  const rendered = createRenderedFindings({
54067
54645
  check: async (frame) => {
54068
- const list = await checkRendered(await browser.get(), {
54646
+ const list = await acrossWidths(frame, async (box) => checkRendered(await browser.get(), {
54069
54647
  baseUrl: baseUrl(),
54070
54648
  root,
54071
54649
  frame: {
54072
54650
  ref: frame.ref,
54073
54651
  path: boardPath(root, frame.path),
54074
- box: {
54075
- width: frame.box.width,
54076
- height: frame.box.height
54077
- }
54652
+ box,
54653
+ scroll: frame.scroll,
54654
+ hugHeight: frame.hugHeight
54078
54655
  },
54079
54656
  config: readConfig(root, frame.project)
54080
- });
54657
+ }));
54658
+ if (list === null) return null;
54081
54659
  return await modifiedAt(frame.path) === frame.modifiedAt ? list : null;
54082
54660
  },
54083
54661
  onResult: (ref, list) => {
@@ -54090,11 +54668,11 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
54090
54668
  });
54091
54669
  }
54092
54670
  });
54093
- const measure = async (frame) => measureContent(await browser.get(), {
54671
+ const measure = async (frame, box) => measureContent(await browser.get(), {
54094
54672
  baseUrl: baseUrl(),
54095
54673
  ref: frame.ref,
54096
- box: frame.box,
54097
- hugWidth: frame.hugWidth,
54674
+ box: box ?? frame.box,
54675
+ hugWidth: box === void 0 && frame.hugWidth,
54098
54676
  fonts: "wait"
54099
54677
  });
54100
54678
  const hug = createHug({
@@ -54250,6 +54828,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
54250
54828
  let board;
54251
54829
  let own;
54252
54830
  let placed;
54831
+ let relisted = [];
54253
54832
  try {
54254
54833
  await landReserved(root, /* @__PURE__ */ new Date()).catch(() => []);
54255
54834
  board = await scanBoard(root);
@@ -54257,6 +54836,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
54257
54836
  scanned.board = board;
54258
54837
  own = ownFileRefs(board, paths);
54259
54838
  placed = previous ? placedRefs(previous, board, paths).filter((ref) => !own.includes(ref)) : [];
54839
+ relisted = previous ? relistedRefs(previous, board) : [];
54260
54840
  if (await hug.now(board, [...own, ...placed]).catch(() => false)) {
54261
54841
  const measured = board;
54262
54842
  board = await scanBoard(root);
@@ -54277,7 +54857,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
54277
54857
  const last = shown.board;
54278
54858
  shown.board = board;
54279
54859
  const refs = reloadRefs(root, paths, board, tokens);
54280
- hug.later(board, refs.filter((ref) => !own.includes(ref) && !placed.includes(ref)));
54860
+ hug.later(board, [.../* @__PURE__ */ new Set([...refs, ...relisted])].filter((ref) => !own.includes(ref) && !placed.includes(ref)));
54281
54861
  if (refs.length > 0) {
54282
54862
  const reloads = unmovedRefs(refs, board, moved(), last);
54283
54863
  if (reloads.length > 0) hub.broadcast({