frameboard 0.14.0 → 0.16.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.
Files changed (90) hide show
  1. package/README.md +32 -100
  2. package/dist/cli.js +313 -65
  3. package/dist/client/assets/index-Dg25rx_8.js +110 -0
  4. package/dist/client/assets/index-EciSUFrP.css +2 -0
  5. package/dist/client/index.html +2 -2
  6. package/dist/faces/inter/LICENSE +93 -0
  7. package/dist/faces/inter/files/inter-cyrillic-ext-opsz-italic.woff2 +0 -0
  8. package/dist/faces/inter/files/inter-cyrillic-ext-opsz-normal.woff2 +0 -0
  9. package/dist/faces/inter/files/inter-cyrillic-ext-standard-italic.woff2 +0 -0
  10. package/dist/faces/inter/files/inter-cyrillic-ext-standard-normal.woff2 +0 -0
  11. package/dist/faces/inter/files/inter-cyrillic-ext-wght-italic.woff2 +0 -0
  12. package/dist/faces/inter/files/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  13. package/dist/faces/inter/files/inter-cyrillic-opsz-italic.woff2 +0 -0
  14. package/dist/faces/inter/files/inter-cyrillic-opsz-normal.woff2 +0 -0
  15. package/dist/faces/inter/files/inter-cyrillic-standard-italic.woff2 +0 -0
  16. package/dist/faces/inter/files/inter-cyrillic-standard-normal.woff2 +0 -0
  17. package/dist/faces/inter/files/inter-cyrillic-wght-italic.woff2 +0 -0
  18. package/dist/faces/inter/files/inter-cyrillic-wght-normal.woff2 +0 -0
  19. package/dist/faces/inter/files/inter-greek-ext-opsz-italic.woff2 +0 -0
  20. package/dist/faces/inter/files/inter-greek-ext-opsz-normal.woff2 +0 -0
  21. package/dist/faces/inter/files/inter-greek-ext-standard-italic.woff2 +0 -0
  22. package/dist/faces/inter/files/inter-greek-ext-standard-normal.woff2 +0 -0
  23. package/dist/faces/inter/files/inter-greek-ext-wght-italic.woff2 +0 -0
  24. package/dist/faces/inter/files/inter-greek-ext-wght-normal.woff2 +0 -0
  25. package/dist/faces/inter/files/inter-greek-opsz-italic.woff2 +0 -0
  26. package/dist/faces/inter/files/inter-greek-opsz-normal.woff2 +0 -0
  27. package/dist/faces/inter/files/inter-greek-standard-italic.woff2 +0 -0
  28. package/dist/faces/inter/files/inter-greek-standard-normal.woff2 +0 -0
  29. package/dist/faces/inter/files/inter-greek-wght-italic.woff2 +0 -0
  30. package/dist/faces/inter/files/inter-greek-wght-normal.woff2 +0 -0
  31. package/dist/faces/inter/files/inter-latin-ext-opsz-italic.woff2 +0 -0
  32. package/dist/faces/inter/files/inter-latin-ext-opsz-normal.woff2 +0 -0
  33. package/dist/faces/inter/files/inter-latin-ext-standard-italic.woff2 +0 -0
  34. package/dist/faces/inter/files/inter-latin-ext-standard-normal.woff2 +0 -0
  35. package/dist/faces/inter/files/inter-latin-ext-wght-italic.woff2 +0 -0
  36. package/dist/faces/inter/files/inter-latin-ext-wght-normal.woff2 +0 -0
  37. package/dist/faces/inter/files/inter-latin-opsz-italic.woff2 +0 -0
  38. package/dist/faces/inter/files/inter-latin-opsz-normal.woff2 +0 -0
  39. package/dist/faces/inter/files/inter-latin-standard-italic.woff2 +0 -0
  40. package/dist/faces/inter/files/inter-latin-standard-normal.woff2 +0 -0
  41. package/dist/faces/inter/files/inter-latin-wght-italic.woff2 +0 -0
  42. package/dist/faces/inter/files/inter-latin-wght-normal.woff2 +0 -0
  43. package/dist/faces/inter/files/inter-vietnamese-opsz-italic.woff2 +0 -0
  44. package/dist/faces/inter/files/inter-vietnamese-opsz-normal.woff2 +0 -0
  45. package/dist/faces/inter/files/inter-vietnamese-standard-italic.woff2 +0 -0
  46. package/dist/faces/inter/files/inter-vietnamese-standard-normal.woff2 +0 -0
  47. package/dist/faces/inter/files/inter-vietnamese-wght-italic.woff2 +0 -0
  48. package/dist/faces/inter/files/inter-vietnamese-wght-normal.woff2 +0 -0
  49. package/dist/faces/inter/index.css +69 -0
  50. package/dist/faces/source-serif-4/LICENSE +93 -0
  51. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-ext-opsz-italic.woff2 +0 -0
  52. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-ext-opsz-normal.woff2 +0 -0
  53. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-ext-standard-italic.woff2 +0 -0
  54. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-ext-standard-normal.woff2 +0 -0
  55. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-ext-wght-italic.woff2 +0 -0
  56. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-ext-wght-normal.woff2 +0 -0
  57. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-opsz-italic.woff2 +0 -0
  58. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-opsz-normal.woff2 +0 -0
  59. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-standard-italic.woff2 +0 -0
  60. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-standard-normal.woff2 +0 -0
  61. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-wght-italic.woff2 +0 -0
  62. package/dist/faces/source-serif-4/files/source-serif-4-cyrillic-wght-normal.woff2 +0 -0
  63. package/dist/faces/source-serif-4/files/source-serif-4-greek-opsz-italic.woff2 +0 -0
  64. package/dist/faces/source-serif-4/files/source-serif-4-greek-opsz-normal.woff2 +0 -0
  65. package/dist/faces/source-serif-4/files/source-serif-4-greek-standard-italic.woff2 +0 -0
  66. package/dist/faces/source-serif-4/files/source-serif-4-greek-standard-normal.woff2 +0 -0
  67. package/dist/faces/source-serif-4/files/source-serif-4-greek-wght-italic.woff2 +0 -0
  68. package/dist/faces/source-serif-4/files/source-serif-4-greek-wght-normal.woff2 +0 -0
  69. package/dist/faces/source-serif-4/files/source-serif-4-latin-ext-opsz-italic.woff2 +0 -0
  70. package/dist/faces/source-serif-4/files/source-serif-4-latin-ext-opsz-normal.woff2 +0 -0
  71. package/dist/faces/source-serif-4/files/source-serif-4-latin-ext-standard-italic.woff2 +0 -0
  72. package/dist/faces/source-serif-4/files/source-serif-4-latin-ext-standard-normal.woff2 +0 -0
  73. package/dist/faces/source-serif-4/files/source-serif-4-latin-ext-wght-italic.woff2 +0 -0
  74. package/dist/faces/source-serif-4/files/source-serif-4-latin-ext-wght-normal.woff2 +0 -0
  75. package/dist/faces/source-serif-4/files/source-serif-4-latin-opsz-italic.woff2 +0 -0
  76. package/dist/faces/source-serif-4/files/source-serif-4-latin-opsz-normal.woff2 +0 -0
  77. package/dist/faces/source-serif-4/files/source-serif-4-latin-standard-italic.woff2 +0 -0
  78. package/dist/faces/source-serif-4/files/source-serif-4-latin-standard-normal.woff2 +0 -0
  79. package/dist/faces/source-serif-4/files/source-serif-4-latin-wght-italic.woff2 +0 -0
  80. package/dist/faces/source-serif-4/files/source-serif-4-latin-wght-normal.woff2 +0 -0
  81. package/dist/faces/source-serif-4/files/source-serif-4-vietnamese-opsz-italic.woff2 +0 -0
  82. package/dist/faces/source-serif-4/files/source-serif-4-vietnamese-opsz-normal.woff2 +0 -0
  83. package/dist/faces/source-serif-4/files/source-serif-4-vietnamese-standard-italic.woff2 +0 -0
  84. package/dist/faces/source-serif-4/files/source-serif-4-vietnamese-standard-normal.woff2 +0 -0
  85. package/dist/faces/source-serif-4/files/source-serif-4-vietnamese-wght-italic.woff2 +0 -0
  86. package/dist/faces/source-serif-4/files/source-serif-4-vietnamese-wght-normal.woff2 +0 -0
  87. package/dist/faces/source-serif-4/index.css +59 -0
  88. package/package.json +5 -3
  89. package/dist/client/assets/index-D6XyJYZH.css +0 -2
  90. package/dist/client/assets/index-RAnQsb-L.js +0 -110
