frameboard 0.45.0 → 0.47.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
@@ -9635,22 +9635,42 @@ function topInset(device, turn) {
9635
9635
  return device === "phone" && !isTurned(device, turn) ? STATUS_BAR.height : 0;
9636
9636
  }
9637
9637
  /**
9638
- * The page's box inside a frame's box, less the status bar while an upright
9639
- * phone shows. A frame's box keeps the screen's size, and every surface reads
9640
- * the page through this.
9638
+ * The width a turned phone's or foldable's page stands in from each side edge
9639
+ * its island can stand on, 10 past the island as a phone's status bar ends,
9640
+ * so the island never covers it and the page stays centered. 0 otherwise.
9641
+ */
9642
+ function sideInset(device, turn) {
9643
+ if (!isTurned(device, turn)) return 0;
9644
+ if (device === "phone") return STATUS_BAR.height;
9645
+ return device === "foldable" ? FOLDABLE_ISLAND.top + FOLDABLE_ISLAND.height + 10 : 0;
9646
+ }
9647
+ /** Whether a page stands in from its box, so the strips around it paint the page's fill. */
9648
+ function insetsPage(device, turn) {
9649
+ return topInset(device, turn) > 0 || sideInset(device, turn) > 0;
9650
+ }
9651
+ /**
9652
+ * The page's box inside a frame's box, less an upright phone's status bar or
9653
+ * a turned phone's or foldable's side insets. A frame's box keeps the screen's size, and
9654
+ * every surface reads the page through this.
9641
9655
  */
9642
9656
  function pageBox(box, device, turn) {
9643
- const inset = topInset(device, turn);
9657
+ const top = topInset(device, turn);
9658
+ const side = sideInset(device, turn);
9644
9659
  return {
9645
- x: box.x,
9646
- y: box.y + inset,
9647
- width: box.width,
9648
- height: Math.max(0, box.height - inset)
9660
+ x: box.x + side,
9661
+ y: box.y + top,
9662
+ width: Math.max(0, box.width - 2 * side),
9663
+ height: Math.max(0, box.height - top)
9649
9664
  };
9650
9665
  }
9651
- /** The page's corners as a CSS `border-radius`, square on top under an upright phone's status bar. */
9666
+ /**
9667
+ * The page's corners as a CSS `border-radius`, square on top under an upright
9668
+ * phone's status bar and square all round between a turned phone's or
9669
+ * foldable's strips.
9670
+ */
9652
9671
  function pageCorners(device, turn) {
9653
- if (device !== "phone" || isTurned(device, turn)) return screenCorners(device);
9672
+ if (sideInset(device, turn) > 0) return "0";
9673
+ if (device !== "phone") return screenCorners(device);
9654
9674
  const { screenRadius } = BEZELS.phone;
9655
9675
  return `0 0 ${screenRadius}px ${screenRadius}px`;
9656
9676
  }
@@ -24845,8 +24865,8 @@ function readTransitionSheet(name, css) {
24845
24865
  const leave = held.get("leave");
24846
24866
  return {
24847
24867
  ok: true,
24848
- enter: bodyOf(enter),
24849
- leave: leave ? bodyOf(leave) : null
24868
+ enter: bodyOf$1(enter),
24869
+ leave: leave ? bodyOf$1(leave) : null
24850
24870
  };
24851
24871
  }
24852
24872
  function refused$2(problems) {
@@ -24917,7 +24937,7 @@ function problemAt(node, message) {
24917
24937
  };
24918
24938
  }
24919
24939
  /** The steps inside a keyframes block, on one line, with its comments dropped. */
24920
- function bodyOf(block) {
24940
+ function bodyOf$1(block) {
24921
24941
  return (block.nodes ?? []).filter((node) => node.type === "rule").map((step) => {
24922
24942
  const declarations = step.nodes.filter((child) => child.type === "decl").map((child) => `${child.prop}: ${child.value}${child.important ? " !important" : ""}`);
24923
24943
  return `${step.selector.trim()} { ${declarations.join("; ")} }`;
@@ -25392,7 +25412,7 @@ async function isDirectory(path) {
25392
25412
  }
25393
25413
  }
25394
25414
  // package.json
25395
- var version$1 = "0.45.0";
25415
+ var version$1 = "0.47.0";
25396
25416
  var dependencies = { "playwright-core": "1.65.0" };
25397
25417
  var peerDependencies = { "oxfmt": "0.78.0" };
25398
25418
  // src/shared/version.ts
@@ -26253,7 +26273,39 @@ async function setFrameDevice(root, ref, show, { foldable: name, pose: fold, isl
26253
26273
  hugWidth: false,
26254
26274
  hugHeight: false
26255
26275
  };
26256
- });
26276
+ }, fold || turn || name !== void 0 ? pushAlong : void 0);
26277
+ }
26278
+ /**
26279
+ * Shifts each frame on the grown body's rows at or past its old right edge by
26280
+ * the growth, keeping the gap. A shrink pulls none back, since the developer
26281
+ * may have arranged them since, and a bare show or hide never calls this.
26282
+ */
26283
+ function pushAlong(layout, name, before) {
26284
+ const was = bodyOf(before);
26285
+ const now = bodyOf(layout.placement(name));
26286
+ const edge = was.x + was.width;
26287
+ const growth = now.x + now.width - edge;
26288
+ if (growth <= 0) return;
26289
+ const pushed = layout.names.filter((other) => other !== name && layout.hasEntry(other)).map((other) => ({
26290
+ other,
26291
+ placement: layout.placement(other)
26292
+ })).filter(({ placement }) => {
26293
+ const body = bodyOf(placement);
26294
+ return body.x >= edge && body.y < now.y + now.height && body.y + body.height > now.y;
26295
+ });
26296
+ for (const { other, placement } of pushed) {
26297
+ const { box } = placement;
26298
+ layout.set(other, {
26299
+ ...placement,
26300
+ box: {
26301
+ ...box,
26302
+ x: box.x + growth
26303
+ }
26304
+ });
26305
+ }
26306
+ }
26307
+ function bodyOf({ box, device, turn }) {
26308
+ return bezelBox(box, device, turn);
26257
26309
  }
