frameboard 0.51.0 → 0.53.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
@@ -3423,7 +3423,7 @@ function slugify(input) {
3423
3423
  return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
3424
3424
  }
3425
3425
  const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
3426
- function isObject(data) {
3426
+ function isObject$1(data) {
3427
3427
  return typeof data === "object" && data !== null && !Array.isArray(data);
3428
3428
  }
3429
3429
  const allowsEval = /* @__PURE__*/ cached(() => {
@@ -3437,12 +3437,12 @@ const allowsEval = /* @__PURE__*/ cached(() => {
3437
3437
  }
3438
3438
  });
3439
3439
  function isPlainObject(o) {
3440
- if (isObject(o) === false) return false;
3440
+ if (isObject$1(o) === false) return false;
3441
3441
  const ctor = o.constructor;
3442
3442
  if (ctor === void 0) return true;
3443
3443
  if (typeof ctor !== "function") return true;
3444
3444
  const prot = ctor.prototype;
3445
- if (isObject(prot) === false) return false;
3445
+ if (isObject$1(prot) === false) return false;
3446
3446
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
3447
3447
  return true;
3448
3448
  }
@@ -5333,7 +5333,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
5333
5333
  }
5334
5334
  return propValues;
5335
5335
  });
5336
- const isObject$1 = isObject;
5336
+ const isObject = isObject$1;
5337
5337
  const catchall = def.catchall;
5338
5338
  let value;
5339
5339
  const memo = globalConfig.memoizer;