package/dist/cli.js CHANGED
@@ -9031,7 +9031,88 @@ const FRAME_SIZES = {
9031
9031
  height: 900
9032
9032
  }
9033
9033
  };
9034
+ /**
9035
+ * The devices the Frame tool and `--size` offer beside the three presets.
9036
+ * The iPad Pro 11 and a 1440 desktop are the tablet and desktop presets, so
9037
+ * neither repeats here.
9038
+ */
9039
+ const DEVICE_SIZES = [
9040
+ {
9041
+ name: "small-phone",
9042
+ label: "Small phone",
9043
+ group: "phone",
9044
+ width: 375,
9045
+ height: 667
9046
+ },
9047
+ {
9048
+ name: "iphone-16",
9049
+ label: "iPhone 16",
9050
+ group: "phone",
9051
+ width: 393,
9052
+ height: 852
9053
+ },
9054
+ {
9055
+ name: "android",
9056
+ label: "Android",
9057
+ group: "phone",
9058
+ width: 412,
9059
+ height: 917
9060
+ },
9061
+ {
9062
+ name: "iphone-16-pro-max",
9063
+ label: "iPhone 16 Pro Max",
9064
+ group: "phone",
9065
+ width: 440,
9066
+ height: 956
9067
+ },
9068
+ {
9069
+ name: "ipad-mini",
9070
+ label: "iPad mini",
9071
+ group: "tablet",
9072
+ width: 744,
9073
+ height: 1133
9074
+ },
9075
+ {
9076
+ name: "ipad-pro-12-9",
9077
+ label: "iPad Pro 12.9",
9078
+ group: "tablet",
9079
+ width: 1024,
9080
+ height: 1366
9081
+ },
9082
+ {
9083
+ name: "macbook-air",
9084
+ label: "MacBook Air",
9085
+ group: "desktop",
9086
+ width: 1280,
9087
+ height: 832
9088
+ },
9089
+ {
9090
+ name: "full-hd",
9091
+ label: "Full HD",
9092
+ group: "desktop",
9093
+ width: 1920,
9094
+ height: 1080
9095
+ }
9096
+ ];
9097
+ /** Every size name, the three presets first, then the devices. */
9098
+ const FRAME_SIZE_NAMES = [
9099
+ "phone",
9100
+ "tablet",
9101
+ "desktop",
9102
+ ...DEVICE_SIZES.map((device) => device.name)
9103
+ ];
9034
9104
  const DEFAULT_FRAME_SIZE = "desktop";