26258
26310
  /**
26259
26311
  * A named foldable left as it is while it stays named, and stood upright at
@@ -26401,12 +26453,14 @@ async function deleteFrame(root, ref, options) {
26401
26453
  }, journal);
26402
26454
  return { deleted: refOf$1(frame) };
26403
26455
  }
26404
- async function updatePlacement(root, ref, options, change) {
26456
+ async function updatePlacement(root, ref, options, change, settle) {
26405
26457
  const frame = await resolveFrameRef(root, ref, options);
26406
26458
  const page = pageDir(frame);
26407
26459
  await withLayouts([page], async (layouts) => {
26408
26460
  const layout = layoutAt(layouts, page);
26409
- layout.set(frame.name, change(layout.placement(frame.name), refOf$1(frame)));
26461
+ const before = layout.placement(frame.name);
26462
+ layout.set(frame.name, change(before, refOf$1(frame)));
26463
+ settle?.(layout, frame.name, before);
26410
26464
  }, options.journal);
26411
26465
  return frameRecord(root, frame.project, frame.page, frame.name);
26412
26466
  }
@@ -31467,6 +31521,149 @@ function cssUrls(css) {
31467
31521
  });
31468
31522
  return urls;
31469
31523
  }
31524
+ // src/server/edit/start-tag.ts
31525
+ function isSpace(char) {
31526
+ return char === " " || char === " " || char === "\n" || char === "\f" || char === "\r";
31527
+ }
31528
+ /**
31529
+ * Scans a start tag through the tokenizer states, since parse5 records neither
31530
+ * self-closing nor duplicates, and `<circle id=x/>` is not self-closed.
31531
+ */
31532
+ function scanStartTag(source, tag) {
31533
+ const names = [];
31534
+ let state = "tagName";
31535
+ let quote = "";
31536
+ let nameStart = 0;
31537
+ let slash;
31538
+ const end = tag.endOffset - 1;
31539
+ for (let at = tag.startOffset + 1; at < end; at += 1) {
31540
+ const char = source[at];
31541
+ slash = void 0;
31542
+ switch (state) {
31543
+ case "tagName":
31544
+ if (isSpace(char)) state = "beforeAttrName";
31545
+ else if (char === "/") {
31546
+ state = "beforeAttrName";
31547
+ slash = at;
31548
+ }
31549
+ break;
31550
+ case "beforeAttrName":
31551
+ if (char === "/") slash = at;
31552
+ else if (!isSpace(char)) {
31553
+ state = "attrName";
31554
+ nameStart = at;
31555
+ }
31556
+ break;
31557
+ case "attrName":
31558
+ if (isSpace(char) || char === "/" || char === "=") {
31559
+ names.push(source.slice(nameStart, at).toLowerCase());
31560
+ if (char === "=") state = "beforeValue";
31561
+ else if (char === "/") {
31562
+ state = "beforeAttrName";
31563
+ slash = at;
31564
+ } else state = "afterAttrName";
31565
+ }
31566
+ break;
31567
+ case "afterAttrName":
31568
+ if (char === "/") {
31569
+ state = "beforeAttrName";
31570
+ slash = at;
31571
+ } else if (char === "=") state = "beforeValue";
31572
+ else if (!isSpace(char)) {
31573
+ state = "attrName";
31574
+ nameStart = at;
31575
+ }
31576
+ break;
31577
+ case "beforeValue":
31578
+ if (char === "\"" || char === "'") {
31579
+ quote = char;
31580
+ state = "quoted";
31581
+ } else if (!isSpace(char)) state = "unquoted";
31582
+ break;
31583
+ case "quoted":
31584
+ if (char === quote) state = "beforeAttrName";
31585
+ break;
31586
+ case "unquoted": if (isSpace(char)) state = "beforeAttrName";
31587
+ }
31588
+ }
31589
+ if (state === "attrName") names.push(source.slice(nameStart, end).toLowerCase());
31590
+ return {
31591
+ slash,
31592
+ names
31593
+ };
31594
+ }
31595
+ // src/server/edit/attribute.ts
31596
+ /** Escapes a value for a double-quoted attribute. */
31597
+ function escapeAttribute$1(value) {
31598
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
31599
+ }
31600
+ function splice(source, start, end, insert) {
31601
+ return source.slice(0, start) + insert + source.slice(end);
31602
+ }
31603
+ /** The value inside one attribute's source span, without its quotes. */
31604
+ function valueSpan(source, span) {
31605
+ const text = source.slice(span.startOffset, span.endOffset);
31606
+ const equals = text.indexOf("=");
31607
+ if (equals === -1) return {
31608
+ start: span.endOffset,
31609
+ end: span.endOffset,
31610
+ quote: void 0,
31611
+ isBare: true
31612
+ };
31613
+ let at = equals + 1;
31614
+ while (/\s/.test(text[at] ?? "")) at += 1;
31615
+ const opener = text[at];
31616
+ const quote = opener === "\"" || opener === "'" ? opener : void 0;
31617
+ return {
31618
+ start: span.startOffset + at + (quote ? 1 : 0),
31619
+ end: span.endOffset - (quote ? 1 : 0),
31620
+ quote,
31621
+ isBare: false
31622
+ };
31623
+ }
31624
+ function attributeSpan(element, name) {
31625
+ return element.sourceCodeLocation?.attrs?.[name];
31626
+ }
31627
+ /** The attribute's value as the file states it, still encoded, or undefined when it is absent. */
31628
+ function rawAttribute(source, element, name) {
31629
+ const span = attributeSpan(element, name);
31630
+ if (!span) return void 0;
31631
+ const value = valueSpan(source, span);
31632
+ return source.slice(value.start, value.end);
31633
+ }
31634
+ /**
31635
+ * Sets one attribute inside its value span, a new one going before the real
31636
+ * self-closing `/`, which only the start-tag scan tells from an unquoted value's.
31637
+ */
31638
+ function setRawAttribute(source, element, name, raw) {
31639
+ const span = attributeSpan(element, name);
31640
+ if (span) {
31641
+ const value = valueSpan(source, span);
31642
+ if (value.isBare) return splice(source, span.endOffset, span.endOffset, `="${raw}"`);
31643
+ if (value.quote === "'") return splice(source, value.start, value.end, raw.replace(/'/g, "&#39;"));
31644
+ if (value.quote === "\"") return splice(source, value.start, value.end, raw);
31645
+ return splice(source, value.start, value.end, `"${raw.replace(/"/g, "&quot;")}"`);
31646
+ }
31647
+ const startTag = element.sourceCodeLocation?.startTag;
31648
+ if (!startTag) return source;
31649
+ const at = scanStartTag(source, startTag).slash ?? startTag.endOffset - 1;
31650
+ return splice(source, at, at, `${/\s/.test(source[at - 1] ?? "") ? "" : " "}${name}="${raw}"${source[at] === "/" ? " " : ""}`);
31651
+ }
31652
+ /**
31653
+ * Removes one attribute and the whitespace run ahead of it. A later duplicate
31654
+ * would come into force once the first is gone, so the first is emptied
31655
+ * instead, and a bare one is left as it is, already empty.
31656
+ */
31657
+ function removeAttribute(source, element, name) {
31658
+ const span = attributeSpan(element, name);
31659
+ const startTag = element.sourceCodeLocation?.startTag;
31660
+ if (!span || !startTag) return source;
31661
+ const { names } = scanStartTag(source, startTag);
31662
+ if (names.filter((stated) => stated === name).length > 1) return valueSpan(source, span).isBare ? source : setRawAttribute(source, element, name, "");
31663
+ let start = span.startOffset;
31664
+ while (/\s/.test(source[start - 1] ?? "")) start -= 1;
31665
+ return splice(source, start, span.endOffset, "");
31666
+ }
31470
31667
  // src/server/board/asset-usage.ts
31471
31668
  /**
31472
31669
  * A per-project cache of how many frames link each asset, counted from the
@@ -31547,32 +31744,49 @@ async function framesLinking(root, project, path) {
31547
31744
  }
31548
31745
  /**
31549
31746
  * The frame's markup with each load of `from` pointed at `to`, or null when no load in its own file names it.
31747
+ * An element whose load moved takes the new file name while its `data-name` is still the old one, so a name set by hand stays.
31550
31748
  * A linked sheet's load, or a URL written through an entity or escape, stays for the link check to report.
31551
31749
  */
31552
31750
  function rewriteAssetLinks(source, from, to) {
31553
31751
  const framePath = boardPath(source.root, source.path);
31554
- const edits = /* @__PURE__ */ new Map();
31752
+ const moved = /* @__PURE__ */ new Map();
31555
31753
  for (const load of frameLoads(source)) {
31556
31754
  if (load.path !== framePath || load.location === null) continue;
31557
31755
  if (localTarget(load.url, load.base) !== from) continue;
31558
31756
  const { startOffset: start, endOffset: end } = load.location;
31559
- edits.set(`${start}:${end}:${load.url}`, {
31757
+ moved.set(`${start}:${end}:${load.url}`, {
31560
31758
  start,
31561
31759
  end,
31562
31760
  url: load.url
31563
31761
  });
31564
31762
  }
31763
+ const loads = [...moved.values()];
31764
+ const edits = loads.map(({ start, end, url }) => ({
31765
+ start,
31766
+ end,
31767
+ write: (span) => span.replace(urlPattern(url), (_, lead) => `${lead}${renamedUrl(url, basename(to))}`)
31768
+ }));
31769
+ const rewritten = loads.filter(({ start, end, url }) => urlPattern(url).test(source.html.slice(start, end)));
31770
+ edits.push(...nameEdits(source, rewritten, basename(from), basename(to)));
31565
31771
  let html = source.html;
31566
- let changed = false;
31567
- const ordered = [...edits.values()].sort((a, b) => b.start - a.start);
31568
- for (const { start, end, url } of ordered) {
31569
- const written = html.slice(start, end).replace(urlPattern(url), (_, lead) => {
31570
- changed = true;
31571
- return `${lead}${renamedUrl(url, basename(to))}`;
31572
- });
31573
- html = html.slice(0, start) + written + html.slice(end);
31574
- }
31575
- return changed ? html : null;
31772
+ for (const { start, end, write } of edits.sort((a, b) => b.start - a.start)) html = html.slice(0, start) + write(html.slice(start, end)) + html.slice(end);
31773
+ return html === source.html ? null : html;
31774
+ }
31775
+ /** A `data-name` of `oldName` set to `newName` on each element one of `loads` sits in. */
31776
+ function nameEdits(source, loads, oldName, newName) {
31777
+ return source.elements.flatMap((element) => {
31778
+ if (element.attribs["data-name"] !== oldName) return [];
31779
+ const tag = element.sourceCodeLocation;
31780
+ const name = tag?.attrs?.["data-name"];
31781
+ const startTag = tag?.startTag;
31782
+ if (!name || !startTag) return [];
31783
+ if (!loads.some(({ start }) => start >= startTag.startOffset && start < startTag.endOffset)) return [];
31784
+ return [{
31785
+ start: name.startOffset,
31786
+ end: name.endOffset,
31787
+ write: () => `data-name="${escapeAttribute$1(newName)}"`
31788
+ }];
31789
+ });
31576
31790
  }
31577
31791
  /** The URL as a whole token, so `a.jpg` never matches inside `a.jpg-2.jpg`. */
31578
31792
  function urlPattern(url) {
@@ -31866,8 +32080,6 @@ const imageGenerateSchema = object$1({
31866
32080
  });
31867
32081
  object$1({
31868
32082
  version: literal(1),
31869
- /** Whether the board may generate at all, false while generating from a tab is switched off. */
31870
- enabled: boolean$1(),
31871
32083
  /** The first provider whose key is set, null when none is. */
31872
32084
  provider: object$1({
31873
32085
  name: _enum$1(IMAGE_PROVIDERS),
@@ -33180,149 +33392,6 @@ function clipboardRoutes(root, access, render, clipboard) {
33180
33392
  });
33181
33393
  return app;
33182
33394
  }
33183
- // src/server/edit/start-tag.ts
33184
- function isSpace(char) {
33185
- return char === " " || char === " " || char === "\n" || char === "\f" || char === "\r";
33186
- }
33187
- /**
33188
- * Scans a start tag through the tokenizer states, since parse5 records neither
33189
- * self-closing nor duplicates, and `<circle id=x/>` is not self-closed.
33190
- */
33191
- function scanStartTag(source, tag) {
33192
- const names = [];
33193
- let state = "tagName";
33194
- let quote = "";
33195
- let nameStart = 0;
33196
- let slash;
33197
- const end = tag.endOffset - 1;
33198
- for (let at = tag.startOffset + 1; at < end; at += 1) {
33199
- const char = source[at];
33200
- slash = void 0;
33201
- switch (state) {
33202
- case "tagName":
33203
- if (isSpace(char)) state = "beforeAttrName";
33204
- else if (char === "/") {
33205
- state = "beforeAttrName";
33206
- slash = at;
33207
- }
33208
- break;
33209
- case "beforeAttrName":
33210
- if (char === "/") slash = at;
33211
- else if (!isSpace(char)) {
33212
- state = "attrName";
33213
- nameStart = at;
33214
- }
33215
- break;
33216
- case "attrName":
33217
- if (isSpace(char) || char === "/" || char === "=") {
33218
- names.push(source.slice(nameStart, at).toLowerCase());
33219
- if (char === "=") state = "beforeValue";
33220
- else if (char === "/") {
33221
- state = "beforeAttrName";
33222
- slash = at;
33223
- } else state = "afterAttrName";
33224
- }
33225
- break;
33226
- case "afterAttrName":
33227
- if (char === "/") {
33228
- state = "beforeAttrName";
33229
- slash = at;
33230
- } else if (char === "=") state = "beforeValue";
33231
- else if (!isSpace(char)) {
33232
- state = "attrName";
33233
- nameStart = at;
33234
- }
33235
- break;
33236
- case "beforeValue":
33237
- if (char === "\"" || char === "'") {
33238
- quote = char;
33239
- state = "quoted";
33240
- } else if (!isSpace(char)) state = "unquoted";
33241
- break;
33242
- case "quoted":
33243
- if (char === quote) state = "beforeAttrName";
33244
- break;
33245
- case "unquoted": if (isSpace(char)) state = "beforeAttrName";
33246
- }
33247
- }
33248
- if (state === "attrName") names.push(source.slice(nameStart, end).toLowerCase());
33249
- return {
33250
- slash,
33251
- names
33252
- };
33253
- }
33254
- // src/server/edit/attribute.ts
33255
- /** Escapes a value for a double-quoted attribute. */
33256
- function escapeAttribute$1(value) {
33257
- return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
33258
- }
33259
- function splice(source, start, end, insert) {
33260
- return source.slice(0, start) + insert + source.slice(end);
33261
- }
33262
- /** The value inside one attribute's source span, without its quotes. */
33263
- function valueSpan(source, span) {
33264
- const text = source.slice(span.startOffset, span.endOffset);
33265
- const equals = text.indexOf("=");
33266
- if (equals === -1) return {
33267
- start: span.endOffset,
33268
- end: span.endOffset,
33269
- quote: void 0,
33270
- isBare: true
33271
- };
33272
- let at = equals + 1;
33273
- while (/\s/.test(text[at] ?? "")) at += 1;
33274
- const opener = text[at];
33275
- const quote = opener === "\"" || opener === "'" ? opener : void 0;
33276
- return {
33277
- start: span.startOffset + at + (quote ? 1 : 0),
33278
- end: span.endOffset - (quote ? 1 : 0),
33279
- quote,
33280
- isBare: false
33281
- };
33282
- }
33283
- function attributeSpan(element, name) {
33284
- return element.sourceCodeLocation?.attrs?.[name];
33285
- }
33286
- /** The attribute's value as the file states it, still encoded, or undefined when it is absent. */
33287
- function rawAttribute(source, element, name) {
33288
- const span = attributeSpan(element, name);
33289
- if (!span) return void 0;
33290
- const value = valueSpan(source, span);
33291
- return source.slice(value.start, value.end);
33292
- }
33293
- /**
33294
- * Sets one attribute inside its value span, a new one going before the real
33295
- * self-closing `/`, which only the start-tag scan tells from an unquoted value's.
33296
- */
33297
- function setRawAttribute(source, element, name, raw) {
33298
- const span = attributeSpan(element, name);
33299
- if (span) {
33300
- const value = valueSpan(source, span);
33301
- if (value.isBare) return splice(source, span.endOffset, span.endOffset, `="${raw}"`);
33302
- if (value.quote === "'") return splice(source, value.start, value.end, raw.replace(/'/g, "&#39;"));
33303
- if (value.quote === "\"") return splice(source, value.start, value.end, raw);
33304
- return splice(source, value.start, value.end, `"${raw.replace(/"/g, "&quot;")}"`);
33305
- }
33306
- const startTag = element.sourceCodeLocation?.startTag;
33307
- if (!startTag) return source;
33308
- const at = scanStartTag(source, startTag).slash ?? startTag.endOffset - 1;
33309
- return splice(source, at, at, `${/\s/.test(source[at - 1] ?? "") ? "" : " "}${name}="${raw}"${source[at] === "/" ? " " : ""}`);
33310
- }
33311
- /**
33312
- * Removes one attribute and the whitespace run ahead of it. A later duplicate
33313
- * would come into force once the first is gone, so the first is emptied
33314
- * instead, and a bare one is left as it is, already empty.
33315
- */
33316
- function removeAttribute(source, element, name) {
33317
- const span = attributeSpan(element, name);
33318
- const startTag = element.sourceCodeLocation?.startTag;
33319
- if (!span || !startTag) return source;
33320
- const { names } = scanStartTag(source, startTag);
33321
- if (names.filter((stated) => stated === name).length > 1) return valueSpan(source, span).isBare ? source : setRawAttribute(source, element, name, "");
33322
- let start = span.startOffset;
33323
- while (/\s/.test(source[start - 1] ?? "")) start -= 1;
33324
- return splice(source, start, span.endOffset, "");
33325
- }
33326
33395
  // src/server/edit/element-span.ts
33327
33396
  const OTHER$1 = {
33328
33397
  before: "after",
@@ -38871,11 +38940,16 @@ function declaredValues(style, property) {
38871
38940
  return declarations(style).segments.filter((segment) => propertyOf(segment) === property).map((segment) => segment.slice(segment.indexOf(":") + 1).trim());
38872
38941
  }
38873
38942
  /**
38874
- * The part of a decoded style's last shorthand that a paint longhand reads
38875
- * from, which `setDeclaration` writes in place of the longhand. Undefined for
38876
- * a property with no such shorthand, or a shorthand holding no such part.
38943
+ * The part of a decoded style's last shorthand a paint longhand or padding
38944
+ * side reads, which `setDeclaration` writes in place of the longhand.
38945
+ * Undefined where no shorthand or no such part is declared.
38877
38946
  */
38878
38947
  function shorthandValue(style, property) {
38948
+ const side = PADDING_LONGHANDS.indexOf(property);
38949
+ if (side >= 0) {
38950
+ const padding = declaredValues(style, "padding").at(-1);
38951
+ return padding === void 0 ? void 0 : paddingSides(padding)?.[side];
38952
+ }
38879
38953
  const shorthand = PART_SHORTHANDS[property];
38880
38954
  if (!shorthand) return void 0;
38881
38955
  const value = declaredValues(style, shorthand).at(-1);
@@ -38883,9 +38957,17 @@ function shorthandValue(style, property) {
38883
38957
  }
38884
38958
  /**
38885
38959
  * Sets or drops one declaration, dropping later ones so nothing overrides the
38886
- * edit, and refusing a style ending inside an open quote or comment.
38960
+ * edit, and refusing a style ending inside an open quote or comment. A padding
38961
+ * side folds the inline padding into one `padding` once all four are declared.
38887
38962
  */
38888
38963
  function setDeclaration(style, property, value) {
38964
+ const written = writeDeclaration(style, property, value);
38965
+ return written.ok && PADDING_LONGHANDS.includes(property) ? {
38966
+ ok: true,
38967
+ style: foldPadding(written.style)
38968
+ } : written;
38969
+ }
38970
+ function writeDeclaration(style, property, value) {
38889
38971
  const parsed = declarations(style);
38890
38972
  if (parsed.isOpen) return { ok: false };
38891
38973
  const longhands = SHORTHAND_LONGHANDS[property] ?? [];
@@ -38925,6 +39007,68 @@ function setDeclaration(style, property, value) {
38925
39007
  }).join(";")
38926
39008
  };
38927
39009
  }
39010
+ const PADDING_LONGHANDS = SHORTHAND_LONGHANDS.padding ?? [];
39011
+ /**
39012
+ * A length or percentage `padding` accepts, so a fold never puts a value one
39013
+ * side would drop into a shorthand, where it would drop all four.
39014
+ */
39015
+ const PADDING_LENGTH = /^(?:0|(?:\d+(?:\.\d+)?|\.\d+)(?:%|px|r?em|r?lh|r?ex|r?ch|r?cap|r?ic|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max)|pt|pc|cm|mm|q|in))$/i;
39016
+ /** The top, right, bottom, and left a padding shorthand sets, if each is a plain length. */
39017
+ function paddingSides(value) {
39018
+ const parts = value.trim().split(/\s+/);
39019
+ if (parts.length > 4 || !parts.every((part) => PADDING_LENGTH.test(part))) return;
39020
+ const [top = "", right = top, bottom = top, left = right] = parts;
39021
+ return [
39022
+ top,
39023
+ right,
39024
+ bottom,
39025
+ left
39026
+ ];
39027
+ }
39028
+ function paddingShorthand([top, right, bottom, left]) {
39029
+ if (left !== right) return `${top} ${right} ${bottom} ${left}`;
39030
+ if (bottom !== top) return `${top} ${right} ${bottom}`;
39031
+ return right === top ? `${top}` : `${top} ${right}`;
39032
+ }
39033
+ /**
39034
+ * Folds the padding into one `padding` once all four sides are inline, so it
39035
+ * overrides nothing a sheet sets. Leaves it as written where a side is no plain
39036
+ * length, or a comment, a logical side, or a later shorthand would disagree.
39037
+ */
39038
+ function foldPadding(style) {
39039
+ const { segments } = declarations(style);
39040
+ const sides = [
39041
+ void 0,
39042
+ void 0,
39043
+ void 0,
39044
+ void 0
39045
+ ];
39046
+ const at = [];
39047
+ for (const [index, segment] of segments.entries()) {
39048
+ const property = propertyOf(segment);
39049
+ if (!property.startsWith("padding")) continue;
39050
+ if (segment.includes("/*")) return style;
39051
+ const value = segment.slice(segment.indexOf(":") + 1);
39052
+ if (property === "padding") {
39053
+ const all = paddingSides(value);
39054
+ if (!all || at.length > 0) return style;
39055
+ sides.splice(0, 4, ...all);
39056
+ } else {
39057
+ const side = PADDING_LONGHANDS.indexOf(property);
39058
+ if (side < 0 || !PADDING_LENGTH.test(value.trim())) return style;
39059
+ sides[side] = value.trim();
39060
+ }
39061
+ at.push(index);
39062
+ }
39063
+ const [first] = at;
39064
+ const known = sides.filter((side) => side !== void 0);
39065
+ if (first === void 0 || at.length < 2 || known.length < 4) return style;
39066
+ const lead = /^\s*/.exec(segments[first] ?? "")?.[0] ?? "";
39067
+ return segments.flatMap((segment, index) => {
39068
+ if (index === first) return [`${lead}padding: ${paddingShorthand(known)}`];
39069
+ return at.includes(index) ? [] : [segment];
39070
+ }).join(";");
39071
+ }
38928
39072
  /**
38929
39073
  * The segments with `value` in the last shorthand's part, so a paint edit
38930
39074
  * leaves no dead token behind, null when a later declaration would still win.
@@ -39483,7 +39627,7 @@ function elementMarkup(element, paint, font) {
39483
39627
  };
39484
39628
  const box = (shape) => `${size(shape)}; background: ${fill}`;
39485
39629
  switch (element.kind) {
39486
- case "text": return `<p data-name="Text" style="font-family: ${font}; width: fit-content">Text</p>`;
39630
+ case "text": return `<p data-name="Text" style="font-family: ${font}; width: fit-content"></p>`;
39487
39631
  case "rectangle": return `<div data-name="Rectangle" style="${box(element)}"></div>`;
39488
39632
  case "ellipse": return `<div data-name="Ellipse" style="${box(element)}; border-radius: 50%"></div>`;
39489
39633
  case "divider": return `<hr data-name="Divider" style="align-self: stretch; margin: 0; border: 0; ${element.vertical ? "border-left" : "border-top"}: 1px solid ${line}">`;
@@ -41079,15 +41223,16 @@ function taken(page, holder) {
41079
41223
  });
41080
41224
  }
41081
41225
  // src/server/board/projects.ts
41082
- /** A new project holding one empty page. */
41083
- async function addProject(root, name, now = /* @__PURE__ */ new Date(), { journal } = {}) {
41226
+ /** A new project holding one empty page, filed under `group` when one is given. */
41227
+ async function addProject(root, name, now = /* @__PURE__ */ new Date(), { journal, group } = {}) {
41084
41228
  assertValidName("project", name);
41085
41229
  await assertFree$1(root, name);
41086
41230
  await mkdir(join(root, name, START_PAGE), { recursive: true });
41087
41231
  await writeRecord(join(root, name, PROJECT_FILE), {
41088
41232
  version: 1,
41089
41233
  pages: [START_PAGE],
41090
- createdAt: now.toISOString()
41234
+ createdAt: now.toISOString(),
41235
+ ...group?.trim() ? { group: group.trim() } : {}
41091
41236
  });
41092
41237
  await journal?.created(join(root, name));
41093
41238
  return scanProject(root, name);
@@ -41810,6 +41955,12 @@ var StepJournal = class {
41810
41955
  }
41811
41956
  entry(page, frame, before, after) {
41812
41957
  const layout = join(page, LAYOUT_FILE);
41958
+ const last = this.changes.findLastIndex((change) => change.kind === "entry" && change.layout === layout && change.frame === frame);
41959
+ const held = this.changes[last];
41960
+ if (held?.kind === "entry" && this.changes.slice(last + 1).every((change) => change.kind === "entry")) {
41961
+ held.after = after;
41962
+ return;
41963
+ }
41813
41964
  this.changes.push({
41814
41965
  kind: "entry",
41815
41966
  layout,
@@ -46205,7 +46356,7 @@ const STATUS = {
46205
46356
  * the modules `frameboard image` calls. Finding and the provider's price read
46206
46357
  * only; saving and generating need a writer. No answer carries a key.
46207
46358
  */
46208
- function sourcingRoutes(root, access, { send = (input, init) => fetch(input, init), env = process.env, generate = false } = {}) {
46359
+ function sourcingRoutes(root, access, { send = (input, init) => fetch(input, init), env = process.env } = {}) {
46209
46360
  const app = new Hono();
46210
46361
  const authorized = requireWriter(access);
46211
46362
  const base = "/api/projects/:project/sourcing";
@@ -46280,18 +46431,11 @@ function sourcingRoutes(root, access, { send = (input, init) => fetch(input, ini
46280
46431
  projectOf$1(root, c.req.param("project"));
46281
46432
  return c.json({
46282
46433
  ok: true,
46283
- data: offer(env, generate)
46434
+ data: offer(env)
46284
46435
  });
46285
46436
  });
46286
46437
  app.post(`${base}/generate`, authorized, async (c) => {
46287
46438
  const project = projectOf$1(root, c.req.param("project"));
46288
- if (!generate) return c.json({
46289
- ok: false,
46290
- error: {
46291
- code: "generate-off",
46292
- message: "Generating from the board is off in this release. Run `frameboard image generate` instead."
46293
- }
46294
- }, 403);
46295
46439
  const { prompt } = await parseBody$1(c.req.raw, generateBodySchema);
46296
46440
  if (generating) return c.json({
46297
46441
  ok: false,
@@ -46315,6 +46459,7 @@ function sourcingRoutes(root, access, { send = (input, init) => fetch(input, ini
46315
46459
  prompt,
46316
46460
  ...plan.size,
46317
46461
  priceUsd: plan.priceUsd,
46462
+ ...plan.provider.name === "comfyui" && { seed: plan.seed },
46318
46463
  savedAt: (/* @__PURE__ */ new Date()).toISOString()
46319
46464
  });
46320
46465
  const record = {
@@ -46350,7 +46495,7 @@ async function saveFoundModel(project, body, send) {
46350
46495
  }, /* @__PURE__ */ new Date()));
46351
46496
  }
46352
46497
  /** The provider a generation would run on and its price, naming each key by its variable alone. */
46353
- function offer(env, enabled) {
46498
+ function offer(env) {
46354
46499
  const keys = PROVIDERS.map((provider) => provider.keyEnv);
46355
46500
  try {
46356
46501
  const plan = planGeneration({
@@ -46359,7 +46504,6 @@ function offer(env, enabled) {
46359
46504
  }, env);
46360
46505
  return {
46361
46506
  version: 1,
46362
- enabled,
46363
46507
  provider: {
46364
46508
  name: plan.provider.name,
46365
46509
  model: plan.provider.model,
@@ -46373,7 +46517,6 @@ function offer(env, enabled) {
46373
46517
  if (!(error instanceof FrameboardError) || error.code !== "no-provider") throw error;
46374
46518
  return {
46375
46519
  version: 1,
46376
- enabled,
46377
46520
  provider: null,
46378
46521
  keys
46379
46522
  };
@@ -47747,7 +47890,7 @@ function createWarmRenderer({ baseUrl, browser, scale: defaultScale }) {
47747
47890
  let colors = null;
47748
47891
  try {
47749
47892
  await hideControls(opened.page);
47750
- if (topInset(device, frame.turn) > 0) colors = await readPageColors(opened.page);
47893
+ if (insetsPage(device, frame.turn)) colors = await readPageColors(opened.page);
47751
47894
  shot = element === void 0 ? await opened.page.screenshot({
47752
47895
  animations: "disabled",
47753
47896
  caret: "hide"
@@ -47803,16 +47946,14 @@ async function shootElement(page, ref, index, scale) {
47803
47946
  * page the size of the body, so the PNG holds the body and nothing past it.
47804
47947
  */
47805
47948
  async function drawBezel(browser, shot, box, { device, pose = "closed", island = "compact", turn, bar }, scale) {
47806
- const outer = bezelBox({
47807
- x: 0,
47808
- y: 0,
47809
- ...box
47810
- }, device, turn);
47811
- const page = pageBox({
47949
+ const screen = {
47812
47950
  x: 0,
47813
47951
  y: 0,
47814
- ...box
47815
- }, device, turn);
47952
+ width: box.width,
47953
+ height: box.height
47954
+ };
47955
+ const outer = bezelBox(screen, device, turn);
47956
+ const page = pageBox(screen, device, turn);
47816
47957
  const laptop = device === "laptop";
47817
47958
  const context = await browser.newContext({
47818
47959
  viewport: {
@@ -47824,9 +47965,9 @@ async function drawBezel(browser, shot, box, { device, pose = "closed", island =
47824
47965
  try {
47825
47966
  const tab = await context.newPage();
47826
47967
  const sideways = turnOf(turn);
47827
- const marks = device === "phone" ? sideways === "upright" ? statusBarHtml(bar.colors, bar.theme) + phoneMarks(island) : turnedPhoneMarks(island, sideways) : laptop ? laptopMarks(box) : device === "foldable" ? foldableMarks(pose, sideways) : "";
47968
+ const marks = device === "phone" ? sideways === "upright" ? statusBarHtml(bar.colors, bar.theme) + phoneMarks(island) : sideStripsHtml(bar.colors, bar.theme) + turnedPhoneMarks(island, sideways) : laptop ? laptopMarks(box) : device === "foldable" ? (sideways === "upright" ? "" : sideStripsHtml(bar.colors, bar.theme, { device })) + foldableMarks(pose, sideways) : "";
47828
47969
  const radius = screenCorners(device);
47829
- await tab.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:0;top:${page.y}px;width:${page.width}px;height:${page.height}px;border-radius:${pageCorners(device, turn)}"><div style="position:absolute;inset:0;border-radius:${radius};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
47970
+ await tab.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:${page.x}px;top:${page.y}px;width:${page.width}px;height:${page.height}px;border-radius:${pageCorners(device, turn)}"><div style="position:absolute;inset:0;border-radius:${radius};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
47830
47971
  return await tab.screenshot({
47831
47972
  omitBackground: true,
47832
47973
  caret: "hide"
@@ -47836,22 +47977,27 @@ async function drawBezel(browser, shot, box, { device, pose = "closed", island =
47836
47977
  }
47837
47978
  }
47838
47979
  /**
47839
- * A phone frame's shot of its page set under the status bar, at the frame's
47840
- * box with no body, so a capture holds the screen the board draws.
47980
+ * A phone frame's shot of its page set under the status bar upright, or a
47981
+ * phone's or foldable's between the side strips turned, at the frame's box
47982
+ * with no body, so a capture holds the screen the board draws.
47841
47983
  */
47842
- async function underStatusBar(browser, shot, box, { colors, theme }, scale) {
47984
+ async function underPageInsets(browser, shot, box, { device, turn, colors, theme }, scale) {
47843
47985
  const page = pageBox({
47844
47986
  x: 0,
47845
47987
  y: 0,
47846
47988
  ...box
47847
- }, "phone", "upright");
47989
+ }, device, turn);
47990
+ const chrome = device && isTurned(device, turn) ? sideStripsHtml(colors, theme, {
47991
+ device,
47992
+ rounded: false
47993
+ }) : statusBarHtml(colors, theme, { rounded: false });
47848
47994
  const context = await browser.newContext({
47849
47995
  viewport: box,
47850
47996
  deviceScaleFactor: scale
47851
47997
  });
47852
47998
  try {
47853
47999
  const tab = await context.newPage();
47854
- await tab.setContent(`<!doctype html><html><body style="margin:0;position:relative;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:0;top:${page.y}px;width:${page.width}px;height:${page.height}px">` + statusBarHtml(colors, theme, { rounded: false }) + `</body></html>`, { waitUntil: "load" });
48000
+ await tab.setContent(`<!doctype html><html><body style="margin:0;position:relative;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:${page.x}px;top:${page.y}px;width:${page.width}px;height:${page.height}px">` + chrome + `</body></html>`, { waitUntil: "load" });
47855
48001
  return await tab.screenshot({ caret: "hide" });
47856
48002
  } finally {
47857
48003
  await context.close();
@@ -47861,7 +48007,7 @@ async function underStatusBar(browser, shot, box, { colors, theme }, scale) {
47861
48007
  function readPageColors(page) {
47862
48008
  return page.evaluate(pageColors);
47863
48009
  }
47864
- /** The viewport a frame's page opens at, its box less a phone's status bar, at least one pixel tall. */
48010
+ /** The viewport a frame's page opens at, its box less a phone's insets, at least one pixel tall. */
47865
48011
  function pageSize(box, device, turn) {
47866
48012
  const page = pageBox({
47867
48013
  x: 0,
@@ -47886,6 +48032,17 @@ function statusBarHtml(colors, theme, { rounded = true } = {}) {
47886
48032
  return `<div style="position:absolute;left:0;right:0;top:0;height:${STATUS_BAR.height}px;border-radius:${corners};color-scheme:${theme};background:${colors?.fill ?? "Canvas"};color:${colors?.ink ?? "CanvasText"}"><div style="position:absolute;left:0;right:0;top:${STATUS_BAR.band.top}px;height:${STATUS_BAR.band.height}px;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;padding:0 ${STATUS_BAR.side}px;font:600 ${STATUS_BAR.font}px/1 ${STATUS_FONT};font-variant-numeric:tabular-nums"><span>${STATUS_BAR.time}</span><span style="display:flex;align-items:center;gap:6px"><span style="display:flex;align-items:flex-end;gap:2px">${signal}</span>${battery}</span></div></div>`;
47887
48033
  }
47888
48034
  /**
48035
+ * A turned phone's or foldable's two side strips as the board draws them, the
48036
+ * side inset wide in the page's fill or its theme's own, rounded on the
48037
+ * screen's outer corners inside a body and square on a frame's bare box.
48038
+ */
48039
+ function sideStripsHtml(colors, theme, { device = "phone", rounded = true } = {}) {
48040
+ const radius = rounded ? BEZELS[device].screenRadius : 0;
48041
+ const width = sideInset(device, "left");
48042
+ const strip = (side, corners) => `<div style="position:absolute;${side}:0;top:0;bottom:0;width:${width}px;border-radius:${corners};color-scheme:${theme};background:${colors?.fill ?? "Canvas"}"></div>`;
48043
+ return strip("left", `${radius}px 0 0 ${radius}px`) + strip("right", `0 ${radius}px ${radius}px 0`);
48044
+ }
48045
+ /**
47889
48046
  * The laptop's chin and base as the board draws them, past the screen's
47890
48047
  * bottom, with the body's edge as its last pixel rather than past it.
47891
48048
  */
@@ -48021,10 +48178,11 @@ async function readFreshAt(browser, options) {
48021
48178
  * width too, reporting the width and never changing it.
48022
48179
  */
48023
48180
  async function fitFrame(browser, { baseUrl, frame, ...options }) {
48181
+ const page = pageBox(frame.box, frame.device, frame.turn);
48024
48182
  const measured = await measureContent(browser, {
48025
48183
  baseUrl,
48026
48184
  ref: frame.ref,
48027
- box: pageBox(frame.box, frame.device, frame.turn),
48185
+ box: page,
48028
48186
  hugWidth: false
48029
48187
  });
48030
48188
  const widths = [];
@@ -48050,7 +48208,7 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
48050
48208
  }),
48051
48209
  contentHeight: measured.height,
48052
48210
  contentWidth: measured.contentWidth,
48053
- tooWide: measured.contentWidth > frame.box.width
48211
+ tooWide: measured.contentWidth > page.width
48054
48212
  };
48055
48213
  }
48056
48214
  async function readAt(page, viewport) {
@@ -49419,7 +49577,11 @@ const sectionSchema = object$1({
49419
49577
  page: ref,
49420
49578
  section: name
49421
49579
  });
49422
- const projectAddSchema = object$1({ name: name.optional() });
49580
+ const projectAddSchema = object$1({
49581
+ name: name.optional(),
49582
+ /** The home folder the project starts filed in. */
49583
+ group: name.optional()
49584
+ });
49423
49585
  const projectSchema = object$1({ ref });
49424
49586
  /** More projects than any board holds, so a body cannot grow without bound. */
49425
49587
  const projectRefs$1 = array$1(ref).min(1).max(1e3);
@@ -49941,8 +50103,12 @@ function structureRoutes(root, access, history, measure, tokens = null) {
49941
50103
  frames: []
49942
50104
  });
49943
50105
  app.post("/api/project/add", async (c) => {
49944
- const projectName = (await parseBody$1(c.req.raw, projectAddSchema)).name ?? nextFreeName("untitled", await listProjects(root));
49945
- const project = await recorded((journal) => addProject(root, projectName, /* @__PURE__ */ new Date(), { journal }), onHome);
50106
+ const body = await parseBody$1(c.req.raw, projectAddSchema);
50107
+ const projectName = body.name ?? nextFreeName("untitled", await listProjects(root));
50108
+ const project = await recorded((journal) => addProject(root, projectName, /* @__PURE__ */ new Date(), {
50109
+ journal,
50110
+ group: body.group
50111
+ }), onHome);
49946
50112
  return c.json({
49947
50113
  ok: true,
49948
50114
  data: project
@@ -50657,14 +50823,16 @@ async function holdShots(browser, { baseUrl, ref, view, device, turn, theme, sca
50657
50823
  });
50658
50824
  try {
50659
50825
  const motion = await findMotion(opened.page, ref, motionTimeoutMs);
50660
- const colors = topInset(device, turn) > 0 ? await readPageColors(opened.page) : null;
50826
+ const colors = insetsPage(device, turn) ? await readPageColors(opened.page) : null;
50661
50827
  const held = [];
50662
50828
  for (const moment of moments(motion)) {
50663
50829
  const at = await seekMotion(opened.page, motion, moment);
50664
50830
  const shot = await opened.page.screenshot(HELD_SCREENSHOT);
50665
50831
  held.push({
50666
50832
  held: at,
50667
- bytes: colors ? await underStatusBar(browser, shot, view, {
50833
+ bytes: colors ? await underPageInsets(browser, shot, view, {
50834
+ device,
50835
+ turn,
50668
50836
  colors,
50669
50837
  theme
50670
50838
  }, scale) : shot
@@ -50705,7 +50873,9 @@ async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll)
50705
50873
  const scrollY = scroll === void 0 ? void 0 : await opened.page.evaluate(scrollAndSettle, scroll);
50706
50874
  const shot = await opened.page.screenshot(SCREENSHOT);
50707
50875
  return {
50708
- bytes: topInset(device, frame.turn) > 0 ? await underStatusBar(browser, shot, box, {
50876
+ bytes: insetsPage(device, frame.turn) ? await underPageInsets(browser, shot, box, {
50877
+ device,
50878
+ turn: frame.turn,
50709
50879
  colors: await readPageColors(opened.page),
50710
50880
  theme
50711
50881
  }, scale) : shot,
@@ -51819,7 +51989,7 @@ function contentFormat() {
51819
51989
  `showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side, with side buttons 4 px past that, and the tablet's ${BEZELS.tablet.border}, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file, its size, or its box. frame add, frame duplicate, and a paste place a frame beside another with its own body, a laptop's base included, 80 px past the other's body. A frame given --x keeps that x, a frame landing in a reserved box keeps that box with no room for a device, and a placed frame stays where it stands when its device turns on. Linked widths draw no device. Any other value of showDevice reads as off and is kept on write. A device string from before showDevice reads as on, and the entry's next write replaces it with showDevice. frame add --device on and frame device <frame-ref> <on|off> set it, taking phone and tablet as on and none as off.`,
51820
51990
  `While a phone shows, the board draws a status bar over the top ${STATUS_BAR.height} px of the frame's box, in the page's own fill and text color, and the page starts under it: a frame ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height} shows a page ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height - STATUS_BAR.height}. The box in layout.json keeps the screen's size, and the frame file gains no padding. A hugging height measures the page and stores it plus the bar, frame fit does the same, and capture, check, inspect, and present each read the page under the bar. An export draws the bar only with its device included, and lays the page out at the whole box without it. A linked width draws no device and no bar. With the device off, or on any other device, the page is the whole box.`,
51821
51991
  `island wide has a phone draw its wide island, the one a call or a timer shows, and absent draws the compact one. It is kept while the device is off and reads as compact on any other device. Any other value reads as compact and is kept on write. frame device <frame-ref> --island wide sets it, --island compact clears it, and both refuse a frame whose width names no phone or that names the foldable.`,
51822
- `turn left or right turns a phone, a tablet, or a foldable a quarter, with the island on the left side for left and the right for right, and absent stands it upright. A phone's or a tablet's first turn keeps the box's upright width and height in upright, and the upright width still picks the device, so a turned phone reads as a phone however wide its box. A fixed or scroll box swaps its sides, and a hugging one takes the reference height of its upright width, ${FRAME_SIZES.phone.height} px for a phone, and hugs its height at that width. A turned phone draws no status bar, so its page is the whole box, and its buttons stand on its long edges. list reports turn while the frame is turned, shown or not, and never upright. Turning upright restores the kept size, even after a hand resize of the turned box. A turned foldable keeps no upright, since its pose gives its screen: its box is that screen with the sides swapped, ${POSE_SIZES.closed.height} by ${POSE_SIZES.closed.width} closed and ${POSE_SIZES.open.height} by ${POSE_SIZES.open.width} half or open, its island sits where the quarter turn puts it, and its fold runs across the screen. A fold keeps the turn and takes the new pose's swapped screen, upright restores the pose's screen, and --no-foldable stands it upright at that screen. frame device <frame-ref> --turn <upright|left|right> sets it, writing the layout entry alone, and a quarter turn refuses a laptop, a frame showing no device, and a frame holding extra widths, each with usage. A turned frame refuses new extra widths, and naming a turned phone or tablet the foldable stands it upright first. A phone's or a tablet's turn with no readable upright, or a value no reader knows, reads as upright.`,
51992
+ `turn left or right turns a phone, a tablet, or a foldable a quarter, with the island on the left side for left and the right for right, and absent stands it upright. A phone's or a tablet's first turn keeps the box's upright width and height in upright, and the upright width still picks the device, so a turned phone reads as a phone however wide its box. A fixed or scroll box swaps its sides, and a hugging one takes the reference height of its upright width, ${FRAME_SIZES.phone.height} px for a phone, and hugs its height at that width. A turned phone draws no status bar and insets its page ${STATUS_BAR.height} px from each short side instead, with both strips in the page's own fill so the island stands over no content, and its buttons stand on its long edges: an ${FRAME_SIZES.phone.height} by ${FRAME_SIZES.phone.width} turned box shows a page ${FRAME_SIZES.phone.height - 2 * STATUS_BAR.height} by ${FRAME_SIZES.phone.width}, and a hugging one hugs at that page width. list reports turn while the frame is turned, shown or not, and never upright. Turning upright restores the kept size, even after a hand resize of the turned box. A turned foldable keeps no upright, since its pose gives its screen: its box is that screen with the sides swapped, ${POSE_SIZES.closed.height} by ${POSE_SIZES.closed.width} closed and ${POSE_SIZES.open.height} by ${POSE_SIZES.open.width} half or open, its island sits where the quarter turn puts it, its fold runs across the screen, and its page insets ${sideInset("foldable", "left")} px from each side edge in the page's own fill as a turned phone's does, so a turned closed box shows a page ${POSE_SIZES.closed.height - 2 * sideInset("foldable", "left")} by ${POSE_SIZES.closed.width}. A fold keeps the turn and takes the new pose's swapped screen, upright restores the pose's screen, and --no-foldable stands it upright at that screen. frame device <frame-ref> --turn <upright|left|right> sets it, writing the layout entry alone, and a quarter turn refuses a laptop, a frame showing no device, and a frame holding extra widths, each with usage. A turned frame refuses new extra widths, and naming a turned phone or tablet the foldable stands it upright first. A phone's or a tablet's turn with no readable upright, or a value no reader knows, reads as upright.`,
51823
51993
  `foldable true has the frame name the foldable device over the one its width picks, and pose folds it: closed is the cover screen at ${POSE_SIZES.closed.width} by ${POSE_SIZES.closed.height}, and half and open are the inner screen at ${POSE_SIZES.open.width} by ${POSE_SIZES.open.height}, half shading the fold. Naming a foldable or setting a pose sets the box's width and height to that screen and turns both hug flags off, and writes the layout entry alone, never the frame file, so one file shows every pose and its content reflows as on the device. The body stands ${BEZELS.foldable.border} px past the box on every side. A newly named foldable starts in the pose nearest its width, closed up to 678 px wide and open past it. list reports device as foldable while it shows, and pose on every frame naming one, shown or not. With showDevice off the box keeps its pose's size and no body draws. A foldable draws no linked width and refuses a new one, and widths its entry held from before stay in the file undrawn, draw again once --no-foldable un-names it, and clear on frame resize --no-widths. Any other value of foldable reads as width-picked, a pose no reader knows reads as closed, and both are kept on write. An older Frameboard rewriting the entry may drop both keys, leaving a width-picked frame at the pose's size. frame device <frame-ref> --foldable names it and shows it, --pose <closed|half|open> folds it, and --no-foldable hands the pick back to the width at the size it stands.`,
51824
51994
  `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.`,
51825
51995
  "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.",
@@ -52314,7 +52484,7 @@ function registerFrame(program, context) {
52314
52484
  baseUrl,
52315
52485
  frame
52316
52486
  }));
52317
- const wide = result.tooWide ? `, and its content is ${result.contentWidth} px wide against ${result.frame.box.width}` : "";
52487
+ const wide = result.tooWide ? `, and its content is ${result.contentWidth} px wide against its ${pageBox(result.frame.box, result.frame.device, result.frame.turn).width} px page` : "";
52318
52488
  return {
52319
52489
  data: result,
52320
52490
  human: `Fit ${result.frame.ref} to ${result.contentHeight} px${wide}`
@@ -57341,11 +57511,12 @@ function terminalCode(modules) {
57341
57511
  function registerProject(program, context) {
57342
57512
  const { io } = context;
57343
57513
  const project = program.command("project").description("Manage projects");
57344
- act(addVerb(project, "add", "Add a project holding one empty page").argument("<name>", "the new project"), context, async ([name = ""], options) => {
57345
- const record = await addProject(await boardOf(options, io), name);
57514
+ act(addVerb(project, "add", "Add a project holding one empty page").argument("<name>", "the new project").option("--group <folder>", "file the project under a home folder, created when no project holds it"), context, async ([name = ""], options) => {
57515
+ const group = options.group === void 0 ? void 0 : validFolder(options.group);
57516
+ const record = await addProject(await boardOf(options, io), name, void 0, { group });
57346
57517
  return {
57347
57518
  data: record,
57348
- human: `Added project ${record.name}`
57519
+ human: group ? `Added project ${record.name} under ${group}` : `Added project ${record.name}`
57349
57520
  };
57350
57521
  });
57351
57522
  act(addVerb(project, "rename", "Rename a project").argument("<name>", "the project").argument("<new-name>", "its new name"), context, async ([name = "", newName = ""], options) => {
@@ -57410,6 +57581,10 @@ function folderOf(folder, clear) {
57410
57581
  if (clear && folder !== void 0) throw new FrameboardError("usage", "Give a folder or --clear, not both.");
57411
57582
  if (clear) return null;
57412
57583
  if (folder === void 0) throw new FrameboardError("usage", "Give a folder, or --clear to leave one.");
57584
+ return validFolder(folder);
57585
+ }
57586
+ /** The trimmed folder, refusing a blank or overlong one. */
57587
+ function validFolder(folder) {
57413
57588
  const name = folder.trim();
57414
57589
  if (name === "" || name.length > MAX_FOLDER) throw new FrameboardError("invalid-name", `A folder name holds 1 to ${MAX_FOLDER} characters.`);
57415
57590
  return name;
@@ -61858,7 +62033,7 @@ async function measureParts(measure, frame, parts) {
61858
62033
  box: page
61859
62034
  });
61860
62035
  if (!own.empty) Object.assign(size, {
61861
- width: own.width,
62036
+ width: own.width + 2 * sideInset(frame.device, frame.turn),
61862
62037
  height: own.height + topInset(frame.device, frame.turn)
61863
62038
  });
61864
62039
  }