@@ -5341,7 +5341,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
5341
5341
  inst._zod.parse = (payload, ctx) => {
5342
5342
  value ?? (value = _normalized.value);
5343
5343
  const input = payload.value;
5344
- if (!isObject$1(input)) {
5344
+ if (!isObject(input)) {
5345
5345
  payload.issues.push({
5346
5346
  expected: "object",
5347
5347
  code: "invalid_type",
@@ -5471,7 +5471,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
5471
5471
  return doc.compile();
5472
5472
  };
5473
5473
  let fastpass;
5474
- const isObject$2 = isObject;
5474
+ const isObject = isObject$1;
5475
5475
  const jit = !globalConfig.jitless;
5476
5476
  const fastEnabled = jit && allowsEval.value;
5477
5477
  const catchall = def.catchall;
@@ -5479,7 +5479,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
5479
5479
  inst._zod.parse = (payload, ctx) => {
5480
5480
  value ?? (value = _normalized.value);
5481
5481
  const input = payload.value;
5482
- if (!isObject$2(input)) {
5482
+ if (!isObject(input)) {
5483
5483
  payload.issues.push({
5484
5484
  expected: "object",
5485
5485
  code: "invalid_type",
@@ -5590,7 +5590,7 @@ const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnio
5590
5590
  const disc = cached(() => discriminatorMap(def));
5591
5591
  inst._zod.parse = (payload, ctx) => {
5592
5592
  const input = payload.value;
5593
- if (!isObject(input)) {
5593
+ if (!isObject$1(input)) {
5594
5594
  payload.issues.push({
5595
5595
  code: "invalid_type",
5596
5596
  expected: "object",
@@ -6251,16 +6251,16 @@ function cloneIssues(issues) {
6251
6251
  }
6252
6252
  const recursive = /*@__PURE__*/ new WeakMap();
6253
6253
  /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
6254
- const NONE = 0;
6254
+ const NONE$1 = 0;
6255
6255
  const ASSUMED = 1;
6256
6256
  const PROVEN = 2;
6257
6257
  /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
6258
6258
  function isRecursive(inst, stack, resolve) {
6259
6259
  const cached = recursive.get(inst);
6260
- if (cached !== void 0) return cached ? PROVEN : NONE;
6260
+ if (cached !== void 0) return cached ? PROVEN : NONE$1;
6261
6261
  if (stack.has(inst)) return PROVEN;
6262
6262
  stack.add(inst);
6263
- let result = NONE;
6263
+ let result = NONE$1;
6264
6264
  const check = (child) => {
6265
6265
  if (result !== PROVEN && child?._zod) {
6266
6266
  const answer = isRecursive(child, stack, resolve);
@@ -6268,11 +6268,11 @@ function isRecursive(inst, stack, resolve) {
6268
6268
  }
6269
6269
  };
6270
6270
  const shape = (sh, spread) => {
6271
- let answer = NONE;
6271
+ let answer = NONE$1;
6272
6272
  for (const key of Reflect.ownKeys(sh)) {
6273
6273
  const desc = Object.getOwnPropertyDescriptor(sh, key);
6274
6274
  if (spread && !desc.enumerable) continue;
6275
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
6275
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE$1;
6276
6276
  if (child > answer) answer = child;
6277
6277
  }
6278
6278
  return answer;
@@ -6419,7 +6419,7 @@ const memo$1 = {
6419
6419
  const wrapped = (payload, ctx) => {
6420
6420
  if (isRecursiveInst === void 0) {
6421
6421
  const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
6422
- if (walked === NONE) {
6422
+ if (walked === NONE$1) {
6423
6423
  inst._zod.parse = base;
6424
6424
  if (inst._zod.run === wrapped) inst._zod.run = base;
6425
6425
  return base(payload, ctx);
@@ -9435,9 +9435,9 @@ const LAPTOP_BASE = {
9435
9435
  radius: 10
9436
9436
  };
9437
9437
  /**
9438
- * Bezels measured off a current Pro phone and 13-inch tablet, the laptop
9439
- * scaled off the picked mock, and the foldable's body less its glass. The
9440
- * tablet's and the foldable's screen radii are guesses no source gives.
9438
+ * Bezels measured off a current Pro phone, the tablet's and the laptop's off
9439
+ * the picked mocks, and the foldable's body less its glass. The tablet's and
9440
+ * the foldable's screen radii are guesses no source gives.
9441
9441
  */
9442
9442
  const BEZELS = {
9443
9443
  phone: {
@@ -9447,10 +9447,10 @@ const BEZELS = {
9447
9447
  bodyRadius: 78
9448
9448
  },
9449
9449
  tablet: {
9450
- border: 44,
9451
- bottom: 44,
9450
+ border: 32,
9451
+ bottom: 32,
9452
9452
  screenRadius: 18,
9453
- bodyRadius: 62
9453
+ bodyRadius: 50
9454
9454
  },
9455
9455
  laptop: {
9456
9456
  border: 20,
@@ -9489,7 +9489,7 @@ function deviceForWidth(width) {
9489
9489
  }
9490
9490
  /**
9491
9491
  * The body's colors, fixed in both themes, since the board draws hardware
9492
- * rather than chrome: the body, the hairline around it, and the island.
9492
+ * rather than chrome: the body, its hairline, its marks, and the island.
9493
9493
  */
9494
9494
  const BEZEL_COLORS = {
9495
9495
  body: "#17181b",
@@ -9498,6 +9498,10 @@ const BEZEL_COLORS = {
9498
9498
  island: "#050506",
9499
9499
  homeBar: "rgba(128, 128, 128, 0.6)",
9500
9500
  button: "#2a2c31",
9501
+ tabletButton: "#4a4e57",
9502
+ cameraRing: "#4a4e57",
9503
+ cameraLens: "#0a0a0c",
9504
+ cameraGlint: "#5b6170",
9501
9505
  islandText: "#ffffff",
9502
9506
  islandLive: "#34c759"
9503
9507
  };
@@ -9564,6 +9568,100 @@ const PHONE_BUTTONS = [
9564
9568
  height: 95
9565
9569
  }
9566
9570
  ];
9571
+ /** A camera's look, a lens with a glint in a ring past its size. */
9572
+ const CAMERA = {
9573
+ ring: 2,
9574
+ fill: `radial-gradient(circle at 35% 35%, ${BEZEL_COLORS.cameraGlint} 0 18%, ${BEZEL_COLORS.cameraLens} 22%)`
9575
+ };
9576
+ const CAMERA_SIZES = {
9577
+ laptop: 10,
9578
+ tablet: 12
9579
+ };
9580
+ /** The edge each edge of an upright body stands on once turned. */
9581
+ const TURNED_EDGES = {
9582
+ upright: {
9583
+ top: "top",
9584
+ right: "right",
9585
+ bottom: "bottom",
9586
+ left: "left"
9587
+ },
9588
+ left: {
9589
+ top: "left",
9590
+ right: "top",
9591
+ bottom: "right",
9592
+ left: "bottom"
9593
+ },
9594
+ right: {
9595
+ top: "right",
9596
+ right: "bottom",
9597
+ bottom: "left",
9598
+ left: "top"
9599
+ }
9600
+ };
9601
+ /**
9602
+ * An upright tablet's power button and two volume buttons off the picked
9603
+ * mock, each on an edge and `at` points from the screen's end it counts from.
9604
+ */
9605
+ const TABLET_BUTTONS = [
9606
+ {
9607
+ name: "power",
9608
+ edge: "top",
9609
+ from: "right",
9610
+ at: 60,
9611
+ length: 80
9612
+ },
9613
+ {
9614
+ name: "volume-up",
9615
+ edge: "right",
9616
+ from: "top",
9617
+ at: 90,
9618
+ length: 64
9619
+ },
9620
+ {
9621
+ name: "volume-down",
9622
+ edge: "right",
9623
+ from: "top",
9624
+ at: 165,
9625
+ length: 64
9626
+ }
9627
+ ];
9628
+ /** A laptop's camera, or a tablet's camera and buttons as its turn stands them, none for another device. */
9629
+ function bodyParts(device, turn) {
9630
+ if (device !== "laptop" && device !== "tablet") return [];
9631
+ const edges = TURNED_EDGES[isTurned(device, turn) ? turnOf(turn) : "upright"];
9632
+ const { border } = BEZELS[device];
9633
+ const size = CAMERA_SIZES[device];
9634
+ const camera = edges.top;
9635
+ const parts = [{
9636
+ name: "camera",
9637
+ edge: camera,
9638
+ place: {
9639
+ [camera]: `${-(border + size) / 2}px`,
9640
+ [runsAcross(camera) ? "left" : "top"]: `calc(50% - ${size / 2}px)`,
9641
+ width: `${size}px`,
9642
+ height: `${size}px`
9643
+ }
9644
+ }];
9645
+ if (device === "laptop") return parts;
9646
+ const depth = `6px`;
9647
+ return parts.concat(TABLET_BUTTONS.map(({ name, edge: upright, from, at, length }) => {
9648
+ const edge = edges[upright];
9649
+ const across = runsAcross(edge);
9650
+ return {
9651
+ name,
9652
+ edge,
9653
+ place: {
9654
+ [edge]: `${-border - 6}px`,
9655
+ [edges[from]]: `${at}px`,
9656
+ width: across ? `${length}px` : depth,
9657
+ height: across ? depth : `${length}px`
9658
+ }
9659
+ };
9660
+ }));
9661
+ }
9662
+ function runsAcross(edge) {
9663
+ return edge === "top" || edge === "bottom";
9664
+ }
9567
9665
  /**
9568
9666
  * The phone's status bar, ending 10 below the island so a page under it
9569
9667
  * clears the island, its time and marks in the island's band `side` in from
@@ -9804,9 +9902,10 @@ function laptopParts({ width, height }) {
9804
9902
  }
9805
9903
  };
9806
9904
  }
9807
- /** How far a device's parts stand past its body's sides, a laptop's base or a phone's buttons. */
9905
+ /** How far a device's parts stand past its body's sides, a laptop's base or a phone's or tablet's buttons. */
9808
9906
  function sideReach(device, width) {
9809
9907
  if (device === "laptop") return baseReach(width);
9908
+ if (device === "tablet") return 6;
9810
9909
  return device === "phone" ? 4 : 0;
9811
9910
  }
9812
9911
  function baseReach(width) {
@@ -9827,16 +9926,17 @@ function bezelShadow(device, { board = true } = {}) {
9827
9926
  }
9828
9927
  /**
9829
9928
  * The box a device's body covers around a frame's box, the box itself with
9830
- * none. A laptop's base and a phone's buttons reach past its sides, and a
9831
- * turned phone's buttons past its top and bottom instead.
9929
+ * none. A phone's buttons reach past its sides, or its ends once turned, and
9930
+ * a tablet's past every edge alike, so no turn shifts it off center.
9832
9931
  */
9833
9932
  function bezelBox(box, device, turn) {
9834
9933
  if (!device) return { ...box };
9835
9934
  const { border, bottom } = BEZELS[device];
9836
9935
  const reach = sideReach(device, box.width);
9837
9936
  const turned = isTurned(device, turn);
9838
- const side = border + (turned ? 0 : reach);
9839
- const end = turned ? reach : 0;
9937
+ const everyEdge = device === "tablet";
9938
+ const side = border + (turned && !everyEdge ? 0 : reach);
9939
+ const end = turned || everyEdge ? reach : 0;
9840
9940
  return {
9841
9941
  x: box.x - side,
9842
9942
  y: box.y - border - end,
@@ -9874,33 +9974,50 @@ function drawnWidths(entry) {
9874
9974
  function isSize(value) {
9875
9975
  return typeof value === "number" && Number.isInteger(value) && value >= 1;
9876
9976
  }
9977
+ /** The device a linked width draws inside, the one its own width names while the frame shows its device. */
9978
+ function linkedDevice({ showDevice }, width) {
9979
+ return showDevice ? deviceForWidth(width) : null;
9980
+ }
9877
9981
  /**
9878
- * Where each linked width draws, in a row past the frame, moved out by a
9879
- * laptop base's reach so a taller width never meets it.
9982
+ * The device and turn a frame's view at a width draws its page under, its own
9983
+ * at its own width. A linked view stands upright in the device it names.
9880
9984
  */
9881
- function linkedBoxes(box, widths, device) {
9985
+ function viewDevice(frame, width) {
9986
+ return width === frame.box.width ? {
9987
+ device: frame.device ?? null,
9988
+ turn: frame.turn
9989
+ } : { device: linkedDevice(frame, width) };
9990
+ }
9991
+ /** The height a linked width's status bar takes off its box, so a hugging one holds its page and the bar. */
9992
+ function linkedBar(frame, width) {
9993
+ return topInset(linkedDevice(frame, width), "upright");
9994
+ }
9995
+ /** Where each linked width draws, in a row past the frame, each body the gap past the last. */
9996
+ function linkedBoxes(box, widths, shown = {}) {
9882
9997
  const boxes = [];
9883
- const body = bezelBox(box, device, "upright");
9884
- const lid = device ? BEZELS[device].border : 0;
9885
- let x = body.x + body.width - lid;
9998
+ let edge = rightOf$1(bezelBox(box, shown.device, "upright"));
9886
9999
  for (const { width, height } of widths) {
9887
- x += 80;
9888
- boxes.push({
9889
- x,
10000
+ const device = linkedDevice(shown, width);
10001
+ const linked = {
10002
+ x: xPast(edge, width, device),
9890
10003
  y: box.y,
9891
10004
  width,
9892
10005
  height
9893
- });
9894
- x += width;
10006
+ };
10007
+ boxes.push(linked);
10008
+ edge = rightOf$1(bezelBox(linked, device, "upright"));
9895
10009
  }
9896
10010
  return boxes;
9897
10011
  }
10012
+ function rightOf$1({ x, width }) {
10013
+ return x + width;
10014
+ }
9898
10015
  /**
9899
- * The box holding a frame, the device body drawn around it, and every linked
9900
- * width it draws, the frame's own with neither. Linked widths draw no device.
10016
+ * The box holding a frame, every linked width it draws, and the device body
10017
+ * around each, the frame's own with neither.
9901
10018
  */
9902
- function drawnExtent(box, widths, device) {
9903
- const boxes = [bezelBox(box, device, "upright"), ...linkedBoxes(box, widths, device)];
10019
+ function drawnExtent(box, widths, shown = {}) {
10020
+ const boxes = [bezelBox(box, shown.device, "upright"), ...linkedBoxes(box, widths, shown).map((linked) => bezelBox(linked, linkedDevice(shown, linked.width), "upright"))];
9904
10021
  const left = Math.min(...boxes.map(({ x }) => x));
9905
10022
  const top = Math.min(...boxes.map(({ y }) => y));
9906
10023
  const right = Math.max(...boxes.map(({ x, width }) => x + width));
@@ -9972,6 +10089,16 @@ function titledFolder(current, title, taken) {
9972
10089
  function folderName(typed) {
9973
10090
  return typed.trim().normalize("NFD").replace(/\p{M}/gu, "").replace(/đ/gi, "d").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
9974
10091
  }
10092
+ /** Leaves room under the name limit for the suffix a taken name grows. */
10093
+ const ELEMENT_FRAME_STEM = 56;
10094
+ /**
10095
+ * The name a frame made for one element asks for, being its `data-name` in
10096
+ * kebab case, else its tag.
10097
+ */
10098
+ function elementFrameName(name, tagName) {
10099
+ const kebab = folderName(name ?? "").replace(/[^a-z0-9]+/g, "-").slice(0, ELEMENT_FRAME_STEM).replace(/-+$/, "");
10100
+ return kebab === "" ? tagName : kebab;
10101
+ }
9975
10102
  // src/shared/kits.ts
9976
10103
  /**
9977
10104
  * The names a design kit's folder of plain files is laid out by, installed so
@@ -10176,6 +10303,7 @@ const layoutEntrySchema = looseObject({
10176
10303
  foldable: unknown().optional(),
10177
10304
  pose: unknown().optional(),
10178
10305
  island: unknown().optional(),
10306
+ showOverflow: unknown().optional(),
10179
10307
  turn: unknown().optional(),
10180
10308
  upright: unknown().optional(),
10181
10309
  transition: unknown().optional(),
@@ -16207,7 +16335,7 @@ import_postcss.default.Warning;
16207
16335
  import_postcss.default.AtRule;
16208
16336
  import_postcss.default.Result;
16209
16337
  import_postcss.default.Input;
16210
- import_postcss.default.Rule;
16338
+ const Rule = import_postcss.default.Rule;
16211
16339
  import_postcss.default.Root;
16212
16340
  import_postcss.default.Node;
16213
16341
  // node_modules/parse5/dist/common/unicode.js
@@ -23872,6 +24000,32 @@ function serialize$1(node, options) {
23872
24000
  const container = treeAdapter.isElementNode(node) && treeAdapter.getTagName(node) === TAG_NAMES.TEMPLATE && treeAdapter.getNamespaceURI(node) === NS.HTML ? treeAdapter.getTemplateContent(node) : node;
23873
24001
  return serializeNodes((_a = treeAdapter.getChildNodes(container)) !== null && _a !== void 0 ? _a : [], opts);
23874
24002
  }
24003
+ /**
24004
+ * Serializes an AST element node to an HTML string, including the element node.
24005
+ *
24006
+ * @example
24007
+ *
24008
+ * ```js
24009
+ * const parse5 = require('parse5');
24010
+ *
24011
+ * const document = parse5.parseFragment('<div>Hello, <b>world</b>!</div>');
24012
+ *
24013
+ * // Serializes the <div> element.
24014
+ * const str = parse5.serializeOuter(document.childNodes[0]);
24015
+ *
24016
+ * console.log(str); //> '<div>Hello, <b>world</b>!</div>'
24017
+ * ```
24018
+ *
24019
+ * @param node Node to serialize.
24020
+ * @param options Serialization options.
24021
+ */
24022
+ function serializeOuter(node, options) {
24023
+ const opts = {
24024
+ ...defaultOpts,
24025
+ ...options
24026
+ };
24027
+ return serializeNodes([node], opts);
24028
+ }
23875
24029
  function serializeNodes(nodes, options) {
23876
24030
  var _a;
23877
24031
  const { treeAdapter } = options;
@@ -25189,6 +25343,7 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
25189
25343
  turn,
25190
25344
  upright
25191
25345
  } : {},
25346
+ ...entry.showOverflow === true ? { showOverflow: true } : {},
25192
25347
  ...transition ? { transition } : {},
25193
25348
  ...speakerNotes ? { speakerNotes } : {},
25194
25349
  ...kit ? { kit } : {},
@@ -25216,8 +25371,8 @@ function placeNext(placed, body = {
25216
25371
  width: FRAME_SIZES[DEFAULT_FRAME_SIZE].width,
25217
25372
  device: null
25218
25373
  }) {
25219
- const right = Math.max(...placed.map(({ box, widths, device }) => {
25220
- const extent = drawnExtent(box, widths, device);
25374
+ const right = Math.max(...placed.map((placement) => {
25375
+ const extent = drawnExtent(placement.box, placement.widths, placement);
25221
25376
  return xPast(extent.x + extent.width, body.width, body.device);
25222
25377
  }), 0);
25223
25378
  const order = Math.max(...placed.map((placement) => placement.order + 1), 0);
@@ -25420,7 +25575,7 @@ async function isDirectory(path) {
25420
25575
  }
25421
25576
  }
25422
25577
  // package.json
25423
- var version$1 = "0.51.0";
25578
+ var version$1 = "0.53.0";
25424
25579
  var dependencies = { "playwright-core": "1.65.1" };
25425
25580
  var peerDependencies = { "oxfmt": "0.79.0" };
25426
25581
  // src/shared/version.ts
@@ -25532,7 +25687,9 @@ const claimBoxSchema = object$1({
25532
25687
  width: number(),
25533
25688
  height: number(),
25534
25689
  hugWidth: boolean$1().optional(),
25535
- hugHeight: boolean$1().optional()
25690
+ hugHeight: boolean$1().optional(),
25691
+ /** Set on a box its frame's name sized, which lands inside the device its width names. */
25692
+ showDevice: boolean$1().optional()
25536
25693
  });
25537
25694
  /** One session's hold on a frame while its agent rewrites it. */
25538
25695
  const claimSchema = looseObject({
@@ -25699,17 +25856,17 @@ async function releaseReservation(root, frame, now) {
25699
25856
  return dropped;
25700
25857
  }
25701
25858
  /**
25702
- * Drops a session's claim on one frame, or every claim it holds when no
25703
- * frame is named, returning what it dropped.
25859
+ * Drops a session's claims on the frames named in one write, or every claim
25860
+ * it holds when `frames` is undefined, returning what it dropped.
25704
25861
  */
25705
- async function release(root, session, frame, now) {
25862
+ async function release(root, session, frames, now) {
25706
25863
  const dropped = [];
25707
25864
  await ensureRunFolder(root);
25708
25865
  await updateRecord(claimsPath(root), claimsSpec, (file) => {
25709
25866
  const kept = [];
25710
25867
  for (const each of file.claims) {
25711
25868
  if (!isLive(each, now)) continue;
25712
- (each.session === session && (frame === void 0 || each.frame === frame) ? dropped : kept).push(each);
25869
+ (each.session === session && (frames === void 0 || frames.includes(each.frame)) ? dropped : kept).push(each);
25713
25870
  }
25714
25871
  return {
25715
25872
  ...file,
@@ -25733,11 +25890,12 @@ async function addFrame(root, ref, options) {
25733
25890
  const page = pageDir(frame);
25734
25891
  const reserved = options.x === void 0 && options.y === void 0 ? await reservedBox(root, refOf$1(frame)) : void 0;
25735
25892
  const sized = options.size !== void 0 || options.width !== void 0 || options.height !== void 0;
25893
+ const scroll = options.scroll ?? false;
25894
+ const reservedDevice = !sized && reserved?.showDevice === true;
25736
25895
  const statedSize = reserved && !sized ? {
25737
25896
  width: reserved.width,
25738
- height: reserved.height
25897
+ ...reservedDevice && scroll ? {} : { height: reserved.height }
25739
25898
  } : sizeOf(options);
25740
- const scroll = options.scroll ?? false;
25741
25899
  const statedHugs = scroll ? {
25742
25900
  hugWidth: false,
25743
25901
  hugHeight: false
@@ -25757,7 +25915,7 @@ async function addFrame(root, ref, options) {
25757
25915
  ...statedHugs,
25758
25916
  hugWidth: false
25759
25917
  };
25760
- const showDevice = options.showDevice || named !== void 0;
25918
+ const showDevice = options.showDevice || reservedDevice || named !== void 0;
25761
25919
  const names = exists ? layout.names : [...layout.names, frame.name].sort();
25762
25920
  const placed = placeFrames(layout.file.frames, names.filter((name) => layout.hasEntry(name)));
25763
25921
  const stale = placed.get(frame.name);
@@ -25991,8 +26149,9 @@ function linkedWidths(ref, requested, { width, hugWidth, held }) {
25991
26149
  }));
25992
26150
  }
25993
26151
  /** The x a copy placed beside a frame takes, its own body clear of the frame's device and linked widths. */
25994
- function pastExtent({ box, widths, device }) {
25995
- const extent = drawnExtent(box, widths, device);
26152
+ function pastExtent(placement) {
26153
+ const { box, widths, device } = placement;
26154
+ const extent = drawnExtent(box, widths, placement);
25996
26155
  return xPast(extent.x + extent.width, box.width, device);
25997
26156
  }
25998
26157
  /**
@@ -26215,10 +26374,17 @@ async function orderFrame(root, ref, { index, ...options }) {
26215
26374
  return frameRecord(root, frame.project, frame.page, frame.name);
26216
26375
  }
26217
26376
  async function setFrameFlag(root, ref, flag, { on, ...options }) {
26218
- return updatePlacement(root, ref, options, (placement) => ({
26219
- ...placement,
26220
- [flag]: on
26221
- }));
26377
+ return updatePlacement(root, ref, options, (placement) => {
26378
+ if (flag !== "showOverflow") return {
26379
+ ...placement,
26380
+ [flag]: on
26381
+ };
26382
+ const { showOverflow: _held, ...rest } = placement;
26383
+ return on ? {
26384
+ ...rest,
26385
+ showOverflow: true
26386
+ } : rest;
26387
+ });
26222
26388
  }
26223
26389
  /**
26224
26390
  * Shows or hides a frame's device, names, folds, or turns it, never writing
@@ -26550,7 +26716,7 @@ var PageLayout = class {
26550
26716
  * Writes the fixed keys after the entry's own, so unknown keys survive, and a
26551
26717
  * flag only once on or already held, so an older entry gains no key.
26552
26718
  */
26553
- set(name, { box, order, hidden, locked, scroll, widths, showDevice, foldable, pose, keptWidths, island, turn, upright, transition, speakerNotes, kit, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
26719
+ set(name, { box, order, hidden, locked, scroll, widths, showDevice, foldable, pose, keptWidths, island, turn, upright, showOverflow, transition, speakerNotes, kit, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
26554
26720
  const hugWidth = hugsWidth && !scroll;
26555
26721
  const hugHeight = hugsHeight && !scroll;
26556
26722
  const held = this.file.frames[name];
@@ -26583,6 +26749,7 @@ var PageLayout = class {
26583
26749
  }
26584
26750
  } : {},
26585
26751
  ...turn && foldable ? { turn } : {},
26752
+ ...showOverflow ? { showOverflow } : {},
26586
26753
  ...transition ? { transition: { ...transition } } : {},
26587
26754
  ...speakerNotes ? { speakerNotes } : {},
26588
26755
  ...kit ? { kit } : {}
@@ -26600,6 +26767,7 @@ var PageLayout = class {
26600
26767
  }
26601
26768
  if (turn && foldable) delete entry.upright;
26602
26769
  if (typeof held?.device === "string") delete entry.device;
26770
+ if (!showOverflow && held?.showOverflow === true) delete entry.showOverflow;
26603
26771
  if (!transition && storedTransitionOf(held?.transition)) delete entry.transition;
26604
26772
  if (!speakerNotes && speakerNotesOf(held?.speakerNotes)) delete entry.speakerNotes;
26605
26773
  if (!kit && kitOf(held?.kit)) delete entry.kit;
@@ -30357,29 +30525,117 @@ function matches$1(given, expected) {
30357
30525
  const b = Buffer.from(expected);
30358
30526
  return a.length === b.length && timingSafeEqual(a, b);
30359
30527
  }
30528
+ // src/server/access/tickets.ts
30529
+ const TICKET_TTL_MS = 12e4;
30530
+ /** Tickets live in memory only, so a restart voids them and nothing reaches disk. */
30531
+ function createTickets(now = Date.now) {
30532
+ const expiries = /* @__PURE__ */ new Map();
30533
+ return {
30534
+ mint: (ttlMs = TICKET_TTL_MS) => {
30535
+ for (const [ticket, expiry] of expiries) if (expiry <= now()) expiries.delete(ticket);
30536
+ const ticket = randomBytes(16).toString("hex");
30537
+ const expiry = now() + Math.min(ttlMs, 36e5);
30538
+ expiries.set(ticket, expiry);
30539
+ return {
30540
+ ticket,
30541
+ expiresAt: new Date(expiry).toISOString()
30542
+ };
30543
+ },
30544
+ redeem: (ticket) => {
30545
+ const expiry = expiries.get(ticket);
30546
+ expiries.delete(ticket);
30547
+ return expiry !== void 0 && expiry > now();
30548
+ }
30549
+ };
30550
+ }
30551
+ // src/server/routes/envelope.ts
30552
+ /** The status each refusal of a structure or history write answers with. */
30553
+ const STATUS$6 = {
30554
+ usage: 400,
30555
+ "invalid-name": 400,
30556
+ "project-required": 400,
30557
+ "project-not-found": 404,
30558
+ "page-not-found": 404,
30559
+ "frame-not-found": 404,
30560
+ "section-not-found": 404,
30561
+ "asset-not-found": 404,
30562
+ "name-taken": 409,
30563
+ "stale-layout": 409,
30564
+ "stale-address": 409,
30565
+ "invalid-utf8": 422,
30566
+ "frame-claimed": 409,
30567
+ "asset-held": 409,
30568
+ "asset-type-refused": 400,
30569
+ "undo-overtaken": 409,
30570
+ "nothing-to-undo": 409,
30571
+ "tokens-exist": 409,
30572
+ "stale-tokens": 409,
30573
+ "invalid-edit": 409,
30574
+ "frame-locked": 423,
30575
+ "layout-invalid": 422,
30576
+ "project-file-invalid": 422,
30577
+ "fit-unbounded": 422,
30578
+ "fit-scroll": 422,
30579
+ "claims-invalid": 422,
30580
+ "lock-timeout": 503,
30581
+ "browser-not-found": 503
30582
+ };
30583
+ /**
30584
+ * Answers a refusal in the CLI's `{ ok, error }` envelope, for a route
30585
+ * module's `onError`. Anything else is a fault and goes on to Hono.
30586
+ */
30587
+ function answerRefusal(error, c) {
30588
+ if (!(error instanceof FrameboardError)) throw error;
30589
+ return c.json({
30590
+ ok: false,
30591
+ error: {
30592
+ code: error.code,
30593
+ message: error.message,
30594
+ details: error.details
30595
+ }
30596
+ }, STATUS$6[error.code] ?? 500);
30597
+ }
30598
+ /** The request's JSON body as the schema reads it, or `usage` naming what failed. */
30599
+ async function parseBody$1(request, schema) {
30600
+ const parsed = schema.safeParse(await request.json().catch(() => null));
30601
+ if (!parsed.success) throw new FrameboardError("usage", `The body ${parsed.error.message}`);
30602
+ return parsed.data;
30603
+ }
30360
30604
  // src/server/routes/access.ts
30361
30605
  const COOKIE_MAX_AGE_S = 3456e4;
30606
+ const ticketSchema = object$1({
30607
+ /** Minutes the ticket lives, the default life when left out. */
30608
+ ttl: number().int().min(1).max(60).optional() });
30362
30609
  /**
30363
30610
  * How a tab becomes a writer, a used ticket still landing on a reading board.
30364
- * `openRoute` stays off unless asked, since it makes any local browser a writer.
30611
+ * Both options stay off unless asked, since each widens who may write.
30365
30612
  */
30366
- function accessRoutes(access, tickets, { openRoute = false } = {}) {
30613
+ function accessRoutes(access, tickets, { openRoute = false, editButton = false } = {}) {
30367
30614
  const app = new Hono();
30368
30615
  app.get("/api/access/redeem", (c) => {
30369
30616
  const ticket = c.req.query("ticket");
30370
30617
  if (ticket !== void 0 && tickets.redeem(ticket)) {
30371
- setCookie(c, access.cookieName, access.key, {
30372
- httpOnly: true,
30373
- sameSite: "Strict",
30374
- path: "/api",
30375
- maxAge: COOKIE_MAX_AGE_S
30376
- });
30618
+ setKeyCookie(c, access);
30377
30619
  return c.redirect("/", 303);
30378
30620
  }
30379
30621
  return c.redirect("/?link=expired", 303);
30380
30622
  });
30381
30623
  if (openRoute) app.get("/api/access/open", (c) => c.redirect(`/api/access/redeem?ticket=${tickets.mint().ticket}`, 303));
30382
- app.post("/api/access/ticket", (c) => {
30624
+ if (editButton) app.post("/api/access/edit", (c) => {
30625
+ if (!isBoardPageFetch(c, access)) return c.json({
30626
+ ok: false,
30627
+ error: {
30628
+ code: "forbidden",
30629
+ message: "Only the board's own page can ask for edit access."
30630
+ }
30631
+ }, 403);
30632
+ setKeyCookie(c, access);
30633
+ return c.json({
30634
+ ok: true,
30635
+ data: { write: true }
30636
+ });
30637
+ });
30638
+ app.post("/api/access/ticket", async (c) => {
30383
30639
  if (!isWriter({ authorization: c.req.header("authorization") }, access)) return c.json({
30384
30640
  ok: false,
30385
30641
  error: {
@@ -30387,8 +30643,9 @@ function accessRoutes(access, tickets, { openRoute = false } = {}) {
30387
30643
  message: "Minting a ticket needs the address file token."
30388
30644
  }
30389
30645
  }, 401);
30646
+ const { ttl } = c.req.header("content-type") ? await parseBody$1(c.req.raw, ticketSchema) : {};
30390
30647
  const url = new URL("/api/access/redeem", c.req.url);
30391
- const { ticket, expiresAt } = tickets.mint();
30648
+ const { ticket, expiresAt } = tickets.mint(ttl === void 0 ? void 0 : ttl * 6e4);
30392
30649
  url.searchParams.set("ticket", ticket);
30393
30650
  return c.json({
30394
30651
  ok: true,
@@ -30398,8 +30655,32 @@ function accessRoutes(access, tickets, { openRoute = false } = {}) {
30398
30655
  }
30399
30656
  });
30400
30657
  });
30658
+ app.onError(answerRefusal);
30401
30659
  return app;
30402
30660
  }
30661
+ function setKeyCookie(c, access) {
30662
+ setCookie(c, access.cookieName, access.key, {
30663
+ httpOnly: true,
30664
+ sameSite: "Strict",
30665
+ path: "/api",
30666
+ maxAge: COOKIE_MAX_AGE_S
30667
+ });
30668
+ }
30669
+ /**
30670
+ * True for a fetch a script on the board's own page sent, which keeps out other
30671
+ * pages, frames, and the forms and pings a scriptless kit page can send from
30672
+ * the board's origin. A program that is no browser can send the same headers.
30673
+ */
30674
+ function isBoardPageFetch(c, access) {
30675
+ const own = new URL(c.req.url);
30676
+ if (c.req.header("origin") !== own.origin) return false;
30677
+ if (!access.isOwnOrigin(own.host)) return false;
30678
+ if (c.req.header("content-type")?.split(";")[0]?.trim().toLowerCase() !== "application/json") return false;
30679
+ return absentOr(c.req.header("sec-fetch-site"), "same-origin") && absentOr(c.req.header("sec-fetch-mode"), "cors");
30680
+ }
30681
+ function absentOr(header, expected) {
30682
+ return header === void 0 || header === expected;
30683
+ }
30403
30684
  // src/server/author.ts
30404
30685
  const run$1 = promisify(execFile);
30405
30686
  /** The longest name a note is signed with. */
@@ -31182,7 +31463,7 @@ const boxesBodySchema = object$1({
31182
31463
  sections: boxesSchema.optional(),
31183
31464
  expectedSections: boxesSchema.optional()
31184
31465
  });
31185
- const STATUS$6 = {
31466
+ const STATUS$5 = {
31186
31467
  usage: 400,
31187
31468
  "invalid-name": 400,
31188
31469
  "project-required": 400,
@@ -31245,7 +31526,7 @@ function apiRoutes(root, actions, look, history) {
31245
31526
  code: error.code,
31246
31527
  message: error.message
31247
31528
  }
31248
- }, STATUS$6[error.code] ?? 500);
31529
+ }, STATUS$5[error.code] ?? 500);
31249
31530
  }
31250
31531
  return c.json({
31251
31532
  ok: true,
@@ -31316,7 +31597,7 @@ function apiRoutes(root, actions, look, history) {
31316
31597
  message: error.message,
31317
31598
  details: error.details
31318
31599
  }
31319
- }, STATUS$6[error.code] ?? 500);
31600
+ }, STATUS$5[error.code] ?? 500);
31320
31601
  }
31321
31602
  });
31322
31603
  return app;
@@ -32207,8 +32488,8 @@ const installedFontSchema = object$1({
32207
32488
  files: int$1(),
32208
32489
  /** Whether the board serves the family too, so its frames keep drawing once it is removed. */
32209
32490
  bundled: boolean$1(),
32210
- /** The refs of the frames drawing text in the family, in page then frame order. */
32211
- frames: array$1(string$1())
32491
+ /** The refs of the frames drawing text in the family, in page then frame order, absent where the read skipped them. */
32492
+ frames: array$1(string$1()).optional()
32212
32493
  });
32213
32494
  /** What `font list` answers, by family name. */
32214
32495
  const fontListSchema = object$1({
@@ -37434,6 +37715,7 @@ function buildCascade(source, tokens, { properties = READ } = {}) {
37434
37715
  rule: ruleOf(declaration)
37435
37716
  };
37436
37717
  },
37718
+ declares: (element, property) => declaredOn(element).has(property),
37437
37719
  resolve: (value, element, keep) => resolveVars(value, element, keep)
37438
37720
  };
37439
37721
  }
@@ -38493,11 +38775,14 @@ function fontSheet(fonts) {
38493
38775
  function weightOf({ min, max }) {
38494
38776
  return min === max ? `${min}` : `${min} ${max}`;
38495
38777
  }
38496
- /** A project's installed fonts as `font list` answers them. */
38497
- async function listFonts(root, ref) {
38778
+ /**
38779
+ * A project's installed fonts as `font list` answers them. `frames: false`
38780
+ * skips reading every frame and leaves each font's `frames` out.
38781
+ */
38782
+ async function listFonts(root, ref, { frames: withFrames = true } = {}) {
38498
38783
  const project = await resolveProject(root, ref);
38499
38784
  const fonts = await projectFonts(project.path);
38500
- const frames = await framesByFamily(root, project.name, fonts.map((font) => font.record.family));
38785
+ const frames = withFrames ? await framesByFamily(root, project.name, fonts.map((font) => font.record.family)) : null;
38501
38786
  return {
38502
38787
  version: 1,
38503
38788
  project: project.name,
@@ -38514,7 +38799,7 @@ async function listFonts(root, ref) {
38514
38799
  path: `${FONTS_FOLDER}/${id}`,
38515
38800
  files: record.faces.length,
38516
38801
  bundled: isBundled(record.family),
38517
- frames: frames.get(record.family) ?? []
38802
+ ...frames ? { frames: frames.get(record.family) ?? [] } : {}
38518
38803
  }))
38519
38804
  };
38520
38805
  }
@@ -38967,59 +39252,6 @@ object$1({ transitions: array$1(object$1({
38967
39252
  name: string$1(),
38968
39253
  css: string$1()
38969
39254
  })) });
38970
- // src/server/routes/envelope.ts
38971
- /** The status each refusal of a structure or history write answers with. */
38972
- const STATUS$5 = {
38973
- usage: 400,
38974
- "invalid-name": 400,
38975
- "project-required": 400,
38976
- "project-not-found": 404,
38977
- "page-not-found": 404,
38978
- "frame-not-found": 404,
38979
- "section-not-found": 404,
38980
- "asset-not-found": 404,
38981
- "name-taken": 409,
38982
- "stale-layout": 409,
38983
- "stale-address": 409,
38984
- "invalid-utf8": 422,
38985
- "frame-claimed": 409,
38986
- "asset-held": 409,
38987
- "asset-type-refused": 400,
38988
- "undo-overtaken": 409,
38989
- "nothing-to-undo": 409,
38990
- "tokens-exist": 409,
38991
- "stale-tokens": 409,
38992
- "invalid-edit": 409,
38993
- "frame-locked": 423,
38994
- "layout-invalid": 422,
38995
- "project-file-invalid": 422,
38996
- "fit-unbounded": 422,
38997
- "fit-scroll": 422,
38998
- "claims-invalid": 422,
38999
- "lock-timeout": 503,
39000
- "browser-not-found": 503
39001
- };
39002
- /**
39003
- * Answers a refusal in the CLI's `{ ok, error }` envelope, for a route
39004
- * module's `onError`. Anything else is a fault and goes on to Hono.
39005
- */
39006
- function answerRefusal(error, c) {
39007
- if (!(error instanceof FrameboardError)) throw error;
39008
- return c.json({
39009
- ok: false,
39010
- error: {
39011
- code: error.code,
39012
- message: error.message,
39013
- details: error.details
39014
- }
39015
- }, STATUS$5[error.code] ?? 500);
39016
- }
39017
- /** The request's JSON body as the schema reads it, or `usage` naming what failed. */
39018
- async function parseBody$1(request, schema) {
39019
- const parsed = schema.safeParse(await request.json().catch(() => null));
39020
- if (!parsed.success) throw new FrameboardError("usage", `The body ${parsed.error.message}`);
39021
- return parsed.data;
39022
- }
39023
39255
  // src/shared/board-urls.ts
39024
39256
  /** Where the server serves a frame's file, with each name encoded as its own segment. */
39025
39257
  function frameUrl(ref) {
@@ -40387,6 +40619,20 @@ function applyEdit(source, address, change) {
40387
40619
  span
40388
40620
  };
40389
40621
  }
40622
+ // src/shared/element-marks.ts
40623
+ /** The tags a browser gives no box, which no Layers row lists and no canvas press picks. */
40624
+ const UNRENDERED_TAGS = /* @__PURE__ */ new Set([
40625
+ "script",
40626
+ "style",
40627
+ "template",
40628
+ "noscript",
40629
+ "link",
40630
+ "meta"
40631
+ ]);
40632
+ /** Marks an element the canvas pick passes over, whatever its value, while its Layers row still selects it. */
40633
+ const LOCKED_ATTRIBUTE = "data-locked";
40634
+ /** Keeps the inline `display` a hide replaced, which a show puts back. */
40635
+ const SHOWN_DISPLAY_ATTRIBUTE = "data-shown-display";
40390
40636
  // src/server/edit/elements.ts
40391
40637
  /** How long a text-only element's text may run as its name. */
40392
40638
  const NAME_LENGTH = 40;
@@ -40401,13 +40647,16 @@ const ROUND_PROPERTIES = /* @__PURE__ */ new Set(["border-radius"]);
40401
40647
  const PLACE_PROPERTIES = /* @__PURE__ */ new Set([
40402
40648
  "position",
40403
40649
  "width",
40404
- "height"
40650
+ "height",
40651
+ "transform",
40652
+ "translate"
40405
40653
  ]);
40406
40654
  /**
40407
- * A frame's elements under `body` by `edit` index, refused where the browser
40408
- * builds an unstated element, since every later index would name another.
40655
+ * A frame's elements under `body` by `edit` index, leaving out what renders
40656
+ * nothing while counting it, refused where the browser builds an unstated
40657
+ * element, since every later index would name another.
40409
40658
  */
40410
- function elementTree(source, layouts = [], rounds = [], facts = []) {
40659
+ function elementTree(source, layouts = [], rounds = [], facts = [], hidden = []) {
40411
40660
  const tree = parseFrame(source);
40412
40661
  if (tree.unstated) return refuse$2("address-mismatch", `the browser builds a <${tree.unstated.tagName}> the file does not state, so indices after it disagree`);
40413
40662
  const index = new Map(tree.elements.map((element, at) => [element, at]));
@@ -40418,16 +40667,23 @@ function elementTree(source, layouts = [], rounds = [], facts = []) {
40418
40667
  const parent = element.parentNode;
40419
40668
  if (!body || !parent || !hasTag(parent)) continue;
40420
40669
  if (parent !== body && !inBody.has(parent)) continue;
40670
+ if (UNRENDERED_TAGS.has(element.tagName)) continue;
40421
40671
  inBody.add(element);
40672
+ const next = nextElement(element);
40673
+ const unlistedNext = next && UNRENDERED_TAGS.has(next.tagName) ? index.get(next) : void 0;
40422
40674
  listed.push({
40423
40675
  index: at,
40424
40676
  parent: parent === body ? null : index.get(parent) ?? null,
40425
40677
  tag: element.tagName,
40426
40678
  name: elementName(element),
40679
+ ...statedName(element) ? { named: true } : {},
40427
40680
  textOnly: ownText(element) !== null || element.tagName === "p" && isEmpty(element),
40428
40681
  layout: layouts[at] ?? "block",
40429
40682
  round: (rounds[at] ?? false) && isEmpty(element),
40430
- placed: isPlaced(facts[at])
40683
+ placed: isPlaced(facts[at]),
40684
+ ...hidden[at] ? { hidden: true } : {},
40685
+ ...attribute$2(element, "data-locked") === void 0 ? {} : { locked: true },
40686
+ ...unlistedNext === void 0 ? {} : { unlistedNext }
40431
40687
  });
40432
40688
  }
40433
40689
  return listed;
@@ -40464,9 +40720,17 @@ function elementPlaceFacts(source, tokens) {
40464
40720
  return source.elements.map((element) => ({
40465
40721
  position: own(element, "position"),
40466
40722
  width: own(element, "width") !== null,
40467
- height: own(element, "height") !== null
40723
+ height: own(element, "height") !== null,
40724
+ ...shiftOf(own(element, "transform"), own(element, "translate"))
40468
40725
  }));
40469
40726
  }
40727
+ /** The shifts an author rule sets, each left out where none does. */
40728
+ function shiftOf(transform, translate) {
40729
+ return {
40730
+ ...transform === null ? {} : { transform },
40731
+ ...translate === null ? {} : { translate }
40732
+ };
40733
+ }
40470
40734
  function isPlaced(facts) {
40471
40735
  const position = facts?.position?.trim().toLowerCase();
40472
40736
  return position === "absolute" || position === "fixed";
@@ -40486,11 +40750,15 @@ function words(value) {
40486
40750
  * something to the frame's CSS, scripts, and readers.
40487
40751
  */
40488
40752
  function elementName(element) {
40489
- const named = attribute$1(element, "data-name")?.trim();
40753
+ const named = statedName(element);
40490
40754
  if (named) return named;
40491
40755
  const text = ownText(element);
40492
40756
  if (text !== null) return text.slice(0, NAME_LENGTH);
40493
- return (element.tagName === "img" ? attribute$1(element, "alt")?.trim() : "") || element.tagName;
40757
+ return (element.tagName === "img" ? attribute$2(element, "alt")?.trim() : "") || element.tagName;
40758
+ }
40759
+ /** An element's `data-name`, null when it states none or a blank one. */
40760
+ function statedName(element) {
40761
+ return attribute$2(element, "data-name")?.trim() || null;
40494
40762
  }
40495
40763
  /** The whitespace-collapsed text of an element holding text alone, else null. */
40496
40764
  function ownText(element) {
@@ -40503,12 +40771,158 @@ function ownText(element) {
40503
40771
  function isEmpty(element) {
40504
40772
  return element.childNodes.every((node) => isText(node) && node.value.trim() === "");
40505
40773
  }
40774
+ function nextElement(element) {
40775
+ const siblings = element.parentNode?.childNodes ?? [];
40776
+ return siblings.slice(siblings.indexOf(element) + 1).find(hasTag);
40777
+ }
40506
40778
  function isText(node) {
40507
40779
  return node.nodeName === "#text";
40508
40780
  }
40781
+ function attribute$2(element, name) {
40782
+ return element.attrs.find((attr) => attr.name === name)?.value;
40783
+ }
40784
+ // src/server/edit/hide.ts
40785
+ const DISPLAY = /* @__PURE__ */ new Set(["display", "all"]);
40786
+ const XHTML = "http://www.w3.org/1999/xhtml";
40787
+ const PSEUDO_ELEMENT = /::|:(?:before|after|first-line|first-letter)\b/i;
40788
+ const NONE = /^\s*none\b/i;
40789
+ /**
40790
+ * Hides an element or shows it again by its start tag. A hide states `hidden`,
40791
+ * and where the page could draw the element through that, an inline
40792
+ * `display: none` over the display it keeps for the show.
40793
+ */
40794
+ function hideElement(source, index, hidden, mayShow) {
40795
+ const { elements } = parseFrame(source);
40796
+ const element = elements[index];
40797
+ if (!element) return refuse$2("invalid-address", `the frame holds elements 0 to ${elements.length - 1}, so ${index} names none`);
40798
+ let html = source;
40799
+ for (const changes of hidden ? hides(element) : [shows(element)]) {
40800
+ for (const change of changes) {
40801
+ const applied = applyEdit(html, { index }, change);
40802
+ if (!applied.ok) return applied;
40803
+ html = applied.html;
40804
+ }
40805
+ if (hidden && !mayShow(html, index)) break;
40806
+ }
40807
+ const written = parseFrame(html).elements[index] ?? element;
40808
+ return {
40809
+ ok: true,
40810
+ html,
40811
+ span: {
40812
+ scope: "start-tag",
40813
+ index,
40814
+ count: elements.length,
40815
+ before: spanText(source, element, "start-tag"),
40816
+ after: spanText(html, written, "start-tag")
40817
+ }
40818
+ };
40819
+ }
40820
+ /** What a hide writes step by step, each step only where the one before left the element drawing. */
40821
+ function hides(element) {
40822
+ const stated = attribute$1(element, "hidden")?.toLowerCase();
40823
+ const isStated = stated !== void 0 && stated !== "until-found";
40824
+ const display = inlineDisplay(element);
40825
+ const none = {
40826
+ kind: "style",
40827
+ property: "display"
40828
+ };
40829
+ const keep = display === void 0 ? [] : [{
40830
+ kind: "attribute",
40831
+ name: SHOWN_DISPLAY_ATTRIBUTE,
40832
+ value: display
40833
+ }];
40834
+ const isNone = display !== void 0 && NONE.test(display);
40835
+ return [
40836
+ isStated ? [] : [{
40837
+ kind: "attribute",
40838
+ name: "hidden",
40839
+ value: ""
40840
+ }, ...isNone ? keep : []],
40841
+ [...isNone ? [] : keep, {
40842
+ ...none,
40843
+ value: "none"
40844
+ }],
40845
+ [{
40846
+ ...none,
40847
+ value: "none !important"
40848
+ }]
40849
+ ];
40850
+ }
40851
+ function shows(element) {
40852
+ const kept = attribute$1(element, SHOWN_DISPLAY_ATTRIBUTE);
40853
+ const changes = [];
40854
+ if (attribute$1(element, "hidden") !== void 0) changes.push({
40855
+ kind: "attribute",
40856
+ name: "hidden",
40857
+ remove: true
40858
+ });
40859
+ if (NONE.test(inlineDisplay(element) ?? "")) changes.push({
40860
+ kind: "style",
40861
+ property: "display",
40862
+ value: kept ?? ""
40863
+ });
40864
+ if (kept !== void 0) changes.push({
40865
+ kind: "attribute",
40866
+ name: SHOWN_DISPLAY_ATTRIBUTE,
40867
+ remove: true
40868
+ });
40869
+ return changes;
40870
+ }
40871
+ /** The inline `display` that applies, with any `!important`. */
40872
+ function inlineDisplay(element) {
40873
+ return declaredValues(attribute$1(element, "style") ?? "", "display").at(-1);
40874
+ }
40509
40875
  function attribute$1(element, name) {
40510
40876
  return element.attrs.find((attr) => attr.name === name)?.value;
40511
40877
  }
40878
+ /**
40879
+ * Whether an element may draw with its `hidden` attribute and inline `display`
40880
+ * as written, true wherever the static cascade cannot rule it out.
40881
+ */
40882
+ function mayShow(source, tokens, index) {
40883
+ const element = source.elements[index];
40884
+ if (!element) return false;
40885
+ const cascade = buildCascade(source, tokens, { properties: DISPLAY });
40886
+ const display = cascade.specified(element, "display");
40887
+ if (display) return !((display.rule === null || /\[hidden/i.test(display.rule.selector)) && NONE.test(display.value));
40888
+ return cascade.declares(element, "display") || cascade.declares(element, "all") || !hiddenByBrowser(element) || [...tokens, ...source.sheets].some(setsDisplayUnread);
40889
+ }
40890
+ /** Whether each element's `hidden` attribute hides it, by the edit index. */
40891
+ function elementHidden(source, tokens) {
40892
+ const stated = source.elements.map((element) => element.attribs.hidden !== void 0);
40893
+ if (!stated.includes(true)) return stated;
40894
+ const cascade = buildCascade(source, tokens, { properties: DISPLAY });
40895
+ return source.elements.map((element, at) => {
40896
+ if (!stated[at]) return false;
40897
+ const display = cascade.specified(element, "display");
40898
+ return display ? NONE.test(display.value) : hiddenByBrowser(element) && !cascade.declares(element, "display");
40899
+ });
40900
+ }
40901
+ /** Whether the browser's own `[hidden]` rule hides it, which reaches no SVG and loses to a custom element's shadow styles. */
40902
+ function hiddenByBrowser(element) {
40903
+ return (element.namespace ?? XHTML) === XHTML && !element.name.includes("-");
40904
+ }
40905
+ /** Whether a sheet sets `display` by a rule the static cascade reads past, such as a nested one or a `:hover`. */
40906
+ function setsDisplayUnread({ css }) {
40907
+ let root;
40908
+ try {
40909
+ root = postcss_default.parse(css);
40910
+ } catch {
40911
+ return true;
40912
+ }
40913
+ let unread = false;
40914
+ root.walkDecls(/^(?:display|all)$/i, (declaration) => {
40915
+ unread ||= isUnread(declaration);
40916
+ });
40917
+ return unread;
40918
+ }
40919
+ function isUnread(declaration) {
40920
+ const parent = declaration.parent;
40921
+ const rule = parent instanceof Rule ? parent : null;
40922
+ const around = rule ? rule.parent : parent;
40923
+ for (let at = around; at; at = at.parent) if (at instanceof Rule) return true;
40924
+ return rule !== null && styles(rule) && rule.selectors.some((selector) => !PSEUDO_ELEMENT.test(selector) && compileSelector(selector) === null);
40925
+ }
40512
40926
  // src/shared/model-viewer.ts
40513
40927
  /** The custom element a frame shows a 3D model through. */
40514
40928
  const VIEWER_TAG = "model-viewer";
@@ -40909,6 +41323,64 @@ function removeElement(source, index) {
40909
41323
  span: back.span
40910
41324
  };
40911
41325
  }
41326
+ /**
41327
+ * Takes an element out as `removeElement` does, and stands its bytes alone in
41328
+ * a file under the source's head and `body` tag, refusing one the parser would
41329
+ * rebuild there, such as a table row.
41330
+ */
41331
+ function extractElement(source, index) {
41332
+ const removed = removeElement(source, index);
41333
+ if (!removed.ok) return removed;
41334
+ const tree = parseFrame(source);
41335
+ const taken = takeOut$1(source, tree, index);
41336
+ if (!taken || restoreInserted(taken.html, taken.span)?.html !== source) return refuse$2("verify-failed", `the element at ${index} could not be put back once taken out, so nothing was written`);
41337
+ const element = tree.elements[index];
41338
+ const { markup } = taken.span;
41339
+ const frame = element ? frameHolding(source, tree, element, markup) : "";
41340
+ const stood = parseFrame(frame).elements;
41341
+ const at = stood.findIndex(({ tagName }) => tagName === "body") + 1;
41342
+ const alone = stood[at];
41343
+ if (!element || !alone || alone.namespaceURI !== element.namespaceURI || spanText(frame, alone, "element") !== markup || serializeOuter(alone) !== serializeOuter(element)) return refuse$2("invalid-container", `a <${element?.tagName ?? "missing element"}> cannot stand alone in a frame, so nothing was written`);
41344
+ return {
41345
+ ok: true,
41346
+ html: taken.html,
41347
+ span: taken.span,
41348
+ frame,
41349
+ index: at,
41350
+ tagName: element.tagName,
41351
+ name: statedName(element)
41352
+ };
41353
+ }
41354
+ /**
41355
+ * The source's doctype, `html` tag, head, and `body` tag around `markup`. The
41356
+ * head's scripts stay behind, since they expect the page they were written
41357
+ * for, except a viewer's where the element holds a model.
41358
+ */
41359
+ function frameHolding(source, tree, element, markup) {
41360
+ const tagOf = (tagName) => {
41361
+ const wrapper = tree.elements.find((each) => each.tagName === tagName);
41362
+ return wrapper && startTag(source, wrapper) || `<${tagName}>`;
41363
+ };
41364
+ const head = tree.elements.find(({ tagName }) => tagName === "head");
41365
+ const viewers = holdsModel(element) ? tree.elements.filter(loadsViewer) : [];
41366
+ let inner = "";
41367
+ for (const node of head?.childNodes ?? []) {
41368
+ const at = node.sourceCodeLocation;
41369
+ if (!at) continue;
41370
+ inner = hasTag(node) && node.tagName === "script" && !viewers.includes(node) ? inner.trimEnd() : inner + source.slice(at.startOffset, at.endOffset);
41371
+ }
41372
+ for (const viewer of viewers) if (viewer.parentNode !== head) inner += spanText(source, viewer, "element");
41373
+ const doctype = tree.document.childNodes.find((node) => node.nodeName === "#documentType")?.sourceCodeLocation;
41374
+ return `${doctype ? `${source.slice(doctype.startOffset, doctype.endOffset)}\n` : ""}${tagOf("html")}
41375
+ ${tagOf("head")}${inner}</head>
41376
+ ${tagOf("body")}${markup}</body>
41377
+ </html>
41378
+ `;
41379
+ }
41380
+ /** Whether `element` is a model viewer or holds one at any depth. */
41381
+ function holdsModel(element) {
41382
+ return element.tagName === "model-viewer" || children$1(element).some(holdsModel);
41383
+ }
40912
41384
  function underBody(element) {
40913
41385
  for (let node = element.parentNode; node && hasTag(node); node = node.parentNode) if (node.tagName === "body") return true;
40914
41386
  return false;
@@ -40994,8 +41466,7 @@ function px$1(value) {
40994
41466
  */
40995
41467
  function inFlow(source, element, facts) {
40996
41468
  if (declaredValues(rawAttribute(source, element, "style") ?? "", "position").length > 0) return "";
40997
- const position = facts?.position?.trim().toLowerCase();
40998
- return position === "absolute" || position === "fixed" ? "static" : "";
41469
+ return isPlaced(facts) ? "static" : "";
40999
41470
  }
41000
41471
  /** Whether `element` is anchored above `parent`, with nothing positioned between. */
41001
41472
  function anchorsAbove(element, parent, facts) {
@@ -41094,6 +41565,54 @@ function placeElement(source, index, spot, facts, drop = []) {
41094
41565
  sized
41095
41566
  };
41096
41567
  }
41568
+ /** A transform with the translations taken out, `none` when they were all it held. */
41569
+ function withoutShift(transform) {
41570
+ const kept = splitTopLevel(transform.replace(/\s+/g, " ").replace(/\)(?=[a-z])/gi, ") "), " ").filter((part) => !/^translate/i.test(part)).join(" ").trim();
41571
+ return kept === "" ? "none" : kept;
41572
+ }
41573
+ /**
41574
+ * Stands a placed element in the flow of a frame it has to itself, where its
41575
+ * offsets, and the shift that centers it on them, would draw it outside a
41576
+ * hugging box. It stays positioned, so its own placed children stay put.
41577
+ */
41578
+ function standInFlow(source, index, facts) {
41579
+ const own = facts[index];
41580
+ if (!isPlaced(own)) return {
41581
+ ok: true,
41582
+ html: source
41583
+ };
41584
+ const transform = own?.transform ?? "none";
41585
+ return applyEdit(source, { index }, {
41586
+ kind: "styles",
41587
+ declarations: [
41588
+ {
41589
+ property: "position",
41590
+ value: "relative"
41591
+ },
41592
+ ...[
41593
+ "left",
41594
+ "top",
41595
+ "right",
41596
+ "bottom"
41597
+ ].map((property) => ({
41598
+ property,
41599
+ value: ""
41600
+ })),
41601
+ {
41602
+ property: "inset",
41603
+ value: "auto"
41604
+ },
41605
+ .../translate/i.test(transform) ? [{
41606
+ property: "transform",
41607
+ value: withoutShift(transform)
41608
+ }] : [],
41609
+ ...own?.translate && own.translate !== "none" ? [{
41610
+ property: "translate",
41611
+ value: "none"
41612
+ }] : []
41613
+ ]
41614
+ });
41615
+ }
41097
41616
  // src/server/look/flow.ts
41098
41617
  /** What the flow read takes from the cascade, with the shorthands that set it. */
41099
41618
  const FLOW_PROPERTIES = /* @__PURE__ */ new Set([
@@ -41650,11 +42169,11 @@ function editFrameFile(path, address, change, sourceAt) {
41650
42169
  };
41651
42170
  }
41652
42171
  /**
41653
- * Edits several elements as one write, all or none. One element named twice is
41654
- * refused, since one undo could not put both spans back, except a text beside
41655
- * a style or several attributes, which answer one span over the element.
42172
+ * Edits several elements as one write, all or none. One named twice is refused,
42173
+ * since one undo could not put both spans back, except a text beside a style
42174
+ * or several attributes. A hide with no `mayShow` states the attribute alone.
41656
42175
  */
41657
- function editFrameFileAll(path, hash, edits, sourceAt) {
42176
+ function editFrameFileAll(path, hash, edits, sourceAt, mayShow = () => false) {
41658
42177
  const read = readSource(path);
41659
42178
  if (!read.ok) return read;
41660
42179
  const { source } = read;
@@ -41674,7 +42193,8 @@ function editFrameFileAll(path, hash, edits, sourceAt) {
41674
42193
  let html = source;
41675
42194
  const spans = [];
41676
42195
  for (const [at, { change }] of edits.entries()) {
41677
- const applied = applyEdit(html, { index: indexes[at] ?? -1 }, change);
42196
+ const index = indexes[at] ?? -1;
42197
+ const applied = change.kind === "hidden" ? hideElement(html, index, change.value, mayShow) : applyEdit(html, { index }, change);
41678
42198
  if (!applied.ok) return applied;
41679
42199
  html = applied.html;
41680
42200
  spans.push(applied.span);
@@ -41796,6 +42316,35 @@ function removeFrameFile(path, hash, index) {
41796
42316
  };
41797
42317
  }
41798
42318
  /**
42319
+ * Takes one element out of a frame file and into a new one `target` names,
42320
+ * writing the new file first and taking it back on any failure before the
42321
+ * source's write, so the element stands in one of the two at every moment.
42322
+ */
42323
+ async function extractFrameFile(path, hash, index, target, created) {
42324
+ const read = readSource(path);
42325
+ if (!read.ok) return read;
42326
+ if (read.hash !== hash) return stale$1(path);
42327
+ const extracted = extractElement(read.source, index);
42328
+ if (!extracted.ok) return extracted;
42329
+ const own = target(extracted);
42330
+ if (!own.ok) return own;
42331
+ writeFileSync(own.path, own.html, { flag: "wx" });
42332
+ try {
42333
+ await created(own.path);
42334
+ if (replaceFile(path, hash, extracted.html)) return {
42335
+ ok: true,
42336
+ hash: contentHash(extracted.html),
42337
+ span: extracted.span,
42338
+ remap: takenOut(index, subtreeSize(read.source, index))
42339
+ };
42340
+ } catch (error) {
42341
+ rmSync(own.path, { force: true });
42342
+ throw error;
42343
+ }
42344
+ rmSync(own.path, { force: true });
42345
+ return stale$1(path);
42346
+ }
42347
+ /**
41799
42348
  * Takes several elements out as one write, last in the file first, so the
41800
42349
  * indices ahead of each hold, a nested named element going with its outer one.
41801
42350
  */
@@ -43648,6 +44197,11 @@ const removeResultSchema = object$1({
43648
44197
  ref: string$1(),
43649
44198
  hash
43650
44199
  });
44200
+ object$1({
44201
+ ref: string$1(),
44202
+ hash,
44203
+ frame: string$1()
44204
+ });
43651
44205
  object$1({
43652
44206
  ref: string$1(),
43653
44207
  index: int$1().min(0),
@@ -43737,6 +44291,10 @@ const changeSchema = union([
43737
44291
  })).max(16)
43738
44292
  })
43739
44293
  ]);
44294
+ const hiddenSchema = object$1({
44295
+ kind: literal("hidden"),
44296
+ value: boolean$1()
44297
+ });
43740
44298
  const editSchema$1 = union([object$1({
43741
44299
  ref: string$1().min(1).max(1024),
43742
44300
  index: int$1().min(0),
@@ -43747,7 +44305,7 @@ const editSchema$1 = union([object$1({
43747
44305
  hash: string$1().regex(/^[0-9a-f]{64}$/),
43748
44306
  edits: array$1(object$1({
43749
44307
  index: int$1().min(0),
43750
- change: changeSchema
44308
+ change: union([changeSchema, hiddenSchema])
43751
44309
  })).min(1).max(BATCH)
43752
44310
  })]);
43753
44311
  const insertSchema = object$1({
@@ -43795,6 +44353,18 @@ const removeSchema$1 = union([object$1({
43795
44353
  indexes: array$1(int$1().min(0)).min(1).max(BATCH),
43796
44354
  hash: string$1().regex(/^[0-9a-f]{64}$/)
43797
44355
  })]);
44356
+ const extractSchema = object$1({
44357
+ ref: string$1().min(1).max(1024),
44358
+ hash: string$1().regex(/^[0-9a-f]{64}$/),
44359
+ index: int$1().min(0),
44360
+ /** Where the new frame stands, its size holding until the frame is measured. */
44361
+ box: object$1({
44362
+ x: int$1(),
44363
+ y: int$1(),
44364
+ width: side,
44365
+ height: side
44366
+ })
44367
+ });
43798
44368
  const moveSchema$1 = object$1({
43799
44369
  ref: string$1().min(1).max(1024),
43800
44370
  hash: string$1().regex(/^[0-9a-f]{64}$/),
@@ -43868,7 +44438,7 @@ function editRoutes(root, access, history, version, sheets) {
43868
44438
  await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
43869
44439
  const was = contentHash(await readFile(frame.path)) !== body.hash ? await version?.(ref, body.hash) ?? null : null;
43870
44440
  if ("edits" in body) {
43871
- const result = editFrameFileAll(frame.path, body.hash, body.edits, (hash) => hash === body.hash ? was : null);
44441
+ const result = editFrameFileAll(frame.path, body.hash, body.edits, (hash) => hash === body.hash ? was : null, (html, index) => mayShow(frameFrom(frame, html), tokenSheets(frame), index));
43872
44442
  if (!result.ok) return c.json({
43873
44443
  ok: false,
43874
44444
  error: {
@@ -44086,6 +44656,82 @@ function editRoutes(root, access, history, version, sheets) {
44086
44656
  data
44087
44657
  });
44088
44658
  });
44659
+ app.post("/api/frames/extract", requireWriter(access), async (c) => {
44660
+ const body = await parseBody$1(c.req.raw, extractSchema);
44661
+ const frame = await resolveFrameRef(root, body.ref, { cwd: root });
44662
+ const pageRef = `${frame.project}/${frame.page}`;
44663
+ const ref = `${pageRef}/${frame.name}`;
44664
+ const now = /* @__PURE__ */ new Date();
44665
+ await refuseClaimed(root, [ref], now);
44666
+ const reserved = (await readClaims(root, now)).flatMap((claim) => claim.frame.startsWith(`${pageRef}/`) ? [claim.frame.slice(pageRef.length + 1)] : []);
44667
+ const page = dirname(frame.path);
44668
+ const journal = history.journal();
44669
+ let name = "";
44670
+ const result = await withLayouts([page], async (layouts) => {
44671
+ const layout = layoutAt(layouts, page);
44672
+ const { kit } = layout.placement(frame.name);
44673
+ const taken = [
44674
+ ...layout.names,
44675
+ ...Object.keys(layout.file.frames),
44676
+ ...reserved
44677
+ ];
44678
+ const extracted = await extractFrameFile(frame.path, body.hash, body.index, (element) => {
44679
+ name = nextFreeName(elementFrameName(element.name, element.tagName), taken);
44680
+ const stood = standInFlow(element.frame, element.index, elementPlaceFacts(frameFrom(frame, element.frame), tokenSheets(frame)));
44681
+ if (!stood.ok) return stood;
44682
+ return {
44683
+ ok: true,
44684
+ path: join(page, `${name}${FRAME_EXTENSION}`),
44685
+ html: stood.html
44686
+ };
44687
+ }, (path) => journal.created(path));
44688
+ if (!extracted.ok) return extracted;
44689
+ journal.deletedElement(frame.path, ref, extracted.span);
44690
+ layout.names = [...layout.names, name].sort();
44691
+ layout.set(name, {
44692
+ box: body.box,
44693
+ order: layout.topOrder(),
44694
+ hidden: false,
44695
+ locked: false,
44696
+ hugWidth: true,
44697
+ hugHeight: true,
44698
+ scroll: false,
44699
+ widths: [],
44700
+ placed: true,
44701
+ ...kit ? { kit } : {}
44702
+ });
44703
+ layout.renumber();
44704
+ return extracted;
44705
+ }, journal);
44706
+ if (!result.ok) return c.json({
44707
+ ok: false,
44708
+ error: {
44709
+ code: result.reason,
44710
+ message: result.detail,
44711
+ details: {
44712
+ ref,
44713
+ index: body.index
44714
+ }
44715
+ }
44716
+ }, 409);
44717
+ const own = `${pageRef}/${name}`;
44718
+ history.record({
44719
+ id: journal.id,
44720
+ changes: journal.changes,
44721
+ page: null,
44722
+ frames: [ref, own]
44723
+ });
44724
+ await follow(frame, body.hash, result.hash, result.remap);
44725
+ const data = {
44726
+ ref,
44727
+ hash: result.hash,
44728
+ frame: own
44729
+ };
44730
+ return c.json({
44731
+ ok: true,
44732
+ data
44733
+ });
44734
+ });
44089
44735
  app.post("/api/frames/move", requireWriter(access), async (c) => {
44090
44736
  const body = await parseBody$1(c.req.raw, moveSchema$1);
44091
44737
  const frame = await resolveFrameRef(root, body.ref, { cwd: root });
@@ -44366,11 +45012,13 @@ function elementsRoutes(root, access, selection, tokens = null) {
44366
45012
  const bytes = await readFile(frame.path);
44367
45013
  const source = readFrame$1(frame);
44368
45014
  const sheets = tokenSheets(root, frame.project, tokens, frameKit(frame));
44369
- const elements = elementTree(bytes.toString("utf8"), elementLayouts(source, sheets), elementRounds(source, sheets), elementPlaceFacts(source, sheets));
45015
+ const elements = elementTree(bytes.toString("utf8"), elementLayouts(source, sheets), elementRounds(source, sheets), elementPlaceFacts(source, sheets), elementHidden(source, sheets));
44370
45016
  if (!Array.isArray(elements)) throw new FrameboardError(elements.reason, elements.detail, { ref });
45017
+ const body = source.elements.findIndex(({ name }) => name === "body");
44371
45018
  return {
44372
45019
  ref: `${frame.project}/${frame.page}/${frame.name}`,
44373
45020
  hash: contentHash(bytes),
45021
+ ...body === -1 ? {} : { body },
44374
45022
  elements
44375
45023
  };
44376
45024
  };
@@ -44454,8 +45102,6 @@ function elementsRoutes(root, access, selection, tokens = null) {
44454
45102
  /** How much of a text hit's text shows before the match, and in all. */
44455
45103
  const SNIPPET_BEFORE = 20;
44456
45104
  const SNIPPET_LENGTH = 80;
44457
- /** Elements whose text is code rather than copy. */
44458
- const NOT_COPY = /* @__PURE__ */ new Set(["script", "style"]);
44459
45105
  /**
44460
45106
  * Every case-insensitive hit across a project's shown frames, an element named
44461
45107
  * by its text hitting as text alone so it is listed once.
@@ -44508,7 +45154,7 @@ async function frameHits(frame, needle) {
44508
45154
  for (const row of rows) {
44509
45155
  const element = elements[row.index];
44510
45156
  if (!element) continue;
44511
- const text = NOT_COPY.has(row.tag) ? "" : directText(element);
45157
+ const text = directText(element);
44512
45158
  const at = text.toLowerCase().indexOf(needle);
44513
45159
  const namedByText = row.textOnly && !hasDataName(element);
44514
45160
  const address = {
@@ -44718,20 +45364,34 @@ async function boardKitNames(root) {
44718
45364
  }
44719
45365
  // src/server/kits/install.ts
44720
45366
  /**
44721
- * Adds a kit to a project as a copy of its folder under `assets/kits/`, so
44722
- * a frame can name it, touching no token sheet and no page. Refuses
44723
- * `name-taken` where the project holds a kit by that name, writing nothing.
45367
+ * Copies a kit's folder into a project's `assets/kits/`, touching no token
45368
+ * sheet and no page. Over a kit the project holds, refuses `name-taken` or,
45369
+ * under `replace`, swaps in the copy under the name it is held by.
44724
45370
  */
44725
- async function installKit(root, ref, kit, { journal } = {}) {
45371
+ async function installKit(root, ref, kit, { journal, replace = false } = {}) {
44726
45372
  const project = await resolveProject(root, ref);
44727
45373
  assertValidName("kit", kit.name);
44728
45374
  const held = matchName(await projectKitNames(project.path), kit.name);
44729
- const target = projectKitDir(project.path, kit.name);
44730
- if (held !== void 0 || existsSync(target)) throw new FrameboardError("name-taken", `${project.name} already holds a kit named ${held ?? kit.name}, so none was added. Remove it first with \`frameboard kit remove ${project.name} ${held ?? kit.name}\`.`, {
45375
+ const name = held ?? kit.name;
45376
+ const target = projectKitDir(project.path, name);
45377
+ const swaps = replace && held !== void 0;
45378
+ if (!swaps && (held !== void 0 || existsSync(target))) throw new FrameboardError("name-taken", held === void 0 ? `${target} exists and is not a kit folder, so no kit was added. Move it away first.` : `${project.name} already holds a kit named ${name}, so none was added. Run \`frameboard kit add\` with --replace to put this copy in its place, which keeps the kit on every frame naming it.`, {
44731
45379
  project: project.name,
44732
- kit: held ?? kit.name
45380
+ kit: name
44733
45381
  });
44734
45382
  await readKitFile(kit);
45383
+ const record = {
45384
+ project: project.name,
45385
+ kit: name,
45386
+ written: [target]
45387
+ };
45388
+ if (swaps) {
45389
+ await swapIn(kit.path, target);
45390
+ return {
45391
+ ...record,
45392
+ replaced: true
45393
+ };
45394
+ }
44735
45395
  const made = topmostMissing(target);
44736
45396
  await mkdir(dirname(target), { recursive: true });
44737
45397
  await cp(kit.path, target, {
@@ -44741,11 +45401,33 @@ async function installKit(root, ref, kit, { journal } = {}) {
44741
45401
  filter: (path) => isKitFile(kit.path, path)
44742
45402
  });
44743
45403
  await journal?.created(made);
44744
- return {
44745
- project: project.name,
44746
- kit: kit.name,
44747
- written: [target]
44748
- };
45404
+ return record;
45405
+ }
45406
+ /**
45407
+ * Puts a copy of the kit folder in place of the one at `target`, staged whole
45408
+ * in a dot folder beside it, so a failed copy leaves the held kit as it was.
45409
+ */
45410
+ async function swapIn(kitPath, target) {
45411
+ const stage = await mkdtemp(join(dirname(target), `.${basename(target)}.`));
45412
+ const copy = join(stage, "copy");
45413
+ const aside = join(stage, "held");
45414
+ try {
45415
+ await cp(kitPath, copy, {
45416
+ recursive: true,
45417
+ dereference: true,
45418
+ filter: (path) => isKitFile(kitPath, path)
45419
+ });
45420
+ await rename(target, aside);
45421
+ await rename(copy, target).catch(async (error) => {
45422
+ await rename(aside, target);
45423
+ throw error;
45424
+ });
45425
+ } finally {
45426
+ if (existsSync(target)) await rm(stage, {
45427
+ recursive: true,
45428
+ force: true
45429
+ });
45430
+ }
44749
45431
  }
44750
45432
  /** The highest folder on the way to `path` that does not exist yet, which an undo removes whole. */
44751
45433
  function topmostMissing(path) {
@@ -44867,10 +45549,10 @@ async function savedNames(kits) {
44867
45549
  const name$1 = string$1().min(1).max(256);
44868
45550
  /**
44869
45551
  * The policy on every kit page and SVG, running the theme script alone by
44870
- * hash, since a kit file runs on the board's origin, where a frame could embed
44871
- * one to write as the board, and a sandbox would draw a sample light.
45552
+ * hash and sending no form, since a kit file sits on the board's origin, where
45553
+ * a frame could embed one to write as the board. A sandbox would draw it light.
44872
45554
  */
44873
- const PREVIEW_POLICY = `script-src 'sha256-${createHash("sha256").update(THEME_SCRIPT).digest("base64")}'`;
45555
+ const PREVIEW_POLICY = `script-src 'sha256-${createHash("sha256").update(THEME_SCRIPT).digest("base64")}'; form-action 'none'`;
44874
45556
  const installSchema = object$1({
44875
45557
  project: name$1,
44876
45558
  kit: name$1,
@@ -47696,6 +48378,8 @@ const fontSaveBodySchema = object$1({
47696
48378
  weights: array$1(int$1().min(1).max(1e3)).min(1).max(20).optional()
47697
48379
  });
47698
48380
  const fontRemoveBodySchema = object$1({ id: string$1().min(1).max(200) });
48381
+ /** `?frames=false` skips reading every frame for each font's `frames`, which only a removal reads. */
48382
+ const framesQuerySchema = _enum$1(["true", "false"]).optional();
47699
48383
  const generateBodySchema = object$1({ prompt: string$1().trim().min(1).max(2e3) });
47700
48384
  const STATUS = {
47701
48385
  usage: 400,
@@ -47831,9 +48515,12 @@ function sourcingRoutes(root, access, { send = (input, init) => fetch(input, ini
47831
48515
  });
47832
48516
  app.get(`${base}/fonts/installed`, async (c) => {
47833
48517
  const { name } = projectOf$2(root, c.req.param("project"));
48518
+ const asked = framesQuerySchema.safeParse(c.req.query("frames"));
48519
+ if (!asked.success) throw new FrameboardError("usage", "Send ?frames=false to skip reading frames, or leave it out.");
48520
+ const frames = asked.data !== "false";
47834
48521
  return c.json({
47835
48522
  ok: true,
47836
- data: await listFonts(root, name)
48523
+ data: await listFonts(root, name, { frames })
47837
48524
  });
47838
48525
  });
47839
48526
  app.post(`${base}/fonts/save`, authorized, async (c) => {
@@ -48497,8 +49184,9 @@ async function waitForAnimations(timeoutMs) {
48497
49184
  }
48498
49185
  // src/server/capture/element-shot.ts
48499
49186
  /**
48500
- * Leaves one element showing alone on a transparent ground, answering its box,
48501
- * which can run past the frame's, so the page is shot once and closed.
49187
+ * Leaves one element showing alone on a transparent ground, so the page is
49188
+ * shot once and closed. The box it answers can run past the frame's right and
49189
+ * bottom, and is no reading of the element's place past the left or top.
48502
49190
  */
48503
49191
  async function isolateElement(page, ref, index) {
48504
49192
  const isolated = await page.evaluate(hideAllBut, index);
@@ -48510,7 +49198,9 @@ async function isolateElement(page, ref, index) {
48510
49198
  ref,
48511
49199
  index
48512
49200
  });
48513
- return isolated.box;
49201
+ const { box } = isolated;
49202
+ if (box.x >= 0 && box.y >= 0) return box;
49203
+ return page.evaluate(shiftIntoView);
48514
49204
  }
48515
49205
  function hideAllBut(index) {
48516
49206
  let count = 0;
@@ -48544,6 +49234,52 @@ function hideAllBut(index) {
48544
49234
  }
48545
49235
  };
48546
49236
  }
49237
+ function shiftIntoView() {
49238
+ const root = document.documentElement;
49239
+ const target = document.querySelector("[data-frameboard-shot]");
49240
+ if (!target) throw new Error("No element is isolated.");
49241
+ const painted = () => {
49242
+ const { left, top, right, bottom } = target.getBoundingClientRect();
49243
+ const x = Math.round(left + window.scrollX) + 0;
49244
+ const y = Math.round(top + window.scrollY) + 0;
49245
+ return {
49246
+ x,
49247
+ y,
49248
+ width: Math.max(1, Math.round(right + window.scrollX) - x),
49249
+ height: Math.max(1, Math.round(bottom + window.scrollY) - y)
49250
+ };
49251
+ };
49252
+ const hold = (element, styles) => {
49253
+ for (const [name, value] of Object.entries(styles)) element.style.setProperty(name, value, "important");
49254
+ };
49255
+ const chain = [];
49256
+ for (let element = target; element && element !== root; element = element.parentElement) {
49257
+ const { width, height } = getComputedStyle(element);
49258
+ chain.unshift({
49259
+ element,
49260
+ width,
49261
+ height
49262
+ });
49263
+ }
49264
+ hold(root, {
49265
+ transition: "none",
49266
+ translate: "0px"
49267
+ });
49268
+ for (const { element, ...used } of chain) for (const side of ["width", "height"]) {
49269
+ const size = used[side];
49270
+ if (getComputedStyle(element)[side] === size) continue;
49271
+ hold(element, {
49272
+ transition: "none",
49273
+ [side]: size,
49274
+ [`min-${side}`]: size,
49275
+ [`max-${side}`]: size
49276
+ });
49277
+ }
49278
+ const { x, y } = painted();
49279
+ const shift = (at) => `${Math.max(0, -at) / root.currentCSSZoom}px`;
49280
+ hold(root, { translate: `${shift(x)} ${shift(y)}` });
49281
+ return painted();
49282
+ }
48547
49283
  // src/server/capture/fonts.ts
48548
49284
  /**
48549
49285
  * Families the browser maps to a face itself, so no frame has to supply one.
@@ -49246,7 +49982,8 @@ async function shootElement(page, ref, index, scale) {
49246
49982
  * A frame's shot drawn inside a device's body, as the board draws it, on a
49247
49983
  * page the size of the body, so the PNG holds the body and nothing past it.
49248
49984
  */
49249
- async function drawBezel(browser, shot, box, { device, pose = "closed", island = "compact", turn, bar }, scale) {
49985
+ async function drawBezel(browser, shot, box, body, scale) {
49986
+ const { device, turn } = body;
49250
49987
  const screen = {
49251
49988
  x: 0,
49252
49989
  y: 0,
@@ -49255,7 +49992,6 @@ async function drawBezel(browser, shot, box, { device, pose = "closed", island =
49255
49992
  };
49256
49993
  const outer = bezelBox(screen, device, turn);
49257
49994
  const page = pageBox(screen, device, turn);
49258
- const laptop = device === "laptop";
49259
49995
  const context = await browser.newContext({
49260
49996
  viewport: {
49261
49997
  width: outer.width,
@@ -49265,10 +50001,7 @@ async function drawBezel(browser, shot, box, { device, pose = "closed", island =
49265
50001
  });
49266
50002
  try {
49267
50003
  const tab = await context.newPage();
49268
- const sideways = turnOf(turn);
49269
- 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) : "";
49270
- const radius = screenCorners(device);
49271
- 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" });
50004
+ 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)}">` + bodyHtml(screen, body) + `</div></body></html>`, { waitUntil: "load" });
49272
50005
  return await tab.screenshot({
49273
50006
  omitBackground: true,
49274
50007
  caret: "hide"
@@ -49278,6 +50011,16 @@ async function drawBezel(browser, shot, box, { device, pose = "closed", island =
49278
50011
  }
49279
50012
  }
49280
50013
  /**
50014
+ * A device's body and marks over a screen `box` sized by its parent, with no
50015
+ * `bar` where the shot under it already holds the bar or the side strips.
50016
+ */
50017
+ function bodyHtml(box, { device, pose = "closed", island = "compact", turn, bar }) {
50018
+ const sideways = turnOf(turn);
50019
+ const strips = bar && sideways !== "upright" ? sideStripsHtml(bar.colors, bar.theme, { device }) : "";
50020
+ const marks = device === "phone" ? sideways === "upright" ? (bar ? statusBarHtml(bar.colors, bar.theme) : "") + phoneMarks(island) : strips + turnedPhoneMarks(island, sideways) : device === "foldable" ? strips + foldableMarks(pose, sideways) : (device === "laptop" ? laptopMarks(box) : "") + bodyPartsHtml(device, turn);
50021
+ return `<div style="position:absolute;inset:0;border-radius:${screenCorners(device)};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div>`;
50022
+ }
50023
+ /**
49281
50024
  * A phone frame's shot of its page set under the status bar upright, or a
49282
50025
  * phone's or foldable's between the side strips turned, at the frame's box
49283
50026
  * with no body, so a capture holds the screen the board draws.
@@ -49352,6 +50095,13 @@ function laptopMarks(box) {
49352
50095
  const edge = `1px solid ${BEZEL_COLORS.edge}`;
49353
50096
  return `<span style="position:absolute;box-sizing:border-box;left:${chin.x}px;top:${chin.y}px;width:${chin.width}px;height:${chin.height}px;background:${BEZEL_COLORS.body};border-left:${edge};border-right:${edge}"></span><span style="position:absolute;box-sizing:border-box;left:${base.x}px;top:${base.y}px;width:${base.width}px;height:${base.height}px;background:${BEZEL_COLORS.base};border:${edge};border-radius:0 0 ${LAPTOP_BASE.radius}px ${LAPTOP_BASE.radius}px"></span>`;
49354
50097
  }
50098
+ /** A laptop's camera, or a tablet's camera and buttons, as the board draws them. */
50099
+ function bodyPartsHtml(device, turn) {
50100
+ return bodyParts(device, turn).map(({ name, place }) => {
50101
+ const box = Object.entries(place).map(([side, length]) => `${side}:${length}`).join(";");
50102
+ return name === "camera" ? `<span style="position:absolute;${box};border-radius:50%;background:${CAMERA.fill};box-shadow:0 0 0 ${CAMERA.ring}px ${BEZEL_COLORS.cameraRing}"></span>` : `<span style="position:absolute;${box};border-radius:3px;background:${BEZEL_COLORS.tabletButton}"></span>`;
50103
+ }).join("");
50104
+ }
49355
50105
  /** The phone's buttons, island, and home bar as the board draws them. */
49356
50106
  function phoneMarks(island) {
49357
50107
  const { border } = BEZELS.phone;
@@ -49488,18 +50238,19 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
49488
50238
  });
49489
50239
  const widths = [];
49490
50240
  for (const { width } of frame.widths) {
50241
+ const bar = linkedBar(frame, width);
49491
50242
  const linked = await measureContent(browser, {
49492
50243
  baseUrl,
49493
50244
  ref: frame.ref,
49494
50245
  box: {
49495
50246
  width,
49496
- height: referenceHeight(width)
50247
+ height: referenceHeight(width) - bar
49497
50248
  },
49498
50249
  hugWidth: false
49499
50250
  });
49500
50251
  widths.push({
49501
50252
  width,
49502
- height: linked.height
50253
+ height: linked.height + bar
49503
50254
  });
49504
50255
  }
49505
50256
  return {
@@ -50340,7 +51091,11 @@ const frameSpeakerNotesSchema = object$1({
50340
51091
  });
50341
51092
  const frameFlagSchema = object$1({
50342
51093
  refs,
50343
- flag: _enum$1(["hidden", "locked"]),
51094
+ flag: _enum$1([
51095
+ "hidden",
51096
+ "locked",
51097
+ "showOverflow"
51098
+ ]),
50344
51099
  on: boolean$1()
50345
51100
  });
50346
51101
  const sectionBox = object$1({
@@ -50771,20 +51526,25 @@ function structureRoutes(root, access, history, measure, tokens = null) {
50771
51526
  if (!measure) throw new FrameboardError("browser-not-found", "Fit height needs the board server's browser, and none runs here.");
50772
51527
  for (const target of targets) {
50773
51528
  const frame = await readFrame(root, target.ref, { cwd });
50774
- const content = await measure(frame);
51529
+ const page = pageBox(frame.box, frame.device, frame.turn);
51530
+ const content = await measure({
51531
+ ...frame,
51532
+ box: page
51533
+ });
50775
51534
  const widths = [];
50776
51535
  for (const { width } of frame.widths) {
51536
+ const bar = linkedBar(frame, width);
50777
51537
  const linked = await measure(frame, {
50778
51538
  width,
50779
- height: referenceHeight(width)
51539
+ height: referenceHeight(width) - bar
50780
51540
  });
50781
51541
  widths.push({
50782
51542
  width,
50783
- height: linked.height
51543
+ height: linked.height + bar
50784
51544
  });
50785
51545
  }
50786
51546
  target.measured = {
50787
- height: content.height,
51547
+ height: content.height + topInset(frame.device, frame.turn),
50788
51548
  widths
50789
51549
  };
50790
51550
  }
@@ -51201,7 +51961,7 @@ function boardHostGuard(port) {
51201
51961
  await next();
51202
51962
  };
51203
51963
  }
51204
- function createApp({ clientDir, root, port, framePort, actions, tickets, openRoute, renderFrame, renderFilmstrip, clipboard = null, facesDir, tokens, delivery, dispatch, history, selection, checks, thumbnails, measure, frameVersion, settledVersion, assetUsage, preview }) {
51964
+ function createApp({ clientDir, root, port, framePort, actions, tickets, openRoute, editButton, renderFrame, renderFilmstrip, clipboard = null, facesDir, tokens, delivery, dispatch, history, selection, checks, thumbnails, measure, frameVersion, settledVersion, assetUsage, preview }) {
51205
51965
  const app = new Hono();
51206
51966
  const given = tokens ?? null;
51207
51967
  app.use("*", async (c, next) => {
@@ -51220,7 +51980,10 @@ function createApp({ clientDir, root, port, framePort, actions, tickets, openRou
51220
51980
  tokens: given,
51221
51981
  clipboard: clipboard?.backend ?? null
51222
51982
  }));
51223
- app.route("/", accessRoutes(actions.access, tickets, { openRoute }));
51983
+ app.route("/", accessRoutes(actions.access, tickets, {
51984
+ openRoute,
51985
+ editButton
51986
+ }));
51224
51987
  app.route("/", apiRoutes(root, actions, frames.look, history));
51225
51988
  app.route("/", structureRoutes(root, actions.access, history, measure, given));
51226
51989
  app.route("/", historyRoutes(actions.access, history));
@@ -51245,6 +52008,10 @@ function createApp({ clientDir, root, port, framePort, actions, tickets, openRou
51245
52008
  return c.redirect(url.href, 307);
51246
52009
  });
51247
52010
  app.all("/frames/*", (c) => c.notFound());
52011
+ if (editButton) app.use("*", async (c, next) => {
52012
+ await next();
52013
+ if ((c.res.headers.get("Content-Type") ?? "").startsWith("text/html")) c.header("Content-Security-Policy", "frame-ancestors 'none'");
52014
+ });
51248
52015
  app.use("*", serveStatic({ root: clientDir }));
51249
52016
  app.get("/p/*", serveStatic({
51250
52017
  root: clientDir,
@@ -51397,7 +52164,7 @@ function compositeImagePath(out, page, theme, scale = 1) {
51397
52164
  * `capture-too-large` past Chromium's screenshot limit.
51398
52165
  */
51399
52166
  function compositeBounds(page, frames, scale = 1) {
51400
- const extents = frames.map(({ box, widths, device }) => drawnExtent(box, widths ?? [], device));
52167
+ const extents = frames.map((frame) => drawnExtent(frame.box, frame.widths ?? [], frame));
51401
52168
  const left = Math.min(...extents.map((box) => box.x));
51402
52169
  const top = Math.min(...extents.map((box) => box.y));
51403
52170
  const right = Math.max(...extents.map((box) => box.x + box.width));
@@ -51473,9 +52240,9 @@ function viewsOf(frame, width) {
51473
52240
  return width === void 0 ? views : views.filter((view) => view.width === width);
51474
52241
  }
51475
52242
  /**
51476
- * Captures one image per page and theme, every frame at its layout box on the
51477
- * theme's canvas color. Each frame renders as it does alone, font check
51478
- * included, and no composite is written until every page rendered.
52243
+ * Captures one image per page and theme, every frame at its layout box in the
52244
+ * device it shows, on the theme's canvas color. Each frame renders as it does
52245
+ * alone, and no composite is written until every page rendered.
51479
52246
  */
51480
52247
  async function captureComposites(browser, { baseUrl, pages, themes, out, scale = 1 }) {
51481
52248
  const bounded = pages.map((page) => ({
@@ -51487,11 +52254,11 @@ async function captureComposites(browser, { baseUrl, pages, themes, out, scale =
51487
52254
  const tiles = [];
51488
52255
  const videos = /* @__PURE__ */ new Map();
51489
52256
  const models = /* @__PURE__ */ new Map();
51490
- for (const frame of page.frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths, frame.device)]) {
52257
+ for (const frame of page.frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths, frame)]) {
51491
52258
  const shot = await renderFrame(browser, baseUrl, frame, box, theme, scale);
51492
52259
  for (const video of inFrame(frame.ref, shot.videos)) videos.set(`${video.ref} ${video.index}`, video);
51493
52260
  for (const model of inFrame(frame.ref, shot.models)) models.set(`${model.ref} ${model.index}`, model);
51494
- tiles.push(`<img src="data:image/png;base64,${shot.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">`);
52261
+ tiles.push(compositeTile(frame, box, bounds, shot.bytes));
51495
52262
  }
51496
52263
  rendered.push({
51497
52264
  ref: page.ref,
@@ -51506,6 +52273,20 @@ async function captureComposites(browser, { baseUrl, pages, themes, out, scale =
51506
52273
  }
51507
52274
  return writeImages(rendered);
51508
52275
  }
52276
+ /** One view in a composite, inside the device it shows or bare, its shot already holding its bar. */
52277
+ function compositeTile(frame, box, { dx, dy }, bytes) {
52278
+ const { device, turn } = viewDevice(frame, box.width);
52279
+ const src = `data:image/png;base64,${bytes.toString("base64")}`;
52280
+ const place = `position:absolute;left:${box.x + dx}px;top:${box.y + dy}px;width:${box.width}px;height:${box.height}px`;
52281
+ if (!device) return `<img src="${src}" style="${place}">`;
52282
+ const { pose, island } = frame;
52283
+ return `<div style="${place}"><img src="${src}" style="display:block;width:100%;height:100%;border-radius:${screenCorners(device)}">` + bodyHtml(box, {
52284
+ device,
52285
+ pose,
52286
+ island,
52287
+ turn
52288
+ }) + `</div>`;
52289
+ }
51509
52290
  /**
51510
52291
  * Captures a frame held at moments of its timeline, per theme and width,
51511
52292
  * rendering every image before writing any.
@@ -51522,8 +52303,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
51522
52303
  frame: {
51523
52304
  ref: frame.ref,
51524
52305
  box: view,
51525
- device: viewDevice(frame, view),
51526
- turn: frame.turn
52306
+ ...viewDevice(frame, view.width)
51527
52307
  },
51528
52308
  theme,
51529
52309
  scale,
@@ -51548,8 +52328,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
51548
52328
  baseUrl,
51549
52329
  ref: frame.ref,
51550
52330
  view,
51551
- device: viewDevice(frame, view),
51552
- turn: frame.turn,
52331
+ ...viewDevice(frame, view.width),
51553
52332
  theme,
51554
52333
  scale,
51555
52334
  motionTimeoutMs,
@@ -51648,24 +52427,17 @@ async function holdShots(browser, { baseUrl, ref, view, device, turn, theme, sca
51648
52427
  await opened.close();
51649
52428
  }
51650
52429
  }
51651
- /**
51652
- * The device a view draws its page under: the frame's own while the view
51653
- * is the frame's own box, and none at a linked width, which draws no device.
51654
- */
51655
- function viewDevice(frame, view) {
51656
- return view.width === frame.box.width ? frame.device : void 0;
51657
- }
51658
52430
  async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll) {
51659
52431
  const box = {
51660
52432
  width: view.width,
51661
52433
  height: view.height
51662
52434
  };
51663
52435
  assertScreenshotFits(frame.ref, box, scale);
51664
- const device = viewDevice(frame, view);
52436
+ const { device, turn } = viewDevice(frame, view.width);
51665
52437
  const opened = await openFrame(browser, {
51666
52438
  baseUrl,
51667
52439
  ref: frame.ref,
51668
- box: pageSize(box, device, frame.turn),
52440
+ box: pageSize(box, device, turn),
51669
52441
  theme,
51670
52442
  scale
51671
52443
  });
@@ -51673,9 +52445,9 @@ async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll)
51673
52445
  const scrollY = scroll === void 0 ? void 0 : await opened.page.evaluate(scrollAndSettle, scroll);
51674
52446
  const shot = await opened.page.screenshot(SCREENSHOT);
51675
52447
  return {
51676
- bytes: insetsPage(device, frame.turn) ? await underPageInsets(browser, shot, box, {
52448
+ bytes: insetsPage(device, turn) ? await underPageInsets(browser, shot, box, {
51677
52449
  device,
51678
- turn: frame.turn,
52450
+ turn,
51679
52451
  colors: await readPageColors(opened.page),
51680
52452
  theme
51681
52453
  }, scale) : shot,
@@ -52194,6 +52966,8 @@ const frameRecordSchema = object$1({
52194
52966
  * A turned frame's box is landscape, and a turned phone draws no status bar.
52195
52967
  */
52196
52968
  turn: _enum$1(["left", "right"]).optional(),
52969
+ /** Whether the board paints the frame's content past its edge, absent while it clips. A capture or an export clips either way. */
52970
+ showOverflow: literal(true).optional(),
52197
52971
  /** The transition the frame arrives with in present mode, over its page's, absent when it holds none. */
52198
52972
  transition: transitionRecordSchema.optional(),
52199
52973
  /** What the presenter means to say over the slide, plain text with its line breaks, absent when it holds none. */
@@ -52521,6 +53295,8 @@ const treeElementSchema = object$1({
52521
53295
  tag: string$1(),
52522
53296
  /** `data-name`, else a text-only element's text cut to 40 characters, else an `img`'s `alt`, else the tag. */
52523
53297
  name: string$1(),
53298
+ /** Present when `name` is its `data-name`. */
53299
+ named: literal(true).optional(),
52524
53300
  /** True when the element holds text and nothing else. */
52525
53301
  textOnly: boolean$1(),
52526
53302
  /** Its layout, which a culled frame's Layers rows draw from without an iframe. */
@@ -52528,12 +53304,24 @@ const treeElementSchema = object$1({
52528
53304
  /** True when it holds nothing and its corners round by half or more, so it draws as an ellipse. */
52529
53305
  round: boolean$1(),
52530
53306
  /** True when it is placed out of the flow, as `position: absolute` or `fixed`. */
52531
- placed: boolean$1()
53307
+ placed: boolean$1(),
53308
+ /** True when its `hidden` attribute hides it, false for one that some rule shows anyway. */
53309
+ hidden: boolean$1().optional(),
53310
+ /** True when it carries `data-locked`, which keeps canvas presses off it and what it holds. */
53311
+ locked: boolean$1().optional(),
53312
+ /** The unlisted element right after it, such as a script, which a move to the end of its siblings lands ahead of. */
53313
+ unlistedNext: int$1().min(0).optional()
52532
53314
  });
52533
- /** What `GET /api/frames/elements` answers: a frame's elements under `body` in index order, and the hash they were read from. */
53315
+ /**
53316
+ * What `GET /api/frames/elements` answers: a frame's elements under `body` that
53317
+ * can render, in index order with gaps where one cannot, and the hash they were
53318
+ * read from.
53319
+ */
52534
53320
  const elementTreeSchema = object$1({
52535
53321
  ref: string$1(),
52536
53322
  hash: string$1().regex(/^[0-9a-f]{64}$/),
53323
+ /** The index of `body`, absent from an older server, whose first row sits right after it. */
53324
+ body: int$1().min(0).optional(),
52537
53325
  elements: array$1(treeElementSchema)
52538
53326
  });
52539
53327
  /** One color or shadow as a frame's source states it. */
@@ -52892,14 +53680,15 @@ function contentFormat() {
52892
53680
  "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.",
52893
53681
  "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.",
52894
53682
  `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.`,
52895
- `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.`,
52896
- `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.`,
52897
- `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.`,
53683
+ `widths lists the extra widths one frame file also shows at, as { width, height } objects, each drawn 80 px past the last, or past its device's body, 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.`,
53684
+ `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}, with a power button and two volume buttons 6 px past that, 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, which left room for a device only where its name gave one, and a placed frame stays where it stands when its device turns on. Each linked width draws inside the device its own width names, bare under 320 and whenever the frame's device is off, and capture --composite draws the body of every frame and linked width showing one. 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.`,
53685
+ `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 that names a phone starts its page under a bar the same way, and a hugging one stores its page plus the bar. With the device off, or on any other device, the page is the whole box.`,
53686
+ "showOverflow true has the board paint each element past the frame's edge as a still picture at its place, the first twenty in document order, and absent clips. A shadow or text past the element's own box is cut, and a frame that scrolls or shows its device clips either way. It changes what the board draws in Edit alone: capture, export, and present still cut at the box, and check still reports clipped. list --json gives it while true, any other value reads as clipped and is kept on write, and the developer sets it with the inspector's Clip content switch.",
52898
53687
  `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.`,
52899
53688
  `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.`,
52900
53689
  `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.`,
52901
53690
  `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.`,
52902
- "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. With no --size, --width, or --height, no reserved box, and no entry left in layout.json by a missing file, frame add takes a name ending in -<px>, such as overview-390, as --width 390 with showDevice on, where <px> is the width of a size in frameSizes, and any other ending hugs both axes. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
53691
+ "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. With no --size, --width, or --height, no reserved box, and no entry left in layout.json by a missing file, frame add takes a name ending in -<px>, such as overview-390, as --width 390 with showDevice on, where <px> is the width of a size in frameSizes, and any other ending hugs both axes. editing --new with no size flag reads the name the same way, and frame add into that reserved box keeps its width and device. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
52903
53692
  "Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
52904
53693
  `A frame file with no entry is unplaced: it reads at desktop size, y 0, 80 px past the right edge of every frame placed before it in name order. frame add places it 80 px past the placed frames alone, so the first unplaced file keeps that box and any later one moves left.`,
52905
53694
  "An entry with no frame file beside it is ignored on read and kept on write.",
@@ -52922,7 +53711,7 @@ function contentFormat() {
52922
53711
  ],
52923
53712
  kits: [
52924
53713
  `A kit is a folder of plain files: ${KIT_FILE} naming it, ${TOKEN_FILE} with a light and a dark block, ${KIT_SHEET} of component styles, ${KIT_NOTE} saying what to reach for, and a kit page of sample frames. The tool ships ${SHIPPED_KITS.join(", ")}, and a board keeps the kits saved from its projects in ${KITS_FOLDER}/.`,
52925
- `kit add copies the kit's folder into the project's ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/ and writes no token sheet and no page, so a project holds several kits beside its own look. It refuses name-taken where the project already holds a kit by that name, and accepts --replace without acting on it. kit remove deletes that folder and clears the kit from every frame naming it, refusing kit-not-found for a kit the project lacks. kit save refuses name-taken for a name a shipped or saved kit holds, and tokens-not-found for a project no sheet reaches.`,
53714
+ `kit add copies the kit's folder into the project's ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/ and writes no token sheet and no page, so a project holds several kits beside its own look. It refuses name-taken where the project already holds a kit by that name. kit add --replace puts the copy in place of that kit instead, dropping the old files and any edit made to them, answering replaced true, and every frame naming it keeps its kit. Where the project holds none, it adds the kit. kit remove deletes that folder and clears the kit from every frame naming it, refusing kit-not-found for a kit the project lacks. kit save refuses name-taken for a name a shipped or saved kit holds, and tokens-not-found for a project no sheet reaches.`,
52926
53715
  `A frame draws with a kit only where its ${LAYOUT_FILE} entry names one under kit. frame kit <frame-ref> <kit> sets it and frame kit <frame-ref> ${NO_KIT_WORD} clears it, each writing ${LAYOUT_FILE} alone, and it refuses kit-not-found for a kit the project lacks. The frame file never names the kit, so rewriting the frame keeps it. list --json answers kit on each frame naming one and kits on each project, with every kit's name, title, and frameCount.`,
52927
53716
  `The server imports ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/${TOKEN_FILE} then ${KIT_SHEET} into a frame naming that kit, after the project sheet, and check reads the same sheets. A plain frame beside it loads neither, and a frame naming a kit whose folder is gone loads none and keeps the name. Read ${ASSETS_FOLDER}/${PROJECT_KITS}/<kit>/${KIT_NOTE} and the sample frames under its kit/ folder before drawing a frame that names it.`,
52928
53717
  `A project holding ${ASSETS_FOLDER}/kit/${KIT_FILE} took its kit before a frame could name one, and every frame in it still loads ${ASSETS_FOLDER}/kit/${KIT_SHEET} after the project sheet. An ${ASSETS_FOLDER}/kit/ holding no ${KIT_FILE} is loaded into no frame, so a frame using it links it itself.`
@@ -52951,7 +53740,8 @@ function contentFormat() {
52951
53740
  `font find searches by family name or by one of ${FONT_CATEGORIES.join(", ")}, and --category keeps one. A variable family keeps every subset and weight, and a static one ${DEFAULT_WEIGHTS.join(" and ")} in normal and italic, or the weights --weights names. An install lands whole or not at all, refusing license-refused for another license, name-taken for a family the project holds, so font remove then font find --save updates one, and source-failed when ${FONTSOURCE_SOURCE.name} does not answer. font remove deletes the folder and names the frames still drawing text in the family, which report font-missing on their next capture. Never rename, convert, or subset an installed file, since its license reserves the font's name against a changed one.`,
52952
53741
  "The board sets data-theme and color-scheme to light or dark on each frame's root, with the class dark or light, so define both themes through [data-theme], .dark, prefers-color-scheme, or light-dark(), or take every color from token variables. Never paste a token sheet into a frame.",
52953
53742
  `A change to a token sheet reloads every frame it reaches.`,
52954
- "A style attribute outranks every rule, and may hold a value the developer set by hand, so read it before changing a rule the element matches. While a server runs, check warns as outranked when an agent's write changed a rule in the frame's own <style> that an unchanged style attribute also sets."
53743
+ "A style attribute outranks every rule, and may hold a value the developer set by hand, so read it before changing a rule the element matches. While a server runs, check warns as outranked when an agent's write changed a rule in the frame's own <style> that an unchanged style attribute also sets.",
53744
+ `The developer hides and locks an element from its Layers row, and each is written on that element. A hidden one carries hidden, and where the page would still draw it, an inline display: none too, with ${SHOWN_DISPLAY_ATTRIBUTE} holding any inline display that replaced, which a show puts back. A locked one carries ${LOCKED_ATTRIBUTE} with any value, which keeps the developer's canvas presses and drags off it and what it holds and refuses no edit. Keep these on an element you rewrite. Layers lists no ${[...UNRENDERED_TAGS].join(", ")} element, and each still counts in an index.`
52955
53745
  ]
52956
53746
  };
52957
53747
  }
@@ -53154,7 +53944,7 @@ function tagFor(agent, session, cwd) {
53154
53944
  const ANY_INTEGER$1 = parseInteger(Number.MIN_SAFE_INTEGER);
53155
53945
  function registerEditing(program, context) {
53156
53946
  const { io } = context;
53157
- act(addVerb(program, "editing", "Claim a frame before rewriting it, so the board shows it and another session is told it is taken. With --new, reserve frames not written yet, so the board shows where each will land. Bare, list the live claims", { project: true }).argument("[frame-refs...]", "the frame to claim or release, or with --new every frame to reserve").option("--release", "drop this session's claim on the frame, or every claim it holds").option("--new", "reserve each frame named, none of which may exist yet, as one set that renews together").addOption(new Option("--size <preset>", "with --new, a size preset or device for every frame").choices(FRAME_SIZE_NAMES)).option("--width <n>", "with --new, width in px", parseInteger(1)).option("--height <n>", "with --new, height in px", parseInteger(1)).option("--x <n>", "with --new, board x of the first frame in px", ANY_INTEGER$1).option("--y <n>", "with --new, board y of the row in px", ANY_INTEGER$1).option("--session <id>", `the session holding the claim, defaulting to ${SESSION_ENV}`).option("--agent <name>", "the agent the board names, by its first letter", DEFAULT_AGENT), context, async (refs, options) => {
53947
+ act(addVerb(program, "editing", "Claim a frame before rewriting it, so the board shows it and another session is told it is taken. With --new, reserve frames not written yet, so the board shows where each will land, a -<px> name with no size flag giving its width and device. Bare, list the live claims", { project: true }).argument("[frame-refs...]", "the frame to claim, or every frame to release with --release or reserve with --new").option("--release", "drop this session's claim on each frame named, or every claim it holds").option("--new", "reserve each frame named, none of which may exist yet, as one set that renews together").addOption(new Option("--size <preset>", "with --new, a size preset or device for every frame").choices(FRAME_SIZE_NAMES)).option("--width <n>", "with --new, width in px", parseInteger(1)).option("--height <n>", "with --new, height in px", parseInteger(1)).option("--x <n>", "with --new, board x of the first frame in px", ANY_INTEGER$1).option("--y <n>", "with --new, board y of the row in px", ANY_INTEGER$1).option("--session <id>", `the session holding the claim, defaulting to ${SESSION_ENV}`).option("--agent <name>", "the agent the board names, by its first letter", DEFAULT_AGENT), context, async (refs, options) => {
53158
53948
  const root = await boardOf(options, io);
53159
53949
  const now = /* @__PURE__ */ new Date();
53160
53950
  if (options.new) {
@@ -53169,19 +53959,23 @@ function registerEditing(program, context) {
53169
53959
  human: `Reserved ${claims.map((each) => each.frame).join(", ")}. Claim any of them again within five minutes to keep the set.`
53170
53960
  };
53171
53961
  }
53172
- if (refs.length > 1) throw new FrameboardError("usage", `editing claims one frame at a time. Pass --new to reserve ${refs.length} frames not written yet.`, { refs });
53173
- const [ref] = refs;
53174
53962
  if (options.release) {
53175
53963
  const session = sessionOf(options.session);
53176
- const released = await release(root, session, ref ? await claimable(root, ref, resolving(options, io.cwd), now) : void 0, now);
53964
+ const frames = await targetsOf(root, refs, options, io.cwd);
53965
+ await assertClaimable(root, refs, frames, now);
53966
+ const released = await release(root, session, refs.length > 0 ? frames.map(refOf) : void 0, now);
53177
53967
  return {
53178
53968
  data: { released },
53179
53969
  human: released.length === 0 ? `${session} held no claim to release` : `Released ${released.map((each) => each.frame).join(", ")}`
53180
53970
  };
53181
53971
  }
53972
+ if (refs.length > 1) throw new FrameboardError("usage", `editing claims one frame at a time. Pass --new to reserve ${refs.length} frames not written yet, or --release to drop ${refs.length} claims.`, { refs });
53973
+ const [ref] = refs;
53182
53974
  if (ref) {
53183
53975
  const session = sessionOf(options.session);
53184
- const frame = await claimable(root, ref, resolving(options, io.cwd), now);
53976
+ const target = await targetOf(root, ref, options, io.cwd);
53977
+ await assertClaimable(root, refs, [target], now);
53978
+ const frame = refOf(target);
53185
53979
  const held = await claim(root, {
53186
53980
  frame,
53187
53981
  session,
@@ -53200,26 +53994,31 @@ function registerEditing(program, context) {
53200
53994
  };
53201
53995
  });
53202
53996
  }
53203
- function resolving(options, cwd) {
53204
- return {
53997
+ /** The frame a ref names, whether or not its file is written. */
53998
+ function targetOf(root, ref, options, cwd) {
53999
+ return resolveFrameRef(root, ref, {
53205
54000
  project: options.project,
53206
- cwd
53207
- };
54001
+ cwd,
54002
+ allowMissing: true
54003
+ });
54004
+ }
54005
+ function targetsOf(root, refs, options, cwd) {
54006
+ return Promise.all(refs.map((ref) => targetOf(root, ref, options, cwd)));
53208
54007
  }
53209
54008
  /**
53210
- * The ref a plain claim names: an existing frame, or one a live reservation
53211
- * holds before its file is written, which the agent claims as it turns to
53212
- * draw it. Any other missing frame refuses `frame-not-found` as before.
54009
+ * Refuses the whole call as `frame-not-found`, naming every frame with no
54010
+ * file and no live reservation, which an agent claims as it turns to draw it.
53213
54011
  */
53214
- async function claimable(root, ref, options, now) {
53215
- const frame = await resolveFrameRef(root, ref, {
53216
- ...options,
53217
- allowMissing: true
53218
- });
53219
- const canonical = refOf(frame);
53220
- if (existsSync(frame.path)) return canonical;
53221
- if ((await readClaims(root, now)).some((each) => each.frame === canonical && each.box)) return canonical;
53222
- throw new FrameboardError("frame-not-found", `No frame ${frame.name} in ${frame.project}/${frame.page}.`, { ref });
54012
+ async function assertClaimable(root, refs, frames, now) {
54013
+ const unwritten = frames.filter((frame) => !existsSync(frame.path));
54014
+ const live = unwritten.length > 0 ? await readClaims(root, now) : [];
54015
+ const reserved = new Set(live.filter((each) => each.box).map((each) => each.frame));
54016
+ const missing = unwritten.filter((frame) => !reserved.has(refOf(frame)));
54017
+ const [first] = missing;
54018
+ if (!first) return;
54019
+ if (refs.length === 1) throw new FrameboardError("frame-not-found", `No frame ${first.name} in ${first.project}/${first.page}.`, { ref: refs[0] });
54020
+ const named = missing.map(refOf);
54021
+ throw new FrameboardError("frame-not-found", `No frame or reservation ${named.join(", ")}, so nothing was released.`, { refs: named });
53223
54022
  }
53224
54023
  /** `<project>/<page>/<frame>`, the one form a claim names a frame by. */
53225
54024
  function refOf(frame) {
@@ -53231,45 +54030,73 @@ function refOf(frame) {
53231
54030
  */
53232
54031
  async function reservationsOf(root, refs, options, cwd, now) {
53233
54032
  if (refs.length === 0) throw new FrameboardError("usage", "Name at least one frame to reserve with --new.");
53234
- const frames = await Promise.all(refs.map((ref) => resolveFrameRef(root, ref, {
53235
- ...resolving(options, cwd),
53236
- allowMissing: true
53237
- })));
54033
+ const frames = await targetsOf(root, refs, options, cwd);
53238
54034
  const existing = frames.filter((frame) => existsSync(frame.path));
53239
54035
  if (existing.length > 0) throw new FrameboardError("name-taken", `${existing.map(refOf).join(", ")} already exists, so claim it with editing <ref> rather than reserving it.`, { refs: existing.map(refOf) });
53240
54036
  const named = frames.map(refOf);
53241
54037
  const repeated = named.find((ref, index) => named.indexOf(ref) !== index);
53242
54038
  if (repeated) throw new FrameboardError("usage", `${repeated} is named twice.`, { ref: repeated });
53243
- const size = {
53244
- ...FRAME_SIZES[DEFAULT_FRAME_SIZE],
53245
- ...sizeOf(options)
53246
- };
53247
- const hugs = hugsOf(options);
53248
54039
  const live = await readClaims(root, now);
53249
- const nextX = /* @__PURE__ */ new Map();
54040
+ const edges = /* @__PURE__ */ new Map();
53250
54041
  const reservations = [];
53251
54042
  for (const frame of frames) {
53252
54043
  const page = `${frame.project}/${frame.page}`;
53253
- const x = nextX.get(page) ?? options.x ?? await rightOf(root, frame, live);
53254
- nextX.set(page, x + size.width + 80);
54044
+ const size = await reservedSize(frame, options);
54045
+ const device = deviceOf(size);
54046
+ const edge = edges.get(page);
54047
+ const box = {
54048
+ x: edge === void 0 ? options.x ?? Math.max(xPast(await rightOf(root, frame, live), size.width, device), 0) : xPast(edge, size.width, device),
54049
+ y: options.y ?? 0,
54050
+ ...size
54051
+ };
54052
+ const body = bezelBox(box, device, "upright");
54053
+ edges.set(page, body.x + body.width);
53255
54054
  reservations.push({
53256
54055
  frame: refOf(frame),
53257
- box: {
53258
- x,
53259
- y: options.y ?? 0,
53260
- ...size,
53261
- ...hugs
53262
- }
54056
+ box
53263
54057
  });
53264
54058
  }
53265
54059
  return reservations;
53266
54060
  }
53267
- /** Where a new row starts on a frame's page, past its frames' drawn rows and reserved boxes. */
54061
+ /**
54062
+ * The size a frame reserves, as `frame add` would size it: a flag's, else the
54063
+ * width its name states in that width's device, else the default hugging.
54064
+ */
54065
+ async function reservedSize(frame, options) {
54066
+ const size = {
54067
+ ...FRAME_SIZES[DEFAULT_FRAME_SIZE],
54068
+ ...sizeOf(options),
54069
+ ...hugsOf(options)
54070
+ };
54071
+ const width = options.size !== void 0 || options.width !== void 0 || options.height !== void 0 ? void 0 : namedWidth(frame.name);
54072
+ if (width === void 0 || await hasEntry(frame)) return size;
54073
+ return {
54074
+ ...size,
54075
+ width,
54076
+ hugWidth: false,
54077
+ showDevice: true
54078
+ };
54079
+ }
54080
+ /** Whether the page's layout holds an entry for a frame, none where it does not parse. */
54081
+ async function hasEntry(frame) {
54082
+ try {
54083
+ const layout = await readRecord(join(dirname(frame.path), LAYOUT_FILE), layoutSpec);
54084
+ return Object.hasOwn(layout.frames, frame.name);
54085
+ } catch (error) {
54086
+ if (error instanceof FrameboardError) return false;
54087
+ throw error;
54088
+ }
54089
+ }
54090
+ /** The device a reserved box will land in, none for one no name sized. */
54091
+ function deviceOf({ showDevice, width }) {
54092
+ return showDevice ? deviceForWidth(width) : null;
54093
+ }
54094
+ /** The right edge of a page's frames' drawn rows and reserved bodies. */
53268
54095
  async function rightOf(root, frame, live) {
53269
54096
  const page = await scanPage(root, frame.project, frame.page, 0);
53270
54097
  const prefix = `${frame.project}/${frame.page}/`;
53271
- const boxes = [...page.frames.map((each) => drawnExtent(each.box, each.widths, each.device)), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [each.box] : [])];
53272
- return Math.max(...boxes.map((box) => box.x + box.width + 80), 0);
54098
+ const boxes = [...page.frames.map((each) => drawnExtent(each.box, each.widths, each)), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [bezelBox(each.box, deviceOf(each.box), "upright")] : [])];
54099
+ return Math.max(...boxes.map((box) => box.x + box.width));
53273
54100
  }
53274
54101
  function describe$4(claims, now) {
53275
54102
  if (claims.length === 0) return "No frame is claimed";
@@ -53309,7 +54136,7 @@ function registerFont(program, context) {
53309
54136
  const list = await listFonts(await boardOf(options, io), options.project);
53310
54137
  return {
53311
54138
  data: list,
53312
- human: list.fonts.length === 0 ? `${list.project} has installed no font` : list.fonts.map((each) => `${each.id}\t${each.family}\t${each.license}\t${counted(each.frames)}`).join("\n")
54139
+ human: list.fonts.length === 0 ? `${list.project} has installed no font` : list.fonts.map((each) => `${each.id}\t${each.family}\t${each.license}\t${counted(each.frames ?? [])}`).join("\n")
53313
54140
  };
53314
54141
  });
53315
54142
  act(addVerb(font, "remove", "Take an installed font out of a project, deleting its folder under assets/fonts/ and naming the frames left falling back, whose files it never changes. Refuses font-not-found for one the project has not installed", { project: true }).argument("<id>", "a font `font list` names"), context, async ([id = ""], options) => {
@@ -57767,17 +58594,17 @@ function registerKit(program, context) {
57767
58594
  human: kits.map((each) => `${each.name}\t${each.description}`).join("\n")
57768
58595
  };
57769
58596
  });
57770
- act(addVerb(kit, "add", "Add a kit to a project as a copy under assets/kits/<kit>/, leaving its token sheets alone, so frame kit can set it on a frame. Refuses name-taken where the project already holds a kit by that name").argument("<project>", "the project").argument("[kit]", "a kit `kit list` names").option("--from <folder>", "add the kit in this folder instead").addOption(new Option("--replace").hideHelp()), context, async ([project = "", name], options) => {
58597
+ act(addVerb(kit, "add", "Add a kit to a project as a copy under assets/kits/<kit>/, leaving its token sheets alone, so frame kit can set it on a frame. Refuses name-taken where the project already holds a kit by that name, unless --replace puts this copy in its place").argument("<project>", "the project").argument("[kit]", "a kit `kit list` names").option("--from <folder>", "add the kit in this folder instead").option("--replace", "put this copy in place of a kit the project already holds by that name, dropping its old files and leaving every frame’s kit as it is"), context, async ([project = "", name], options) => {
57771
58598
  if (name === void 0 === (options.from === void 0)) throw new FrameboardError("usage", "Name a kit or pass --from <folder>, not both.");
57772
58599
  const root = await boardOf(options, io);
57773
58600
  const folder = options.from === void 0 ? null : resolve$1(io.cwd, options.from);
57774
58601
  const record = await installKit(root, project, folder === null ? findKit(root, name ?? "") : {
57775
58602
  name: basename(folder),
57776
58603
  path: folder
57777
- });
58604
+ }, { replace: options.replace });
57778
58605
  return {
57779
58606
  data: record,
57780
- human: `Added ${record.kit} to ${record.project}`
58607
+ human: record.replaced ? `Replaced ${record.kit} in ${record.project}` : `Added ${record.kit} to ${record.project}`
57781
58608
  };
57782
58609
  });
57783
58610
  act(addVerb(kit, "remove", "Take a kit out of a project, deleting its folder under assets/kits/ and clearing it from every frame naming it, so each draws with the project’s sheets alone. Refuses kit-not-found for a kit the project holds none under").argument("<project>", "the project").argument("<kit>", "a kit the project holds"), context, async ([project = "", name = ""], options) => {
@@ -58033,11 +58860,11 @@ function describe$1(notes) {
58033
58860
  // src/cli/commands/open.ts
58034
58861
  function registerOpen(program, context) {
58035
58862
  const { io } = context;
58036
- act(addVerb(program, "open", "Open a board tab that can edit, through a single-use link to the running server").option("--no-open", "leave the browser alone and print the link"), context, async (_args, options) => {
58863
+ act(addVerb(program, "open", "Open a board tab that can edit, through a single-use link to the running server").option("--no-open", "leave the browser alone and print the link").option("--ttl <minutes>", `how long the link works, from 1 to 60 minutes, two when left out`, parseTtl), context, async (_args, options) => {
58037
58864
  const root = await boardOf(options, io);
58038
58865
  const live = await findLiveServer(root);
58039
58866
  if (!live) throw new FrameboardError("server-not-running", `No frameboard server is running for ${root}. Run frameboard serve first.`, { root });
58040
- const { url: writeUrl, expiresAt } = await postToBoard(live, "/api/access/ticket", {});
58867
+ const { url: writeUrl, expiresAt } = await postToBoard(live, "/api/access/ticket", { ttl: options.ttl });
58041
58868
  if (options.open) io.openUrl(writeUrl);
58042
58869
  return {
58043
58870
  data: {
@@ -58050,6 +58877,11 @@ function registerOpen(program, context) {
58050
58877
  };
58051
58878
  });
58052
58879
  }
58880
+ function parseTtl(value) {
58881
+ const minutes = parseInteger(1)(value);
58882
+ if (minutes > 60) throw new InvalidArgumentError(`Expected at most 60 minutes.`);
58883
+ return minutes;
58884
+ }
58053
58885
  // src/cli/commands/page.ts
58054
58886
  const PAGE_REF = "a page ref, <page> or <project>/<page>";
58055
58887
  const INDEX = "position in the page order, 0 first, clamped";
@@ -59094,29 +59926,6 @@ async function readKey(path) {
59094
59926
  function cookieName(root) {
59095
59927
  return `frameboard-key-${createHash("sha256").update(root).digest("hex").slice(0, 12)}`;
59096
59928
  }
59097
- // src/server/access/tickets.ts
59098
- const TICKET_TTL_MS = 12e4;
59099
- /** Tickets live in memory only, so a restart voids them and nothing reaches disk. */
59100
- function createTickets(now = Date.now) {
59101
- const expiries = /* @__PURE__ */ new Map();
59102
- return {
59103
- mint: () => {
59104
- for (const [ticket, expiry] of expiries) if (expiry <= now()) expiries.delete(ticket);
59105
- const ticket = randomBytes(16).toString("hex");
59106
- const expiry = now() + TICKET_TTL_MS;
59107
- expiries.set(ticket, expiry);
59108
- return {
59109
- ticket,
59110
- expiresAt: new Date(expiry).toISOString()
59111
- };
59112
- },
59113
- redeem: (ticket) => {
59114
- const expiry = expiries.get(ticket);
59115
- expiries.delete(ticket);
59116
- return expiry !== void 0 && expiry > now();
59117
- }
59118
- };
59119
- }
59120
59929
  // src/server/capture/thumbnails.ts
59121
59930
  const THUMBNAILS_FOLDER = "thumbnails";
59122
59931
  /**
@@ -59292,7 +60101,7 @@ async function landReserved(root, now) {
59292
60101
  for (const { claim, page, name } of due) {
59293
60102
  const layout = layoutAt(layouts, page);
59294
60103
  if (layout.hasEntry(name) || !layout.names.includes(name)) continue;
59295
- const { x, y, width, height, hugWidth, hugHeight } = claim.box;
60104
+ const { x, y, width, height, hugWidth, hugHeight, showDevice } = claim.box;
59296
60105
  layout.set(name, {
59297
60106
  box: {
59298
60107
  x,
@@ -59307,6 +60116,7 @@ async function landReserved(root, now) {
59307
60116
  hugHeight: hugHeight ?? false,
59308
60117
  scroll: false,
59309
60118
  widths: [],
60119
+ ...showDevice ? { showDevice: true } : {},
59310
60120
  placed: true
59311
60121
  });
59312
60122
  layout.renumber();
@@ -59417,6 +60227,159 @@ async function startFrameOrigin(options) {
59417
60227
  })
59418
60228
  };
59419
60229
  }
60230
+ // src/shared/board-sync/patch.ts
60231
+ /** The patch that makes `next` of `held`. */
60232
+ function patchBetween(held, next) {
60233
+ return {
60234
+ ...next,
60235
+ projects: listMoved(held.projects, next.projects, projectPatch)
60236
+ };
60237
+ }
60238
+ function projectPatch(held, next) {
60239
+ return {
60240
+ ...next,
60241
+ pages: listMoved(held?.pages ?? [], next.pages, pagePatch)
60242
+ };
60243
+ }
60244
+ function pagePatch(held, next) {
60245
+ return {
60246
+ ...next,
60247
+ frames: listMoved(held?.frames ?? [], next.frames, (_, frame) => frame)
60248
+ };
60249
+ }
60250
+ function listMoved(held, next, patch) {
60251
+ const byName = namedOf(held);
60252
+ return next.map((record) => {
60253
+ const match = byName.get(record.name);
60254
+ return match !== void 0 && isEqual(match, record) ? record.name : patch(match, record);
60255
+ });
60256
+ }
60257
+ function namedOf(records) {
60258
+ return new Map(records.map((record) => [record.name, record]));
60259
+ }
60260
+ /** Whether two JSON values match on every key, named in their types or not. */
60261
+ function isEqual(a, b) {
60262
+ if (a === b) return true;
60263
+ if (!isObject(a) || !isObject(b)) return false;
60264
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
60265
+ const keys = Object.keys(a);
60266
+ return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && isEqual(a[key], b[key]));
60267
+ }
60268
+ function isObject(value) {
60269
+ return typeof value === "object" && value !== null;
60270
+ }
60271
+ // src/shared/board-sync/rename.ts
60272
+ /**
60273
+ * Whether `board` still waits on a rename, holding `before` and not yet
60274
+ * `after`. Both ends ask it, so a tab and the server's copy of what the tabs
60275
+ * hold take the same renames.
60276
+ */
60277
+ function takesRename(board, before, after) {
60278
+ return holdsRef(board, before) && !holdsRef(board, after);
60279
+ }
60280
+ function holdsRef(board, ref) {
60281
+ return board.projects.some((project) => project.name === ref || project.pages.some((page) => page.ref === ref || page.frames.some((frame) => frame.ref === ref)));
60282
+ }
60283
+ /**
60284
+ * The board with one project, page, or frame renamed, its path and
60285
+ * everything under it following.
60286
+ */
60287
+ function renameOnBoard(board, before, after) {
60288
+ const [project = "", page, frame] = before.split("/");
60289
+ const name = after.split("/").at(-1) ?? after;
60290
+ const repath = (from, to) => (path) => path === from || path.startsWith(`${from}/`) ? `${to}${path.slice(from.length)}` : path;
60291
+ return {
60292
+ ...board,
60293
+ projects: board.projects.map((held) => {
60294
+ if (held.name !== project) return held;
60295
+ if (frame !== void 0) return {
60296
+ ...held,
60297
+ pages: held.pages.map((each) => each.name !== page ? each : {
60298
+ ...each,
60299
+ frames: each.frames.map((one) => one.ref !== before ? one : {
60300
+ ...one,
60301
+ ref: after,
60302
+ name,
60303
+ path: siblingPath(one.path, `${name}.html`)
60304
+ })
60305
+ })
60306
+ };
60307
+ if (page === void 0) {
60308
+ const path = repath(held.path, siblingPath(held.path, name));
60309
+ return {
60310
+ ...held,
60311
+ name,
60312
+ path: path(held.path),
60313
+ pages: held.pages.map((each) => ({
60314
+ ...each,
60315
+ ref: `${name}/${each.name}`,
60316
+ project: name,
60317
+ path: path(each.path),
60318
+ frames: each.frames.map((frame) => ({
60319
+ ...frame,
60320
+ ref: `${name}/${each.name}/${frame.name}`,
60321
+ project: name,
60322
+ path: path(frame.path)
60323
+ }))
60324
+ }))
60325
+ };
60326
+ }
60327
+ return {
60328
+ ...held,
60329
+ pages: held.pages.map((each) => {
60330
+ if (each.name !== page) return each;
60331
+ const path = repath(each.path, siblingPath(each.path, name));
60332
+ return {
60333
+ ...each,
60334
+ ref: after,
60335
+ name,
60336
+ path: path(each.path),
60337
+ frames: each.frames.map((frame) => ({
60338
+ ...frame,
60339
+ ref: `${after}/${frame.name}`,
60340
+ page: name,
60341
+ path: path(frame.path)
60342
+ }))
60343
+ };
60344
+ })
60345
+ };
60346
+ })
60347
+ };
60348
+ }
60349
+ /** The folder path beside `path` named `name`. */
60350
+ function siblingPath(path, name) {
60351
+ return `${path.slice(0, path.lastIndexOf("/") + 1)}${name}`;
60352
+ }
60353
+ // src/server/live/feed.ts
60354
+ /**
60355
+ * Holds the board the tabs hold, which every patch starts from. Each verb
60356
+ * moves it and sends in one synchronous step, so no other crosses between.
60357
+ */
60358
+ function createBoardFeed(hub) {
60359
+ let held = {
60360
+ root: "",
60361
+ projects: []
60362
+ };
60363
+ return {
60364
+ push: (board) => {
60365
+ hub.broadcastBoard(board, patchBetween(held, board));
60366
+ held = board;
60367
+ },
60368
+ rename: (before, after) => {
60369
+ hub.broadcast({
60370
+ type: "renamed",
60371
+ before,
60372
+ after
60373
+ });
60374
+ if (takesRename(held, before, after)) held = renameOnBoard(held, before, after);
60375
+ },
60376
+ join: (board, deliver) => {
60377
+ if (!isEqual(held, board)) hub.broadcastPatch(patchBetween(held, board));
60378
+ held = board;
60379
+ deliver(board);
60380
+ }
60381
+ };
60382
+ }
59420
60383
  // node_modules/readdirp/index.js
59421
60384
  const EntryTypes = {
59422
60385
  FILE_TYPE: "files",
@@ -62774,8 +63737,8 @@ function placedRefs(previous, next, paths, unmeasured = []) {
62774
63737
  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)));
62775
63738
  }
62776
63739
  /**
62777
- * Height-hugging frames whose linked widths changed, measured here, since
62778
- * that write reloads nothing.
63740
+ * Height-hugging frames whose linked widths changed, or the bar each draws
63741
+ * over its page, measured here, since that write reloads nothing.
62779
63742
  */
62780
63743
  function relistedRefs(previous, next) {
62781
63744
  const before = new Map(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.map((frame) => [frame.ref, listed(frame)]))));
@@ -62785,7 +63748,7 @@ function relistedRefs(previous, next) {
62785
63748
  }).map((frame) => frame.ref)));
62786
63749
  }
62787
63750
  function listed(frame) {
62788
- return frame.widths.map(({ width }) => width).join(",");
63751
+ return frame.widths.map(({ width }) => `${width}+${linkedBar(frame, width)}`).join(",");
62789
63752
  }
62790
63753
  /**
62791
63754
  * Frames whose kit changed, reloaded here, since the kit lives in
@@ -62938,11 +63901,20 @@ function checkOne(root, frame, context) {
62938
63901
  * The live socket every board tab holds. An `inbox` client never counts as a
62939
63902
  * tab and needs the bearer token, since a browser page must never register one.
62940
63903
  */
62941
- function createHub({ tabs, port, access, snapshot, findings, notes, delivery, history, claims, changes, closeTab, dispatch = false, framePort }) {
63904
+ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, history, claims, changes, closeTab, dispatch = false, editButton = false, framePort }) {
62942
63905
  const server = new import_websocket_server.default({ noServer: true });
62943
63906
  const boards = /* @__PURE__ */ new Map();
62944
63907
  const inboxes = /* @__PURE__ */ new Map();
62945
63908
  const tabIds = /* @__PURE__ */ new Map();
63909
+ const patching = /* @__PURE__ */ new Set();
63910
+ const joined = /* @__PURE__ */ new Set();
63911
+ const deliver = (socket, board) => {
63912
+ send(socket, {
63913
+ type: "board",
63914
+ data: board
63915
+ });
63916
+ if (patching.has(socket)) joined.add(socket);
63917
+ };
62946
63918
  server.on("connection", (socket, request) => {
62947
63919
  socket.on("message", (data) => {
62948
63920
  const message = parse(String(data));
@@ -62951,7 +63923,11 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
62951
63923
  if (message?.type === "ack") delivery?.ack(inbox, message.id).catch(() => {});
62952
63924
  return;
62953
63925
  }
62954
- if (boards.has(socket) || message?.type !== "hello") return;
63926
+ if (boards.has(socket)) {
63927
+ if (message?.type === "resync" && joined.delete(socket)) snapshot((board) => deliver(socket, board)).catch(() => {});
63928
+ return;
63929
+ }
63930
+ if (message?.type !== "hello") return;
62955
63931
  if (message.role === "inbox") {
62956
63932
  if (!isWriter({ authorization: request.headers.authorization }, access) || !delivery || !message.session) {
62957
63933
  socket.close(1008, "An inbox needs the address token as a bearer.");
@@ -62972,20 +63948,18 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
62972
63948
  }, access);
62973
63949
  boards.set(socket, writer);
62974
63950
  if (typeof message.tab === "string") tabIds.set(socket, message.tab);
63951
+ if (message.patches === true) patching.add(socket);
62975
63952
  tabs.open(writer);
62976
63953
  if (framePort) send(socket, {
62977
63954
  type: "frames",
62978
63955
  port: framePort()
62979
63956
  });
62980
- snapshot().then(async (board) => {
62981
- send(socket, {
62982
- type: "board",
62983
- data: board
62984
- });
63957
+ snapshot((board) => deliver(socket, board)).then(async () => {
62985
63958
  send(socket, {
62986
63959
  type: "access",
62987
63960
  write: writer,
62988
- dispatch: writer && dispatch
63961
+ dispatch: writer && dispatch,
63962
+ ...editButton && !writer ? { editButton: true } : {}
62989
63963
  });
62990
63964
  if (history) send(socket, {
62991
63965
  type: "history",
@@ -63023,6 +63997,8 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
63023
63997
  const writer = boards.get(socket);
63024
63998
  if (writer !== void 0) {
63025
63999
  boards.delete(socket);
64000
+ patching.delete(socket);
64001
+ joined.delete(socket);
63026
64002
  tabs.close(writer);
63027
64003
  }
63028
64004
  const tab = tabIds.get(socket);
@@ -63043,6 +64019,19 @@ function createHub({ tabs, port, access, snapshot, findings, notes, delivery, hi
63043
64019
  broadcast: (message) => {
63044
64020
  for (const socket of boards.keys()) send(socket, message);
63045
64021
  },
64022
+ broadcastBoard: (board, patch) => {
64023
+ for (const socket of boards.keys()) if (joined.has(socket)) send(socket, {
64024
+ type: "patch",
64025
+ data: patch
64026
+ });
64027
+ else deliver(socket, board);
64028
+ },
64029
+ broadcastPatch: (patch) => {
64030
+ for (const socket of joined) send(socket, {
64031
+ type: "patch",
64032
+ data: patch
64033
+ });
64034
+ },
63046
64035
  close: () => {
63047
64036
  for (const socket of server.clients) socket.terminate();
63048
64037
  return new Promise((resolve) => server.close(() => resolve()));
@@ -63192,13 +64181,14 @@ async function measureParts(measure, frame, parts) {
63192
64181
  if (parts !== "own" && frame.hugHeight && frame.widths.length > 0) {
63193
64182
  const widths = [];
63194
64183
  for (const { width } of frame.widths) {
64184
+ const bar = linkedBar(frame, width);
63195
64185
  const linked = await measure(frame, {
63196
64186
  width,
63197
- height: referenceHeight(width)
64187
+ height: referenceHeight(width) - bar
63198
64188
  });
63199
64189
  if (!linked.empty) widths.push({
63200
64190
  width,
63201
- height: linked.height
64191
+ height: linked.height + bar
63202
64192
  });
63203
64193
  }
63204
64194
  if (widths.length > 0) size.widths = widths;
@@ -63303,7 +64293,11 @@ function createFrameKeys(root, { tokens = null, version: version$3 = version } =
63303
64293
  /<(?:iframe|object|embed)\b/i.test(source) ? inPage.frames : null,
63304
64294
  await Promise.all(outside.map((path) => describeFile(join(root, path))))
63305
64295
  ]));
63306
- const drawn = [frame.device ?? null, frame.turn ?? null];
64296
+ const drawn = [
64297
+ frame.device ?? null,
64298
+ frame.showDevice ?? false,
64299
+ frame.turn ?? null
64300
+ ];
63307
64301
  return {
63308
64302
  outside,
63309
64303
  checks,
@@ -63979,7 +64973,7 @@ async function startServer({ strictPort = true, port, ...options }) {
63979
64973
  });
63980
64974
  }
63981
64975
  }
63982
- async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch, pause, dispatch, openRoute }) {
64976
+ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch, pause, dispatch, openRoute, editButton }) {
63983
64977
  const tabs = new BoardTabs();
63984
64978
  const tickets = createTickets();
63985
64979
  let bound = 0;
@@ -64120,11 +65114,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64120
65114
  }];
64121
65115
  }
64122
65116
  const from = side === "after" ? "before" : "after";
64123
- hub.broadcast({
64124
- type: "renamed",
64125
- before: step.renamed[from],
64126
- after: step.renamed[side]
64127
- });
65117
+ feed.rename(step.renamed[from], step.renamed[side]);
64128
65118
  }
64129
65119
  inTurn(() => tracker.own(step));
64130
65120
  });
@@ -64140,9 +65130,10 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64140
65130
  port: boundPort,
64141
65131
  framePort: () => frameOrigin.port,
64142
65132
  access,
64143
- snapshot: () => inTurn(async () => {
64144
- shown.board = await scanBoard(root);
64145
- return shown.board;
65133
+ snapshot: (deliver) => inTurn(async () => {
65134
+ const board = await scanBoard(root);
65135
+ shown.board = board;
65136
+ feed.join(board, deliver);
64146
65137
  }),
64147
65138
  findings: () => inTurn(async () => findings.all()),
64148
65139
  notes: () => inTurn(() => boardView(root)),
@@ -64151,8 +65142,10 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64151
65142
  claims: () => inTurn(() => claims.read()),
64152
65143
  changes: () => inTurn(async () => tracker.log()),
64153
65144
  closeTab: selection.closeTab,
64154
- dispatch: dispatcher !== void 0
65145
+ dispatch: dispatcher !== void 0,
65146
+ editButton
64155
65147
  });
65148
+ const feed = createBoardFeed(hub);
64156
65149
  const claims = createClaimsPush(root, {
64157
65150
  broadcast: (list) => hub.broadcast({
64158
65151
  type: "claims",
@@ -64202,8 +65195,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64202
65195
  box,
64203
65196
  scroll: frame.scroll,
64204
65197
  hugHeight: frame.hugHeight,
64205
- device: box.width === frame.box.width ? frame.device : void 0,
64206
- turn: frame.turn
65198
+ ...viewDevice(frame, box.width)
64207
65199
  },
64208
65200
  config: readConfig(root, frame.project)
64209
65201
  }));
@@ -64255,6 +65247,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64255
65247
  framePort: () => frameOrigin.port,
64256
65248
  tickets,
64257
65249
  openRoute,
65250
+ editButton,
64258
65251
  delivery,
64259
65252
  dispatch: dispatcher,
64260
65253
  history,
@@ -64362,10 +65355,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64362
65355
  latest = await scanBoard(root);
64363
65356
  scanned.unmeasured = placedRefs(scanned.board ?? board, latest, void 0, scanned.unmeasured);
64364
65357
  scanned.board = latest;
64365
- hub.broadcast({
64366
- type: "board",
64367
- data: latest
64368
- });
65358
+ feed.push(latest);
64369
65359
  shown.board = latest;
64370
65360
  const changed = await recheck(latest, stale);
64371
65361
  if (Object.keys(changed).length > 0) hub.broadcast({
@@ -64386,6 +65376,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64386
65376
  if (rest.length === 0) return;
64387
65377
  inTurn(() => pushBatch(root, tokens ?? null, rest, {
64388
65378
  hub,
65379
+ feed,
64389
65380
  recheck,
64390
65381
  rendered,
64391
65382
  delivery,
@@ -64448,7 +65439,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
64448
65439
  * One rescan per batch, pushing the board, then reloads, then findings, then
64449
65440
  * notes, an agent's changes waiting out the grace before the board hears.
64450
65441
  */
64451
- async function pushBatch(root, tokens, paths, { hub, recheck, rendered, delivery, tracker, claims, thumbnails, hug, settleLater, moved, shown, scanned }) {
65442
+ async function pushBatch(root, tokens, paths, { hub, feed, recheck, rendered, delivery, tracker, claims, thumbnails, hug, settleLater, moved, shown, scanned }) {
64452
65443
  let board;
64453
65444
  let own;
64454
65445
  let placed;
@@ -64478,10 +65469,7 @@ async function pushBatch(root, tokens, paths, { hub, recheck, rendered, delivery
64478
65469
  } catch {
64479
65470
  return;
64480
65471
  }
64481
- hub.broadcast({
64482
- type: "board",
64483
- data: board
64484
- });
65472
+ feed.push(board);
64485
65473
  const last = shown.board;
64486
65474
  shown.board = board;
64487
65475
  const refs = [.../* @__PURE__ */ new Set([...reloadRefs(root, paths, board, tokens), ...rekitted])];
@@ -64506,7 +65494,7 @@ async function pushBatch(root, tokens, paths, { hub, recheck, rendered, delivery
64506
65494
  }
64507
65495
  const held = await tracker.update(board, paths, await claims.read());
64508
65496
  if (held.length > 0) settleLater(held);
64509
- const due = recheckRefs(root, paths, board, tokens);
65497
+ const due = [.../* @__PURE__ */ new Set([...recheckRefs(root, paths, board, tokens), ...rekitted])];
64510
65498
  const changed = await recheck(board, due);
64511
65499
  if (Object.keys(changed).length > 0) hub.broadcast({
64512
65500
  type: "findings",
@@ -64635,7 +65623,7 @@ const DEFAULT_PORT = 4173;
64635
65623
  const RECONNECT_WAIT_MS = 1e3;
64636
65624
  function registerServe(program, context) {
64637
65625
  const { io } = context;
64638
- act(addVerb(program, "serve", `Serve the board in a local browser. A note sent to a new session runs the shell command in ${DISPATCH_ENV}, read once at start, with the note in FRAMEBOARD_NOTE, FRAMEBOARD_NOTE_ID, FRAMEBOARD_SESSION, and FRAMEBOARD_ROOT`).option("-p, --port <port>", "port to listen on, falling back to a free one when the default is taken", parsePort, DEFAULT_PORT).option("--no-open", "leave the browser alone").option("--tokens <path>", "a token sheet another tool manages, standing in for the board's tokens.css").addOption(new Option("--open-route", "answer /api/access/open with a fresh edit link per request").default(false).hideHelp()), context, async (_args, options, self) => {
65626
+ act(addVerb(program, "serve", `Serve the board in a local browser. A note sent to a new session runs the shell command in ${DISPATCH_ENV}, read once at start, with the note in FRAMEBOARD_NOTE, FRAMEBOARD_NOTE_ID, FRAMEBOARD_SESSION, and FRAMEBOARD_ROOT`).option("-p, --port <port>", "port to listen on, falling back to a free one when the default is taken", parsePort, DEFAULT_PORT).option("--no-open", "leave the browser alone").option("--tokens <path>", "a token sheet another tool manages, standing in for the board's tokens.css").option("--edit-button", `offer a view-only tab an Edit button. Any program on this machine can then write to the board, send notes to a listening session, start one under ${DISPATCH_ENV}, generate images on the provider keys in the environment, and open the phone link. What it was granted outlives the flag, until .run/board-key.json is deleted and the server restarts. A server already running keeps what it started with`, false).addOption(new Option("--open-route", "answer /api/access/open with a fresh edit link per request").default(false).hideHelp()), context, async (_args, options, self) => {
64639
65627
  const tokens = options.tokens === void 0 ? void 0 : resolve$1(io.cwd, options.tokens);
64640
65628
  if (tokens !== void 0 && !isFile(tokens)) throw new FrameboardError("tokens-not-found", `No token sheet at ${tokens}.`, { tokens });
64641
65629
  const existing = await resolveBoard({
@@ -64673,7 +65661,8 @@ function registerServe(program, context) {
64673
65661
  strictPort: self.getOptionValueSource("port") !== "default",
64674
65662
  openUrl: io.openUrl,
64675
65663
  dispatch: dispatchCommand(io.cwd),
64676
- openRoute: options.openRoute
65664
+ openRoute: options.openRoute,
65665
+ editButton: options.editButton
64677
65666
  });
64678
65667
  const address = newAddress({
64679
65668
  root,