9105
+ function isFrameSizePreset(value) {
9106
+ return Object.hasOwn(FRAME_SIZES, value);
9107
+ }
9108
+ /** The width and height a size name stands for. */
9109
+ function frameSizeOf(name) {
9110
+ const { width, height } = isFrameSizePreset(name) ? FRAME_SIZES[name] : DEVICE_SIZES.find((device) => device.name === name) ?? FRAME_SIZES["desktop"];
9111
+ return {
9112
+ width,
9113
+ height
9114
+ };
9115
+ }
9035
9116
  // src/shared/records/board.ts
9036
9117
  const boardFileSchema = looseObject({ version: literal(1) });
9037
9118
  /** A project's own check rules, absent meaning the built-in rules alone. */
@@ -9173,7 +9254,8 @@ function placeFrames(frames, names) {
9173
9254
  /**
9174
9255
  * Where a frame with no layout entry sits: desktop size at `y` 0, 80 past the
9175
9256
  * right edge of every frame already placed, on top of all of them. The board
9176
- * draws what the scanner returns, and `frame add` persists the same box.
9257
+ * draws what the scanner returns, and `frame add` persists the same box for
9258
+ * the first unplaced file, placing any other past the placed frames alone.
9177
9259
  */
9178
9260
  function placeNext(placed) {
9179
9261
  const right = Math.max(...placed.map(({ box }) => box.x + box.width + 80), 0);
@@ -9333,7 +9415,7 @@ async function isDirectory(path) {
9333
9415
  }
9334
9416
  }
9335
9417
  // package.json
9336
- var version$1 = "0.14.0";
9418
+ var version$1 = "0.16.0";
9337
9419
  var dependencies = { "playwright-core": "1.64.1" };
9338
9420
  // src/shared/version.ts
9339
9421
  const version = version$1;
@@ -9589,8 +9671,9 @@ async function framePathParts(root, ref, cwd) {
9589
9671
  // src/server/board/frames.ts
9590
9672
  /**
9591
9673
  * Places a frame on its page, writing a skeleton file only when none exists.
9592
- * A file with no entry keeps its bytes and takes the box `list` showed for it
9593
- * unless a size or position is given. Every axis no size names hugs its
9674
+ * A file with no entry keeps its bytes and lands 80 past the placed frames,
9675
+ * as `placeNext` puts it, ignoring the page's other unplaced files, unless a
9676
+ * size or position is given. Every axis no size names hugs its
9594
9677
  * content, a preset fixing the width alone, and the box stands in until the
9595
9678
  * server measures.
9596
9679
  */
@@ -9607,7 +9690,8 @@ async function addFrame(root, ref, options) {
9607
9690
  const exists = existsSync(frame.path);
9608
9691
  if (exists && layout.hasEntry(frame.name)) throw new FrameboardError("name-taken", `${frame.project}/${frame.page}/${frame.name} is already a placed frame.`, { ref: refOf(frame) });
9609
9692
  const names = exists ? layout.names : [...layout.names, frame.name].sort();
9610
- const computed = placeFrames(layout.file.frames, names).get(frame.name);
9693
+ const slot = names.filter((name) => name === frame.name || layout.hasEntry(name));
9694
+ const computed = placeFrames(layout.file.frames, slot).get(frame.name);
9611
9695
  if (!computed) throw new Error(`No placement computed for ${frame.name}.`);
9612
9696
  if (!exists) {
9613
9697
  await writeFile(frame.path, skeleton(frame.name), { flag: "wx" });
@@ -9900,7 +9984,7 @@ function sizeOf({ size, width, height }) {
9900
9984
  width,
9901
9985
  height
9902
9986
  });
9903
- if (size !== void 0) return { ...FRAME_SIZES[size] };
9987
+ if (size !== void 0) return frameSizeOf(size);
9904
9988
  return {
9905
9989
  ...width === void 0 ? {} : { width },
9906
9990
  ...height === void 0 ? {} : { height }
@@ -28948,6 +29032,79 @@ function applyEdit(source, address, change) {
28948
29032
  span
28949
29033
  };
28950
29034
  }
29035
+ // src/shared/faces.ts
29036
+ const FACES = [
29037
+ {
29038
+ family: "Geist",
29039
+ package: "@fontsource-variable/geist",
29040
+ packageFamily: "Geist Variable",
29041
+ folder: "geist",
29042
+ weights: {
29043
+ min: 100,
29044
+ max: 900
29045
+ },
29046
+ fallback: "sans-serif",
29047
+ startsLook: true
29048
+ },
29049
+ {
29050
+ family: "Geist Mono",
29051
+ package: "@fontsource-variable/geist-mono",
29052
+ packageFamily: "Geist Mono Variable",
29053
+ folder: "geist-mono",
29054
+ weights: {
29055
+ min: 100,
29056
+ max: 900
29057
+ },
29058
+ fallback: "monospace",
29059
+ startsLook: true
29060
+ },
29061
+ {
29062
+ family: "Inter",
29063
+ package: "@fontsource-variable/inter",
29064
+ packageFamily: "Inter Variable",
29065
+ folder: "inter",
29066
+ weights: {
29067
+ min: 100,
29068
+ max: 900
29069
+ },
29070
+ fallback: "sans-serif",
29071
+ startsLook: true
29072
+ },
29073
+ {
29074
+ family: "Source Serif 4",
29075
+ package: "@fontsource-variable/source-serif-4",
29076
+ packageFamily: "Source Serif 4 Variable",
29077
+ folder: "source-serif-4",
29078
+ weights: {
29079
+ min: 200,
29080
+ max: 900
29081
+ },
29082
+ fallback: "serif",
29083
+ startsLook: true
29084
+ },
29085
+ {
29086
+ family: "Caveat",
29087
+ package: "@fontsource-variable/caveat",
29088
+ packageFamily: "Caveat Variable",
29089
+ folder: "caveat",
29090
+ weights: {
29091
+ min: 400,
29092
+ max: 700
29093
+ },
29094
+ fallback: "cursive",
29095
+ startsLook: false
29096
+ }
29097
+ ];
29098
+ /** Where the server serves the faces folder. */
29099
+ const FACES_URL = "/frameboard/faces";
29100
+ /** The sheet a frame imports to get one face. */
29101
+ function faceSheetUrl(face) {
29102
+ return `${FACES_URL}/${face.folder}/index.css`;
29103
+ }
29104
+ /** The stack naming a face then its fallback, as `'Geist Mono', monospace`. */
29105
+ function faceStack(face) {
29106
+ return `${/\s/.test(face.family) ? `'${face.family}'` : face.family}, ${face.fallback}`;
29107
+ }
28951
29108
  // src/shared/starter-tokens.ts
28952
29109
  /**
28953
29110
  * The looks a new project can start from, each accent paired by hand with a
@@ -28977,16 +29134,10 @@ const STARTER_ACCENTS = {
28977
29134
  }
28978
29135
  };
28979
29136
  /** The served faces a starter sheet may name, keyed by their face folder. */
28980
- const STARTER_FONTS = {
28981
- geist: {
28982
- family: "Geist",
28983
- stack: "Geist, sans-serif"
28984
- },
28985
- "geist-mono": {
28986
- family: "Geist Mono",
28987
- stack: "'Geist Mono', monospace"
28988
- }
28989
- };
29137
+ const STARTER_FONTS = Object.fromEntries(FACES.filter((face) => face.startsLook).map((face) => [face.folder, {
29138
+ family: face.family,
29139
+ stack: faceStack(face)
29140
+ }]));
28990
29141
  const DEFAULT_LOOK = {
28991
29142
  accent: "blue",
28992
29143
  font: "geist"
@@ -35034,7 +35185,9 @@ const PROPERTIES = /* @__PURE__ */ new Set([
35034
35185
  "border-color",
35035
35186
  "border-width",
35036
35187
  "border",
35037
- "box-shadow"
35188
+ "box-shadow",
35189
+ "font-family",
35190
+ "font"
35038
35191
  ]);
35039
35192
  /** The colors Selection colors lists, each a property every element may set. */
35040
35193
  const COLOR_PROPERTIES = [
@@ -35103,12 +35256,18 @@ function frameStyles(source, tokens, index) {
35103
35256
  const part = found.shorthand ? shorthandPart(found.value, property) : found.value;
35104
35257
  return part === null ? null : styleValue(part);
35105
35258
  };
35259
+ const family = (element) => {
35260
+ const found = cascade.specified(element, "font-family");
35261
+ if (!found || found.userAgent || found.shorthand) return null;
35262
+ return styleValue(found.value);
35263
+ };
35106
35264
  const element = target ? {
35107
35265
  color: read(target, "color"),
35108
35266
  backgroundColor: read(target, "background-color"),
35109
35267
  borderColor: read(target, "border-color"),
35110
35268
  borderWidth: read(target, "border-width"),
35111
- boxShadow: read(target, "box-shadow")
35269
+ boxShadow: read(target, "box-shadow"),
35270
+ fontFamily: family(target)
35112
35271
  } : null;
35113
35272
  const root = target ?? source.elements.find((candidate) => candidate.name === "body");
35114
35273
  const subtree = root ? source.elements.filter((candidate) => within(candidate, root)) : source.elements;
@@ -35473,33 +35632,6 @@ function historyRoutes(access, history) {
35473
35632
  app.onError(answerRefusal);
35474
35633
  return app;
35475
35634
  }
35476
- // src/shared/faces.ts
35477
- const FACES = [
35478
- {
35479
- family: "Geist",
35480
- package: "@fontsource-variable/geist",
35481
- packageFamily: "Geist Variable",
35482
- folder: "geist"
35483
- },
35484
- {
35485
- family: "Geist Mono",
35486
- package: "@fontsource-variable/geist-mono",
35487
- packageFamily: "Geist Mono Variable",
35488
- folder: "geist-mono"
35489
- },
35490
- {
35491
- family: "Caveat",
35492
- package: "@fontsource-variable/caveat",
35493
- packageFamily: "Caveat Variable",
35494
- folder: "caveat"
35495
- }
35496
- ];
35497
- /** Where the server serves the faces folder. */
35498
- const FACES_URL = "/frameboard/faces";
35499
- /** The sheet a frame imports to get one face. */
35500
- function faceSheetUrl(face) {
35501
- return `${FACES_URL}/${face.folder}/index.css`;
35502
- }
35503
35635
  // src/shared/board-urls.ts
35504
35636
  /** Where the server serves a frame's file, with each name encoded as its own segment. */
35505
35637
  function frameUrl(ref) {
@@ -36853,7 +36985,7 @@ const refs = array$1(ref).min(1).max(1e3);
36853
36985
  const coordinate = int$1();
36854
36986
  const frameAddSchema = object$1({
36855
36987
  ref,
36856
- size: _enum$1(Object.keys(FRAME_SIZES)).optional(),
36988
+ size: _enum$1(FRAME_SIZE_NAMES).optional(),
36857
36989
  width: int$1().min(1).optional(),
36858
36990
  height: int$1().min(1).optional(),
36859
36991
  x: coordinate.optional(),
@@ -38753,10 +38885,45 @@ function readContentSize() {
38753
38885
  for (let parent = element.parentElement; parent && parent !== document.body; parent = parent.parentElement) if (crops(parent)) return true;
38754
38886
  return false;
38755
38887
  };
38888
+ const hangOf = (lineHeight, height) => lineHeight < height ? (height - lineHeight) / 2 : 0;
38889
+ const textBottom = (element) => {
38890
+ let bottom = -Infinity;
38891
+ if (crops(element)) return bottom;
38892
+ const lineHeight = parseFloat(getComputedStyle(element).lineHeight);
38893
+ for (const child of element.childNodes) {
38894
+ if (child.nodeType !== Node.TEXT_NODE) continue;
38895
+ const range = document.createRange();
38896
+ range.selectNodeContents(child);
38897
+ for (const rect of range.getClientRects()) {
38898
+ if (rect.width === 0 && rect.height === 0) continue;
38899
+ bottom = Math.max(bottom, rect.bottom - hangOf(lineHeight, rect.height));
38900
+ }
38901
+ }
38902
+ return bottom;
38903
+ };
38904
+ const replaced = [
38905
+ "img",
38906
+ "video",
38907
+ "canvas",
38908
+ "iframe",
38909
+ "object",
38910
+ "embed",
38911
+ "audio"
38912
+ ];
38913
+ const ownBottom = (element) => {
38914
+ const rect = element.getBoundingClientRect();
38915
+ if (element.namespaceURI !== "http://www.w3.org/1999/xhtml") return rect.bottom;
38916
+ if (replaced.includes(element.localName)) return rect.bottom;
38917
+ const style = getComputedStyle(element);
38918
+ if (style.display !== "inline") return rect.bottom;
38919
+ if (parseFloat(style.paddingBottom) + parseFloat(style.borderBottomWidth) > 0) return rect.bottom;
38920
+ const above = parseFloat(style.paddingTop) + parseFloat(style.borderTopWidth);
38921
+ return rect.bottom - hangOf(parseFloat(style.lineHeight), rect.height - above);
38922
+ };
38756
38923
  let bottom = root.getBoundingClientRect().bottom;
38757
38924
  for (const element of document.querySelectorAll("body *")) {
38758
38925
  if (isCropped(element)) continue;
38759
- bottom = Math.max(bottom, element.getBoundingClientRect().bottom);
38926
+ bottom = Math.max(bottom, ownBottom(element), textBottom(element));
38760
38927
  }
38761
38928
  return {
38762
38929
  height: Math.max(1, Math.ceil(bottom + window.scrollY)),
@@ -38881,6 +39048,48 @@ function readLayout() {
38881
39048
  for (let parent = element.parentElement; parent && parent !== document.body; parent = parent.parentElement) if (crops(parent)) return true;
38882
39049
  return false;
38883
39050
  };
39051
+ const hangOf = (lineHeight, height) => lineHeight < height ? (height - lineHeight) / 2 : 0;
39052
+ const textReach = (element) => {
39053
+ let bottom = -Infinity;
39054
+ let right = -Infinity;
39055
+ if (crops(element)) return {
39056
+ bottom,
39057
+ right
39058
+ };
39059
+ const lineHeight = parseFloat(getComputedStyle(element).lineHeight);
39060
+ for (const child of element.childNodes) {
39061
+ if (child.nodeType !== Node.TEXT_NODE) continue;
39062
+ const range = document.createRange();
39063
+ range.selectNodeContents(child);
39064
+ for (const rect of range.getClientRects()) {
39065
+ if (rect.width === 0 && rect.height === 0) continue;
39066
+ bottom = Math.max(bottom, rect.bottom - hangOf(lineHeight, rect.height));
39067
+ right = Math.max(right, rect.right);
39068
+ }
39069
+ }
39070
+ return {
39071
+ bottom,
39072
+ right
39073
+ };
39074
+ };
39075
+ const replaced = [
39076
+ "img",
39077
+ "video",
39078
+ "canvas",
39079
+ "iframe",
39080
+ "object",
39081
+ "embed",
39082
+ "audio"
39083
+ ];
39084
+ const ownBottom = (element, rect) => {
39085
+ if (element.namespaceURI !== "http://www.w3.org/1999/xhtml") return rect.bottom;
39086
+ if (replaced.includes(element.localName)) return rect.bottom;
39087
+ const style = getComputedStyle(element);
39088
+ if (style.display !== "inline") return rect.bottom;
39089
+ if (parseFloat(style.paddingBottom) + parseFloat(style.borderBottomWidth) > 0) return rect.bottom;
39090
+ const above = parseFloat(style.paddingTop) + parseFloat(style.borderTopWidth);
39091
+ return rect.bottom - hangOf(parseFloat(style.lineHeight), rect.height - above);
39092
+ };
38884
39093
  const rootRect = root.getBoundingClientRect();
38885
39094
  let index = 0;
38886
39095
  for (const node of document.querySelectorAll("*")) {
@@ -38890,13 +39099,14 @@ function readLayout() {
38890
39099
  if (!(node instanceof HTMLElement || node instanceof SVGElement)) continue;
38891
39100
  if (node === root || node === document.body || !document.body.contains(node)) continue;
38892
39101
  const rect = node.getBoundingClientRect();
38893
- if (rect.width === 0 && rect.height === 0) continue;
39102
+ const text = textReach(node);
39103
+ if (rect.width === 0 && rect.height === 0 && text.right === -Infinity) continue;
38894
39104
  const tag = node.tagName.toLowerCase();
38895
39105
  boxes.push({
38896
39106
  index: own,
38897
39107
  tag,
38898
- bottom: Math.ceil(rect.bottom + window.scrollY),
38899
- right: Math.ceil(rect.right + window.scrollX),
39108
+ bottom: Math.ceil(Math.max(ownBottom(node, rect), text.bottom) + window.scrollY),
39109
+ right: Math.ceil(Math.max(rect.right, text.right) + window.scrollX),
38900
39110
  height: Math.round(rect.height),
38901
39111
  cropped: isCropped(node)
38902
39112
  });
@@ -39457,13 +39667,15 @@ const styleValueSchema = object$1({
39457
39667
  /** The percent a `color-mix()` over the token or a raw hex's alpha keeps, 100 otherwise. */
39458
39668
  percent: number().min(0).max(100)
39459
39669
  });
39460
- /** The selected element's colors, border, and shadow, each null when no author rule sets it. */
39670
+ /** The selected element's colors, border, shadow, and font family, each null when no author rule sets it. */
39461
39671
  const elementStylesSchema = object$1({
39462
39672
  color: styleValueSchema.nullable(),
39463
39673
  backgroundColor: styleValueSchema.nullable(),
39464
39674
  borderColor: styleValueSchema.nullable(),
39465
39675
  borderWidth: styleValueSchema.nullable(),
39466
- boxShadow: styleValueSchema.nullable()
39676
+ boxShadow: styleValueSchema.nullable(),
39677
+ /** The family as written, inherited from an ancestor when the element states none, null for one a `font` shorthand sets. */
39678
+ fontFamily: styleValueSchema.nullable()
39467
39679
  });
39468
39680
  object$1({
39469
39681
  ref: string$1(),
@@ -39604,15 +39816,15 @@ function contentFormat() {
39604
39816
  reservedPageNames: [...RESERVED_PAGE_NAMES],
39605
39817
  collision: "Two names collide when they match case-insensitively. A verb choosing a name itself takes the first free -2, -3, and onward."
39606
39818
  },
39607
- frameSizes: FRAME_SIZES,
39819
+ frameSizes: Object.fromEntries(FRAME_SIZE_NAMES.map((name) => [name, frameSizeOf(name)])),
39608
39820
  defaultFrameSize: DEFAULT_FRAME_SIZE,
39609
39821
  layout: [
39610
39822
  "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.",
39611
39823
  "hidden, locked, hugWidth, and hugHeight read as false when absent, and an axis whose hug flag is false holds the size its entry states.",
39612
- `An axis that hugs takes its size from the frame's content: a running serve measures it after each write to the frame file, 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.`,
39824
+ `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.`,
39613
39825
  "frame add with no size hugs both axes, --size or --width fixes the width and hugs the height, and --height fixes the height alone, its box standing in until serve measures. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
39614
39826
  "Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
39615
- `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, and frame add persists that box.`,
39827
+ `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.`,
39616
39828
  "An entry with no frame file beside it is ignored on read and kept on write.",
39617
39829
  `A ${LAYOUT_FILE} that does not parse is reported by list and refused by every verb writing that page, never overwritten.`,
39618
39830
  `Moving or resizing a frame writes ${LAYOUT_FILE} alone and never the frame file.`
@@ -39860,7 +40072,7 @@ function registerFrame(program, context) {
39860
40072
  const { io } = context;
39861
40073
  const frame = program.command("frame").description("Manage frames");
39862
40074
  const verb = (name, description) => addVerb(frame, name, description, { project: true }).argument("<frame-ref>", FRAME_REF);
39863
- const withSize = (command) => command.addOption(new Option("--size <preset>", "a size preset").choices(Object.keys(FRAME_SIZES))).option("--width <n>", "width in px", parseInteger(1)).option("--height <n>", "height in px", parseInteger(1));
40075
+ const withSize = (command) => command.addOption(new Option("--size <preset>", "a size preset or device").choices(FRAME_SIZE_NAMES)).option("--width <n>", "width in px", parseInteger(1)).option("--height <n>", "height in px", parseInteger(1));
39864
40076
  const withPosition = (command) => command.option("--x <n>", "board x in px", ANY_INTEGER).option("--y <n>", "board y in px", ANY_INTEGER);
39865
40077
  const done = (record, what) => ({
39866
40078
  data: record,
@@ -48243,6 +48455,20 @@ function frameNameOf(name) {
48243
48455
  const temp = name.lastIndexOf(`${FRAME_EXTENSION}.`);
48244
48456
  return temp > 0 ? name.slice(0, temp) : null;
48245
48457
  }
48458
+ /**
48459
+ * The hugging frames `next` holds placed that `previous` held unplaced or
48460
+ * not at all, on a page whose `layout.json` is among `paths`, as one an
48461
+ * agent wrote and then placed. Placing writes `layout.json` alone, which
48462
+ * reloads nothing, so these are measured without a reload. A frame that only
48463
+ * moved was placed in both, and one a folder rename carried has a new ref
48464
+ * but a batch naming the folder alone, so both are left out. Given no
48465
+ * `paths`, as for two scans of one batch, every page is read.
48466
+ */
48467
+ function placedRefs(previous, next, paths) {
48468
+ const written = paths && new Set(paths);
48469
+ const before = new Set(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => frame.placed).map((frame) => frame.ref))));
48470
+ 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)));
48471
+ }
48246
48472
  // src/server/live/findings.ts
48247
48473
  /**
48248
48474
  * The board's check findings, held between batches so a hello needs no
@@ -48494,14 +48720,17 @@ function createHug({ root, measure }) {
48494
48720
  if (size.empty) continue;
48495
48721
  stale ||= frame.hugWidth && size.width !== frame.box.width || frame.hugHeight && size.height !== frame.box.height;
48496
48722
  const page = `${frame.project}/${frame.page}`;
48497
- pages.set(page, {
48498
- ...pages.get(page),
48499
- [frame.name]: size
48500
- });
48723
+ pages.set(page, [...pages.get(page) ?? [], {
48724
+ frame,
48725
+ size
48726
+ }]);
48501
48727
  }
48502
48728
  let written = false;
48503
- for (const [page, sizes] of pages) {
48729
+ for (const [page, measured] of pages) {
48504
48730
  if (closed) break;
48731
+ const unchanged = await Promise.all(measured.map(({ frame }) => unchangedSince(frame)));
48732
+ const sizes = Object.fromEntries(measured.filter((_, index) => unchanged[index]).map(({ frame, size }) => [frame.name, size]));
48733
+ if (Object.keys(sizes).length === 0) continue;
48505
48734
  try {
48506
48735
  const names = await setMeasured(root, page, sizes, { cwd: root });
48507
48736
  written ||= names.length > 0;
@@ -48540,6 +48769,9 @@ async function writtenSinceLayout(board) {
48540
48769
  return hugging.filter((frame) => Date.parse(frame.modifiedAt) > layout).map((frame) => frame.ref);
48541
48770
  }))).flat();
48542
48771
  }
48772
+ async function unchangedSince(frame) {
48773
+ return new Date(await mtimeOf(frame.path)).toISOString() === frame.modifiedAt;
48774
+ }
48543
48775
  async function mtimeOf(path) {
48544
48776
  try {
48545
48777
  return (await stat(path)).mtimeMs;
@@ -48871,6 +49103,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
48871
49103
  settling.add(timer);
48872
49104
  };
48873
49105
  const shown = { board: null };
49106
+ const scanned = { board: null };
48874
49107
  let moved = [];
48875
49108
  const recentlyMoved = () => {
48876
49109
  moved = moved.filter(({ at }) => Date.now() - at < MOVED_MS);
@@ -49045,6 +49278,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
49045
49278
  let board = await scanBoard(root);
49046
49279
  const stale = await writtenSinceLayout(board).catch(() => []);
49047
49280
  if (await hug.now(board, stale).catch(() => false)) board = await scanBoard(root);
49281
+ scanned.board = board;
49048
49282
  await tracker.prime(board);
49049
49283
  findings.update(board, "all");
49050
49284
  rendered.queue(board, []);
@@ -49067,7 +49301,8 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
49067
49301
  hug,
49068
49302
  settleLater,
49069
49303
  moved: recentlyMoved,
49070
- shown
49304
+ shown,
49305
+ scanned
49071
49306
  }));
49072
49307
  });
49073
49308
  return {
@@ -49105,13 +49340,26 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
49105
49340
  * notes or frames it touched, whose queue it offers to delivery. The frames
49106
49341
  * an agent changed wait out the grace before the board hears of them.
49107
49342
  */
49108
- async function pushBatch(root, tokens, paths, { hub, findings, rendered, delivery, tracker, claims, thumbnails, hug, settleLater, moved, shown }) {
49343
+ async function pushBatch(root, tokens, paths, { hub, findings, rendered, delivery, tracker, claims, thumbnails, hug, settleLater, moved, shown, scanned }) {
49109
49344
  let board;
49110
49345
  let own;
49346
+ let placed;
49111
49347
  try {
49112
49348
  board = await scanBoard(root);
49349
+ const previous = scanned.board;
49350
+ scanned.board = board;
49113
49351
  own = ownFileRefs(board, paths);
49114
- if (await hug.now(board, own).catch(() => false)) board = await scanBoard(root);
49352
+ placed = previous ? placedRefs(previous, board, paths).filter((ref) => !own.includes(ref)) : [];
49353
+ if (await hug.now(board, [...own, ...placed]).catch(() => false)) {
49354
+ const measured = board;
49355
+ board = await scanBoard(root);
49356
+ scanned.board = board;
49357
+ const late = placedRefs(measured, board);
49358
+ if (late.length > 0) {
49359
+ placed = [...placed, ...late];
49360
+ if (await hug.now(board, late).catch(() => false)) board = await scanBoard(root);
49361
+ }
49362
+ }
49115
49363
  } catch {
49116
49364
  return;
49117
49365
  }
@@ -49122,7 +49370,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
49122
49370
  const last = shown.board;
49123
49371
  shown.board = board;
49124
49372
  const refs = reloadRefs(root, paths, board, tokens);
49125
- hug.later(board, refs.filter((ref) => !own.includes(ref)));
49373
+ hug.later(board, refs.filter((ref) => !own.includes(ref) && !placed.includes(ref)));
49126
49374
  if (refs.length > 0) {
49127
49375
  const reloads = unmovedRefs(refs, board, moved(), last);
49128
49376
  if (reloads.length > 0) hub.broadcast({