frameboard 0.40.0 → 0.42.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
@@ -3090,6 +3090,7 @@ var FrameboardError = class extends Error {
3090
3090
  */
3091
3091
  const BOARD_FILE = "board.json";
3092
3092
  const PROJECT_FILE = "project.json";
3093
+ const LAYOUT_FILE = "layout.json";
3093
3094
  const ASSETS_FOLDER = "assets";
3094
3095
  const FRAME_EXTENSION = ".html";
3095
3096
  const TOKEN_FILE = "tokens.css";
@@ -9084,11 +9085,15 @@ function datetime(params) {
9084
9085
  return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
9085
9086
  }
9086
9087
  // src/shared/frame-device.ts
9087
- /** The devices the board can draw around a frame, the frame's width picking one. */
9088
+ /**
9089
+ * The devices the board can draw around a frame. A frame's width picks the
9090
+ * first three, and a frame names a foldable.
9091
+ */
9088
9092
  const DEVICES = [
9089
9093
  "phone",
9090
9094
  "tablet",
9091
- "laptop"
9095
+ "laptop",
9096
+ "foldable"
9092
9097
  ];
9093
9098
  /** The laptop lid's chin below the screen, past the border its sides hold. */
9094
9099
  const LAPTOP_CHIN = 28;
@@ -9099,8 +9104,9 @@ const LAPTOP_BASE = {
9099
9104
  radius: 10
9100
9105
  };
9101
9106
  /**
9102
- * Bezels measured off a current Pro phone and 13-inch tablet, the tablet's
9103
- * screen radius a guess, and the laptop scaled off the picked mock.
9107
+ * Bezels measured off a current Pro phone and 13-inch tablet, the laptop
9108
+ * scaled off the picked mock, and the foldable's body less its glass. The
9109
+ * tablet's and the foldable's screen radii are guesses no source gives.
9104
9110
  */
9105
9111
  const BEZELS = {
9106
9112
  phone: {
@@ -9120,6 +9126,12 @@ const BEZELS = {
9120
9126
  bottom: LAPTOP_CHIN + LAPTOP_BASE.height,
9121
9127
  screenRadius: 10,
9122
9128
  bodyRadius: 30
9129
+ },
9130
+ foldable: {
9131
+ border: 20,
9132
+ bottom: 20,
9133
+ screenRadius: 48,
9134
+ bodyRadius: 68
9123
9135
  }
9124
9136
  };
9125
9137
  /**
@@ -9169,6 +9181,67 @@ const HOME_BAR = {
9169
9181
  height: 5,
9170
9182
  bottom: 8
9171
9183
  };
9184
+ /** The ways a foldable is held, each a screen the frame's box takes the size of. */
9185
+ const POSES = [
9186
+ "closed",
9187
+ "half",
9188
+ "open"
9189
+ ];
9190
+ /**
9191
+ * Each pose's screen in points, the cover display closed and the inner one
9192
+ * half open and open. The published pixel counts at three pixels to a point,
9193
+ * a scale no source states for this device.
9194
+ */
9195
+ const POSE_SIZES = {
9196
+ closed: {
9197
+ width: 466,
9198
+ height: 678
9199
+ },
9200
+ half: {
9201
+ width: 890,
9202
+ height: 626
9203
+ },
9204
+ open: {
9205
+ width: 890,
9206
+ height: 626
9207
+ }
9208
+ };
9209
+ /** A layout entry's `pose` as a pose, closed for none or a value no reader knows. */
9210
+ function poseOf(value) {
9211
+ return POSES.find((pose) => pose === value) ?? "closed";
9212
+ }
9213
+ /** The pose a frame this wide starts in, closed or open, whichever moves its box least. */
9214
+ function nearestPose(width) {
9215
+ return Math.abs(width - POSE_SIZES.closed.width) <= Math.abs(width - POSE_SIZES.open.width) ? "closed" : "open";
9216
+ }
9217
+ /**
9218
+ * The foldable's island, a generic pill, centered on the cover screen and on
9219
+ * the right half of the inner one, a place no source gives.
9220
+ */
9221
+ const FOLDABLE_ISLAND = {
9222
+ width: 100,
9223
+ height: 30,
9224
+ top: 14
9225
+ };
9226
+ /** Where the island's center sits across a pose's screen, as a share of its width. */
9227
+ function islandCenter(pose) {
9228
+ return pose === "closed" ? .5 : .75;
9229
+ }
9230
+ /**
9231
+ * The band drawn down the middle of the inner screen, a faint crease open
9232
+ * and a shaded fold half open, null on the cover screen, which has no fold.
9233
+ */
9234
+ function foldBand(pose) {
9235
+ if (pose === "closed") return null;
9236
+ if (pose === "open") return {
9237
+ width: 26,
9238
+ background: "linear-gradient(90deg, transparent, rgba(0,0,0,.05) 35%, rgba(0,0,0,.11) 50%, rgba(255,255,255,.5) 56%, transparent)"
9239
+ };
9240
+ return {
9241
+ width: 150,
9242
+ background: "linear-gradient(90deg, transparent, rgba(0,0,0,.10) 30%, rgba(0,0,0,.34) 49%, rgba(0,0,0,.34) 51%, rgba(0,0,0,.08) 70%, transparent)"
9243
+ };
9244
+ }
9172
9245
  /**
9173
9246
  * The laptop's chin and base, each a box from the frame's top left, which
9174
9247
  * the board and the PNG draw as positioned boxes, since one spread around
@@ -9425,6 +9498,13 @@ function widthsOf(value) {
9425
9498
  }
9426
9499
  return widths;
9427
9500
  }
9501
+ /**
9502
+ * The widths a layout entry draws: none for a frame naming the foldable,
9503
+ * whose poses are its sizes, whatever its `widths` lists.
9504
+ */
9505
+ function drawnWidths(entry) {
9506
+ return entry.foldable === true ? [] : widthsOf(entry.widths);
9507
+ }
9428
9508
  function isSize(value) {
9429
9509
  return typeof value === "number" && Number.isInteger(value) && value >= 1;
9430
9510
  }
@@ -9479,6 +9559,85 @@ function xPast(edge, width, device) {
9479
9559
  }, device);
9480
9560
  return edge + 80 - body.x;
9481
9561
  }
9562
+ // src/shared/names.ts
9563
+ /** One rule for project, page, and frame names, matching v01.3's naming check. */
9564
+ const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
9565
+ /** Names a page may not take, since the folder means something else in a project. */
9566
+ const RESERVED_PAGE_NAMES = ["assets"];
9567
+ function isValidName(name) {
9568
+ return name.length <= 64 && NAME_PATTERN.test(name);
9569
+ }
9570
+ function isReservedPageName(name) {
9571
+ return RESERVED_PAGE_NAMES.some((reserved) => namesCollide(reserved, name));
9572
+ }
9573
+ /** Case-insensitive, since the default macOS volume is. */
9574
+ function namesCollide(a, b) {
9575
+ return a.toLowerCase() === b.toLowerCase();
9576
+ }
9577
+ /** `base` when free, else the first free `base-2`, `base-3`, and onward. */
9578
+ function nextFreeName(base, taken) {
9579
+ const lowered = new Set([...taken].map((name) => name.toLowerCase()));
9580
+ if (!lowered.has(base.toLowerCase())) return base;
9581
+ for (let suffix = 2;; suffix++) {
9582
+ const candidate = `${base}-${suffix}`;
9583
+ if (!lowered.has(candidate.toLowerCase())) return candidate;
9584
+ }
9585
+ }
9586
+ /**
9587
+ * The folder a retitled project lands in, cut back near the length limit so
9588
+ * the folder always stays a valid name.
9589
+ */
9590
+ function titledFolder(current, title, taken) {
9591
+ const folder = folderName(title);
9592
+ if (folder === "" || namesCollide(folder, current)) return current;
9593
+ const others = [...taken].filter((name) => name !== current);
9594
+ for (let cut = folder.length; cut > 0; cut--) {
9595
+ const base = folder.slice(0, cut).replace(/-+$/, "");
9596
+ const free = nextFreeName(base, others);
9597
+ if (base !== "" && free.length <= 64) return free;
9598
+ }
9599
+ return current;
9600
+ }
9601
+ /**
9602
+ * A typed title as the folder it names, lower case with each run of
9603
+ * characters a name may not hold turned into one dash, so `Acme mobile`
9604
+ * becomes `acme-mobile`. Empty when the title holds nothing a name may.
9605
+ */
9606
+ function folderName(typed) {
9607
+ return typed.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
9608
+ }
9609
+ // src/shared/kits.ts
9610
+ /**
9611
+ * The names a design kit's folder of plain files is laid out by, installed so
9612
+ * the frame route imports `assets/kit/` after the token sheets.
9613
+ */
9614
+ const KIT_FILE = "kit.json";
9615
+ const KIT_SHEET = "kit.css";
9616
+ const KIT_NOTE = "kit.md";
9617
+ /** The folder under a project's `assets/` holding each kit it added, one folder per kit. */
9618
+ const PROJECT_KITS = "kits";
9619
+ /** The dot folder in a board holding the kits saved from its projects, which home never lists as a project. */
9620
+ const KITS_FOLDER = ".kits";
9621
+ /**
9622
+ * Where the board serves a kit's files, under `/frameboard/`, since a bare
9623
+ * `/kits` would shadow the client's module folder under the dev server.
9624
+ */
9625
+ const KITS_URL = "/frameboard/kits";
9626
+ /** The word `frame kit` takes in place of a kit to clear the frame's, so a project kit by this name is set over the route alone. */
9627
+ const NO_KIT_WORD = "none";
9628
+ /** The kits the tool ships, in the order a picker shows them. */
9629
+ const SHIPPED_KITS = [
9630
+ "clean",
9631
+ "sketch",
9632
+ "wireframe"
9633
+ ];
9634
+ /**
9635
+ * The project kit a layout entry's `kit` names, null for none, a value of
9636
+ * another type, or a name that could leave the project's kits folder.
9637
+ */
9638
+ function kitOf(value) {
9639
+ return typeof value === "string" && isValidName(value) ? value : null;
9640
+ }
9482
9641
  // src/shared/present-transition.ts
9483
9642
  /**
9484
9643
  * The board's own present transitions in inspector order, beside a project's
@@ -9648,8 +9807,11 @@ const layoutEntrySchema = looseObject({
9648
9807
  })), unknown()]).optional(),
9649
9808
  showDevice: unknown().optional(),
9650
9809
  device: unknown().optional(),
9810
+ foldable: unknown().optional(),
9811
+ pose: unknown().optional(),
9651
9812
  transition: unknown().optional(),
9652
- speakerNotes: unknown().optional()
9813
+ speakerNotes: unknown().optional(),
9814
+ kit: unknown().optional()
9653
9815
  });
9654
9816
  /** The longest speaker note a write accepts, in characters. */
9655
9817
  const SPEAKER_NOTES_MAX = 1e4;
@@ -9687,6 +9849,185 @@ function membersOf(sections, frames) {
9687
9849
  }
9688
9850
  return members;
9689
9851
  }
9852
+ // src/server/board/refs.ts
9853
+ /**
9854
+ * The project a verb acts on: the one named, else the board's only project.
9855
+ * A name matching an existing project in another case resolves to that one.
9856
+ */
9857
+ async function resolveProject(root, project) {
9858
+ const projects = await listProjects(root);
9859
+ if (project === void 0) {
9860
+ const [only, ...others] = projects;
9861
+ if (!only || others.length > 0) throw new FrameboardError("project-required", projects.length === 0 ? "The board has no project. Run frameboard project add <name> first." : `The board has ${projects.length} projects, so pass --project <name> or a ref naming one.`, { projects });
9862
+ return {
9863
+ name: only,
9864
+ path: join(root, only)
9865
+ };
9866
+ }
9867
+ const name = matchName(projects, project);
9868
+ if (!name) throw new FrameboardError("project-not-found", `No project ${project} in ${root}.`, {
9869
+ project,
9870
+ projects
9871
+ });
9872
+ return {
9873
+ name,
9874
+ path: join(root, name)
9875
+ };
9876
+ }
9877
+ /** A page ref is `<page>` or `<project>/<page>`. */
9878
+ async function resolvePageRef(root, ref, options) {
9879
+ const parts = splitRef(ref, 2);
9880
+ const pageName = parts.at(-1) ?? "";
9881
+ const project = await resolveProject(root, agreeingProject(ref, parts.length === 2 ? parts[0] : void 0, options));
9882
+ const page = await findPage(project.path, pageName, options.allowMissing);
9883
+ return {
9884
+ root,
9885
+ project: project.name,
9886
+ page: page.name,
9887
+ name: page.name,
9888
+ path: page.path
9889
+ };
9890
+ }
9891
+ /**
9892
+ * A frame ref is `<page>/<frame>` or `<project>/<page>/<frame>`. An argument
9893
+ * ending in `.html` is instead a path against `cwd`, which must sit in a page
9894
+ * of this board.
9895
+ */
9896
+ async function resolveFrameRef(root, ref, options) {
9897
+ const parts = ref.endsWith(".html") ? await framePathParts(root, ref, options.cwd) : splitRef(ref, 3);
9898
+ if (parts.length < 2) throw new FrameboardError("usage", `${ref} is not a frame ref. Write <page>/<frame>, <project>/<page>/<frame>, or a path to the .html file.`, { ref });
9899
+ const frameName = parts.at(-1) ?? "";
9900
+ const pageName = parts.at(-2) ?? "";
9901
+ const project = await resolveProject(root, agreeingProject(ref, parts.length === 3 ? parts[0] : void 0, options));
9902
+ const page = await findPage(project.path, pageName, false);
9903
+ const frames = await listFrames(page.path);
9904
+ const found = matchName(frames, frameName);
9905
+ if (!found && !options.allowMissing) throw new FrameboardError("frame-not-found", `No frame ${frameName} in ${project.name}/${page.name}.`, {
9906
+ ref,
9907
+ frames
9908
+ });
9909
+ if (!found) assertValidName("frame", frameName);
9910
+ const name = found ?? frameName;
9911
+ return {
9912
+ root,
9913
+ project: project.name,
9914
+ page: page.name,
9915
+ name,
9916
+ path: join(page.path, `${name}${FRAME_EXTENSION}`)
9917
+ };
9918
+ }
9919
+ /** Throws `invalid-name` for a name a new project, page, or frame may not take. */
9920
+ function assertValidName(kind, name) {
9921
+ if (!isValidName(name)) throw new FrameboardError("invalid-name", `${name} is not a valid ${kind} name. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit, at most 64 characters.`, {
9922
+ kind,
9923
+ name
9924
+ });
9925
+ if (kind === "page" && isReservedPageName(name)) throw new FrameboardError("invalid-name", `${name} is reserved for the project's shared files, so a page cannot take it.`, {
9926
+ kind,
9927
+ name
9928
+ });
9929
+ }
9930
+ /** The existing name equal to `name`, else one equal in another case. */
9931
+ function matchName(names, name) {
9932
+ return names.find((n) => n === name) ?? names.find((n) => namesCollide(n, name));
9933
+ }
9934
+ async function findPage(projectDir, name, allowMissing = false) {
9935
+ const pages = await listPageFolders(projectDir);
9936
+ const found = matchName(pages, name);
9937
+ if (!found && !allowMissing) throw new FrameboardError("page-not-found", `No page ${name} in ${projectDir}.`, {
9938
+ page: name,
9939
+ pages
9940
+ });
9941
+ if (!found) assertValidName("page", name);
9942
+ const resolved = found ?? name;
9943
+ return {
9944
+ name: resolved,
9945
+ path: join(projectDir, resolved)
9946
+ };
9947
+ }
9948
+ function splitRef(ref, max) {
9949
+ const parts = ref.split("/");
9950
+ if (parts.length > max || parts.some((part) => part === "")) throw new FrameboardError("usage", `${ref} is not a ${max === 2 ? "page" : "frame"} ref.`, { ref });
9951
+ return parts;
9952
+ }
9953
+ function agreeingProject(ref, fromRef, { project }) {
9954
+ if (fromRef !== void 0 && project !== void 0 && !namesCollide(fromRef, project)) throw new FrameboardError("usage", `${ref} names project ${fromRef} but --project names ${project}.`, {
9955
+ ref,
9956
+ project
9957
+ });
9958
+ return fromRef ?? project;
9959
+ }
9960
+ async function framePathParts(root, ref, cwd) {
9961
+ const path = resolve$1(cwd, ref);
9962
+ let folder = dirname(path);
9963
+ try {
9964
+ folder = await realpath(folder);
9965
+ } catch (error) {
9966
+ if (!isCode(error, "ENOENT")) throw error;
9967
+ }
9968
+ const inside = relative(root, folder);
9969
+ const parts = inside.split(sep);
9970
+ if (inside === "" || inside.startsWith("..") || isAbsolute(inside) || parts.length !== 2) throw new FrameboardError("usage", `${path} does not sit in a page of the board at ${root}.`, {
9971
+ path,
9972
+ root
9973
+ });
9974
+ const file = path.slice(dirname(path).length + 1);
9975
+ return [...parts, file.slice(0, -5)];
9976
+ }
9977
+ // src/server/kits/project.ts
9978
+ /** The folder a project keeps the kit named `kit` in, which a caller checks is a valid name first. */
9979
+ function projectKitDir(projectDir, kit) {
9980
+ return join(projectDir, ASSETS_FOLDER, PROJECT_KITS, kit);
9981
+ }
9982
+ /**
9983
+ * The kits a project added, sorted by name, being each folder under its
9984
+ * `assets/kits/` a frame could name. A hand-built folder counts, since a
9985
+ * kit reaches a frame only where the frame names it.
9986
+ */
9987
+ async function projectKitNames(projectDir) {
9988
+ let entries;
9989
+ try {
9990
+ entries = await readdir(join(projectDir, ASSETS_FOLDER, PROJECT_KITS), { withFileTypes: true });
9991
+ } catch {
9992
+ return [];
9993
+ }
9994
+ return entries.filter((entry) => entry.isDirectory() && isValidName(entry.name)).map((entry) => entry.name).sort();
9995
+ }
9996
+ /** The project's kit `name` answers to, refusing `kit-not-found` with the kits it holds. */
9997
+ async function heldKit(project, name) {
9998
+ const known = await projectKitNames(project.path);
9999
+ const found = matchName(known, name);
10000
+ if (found) return found;
10001
+ throw new FrameboardError("kit-not-found", `${project.name} holds no kit named ${name}. Add one with \`frameboard kit add ${project.name} <kit>\`.`, {
10002
+ kit: name,
10003
+ project: project.name,
10004
+ known
10005
+ });
10006
+ }
10007
+ /**
10008
+ * A project's kits as `list --json` answers them, each with how many of
10009
+ * `pages`' frames name it. The pages come scanned, so a scan never reads
10010
+ * a layout twice.
10011
+ */
10012
+ async function projectKits(projectDir, pages) {
10013
+ const named = pages.flatMap((page) => page.frames.map((frame) => frame.kit));
10014
+ const names = await projectKitNames(projectDir);
10015
+ return Promise.all(names.map(async (name) => ({
10016
+ name,
10017
+ title: await titleOf$1(projectKitDir(projectDir, name), name),
10018
+ frameCount: named.filter((kit) => kit === name).length
10019
+ })));
10020
+ }
10021
+ /** The title a kit's `kit.json` gives, or its folder name where the file gives none. */
10022
+ async function titleOf$1(kitDir, name) {
10023
+ try {
10024
+ const parsed = JSON.parse(await readFile(join(kitDir, KIT_FILE), "utf8"));
10025
+ const title = typeof parsed === "object" && parsed !== null && "title" in parsed ? parsed.title : void 0;
10026
+ return typeof title === "string" && title.trim() !== "" ? title.trim() : name;
10027
+ } catch {
10028
+ return name;
10029
+ }
10030
+ }
9690
10031
  // node_modules/picocolors/picocolors.js
9691
10032
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9692
10033
  let p = process || {};
@@ -23475,7 +23816,7 @@ var Document = class extends NodeWithChildren {
23475
23816
  /**
23476
23817
  * An element within the DOM.
23477
23818
  */
23478
- var Element = class extends NodeWithChildren {
23819
+ var Element$1 = class extends NodeWithChildren {
23479
23820
  name;
23480
23821
  attribs;
23481
23822
  type;
@@ -23587,7 +23928,7 @@ function cloneNode(node, recursive = false) {
23587
23928
  else if (isComment(node)) result = new Comment(node.data);
23588
23929
  else if (isTag(node)) {
23589
23930
  const children = recursive ? cloneChildren(node.children) : [];
23590
- const clone = new Element(node.name, { ...node.attribs }, children);
23931
+ const clone = new Element$1(node.name, { ...node.attribs }, children);
23591
23932
  for (const child of children) child.parent = clone;
23592
23933
  if (node.namespace != null) clone.namespace = node.namespace;
23593
23934
  if (node["x-attribsNamespace"]) clone["x-attribsNamespace"] = { ...node["x-attribsNamespace"] };
@@ -23667,7 +24008,7 @@ const adapter = {
23667
24008
  attribsNamespace[attrName] = attrs[i].namespace;
23668
24009
  attribsPrefix[attrName] = attrs[i].prefix;
23669
24010
  }
23670
- const node = new Element(tagName, attribs, []);
24011
+ const node = new Element$1(tagName, attribs, []);
23671
24012
  node.namespace = namespaceURI;
23672
24013
  node["x-attribsNamespace"] = attribsNamespace;
23673
24014
  node["x-attribsPrefix"] = attribsPrefix;
@@ -24327,7 +24668,6 @@ async function assertKnownTransition(projectDir, transition) {
24327
24668
  });
24328
24669
  }
24329
24670
  // src/server/board/scan.ts
24330
- const LAYOUT_FILE = "layout.json";
24331
24671
  const layoutSpec = {
24332
24672
  schema: layoutFileSchema,
24333
24673
  invalidCode: "layout-invalid",
@@ -24449,9 +24789,13 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
24449
24789
  height: entry.height
24450
24790
  };
24451
24791
  const shown = showsDevice(entry);
24452
- const device = shown ? deviceForWidth(box.width) : null;
24792
+ const foldable = entry.foldable === true;
24793
+ const kept = widthsOf(entry.widths);
24794
+ const named = foldable ? "foldable" : deviceForWidth(box.width);
24795
+ const device = shown ? named : null;
24453
24796
  const transition = readTransition(entry.transition);
24454
24797
  const speakerNotes = speakerNotesOf(entry.speakerNotes);
24798
+ const kit = kitOf(entry.kit);
24455
24799
  placements.set(name, {
24456
24800
  box,
24457
24801
  order: entry.order,
@@ -24460,11 +24804,17 @@ function placeFrames(frames, names, readTransition = storedTransitionOf) {
24460
24804
  hugWidth: !scroll && (entry.hugWidth ?? false),
24461
24805
  hugHeight: !scroll && (entry.hugHeight ?? false),
24462
24806
  scroll,
24463
- widths: widthsOf(entry.widths),
24807
+ widths: drawnWidths(entry),
24464
24808
  ...shown ? { showDevice: true } : {},
24465
24809
  ...device ? { device } : {},
24810
+ ...foldable ? {
24811
+ foldable,
24812
+ pose: poseOf(entry.pose)
24813
+ } : {},
24814
+ ...foldable && kept.length > 0 ? { keptWidths: kept } : {},
24466
24815
  ...transition ? { transition } : {},
24467
24816
  ...speakerNotes ? { speakerNotes } : {},
24817
+ ...kit ? { kit } : {},
24468
24818
  placed: true
24469
24819
  });
24470
24820
  }
@@ -24542,6 +24892,7 @@ async function scanProject(root, name) {
24542
24892
  projectFileError: error,
24543
24893
  transitions,
24544
24894
  checksOff,
24895
+ kits: await projectKits(path, pages),
24545
24896
  pages
24546
24897
  };
24547
24898
  }
@@ -24573,7 +24924,7 @@ async function scanPage(root, project, name, index, transitions) {
24573
24924
  const placements = placeFrames(frames, names, (value) => transitionOf(value, own));
24574
24925
  const stacked = (await Promise.all(names.map(async (frame) => {
24575
24926
  const framePath = join(path, `${frame}${FRAME_EXTENSION}`);
24576
- const placement = placements.get(frame) ?? placeNext([]);
24927
+ const { foldable: _named, keptWidths: _kept, ...placement } = placements.get(frame) ?? placeNext([]);
24577
24928
  return {
24578
24929
  ref: `${project}/${name}/${frame}`,
24579
24930
  project,
@@ -24692,7 +25043,7 @@ async function isDirectory(path) {
24692
25043
  }
24693
25044
  }
24694
25045
  // package.json
24695
- var version$1 = "0.40.0";
25046
+ var version$1 = "0.42.0";
24696
25047
  var dependencies = { "playwright-core": "1.65.0" };
24697
25048
  var peerDependencies = { "oxfmt": "0.78.0" };
24698
25049
  // src/shared/version.ts
@@ -24793,53 +25144,6 @@ async function findLiveServer(root) {
24793
25144
  return null;
24794
25145
  }
24795
25146
  }
24796
- // src/shared/names.ts
24797
- /** One rule for project, page, and frame names, matching v01.3's naming check. */
24798
- const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
24799
- /** Names a page may not take, since the folder means something else in a project. */
24800
- const RESERVED_PAGE_NAMES = ["assets"];
24801
- function isValidName(name) {
24802
- return name.length <= 64 && NAME_PATTERN.test(name);
24803
- }
24804
- function isReservedPageName(name) {
24805
- return RESERVED_PAGE_NAMES.some((reserved) => namesCollide(reserved, name));
24806
- }
24807
- /** Case-insensitive, since the default macOS volume is. */
24808
- function namesCollide(a, b) {
24809
- return a.toLowerCase() === b.toLowerCase();
24810
- }
24811
- /** `base` when free, else the first free `base-2`, `base-3`, and onward. */
24812
- function nextFreeName(base, taken) {
24813
- const lowered = new Set([...taken].map((name) => name.toLowerCase()));
24814
- if (!lowered.has(base.toLowerCase())) return base;
24815
- for (let suffix = 2;; suffix++) {
24816
- const candidate = `${base}-${suffix}`;
24817
- if (!lowered.has(candidate.toLowerCase())) return candidate;
24818
- }
24819
- }
24820
- /**
24821
- * The folder a retitled project lands in, cut back near the length limit so
24822
- * the folder always stays a valid name.
24823
- */
24824
- function titledFolder(current, title, taken) {
24825
- const folder = folderName(title);
24826
- if (folder === "" || namesCollide(folder, current)) return current;
24827
- const others = [...taken].filter((name) => name !== current);
24828
- for (let cut = folder.length; cut > 0; cut--) {
24829
- const base = folder.slice(0, cut).replace(/-+$/, "");
24830
- const free = nextFreeName(base, others);
24831
- if (base !== "" && free.length <= 64) return free;
24832
- }
24833
- return current;
24834
- }
24835
- /**
24836
- * A typed title as the folder it names, lower case with each run of
24837
- * characters a name may not hold turned into one dash, so `Acme mobile`
24838
- * becomes `acme-mobile`. Empty when the title holds nothing a name may.
24839
- */
24840
- function folderName(typed) {
24841
- return typed.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[._-]+/, "").slice(0, 64).replace(/-+$/, "");
24842
- }
24843
25147
  // src/shared/records/claims.ts
24844
25148
  /**
24845
25149
  * Where a reserved frame will land, and which axes take their size from the
@@ -25037,131 +25341,6 @@ async function release(root, session, frame, now) {
25037
25341
  });
25038
25342
  return dropped;
25039
25343
  }
25040
- // src/server/board/refs.ts
25041
- /**
25042
- * The project a verb acts on: the one named, else the board's only project.
25043
- * A name matching an existing project in another case resolves to that one.
25044
- */
25045
- async function resolveProject(root, project) {
25046
- const projects = await listProjects(root);
25047
- if (project === void 0) {
25048
- const [only, ...others] = projects;
25049
- if (!only || others.length > 0) throw new FrameboardError("project-required", projects.length === 0 ? "The board has no project. Run frameboard project add <name> first." : `The board has ${projects.length} projects, so pass --project <name> or a ref naming one.`, { projects });
25050
- return {
25051
- name: only,
25052
- path: join(root, only)
25053
- };
25054
- }
25055
- const name = matchName(projects, project);
25056
- if (!name) throw new FrameboardError("project-not-found", `No project ${project} in ${root}.`, {
25057
- project,
25058
- projects
25059
- });
25060
- return {
25061
- name,
25062
- path: join(root, name)
25063
- };
25064
- }
25065
- /** A page ref is `<page>` or `<project>/<page>`. */
25066
- async function resolvePageRef(root, ref, options) {
25067
- const parts = splitRef(ref, 2);
25068
- const pageName = parts.at(-1) ?? "";
25069
- const project = await resolveProject(root, agreeingProject(ref, parts.length === 2 ? parts[0] : void 0, options));
25070
- const page = await findPage(project.path, pageName, options.allowMissing);
25071
- return {
25072
- root,
25073
- project: project.name,
25074
- page: page.name,
25075
- name: page.name,
25076
- path: page.path
25077
- };
25078
- }
25079
- /**
25080
- * A frame ref is `<page>/<frame>` or `<project>/<page>/<frame>`. An argument
25081
- * ending in `.html` is instead a path against `cwd`, which must sit in a page
25082
- * of this board.
25083
- */
25084
- async function resolveFrameRef(root, ref, options) {
25085
- const parts = ref.endsWith(".html") ? await framePathParts(root, ref, options.cwd) : splitRef(ref, 3);
25086
- if (parts.length < 2) throw new FrameboardError("usage", `${ref} is not a frame ref. Write <page>/<frame>, <project>/<page>/<frame>, or a path to the .html file.`, { ref });
25087
- const frameName = parts.at(-1) ?? "";
25088
- const pageName = parts.at(-2) ?? "";
25089
- const project = await resolveProject(root, agreeingProject(ref, parts.length === 3 ? parts[0] : void 0, options));
25090
- const page = await findPage(project.path, pageName, false);
25091
- const frames = await listFrames(page.path);
25092
- const found = matchName(frames, frameName);
25093
- if (!found && !options.allowMissing) throw new FrameboardError("frame-not-found", `No frame ${frameName} in ${project.name}/${page.name}.`, {
25094
- ref,
25095
- frames
25096
- });
25097
- if (!found) assertValidName("frame", frameName);
25098
- const name = found ?? frameName;
25099
- return {
25100
- root,
25101
- project: project.name,
25102
- page: page.name,
25103
- name,
25104
- path: join(page.path, `${name}${FRAME_EXTENSION}`)
25105
- };
25106
- }
25107
- /** Throws `invalid-name` for a name a new project, page, or frame may not take. */
25108
- function assertValidName(kind, name) {
25109
- if (!isValidName(name)) throw new FrameboardError("invalid-name", `${name} is not a valid ${kind} name. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit, at most 64 characters.`, {
25110
- kind,
25111
- name
25112
- });
25113
- if (kind === "page" && isReservedPageName(name)) throw new FrameboardError("invalid-name", `${name} is reserved for the project's shared files, so a page cannot take it.`, {
25114
- kind,
25115
- name
25116
- });
25117
- }
25118
- /** The existing name equal to `name`, else one equal in another case. */
25119
- function matchName(names, name) {
25120
- return names.find((n) => n === name) ?? names.find((n) => namesCollide(n, name));
25121
- }
25122
- async function findPage(projectDir, name, allowMissing = false) {
25123
- const pages = await listPageFolders(projectDir);
25124
- const found = matchName(pages, name);
25125
- if (!found && !allowMissing) throw new FrameboardError("page-not-found", `No page ${name} in ${projectDir}.`, {
25126
- page: name,
25127
- pages
25128
- });
25129
- if (!found) assertValidName("page", name);
25130
- const resolved = found ?? name;
25131
- return {
25132
- name: resolved,
25133
- path: join(projectDir, resolved)
25134
- };
25135
- }
25136
- function splitRef(ref, max) {
25137
- const parts = ref.split("/");
25138
- if (parts.length > max || parts.some((part) => part === "")) throw new FrameboardError("usage", `${ref} is not a ${max === 2 ? "page" : "frame"} ref.`, { ref });
25139
- return parts;
25140
- }
25141
- function agreeingProject(ref, fromRef, { project }) {
25142
- if (fromRef !== void 0 && project !== void 0 && !namesCollide(fromRef, project)) throw new FrameboardError("usage", `${ref} names project ${fromRef} but --project names ${project}.`, {
25143
- ref,
25144
- project
25145
- });
25146
- return fromRef ?? project;
25147
- }
25148
- async function framePathParts(root, ref, cwd) {
25149
- const path = resolve$1(cwd, ref);
25150
- let folder = dirname(path);
25151
- try {
25152
- folder = await realpath(folder);
25153
- } catch (error) {
25154
- if (!isCode(error, "ENOENT")) throw error;
25155
- }
25156
- const inside = relative(root, folder);
25157
- const parts = inside.split(sep);
25158
- if (inside === "" || inside.startsWith("..") || isAbsolute(inside) || parts.length !== 2) throw new FrameboardError("usage", `${path} does not sit in a page of the board at ${root}.`, {
25159
- path,
25160
- root
25161
- });
25162
- const file = path.slice(dirname(path).length + 1);
25163
- return [...parts, file.slice(0, -5)];
25164
- }
25165
25344
  // src/server/board/frames.ts
25166
25345
  /**
25167
25346
  * Places a frame, writing a skeleton only when no file exists. Every axis no
@@ -25208,7 +25387,7 @@ async function addFrame(root, ref, options) {
25208
25387
  held: []
25209
25388
  });
25210
25389
  if (!exists) {
25211
- await writeFile(frame.path, skeleton(frame.name, options.body), { flag: "wx" });
25390
+ await writeFile(frame.path, skeleton(frame.name, options.body, options.head), { flag: "wx" });
25212
25391
  await journal?.created(frame.path);
25213
25392
  }
25214
25393
  layout.names = names;
@@ -25364,6 +25543,10 @@ async function setLinkedWidths(root, targets, widths, options) {
25364
25543
  }
25365
25544
  /** The placement `resizeFrame` writes, for the size it read off its options. */
25366
25545
  function resizedPlacement(placement, frameRef, size, options) {
25546
+ if (placement.foldable && options.widths && options.widths.length > 0) throw new FrameboardError("usage", `${frameRef} is a foldable, whose poses are its sizes, so it shows at no other width.`, {
25547
+ ref: frameRef,
25548
+ widths: options.widths
25549
+ });
25367
25550
  const scroll = options.scroll ?? placement.scroll;
25368
25551
  const width = size.width ?? placement.box.width;
25369
25552
  const drops = scroll && placement.hugHeight && size.height === void 0;
@@ -25373,8 +25556,10 @@ function resizedPlacement(placement, frameRef, size, options) {
25373
25556
  hugWidth,
25374
25557
  held: placement.widths
25375
25558
  });
25559
+ const { keptWidths, ...kept } = placement;
25376
25560
  return {
25377
- ...placement,
25561
+ ...kept,
25562
+ ...keptWidths && options.widths !== false ? { keptWidths } : {},
25378
25563
  box: {
25379
25564
  ...placement.box,
25380
25565
  ...size,
@@ -25645,17 +25830,54 @@ async function setFrameFlag(root, ref, flag, { on, ...options }) {
25645
25830
  }));
25646
25831
  }
25647
25832
  /**
25648
- * Shows or hides the device the board draws around a frame, which the
25649
- * frame's width picks. The frame's file and box are left as they stand,
25650
- * since the body wraps whatever size the frame is.
25833
+ * Shows or hides a frame's device, names or un-names the foldable, and folds
25834
+ * it, never writing the frame's file. Naming a foldable shows it and, as a
25835
+ * pose does, sets the box to that pose's screen, fixed on both axes.
25651
25836
  */
25652
- async function setFrameDevice(root, ref, show, options) {
25653
- return updatePlacement(root, ref, options, (placement) => {
25654
- const { showDevice: _held, device: _device, ...rest } = placement;
25655
- return show ? {
25837
+ async function setFrameDevice(root, ref, show, { foldable: name, pose: fold, ...options }) {
25838
+ return updatePlacement(root, ref, options, (placement, frameRef) => {
25839
+ const { showDevice: held, device: _device, foldable: named, pose: stored, keptWidths, ...rest } = placement;
25840
+ const foldable = name ?? named === true;
25841
+ if (fold && !foldable) throw new FrameboardError("usage", `${frameRef} is not a foldable, so it has no pose. Name it with --foldable first.`, {
25842
+ ref: frameRef,
25843
+ pose: fold
25844
+ });
25845
+ const shown = show ?? (name === true || held === true);
25846
+ const base = {
25656
25847
  ...rest,
25657
- showDevice: true
25658
- } : rest;
25848
+ ...shown ? { showDevice: true } : {}
25849
+ };
25850
+ if (!foldable) {
25851
+ const widths = (keptWidths ?? rest.widths).filter((linked) => linked.width !== placement.box.width);
25852
+ return {
25853
+ ...base,
25854
+ widths
25855
+ };
25856
+ }
25857
+ const undrawn = keptWidths ?? rest.widths;
25858
+ const kept = {
25859
+ widths: [],
25860
+ ...undrawn.length > 0 ? { keptWidths: undrawn } : {}
25861
+ };
25862
+ const pose = fold ?? stored ?? nearestPose(placement.box.width);
25863
+ if (!fold && named) return {
25864
+ ...base,
25865
+ ...kept,
25866
+ foldable,
25867
+ pose
25868
+ };
25869
+ return {
25870
+ ...base,
25871
+ ...kept,
25872
+ foldable,
25873
+ pose,
25874
+ box: {
25875
+ ...placement.box,
25876
+ ...POSE_SIZES[pose]
25877
+ },
25878
+ hugWidth: false,
25879
+ hugHeight: false
25880
+ };
25659
25881
  });
25660
25882
  }
25661
25883
  /**
@@ -25674,6 +25896,25 @@ async function setFrameTransition(root, ref, transition, options) {
25674
25896
  });
25675
25897
  }
25676
25898
  /**
25899
+ * Sets the project kit a frame draws with, or clears it with null, writing
25900
+ * only its layout entry. Refuses `kit-not-found` for a name the frame's
25901
+ * project holds no kit under, and stores the folder's own spelling.
25902
+ */
25903
+ async function setFrameKit(root, ref, kit, options) {
25904
+ const frame = await resolveFrameRef(root, ref, options);
25905
+ const held = kit === null ? null : await heldKit({
25906
+ name: frame.project,
25907
+ path: join(root, frame.project)
25908
+ }, kit);
25909
+ return updatePlacement(root, ref, options, (placement) => {
25910
+ const { kit: _held, ...rest } = placement;
25911
+ return held ? {
25912
+ ...rest,
25913
+ kit: held
25914
+ } : rest;
25915
+ });
25916
+ }
25917
+ /**
25677
25918
  * Sets a frame's speaker note on its layout entry, null or blank clearing it.
25678
25919
  * Refuses `usage` past `SPEAKER_NOTES_MAX` rather than cutting, and
25679
25920
  * `stale-layout` once `expected`, the note the edit began from, is gone.
@@ -25743,14 +25984,15 @@ function sizeOf({ size, width, height }) {
25743
25984
  * The skeleton states `head` with `body`, so the browser builds neither and
25744
25985
  * every address holds, and a body column has no margin, so media fits exactly.
25745
25986
  */
25746
- function skeleton(name, body) {
25987
+ function skeleton(name, body, head) {
25988
+ const content = body === void 0 ? "<body></body>" : `<body style="margin: 0; display: flex; flex-direction: column; align-items: flex-start">${body}</body>`;
25747
25989
  return `<!doctype html>
25748
25990
  <html lang="en">
25749
25991
  <head>
25750
25992
  <meta charset="utf-8" />
25751
- <title>${name}</title>
25993
+ <title>${name}</title>${head === void 0 ? "" : `\n ${head}`}
25752
25994
  </head>
25753
- ${body === void 0 ? "<body></body>" : `<body style="margin: 0; display: flex; flex-direction: column; align-items: flex-start">${body}</body>`}
25995
+ ${content}
25754
25996
  </html>
25755
25997
  `;
25756
25998
  }
@@ -25786,10 +26028,11 @@ var PageLayout = class {
25786
26028
  * Writes the fixed keys after the entry's own, so unknown keys survive, and a
25787
26029
  * flag only once on or already held, so an older entry gains no key.
25788
26030
  */
25789
- set(name, { box, order, hidden, locked, scroll, widths, showDevice, transition, speakerNotes, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
26031
+ set(name, { box, order, hidden, locked, scroll, widths, showDevice, foldable, pose, keptWidths, transition, speakerNotes, kit, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
25790
26032
  const hugWidth = hugsWidth && !scroll;
25791
26033
  const hugHeight = hugsHeight && !scroll;
25792
26034
  const held = this.file.frames[name];
26035
+ const listed = foldable ? keptWidths ?? [] : widths;
25793
26036
  const entry = {
25794
26037
  ...held,
25795
26038
  x: box.x,
@@ -25802,19 +26045,27 @@ var PageLayout = class {
25802
26045
  ...!held || hugWidth || held.hugWidth !== void 0 ? { hugWidth } : {},
25803
26046
  ...!held || hugHeight || held.hugHeight !== void 0 ? { hugHeight } : {},
25804
26047
  ...scroll || held?.scroll !== void 0 ? { scroll } : {},
25805
- ...widths.length > 0 ? { widths: widths.map(({ width, height }) => ({
26048
+ ...listed.length > 0 ? { widths: listed.map(({ width, height }) => ({
25806
26049
  width,
25807
26050
  height
25808
26051
  })) } : {},
25809
26052
  ...showDevice ? { showDevice } : {},
26053
+ ...foldable ? { foldable } : {},
26054
+ ...foldable && pose && (held?.foldable !== true || poseOf(held.pose) !== pose) ? { pose } : {},
25810
26055
  ...transition ? { transition: { ...transition } } : {},
25811
- ...speakerNotes ? { speakerNotes } : {}
26056
+ ...speakerNotes ? { speakerNotes } : {},
26057
+ ...kit ? { kit } : {}
25812
26058
  };
25813
- if (widths.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
26059
+ if (listed.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
26060
+ if (!foldable && held?.foldable === true) {
26061
+ delete entry.foldable;
26062
+ delete entry.pose;
26063
+ }
25814
26064
  if (!showDevice && held?.showDevice === true) delete entry.showDevice;
25815
26065
  if (typeof held?.device === "string") delete entry.device;
25816
26066
  if (!transition && storedTransitionOf(held?.transition)) delete entry.transition;
25817
26067
  if (!speakerNotes && speakerNotesOf(held?.speakerNotes)) delete entry.speakerNotes;
26068
+ if (!kit && kitOf(held?.kit)) delete entry.kit;
25818
26069
  this.file.frames[name] = entry;
25819
26070
  this.changed = true;
25820
26071
  }
@@ -30590,18 +30841,20 @@ const ASSET_KINDS = [
30590
30841
  "svg",
30591
30842
  "video",
30592
30843
  "audio",
30844
+ "model",
30593
30845
  "font",
30594
30846
  "stylesheet",
30595
30847
  "script",
30596
30848
  "other"
30597
30849
  ];
30598
- /** The kinds a frame shows as an `<img>`, a `<video>`, or an `<audio>`, which the board places by hand. */
30850
+ /** The kinds a frame shows as an `<img>`, a `<video>`, an `<audio>`, or a `<model-viewer>`, which the board places by hand. */
30599
30851
  const PLACEABLE_KINDS = [
30600
30852
  "image",
30601
30853
  "gif",
30602
30854
  "svg",
30603
30855
  "video",
30604
- "audio"
30856
+ "audio",
30857
+ "model"
30605
30858
  ];
30606
30859
  function isPlaceableKind(kind) {
30607
30860
  return PLACEABLE_KINDS.includes(kind);
@@ -30623,6 +30876,8 @@ const ACCEPTED = {
30623
30876
  wav: "audio",
30624
30877
  ogg: "audio",
30625
30878
  m4a: "audio",
30879
+ glb: "model",
30880
+ gltf: "model",
30626
30881
  woff: "font",
30627
30882
  woff2: "font",
30628
30883
  ttf: "font",
@@ -30631,6 +30886,17 @@ const ACCEPTED = {
30631
30886
  js: "script",
30632
30887
  mjs: "script"
30633
30888
  };
30889
+ /** Model formats no frame shows, which a drop refuses with the way to a GLB rather than as an unknown file. */
30890
+ const FOREIGN_MODELS = [
30891
+ "fbx",
30892
+ "obj",
30893
+ "blend",
30894
+ "usd",
30895
+ "stl"
30896
+ ];
30897
+ function isForeignModel(name) {
30898
+ return FOREIGN_MODELS.includes(extensionOf(name));
30899
+ }
30634
30900
  /** The lowercase text after the last dot, empty when the name has none. */
30635
30901
  function extensionOf(name) {
30636
30902
  const dot = name.lastIndexOf(".");
@@ -30844,7 +31110,7 @@ async function resolveAsset(projectDir, path) {
30844
31110
  if (!isPlaceableKind(kind)) return {
30845
31111
  ok: false,
30846
31112
  code: "asset-not-placeable",
30847
- message: `assets/${path} is not an image, GIF, SVG, video, or audio, so a frame cannot show it`
31113
+ message: `assets/${path} is not an image, GIF, SVG, video, audio, or 3D model, so a frame cannot show it`
30848
31114
  };
30849
31115
  return {
30850
31116
  ok: true,
@@ -30865,11 +31131,12 @@ async function addAssets(projectDir, uploads) {
30865
31131
  refused: []
30866
31132
  };
30867
31133
  for (const upload of uploads) {
30868
- if (!isAcceptedUpload(upload.name)) {
31134
+ const refusal = uploadRefusal(upload);
31135
+ if (refusal !== null) {
30869
31136
  result.refused.push({
30870
31137
  name: upload.name,
30871
31138
  code: "asset-type-refused",
30872
- message: `${upload.name} is not an image, GIF, SVG, video, audio, font, stylesheet, or script.`
31139
+ message: refusal
30873
31140
  });
30874
31141
  continue;
30875
31142
  }
@@ -30882,6 +31149,37 @@ async function addAssets(projectDir, uploads) {
30882
31149
  }
30883
31150
  return result;
30884
31151
  }
31152
+ /** Why a drop refuses a file, or null for one it keeps. */
31153
+ function uploadRefusal({ name, bytes }) {
31154
+ if (isForeignModel(name)) return `${name} is a 3D model a frame cannot show. Open it in Blender, export it through File, Export, glTF 2.0 as a glTF Binary (.glb), and drop that file.`;
31155
+ if (!isAcceptedUpload(name)) return `${name} is not an image, GIF, SVG, video, audio, 3D model, font, stylesheet, or script.`;
31156
+ return extensionOf(name) === "gltf" ? gltfRefusal(name, bytes) : null;
31157
+ }
31158
+ /**
31159
+ * Why a `.gltf` cannot land alone, or null for one carrying its buffers and
31160
+ * images inside itself. A drop keeps one file per name, so a `.bin` or a
31161
+ * texture the model loads beside it would be left behind.
31162
+ */
31163
+ function gltfRefusal(name, bytes) {
31164
+ let parsed;
31165
+ try {
31166
+ parsed = JSON.parse(new TextDecoder().decode(bytes));
31167
+ } catch {
31168
+ return `${name} is not a glTF file a model reads. Export it again as a glTF Binary (.glb).`;
31169
+ }
31170
+ const [first] = [...linkedUris(parsed, "buffers"), ...linkedUris(parsed, "images")];
31171
+ return first === void 0 ? null : `${name} loads ${first} from beside it, which a drop cannot keep with it. Export it as one glTF Binary (.glb) instead.`;
31172
+ }
31173
+ /** The `uri` of each entry under `key` that names a file rather than carrying its bytes. */
31174
+ function linkedUris(gltf, key) {
31175
+ if (typeof gltf !== "object" || gltf === null) return [];
31176
+ const entries = gltf[key];
31177
+ if (!Array.isArray(entries)) return [];
31178
+ return entries.flatMap((entry) => {
31179
+ const uri = typeof entry === "object" && entry !== null ? entry.uri : void 0;
31180
+ return typeof uri === "string" && !uri.startsWith("data:") ? [uri] : [];
31181
+ });
31182
+ }
30885
31183
  async function writeFree(folder, { name, bytes }) {
30886
31184
  const { stem, extension } = splitName(name);
30887
31185
  const temp = join(folder, `${randomBytes(6).toString("hex")}${TEMP_SUFFIX}`);
@@ -31250,6 +31548,85 @@ function clipboardRoutes(root, access, render, clipboard) {
31250
31548
  });
31251
31549
  return app;
31252
31550
  }
31551
+ // src/server/checks/tokens.ts
31552
+ /**
31553
+ * Where a project's token sheets sit, the address file read by plain
31554
+ * `JSON.parse`, since the write hook cannot afford its schema.
31555
+ */
31556
+ function tokenSheetPaths(root, project, tokens) {
31557
+ const own = join(root, project, TOKEN_FILE);
31558
+ return {
31559
+ board: boardSheetPath(root, tokens),
31560
+ project: existsSync(own) ? own : null
31561
+ };
31562
+ }
31563
+ /** The board's token sheet alone, resolved the way `tokenSheetPaths` resolves it. */
31564
+ function boardSheetPath(root, tokens = recordedTokens(root)) {
31565
+ const board = tokens ?? join(root, "tokens.css");
31566
+ return existsSync(board) ? board : null;
31567
+ }
31568
+ /** The `--tokens` path the board's running server recorded, or null. */
31569
+ function recordedTokens(root) {
31570
+ try {
31571
+ const parsed = JSON.parse(readFileSync(join(root, RUN_FOLDER, ADDRESS_FILE), "utf8"));
31572
+ const tokens = typeof parsed === "object" && parsed !== null && "tokens" in parsed ? parsed.tokens : void 0;
31573
+ return typeof tokens === "string" ? tokens : null;
31574
+ } catch {
31575
+ return null;
31576
+ }
31577
+ }
31578
+ /**
31579
+ * The kit a frame's layout entry names, null for none or a layout that does
31580
+ * not read, parsed plainly as the address file is.
31581
+ */
31582
+ function frameKit({ root, project, page, name }) {
31583
+ try {
31584
+ return kitOf(keyOf$1(keyOf$1(keyOf$1(JSON.parse(readFileSync(join(root, project, page, LAYOUT_FILE), "utf8")), "frames"), name), "kit"));
31585
+ } catch {
31586
+ return null;
31587
+ }
31588
+ }
31589
+ /** An object's own key, undefined for a value holding none. */
31590
+ function keyOf$1(value, key) {
31591
+ return typeof value === "object" && value !== null && Object.hasOwn(value, key) ? value[key] : void 0;
31592
+ }
31593
+ /**
31594
+ * The kit sheets a frame draws with, as paths under its project in cascade
31595
+ * order: a project-wide kit's where `assets/kit/` holds `kit.json`, then the
31596
+ * tokens and stylesheet of the kit the frame names, each that exists.
31597
+ */
31598
+ function kitSheetFiles(root, project, kit) {
31599
+ const wide = [ASSETS_FOLDER, "kit"];
31600
+ const named = kitOf(kit);
31601
+ return [...existsSync(join(root, project, ...wide, "kit.json")) ? [[...wide, KIT_SHEET]] : [], ...named ? [TOKEN_FILE, KIT_SHEET].map((file) => [
31602
+ ASSETS_FOLDER,
31603
+ PROJECT_KITS,
31604
+ named,
31605
+ file
31606
+ ]) : []].filter((file) => existsSync(join(root, project, ...file))).map((file) => file.join("/"));
31607
+ }
31608
+ /**
31609
+ * The sheets the frame route imports ahead of a frame, being the board's
31610
+ * tokens, the project's, then its kit sheets, which the cascade reads ahead
31611
+ * of the frame's own. `kit` is the kit the frame names, null for a plain one.
31612
+ */
31613
+ function tokenSheets(root, project, tokens, kit = null) {
31614
+ return readSheets(root, project, tokenSheetPaths(root, project, tokens), kit);
31615
+ }
31616
+ /** `tokenSheets` for a caller already holding the project's sheet paths. */
31617
+ function readSheets(root, project, paths, kit) {
31618
+ const kitSheets = kitSheetFiles(root, project, kit).map((file) => join(root, project, file));
31619
+ return [
31620
+ paths.board,
31621
+ paths.project,
31622
+ ...kitSheets
31623
+ ].filter((path) => path !== null).map((path) => ({
31624
+ css: readFileSync(path, "utf8"),
31625
+ origin: "token",
31626
+ path,
31627
+ offset: 0
31628
+ }));
31629
+ }
31253
31630
  // src/server/edit/start-tag.ts
31254
31631
  function isSpace(char) {
31255
31632
  return char === " " || char === " " || char === "\n" || char === "\f" || char === "\r";
@@ -37437,6 +37814,11 @@ function isText(node) {
37437
37814
  function attribute$1(element, name) {
37438
37815
  return element.attrs.find((attr) => attr.name === name)?.value;
37439
37816
  }
37817
+ // src/shared/model-viewer.ts
37818
+ /** The custom element a frame shows a 3D model through. */
37819
+ const VIEWER_TAG = "model-viewer";
37820
+ /** The viewer's script as a project's `assets/` holds it, copied in with the first model placed. */
37821
+ const VIEWER_FILE = "model-viewer.min.js";
37440
37822
  // src/shared/faces.ts
37441
37823
  const FACES = [
37442
37824
  {
@@ -37573,6 +37955,11 @@ function starterSheet({ accent, font }) {
37573
37955
  `;
37574
37956
  }
37575
37957
  // src/server/edit/insert.ts
37958
+ /** The tag a frame shows an asset of `kind` through. */
37959
+ function assetTag(kind) {
37960
+ if (kind === "video" || kind === "audio") return kind;
37961
+ return kind === "model" ? VIEWER_TAG : "img";
37962
+ }
37576
37963
  const SHAPE_SIZE = 100;
37577
37964
  const TEXT_FONT_TOKEN = "--font-text";
37578
37965
  const PAINT_VALUE = /^(?:var\(--[\w-]+\)|#[0-9a-f]{6})$/i;
@@ -37598,6 +37985,7 @@ const CLOSED = /* @__PURE__ */ new Set([
37598
37985
  "title",
37599
37986
  "noscript",
37600
37987
  "iframe",
37988
+ VIEWER_TAG,
37601
37989
  "html",
37602
37990
  "head"
37603
37991
  ]);
@@ -37629,6 +38017,7 @@ function elementMarkup(element, paint, font) {
37629
38017
  if (!Number.isInteger(element.width)) throw new Error(`Unexpected audio width ${element.width}`);
37630
38018
  return `<audio data-name="${name}" src="${src}" controls style="width: ${element.width}px"></audio>`;
37631
38019
  }
38020
+ if (element.tag === "model-viewer") return `<model-viewer data-name="${name}" src="${src}" alt="" style="${size(element)}"></model-viewer>`;
37632
38021
  const style = `${size(element)}; object-fit: cover`;
37633
38022
  return element.tag === "video" ? `<video data-name="${name}" src="${src}" controls autoplay muted loop playsinline style="${style}"></video>` : `<img data-name="${name}" src="${src}" alt="" style="${style}">`;
37634
38023
  }
@@ -37645,6 +38034,66 @@ function assetLink(path) {
37645
38034
  function attribute(text) {
37646
38035
  return text.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;");
37647
38036
  }
38037
+ /** The tag a frame loads the viewer by, from its project's `assets/`. */
38038
+ const VIEWER_SCRIPT = `<script type="module" src="${assetLink(VIEWER_FILE)}"><\/script>`;
38039
+ /**
38040
+ * Writes the viewer's script at the end of the frame's head unless a script
38041
+ * there already loads one, an agent's own copy included. A frame stating no
38042
+ * head takes it ahead of its content, where the browser builds the head.
38043
+ */
38044
+ function ensureViewerScript(source) {
38045
+ const before = parseFrame(source);
38046
+ if (before.elements.some(loadsViewer)) return {
38047
+ ok: true,
38048
+ html: source,
38049
+ index: null
38050
+ };
38051
+ const { offset, lead } = headEnd(source, before);
38052
+ const written = source.slice(0, offset) + lead + VIEWER_SCRIPT + source.slice(offset);
38053
+ const after = parseFrame(written);
38054
+ const index = after.elements.findIndex((element) => element.sourceCodeLocation?.startOffset === offset + lead.length);
38055
+ const added = after.elements[index];
38056
+ const parent = added?.parentNode;
38057
+ if (!added || !parent || !hasTag(parent) || parent.tagName !== "head" || after.elements.length !== before.elements.length + 1 || !addsOnly(before, after, added, lead)) return refuse$2("verify-failed", "the viewer's script would change more than the frame's head, so nothing was written");
38058
+ return {
38059
+ ok: true,
38060
+ html: written,
38061
+ index
38062
+ };
38063
+ }
38064
+ /** Whether an element is a script loading a model viewer build, by its file name. */
38065
+ function loadsViewer(element) {
38066
+ if (element.tagName !== "script") return false;
38067
+ return ((element.attrs.find((attr) => attr.name === "src")?.value ?? "").split(/[?#]/)[0]?.split("/").at(-1) ?? "").includes(VIEWER_TAG);
38068
+ }
38069
+ /**
38070
+ * Where a head's last child ends, with the line break and indent that child
38071
+ * sits on, so the script lands on a line of its own. An unstated head takes
38072
+ * the offset its content would start at.
38073
+ */
38074
+ function headEnd(source, tree) {
38075
+ const head = tree.elements.find((element) => element.tagName === "head");
38076
+ const at = head?.sourceCodeLocation;
38077
+ const last = head?.childNodes.findLast(hasTag)?.sourceCodeLocation;
38078
+ if (last) {
38079
+ const indent = /\n[ \t]*$/.exec(source.slice(0, last.startOffset));
38080
+ return {
38081
+ offset: last.endOffset,
38082
+ lead: indent?.[0] ?? ""
38083
+ };
38084
+ }
38085
+ const stated = at?.startTag?.endOffset;
38086
+ if (stated !== void 0) return {
38087
+ offset: stated,
38088
+ lead: ""
38089
+ };
38090
+ const html = tree.elements.find((element) => element.tagName === "html");
38091
+ const doctype = tree.document.childNodes.find((node) => node.nodeName === "#documentType");
38092
+ return {
38093
+ offset: html?.sourceCodeLocation?.startTag?.endOffset ?? doctype?.sourceCodeLocation?.endOffset ?? 0,
38094
+ lead: ""
38095
+ };
38096
+ }
37648
38097
  function startTag(source, element) {
37649
38098
  return spanText(source, element, "start-tag");
37650
38099
  }
@@ -37719,10 +38168,18 @@ function insertElement(source, placement, markup, lead = "") {
37719
38168
  function descendants(element) {
37720
38169
  return children$1(element).reduce((count, child) => count + 1 + descendants(child), 0);
37721
38170
  }
37722
- /** Whether `after` is `before` with `added` alone added, compared once it is taken out. */
37723
- function addsOnly(before, after, added) {
38171
+ /**
38172
+ * Whether `after` is `before` with `added` alone added, compared once it is
38173
+ * taken out with the `lead` white space written ahead of it.
38174
+ */
38175
+ function addsOnly(before, after, added, lead = "") {
37724
38176
  const parent = added.parentNode;
37725
- parent.childNodes = parent.childNodes.filter((node) => node !== added);
38177
+ const previous = parent.childNodes[parent.childNodes.indexOf(added) - 1];
38178
+ if (lead !== "") {
38179
+ if (!previous || !("value" in previous) || !previous.value.endsWith(lead)) return false;
38180
+ previous.value = previous.value.slice(0, -lead.length);
38181
+ }
38182
+ parent.childNodes = parent.childNodes.filter((node) => node !== added && !("value" in node && node.value === ""));
37726
38183
  return serialize$1(before.document) === serialize$1(after.document);
37727
38184
  }
37728
38185
  /**
@@ -38575,8 +39032,8 @@ function editFrameFile(path, address, change, sourceAt) {
38575
39032
  }
38576
39033
  /**
38577
39034
  * Edits several elements as one write, all or none. One element named twice is
38578
- * refused, since one undo could not put both spans back, except a text and a
38579
- * style change, which answer one span over the whole element.
39035
+ * refused, since one undo could not put both spans back, except a text beside
39036
+ * a style or several attributes, which answer one span over the element.
38580
39037
  */
38581
39038
  function editFrameFileAll(path, hash, edits, sourceAt) {
38582
39039
  const read = readSource(path);
@@ -38640,24 +39097,46 @@ function mergedTwice(source, html, indexes, spans) {
38640
39097
  });
38641
39098
  }
38642
39099
  /**
38643
- * Whether each element a batch names is named once, or twice only as one
38644
- * `text` change and one `style` or `styles` change.
39100
+ * Whether each element a batch names is named once, twice as one `text`
39101
+ * change and one `style` or `styles` change, or by `attribute` changes that
39102
+ * each name another attribute.
38645
39103
  */
38646
39104
  function namedOnceEach(indexes, edits) {
38647
- const kinds = /* @__PURE__ */ new Map();
38648
- for (const [at, index] of indexes.entries()) kinds.set(index, [...kinds.get(index) ?? [], edits[at]?.change.kind ?? ""]);
38649
- return [...kinds.values()].every((named) => named.length === 1 || named.length === 2 && named.filter((kind) => kind === "text").length === 1 && named.some((kind) => kind === "style" || kind === "styles"));
39105
+ const changes = /* @__PURE__ */ new Map();
39106
+ for (const [at, index] of indexes.entries()) {
39107
+ const change = edits[at]?.change;
39108
+ if (change) changes.set(index, [...changes.get(index) ?? [], change]);
39109
+ }
39110
+ return [...changes.values()].every((named) => named.length === 1 || textAndStyle(named) || separateAttributes(named));
39111
+ }
39112
+ function textAndStyle(named) {
39113
+ return named.length === 2 && named.filter(({ kind }) => kind === "text").length === 1 && named.some(({ kind }) => kind === "style" || kind === "styles");
39114
+ }
39115
+ function separateAttributes(named) {
39116
+ const names = named.flatMap((change) => change.kind === "attribute" ? [change.name.toLowerCase()] : []);
39117
+ return names.length === named.length && new Set(names).size === names.length;
38650
39118
  }
38651
39119
  /**
38652
- * Writes one new element as `editFrameFile` writes, refusing a moved hash with
38653
- * no search, since the gap's indices name nothing once the file moved, so a
38654
- * retried insert lands at most once.
39120
+ * Writes one new element, refusing a moved hash with no search, since the
39121
+ * gap's indices name nothing once the file moved, so a retry lands at most
39122
+ * once. With `viewer`, it adds the viewer's script, which an undo leaves.
38655
39123
  */
38656
- function insertFrameFile(path, hash, placement, markup, place) {
39124
+ function insertFrameFile(path, hash, placement, markup, place, viewer = false) {
38657
39125
  const read = readSource(path);
38658
39126
  if (!read.ok) return read;
38659
39127
  if (read.hash !== hash) return stale$1(path);
38660
- const inserted = insertElement(read.source, placement, markup);
39128
+ const scripted = viewer ? ensureViewerScript(read.source) : {
39129
+ ok: true,
39130
+ html: read.source,
39131
+ index: null
39132
+ };
39133
+ if (!scripted.ok) return scripted;
39134
+ const script = scripted.index;
39135
+ const pastScript = (index) => script !== null && index >= script ? index + 1 : index;
39136
+ const inserted = insertElement(scripted.html, {
39137
+ parent: pastScript(placement.parent),
39138
+ before: placement.before === null ? null : pastScript(placement.before)
39139
+ }, markup);
38661
39140
  if (!inserted.ok) return inserted;
38662
39141
  const placed = place?.(inserted.html, inserted.index);
38663
39142
  if (placed && !placed.ok) return placed;
@@ -38665,6 +39144,7 @@ function insertFrameFile(path, hash, placement, markup, place) {
38665
39144
  const element = parseFrame(html).elements[inserted.index];
38666
39145
  if (!element) return stale$1(path);
38667
39146
  if (!replaceFile(path, hash, html)) return stale$1(path);
39147
+ const pastElement = shiftedPast(inserted.index, subtreeSize(html, inserted.index));
38668
39148
  return {
38669
39149
  ok: true,
38670
39150
  hash: contentHash(html),
@@ -38674,7 +39154,7 @@ function insertFrameFile(path, hash, placement, markup, place) {
38674
39154
  markup: spanText(html, element, "element")
38675
39155
  },
38676
39156
  parent: placed && placed.spans.length > 1 ? placed.spans[0] ?? null : null,
38677
- remap: shiftedPast(inserted.index, subtreeSize(html, inserted.index))
39157
+ remap: (index) => pastElement(pastScript(index))
38678
39158
  };
38679
39159
  }
38680
39160
  /**
@@ -38901,6 +39381,33 @@ function replaceFile(path, hash, html) {
38901
39381
  renameSync(temp, path);
38902
39382
  return true;
38903
39383
  }
39384
+ // src/server/models/viewer.ts
39385
+ /**
39386
+ * The viewer build a project's copy is taken from. A built run reads the
39387
+ * `viewer` folder the build put beside the bundle, and a source run reads the
39388
+ * pinned package.
39389
+ */
39390
+ function shippedViewerPath(moduleUrl = import.meta.url) {
39391
+ if (!moduleUrl.endsWith(".ts")) return fileURLToPath(new URL(`./viewer/${VIEWER_FILE}`, moduleUrl));
39392
+ const manifest = createRequire(moduleUrl).resolve("@google/model-viewer/package.json");
39393
+ return join(dirname(manifest), "dist", VIEWER_FILE);
39394
+ }
39395
+ /**
39396
+ * Copies the viewer script into a project's `assets/` unless a file already
39397
+ * holds its name, answering whether this call wrote it. A frame loads nothing
39398
+ * over the network, so each project carries its own copy.
39399
+ */
39400
+ async function ensureViewer(projectDir, shipped = shippedViewerPath()) {
39401
+ const folder = join(projectDir, ASSETS_FOLDER);
39402
+ await mkdir(folder, { recursive: true });
39403
+ try {
39404
+ await copyFile(shipped, join(folder, VIEWER_FILE), constants.COPYFILE_EXCL);
39405
+ return true;
39406
+ } catch (error) {
39407
+ if (isCode(error, "EEXIST")) return false;
39408
+ throw error;
39409
+ }
39410
+ }
38904
39411
  // src/shared/records/notes.ts
38905
39412
  /** Where a note on one element points, in the edit address's terms. */
38906
39413
  const noteAnchorSchema = looseObject({
@@ -40610,7 +41117,7 @@ const insertSchema = object$1({
40610
41117
  orFlow: boolean$1().optional()
40611
41118
  }).optional()
40612
41119
  });
40613
- const removeSchema = union([object$1({
41120
+ const removeSchema$1 = union([object$1({
40614
41121
  ref: string$1().min(1).max(1024),
40615
41122
  index: int$1().min(0),
40616
41123
  hash: string$1().regex(/^[0-9a-f]{64}$/)
@@ -40789,14 +41296,16 @@ function editRoutes(root, access, history, version, sheets) {
40789
41296
  }, 409);
40790
41297
  element = {
40791
41298
  ...body.element,
40792
- tag: asset.kind === "video" || asset.kind === "audio" ? asset.kind : "img"
41299
+ tag: assetTag(asset.kind)
40793
41300
  };
40794
41301
  }
41302
+ const viewer = element.kind === "asset" && element.tag === "model-viewer";
41303
+ if (viewer) await ensureViewer(join(root, frame.project));
40795
41304
  const { at } = body;
40796
41305
  const insert = (place) => insertFrameFile(frame.path, body.hash, {
40797
41306
  parent: body.parent,
40798
41307
  before: body.before
40799
- }, elementMarkup(element, shapePaint(tokens), textFont(tokens)), place);
41308
+ }, elementMarkup(element, shapePaint(tokens), textFont(tokens)), place, viewer);
40800
41309
  const placed = at && insert((html, index) => {
40801
41310
  const bare = element.kind === "text" ? applyEdit(html, { index }, {
40802
41311
  kind: "style",
@@ -40807,7 +41316,7 @@ function editRoutes(root, access, history, version, sheets) {
40807
41316
  html
40808
41317
  };
40809
41318
  if (!bare.ok) return bare;
40810
- const facts = elementPlaceFacts(frameFrom(frame, bare.html), tokenSheets(frame.project));
41319
+ const facts = elementPlaceFacts(frameFrom(frame, bare.html), tokenSheets(frame));
40811
41320
  return placeElement(bare.html, index, {
40812
41321
  left: at.left,
40813
41322
  top: at.top
@@ -40846,7 +41355,7 @@ function editRoutes(root, access, history, version, sheets) {
40846
41355
  });
40847
41356
  });
40848
41357
  app.post("/api/frames/remove", requireWriter(access), async (c) => {
40849
- const body = await parseBody$1(c.req.raw, removeSchema);
41358
+ const body = await parseBody$1(c.req.raw, removeSchema$1);
40850
41359
  const frame = await resolveFrameRef(root, body.ref, { cwd: root });
40851
41360
  const ref = `${frame.project}/${frame.page}/${frame.name}`;
40852
41361
  await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
@@ -40958,7 +41467,7 @@ function editRoutes(root, access, history, version, sheets) {
40958
41467
  index,
40959
41468
  spot,
40960
41469
  drop: spot ? [] : drop ?? []
40961
- })), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame.project)));
41470
+ })), (html) => elementPlaceFacts(frameFrom(frame, html), tokenSheets(frame)));
40962
41471
  if (!result.ok) return c.json({
40963
41472
  ok: false,
40964
41473
  error: {
@@ -40996,7 +41505,7 @@ function editRoutes(root, access, history, version, sheets) {
40996
41505
  });
40997
41506
  }
40998
41507
  const source = readFrame$1(frame);
40999
- const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame.project)) : [];
41508
+ const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame)) : [];
41000
41509
  const result = placeFrameFile(frame.path, body.hash, body.index, body.spot, facts, body.spot ? [] : body.drop ?? []);
41001
41510
  if (!result.ok) return c.json({
41002
41511
  ok: false,
@@ -41038,7 +41547,7 @@ function editRoutes(root, access, history, version, sheets) {
41038
41547
  const ref = `${frame.project}/${frame.page}/${frame.name}`;
41039
41548
  await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
41040
41549
  const source = readFrame$1(frame);
41041
- const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame.project)) : [];
41550
+ const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame)) : [];
41042
41551
  const result = wrapFrameFile(frame.path, body.hash, body.indexes, body.flow, body.spot, facts);
41043
41552
  if (!result.ok) return c.json({
41044
41553
  ok: false,
@@ -41123,86 +41632,11 @@ function editRoutes(root, access, history, version, sheets) {
41123
41632
  data
41124
41633
  });
41125
41634
  });
41126
- /** The project's token sheets as the cascade reads them, board-wide first. */
41127
- const tokenSheets = (project) => {
41128
- const paths = sheets?.(project);
41129
- return [paths?.board ?? null, paths?.project ?? null].filter((path) => path !== null).map((path) => ({
41130
- css: readFileSync(path, "utf8"),
41131
- origin: "token",
41132
- path,
41133
- offset: 0
41134
- }));
41135
- };
41635
+ /** The sheets the frame renders with ahead of its own, as the frame route imports them. */
41636
+ const tokenSheets = (frame) => sheets ? readSheets(root, frame.project, sheets(frame.project), frameKit(frame)) : [];
41136
41637
  app.onError(answerRefusal);
41137
41638
  return app;
41138
41639
  }
41139
- // src/shared/kits.ts
41140
- /**
41141
- * The names a design kit's folder of plain files is laid out by, installed so
41142
- * the frame route imports `assets/kit/` after the token sheets.
41143
- */
41144
- const KIT_FILE = "kit.json";
41145
- const KIT_SHEET = "kit.css";
41146
- const KIT_NOTE = "kit.md";
41147
- /** The dot folder in a board holding the kits saved from its projects, which home never lists as a project. */
41148
- const KITS_FOLDER = ".kits";
41149
- /**
41150
- * Where the board serves a kit's files, under `/frameboard/`, since a bare
41151
- * `/kits` would shadow the client's module folder under the dev server.
41152
- */
41153
- const KITS_URL = "/frameboard/kits";
41154
- /** The kits the tool ships, in the order a picker shows them. */
41155
- const SHIPPED_KITS = [
41156
- "clean",
41157
- "sketch",
41158
- "wireframe"
41159
- ];
41160
- // src/server/checks/tokens.ts
41161
- /**
41162
- * Where a project's token sheets sit, the address file read by plain
41163
- * `JSON.parse`, since the write hook cannot afford its schema.
41164
- */
41165
- function tokenSheetPaths(root, project, tokens) {
41166
- const own = join(root, project, TOKEN_FILE);
41167
- return {
41168
- board: boardSheetPath(root, tokens),
41169
- project: existsSync(own) ? own : null
41170
- };
41171
- }
41172
- /** The board's token sheet alone, resolved the way `tokenSheetPaths` resolves it. */
41173
- function boardSheetPath(root, tokens = recordedTokens(root)) {
41174
- const board = tokens ?? join(root, "tokens.css");
41175
- return existsSync(board) ? board : null;
41176
- }
41177
- /** The `--tokens` path the board's running server recorded, or null. */
41178
- function recordedTokens(root) {
41179
- try {
41180
- const parsed = JSON.parse(readFileSync(join(root, RUN_FOLDER, ADDRESS_FILE), "utf8"));
41181
- const tokens = typeof parsed === "object" && parsed !== null && "tokens" in parsed ? parsed.tokens : void 0;
41182
- return typeof tokens === "string" ? tokens : null;
41183
- } catch {
41184
- return null;
41185
- }
41186
- }
41187
- /**
41188
- * The sheets the frame route imports ahead of a project's frames, being the
41189
- * board's tokens, then the project's, then an installed kit's stylesheet,
41190
- * which the cascade reads ahead of each frame's own sheets.
41191
- */
41192
- function tokenSheets(root, project, tokens) {
41193
- const paths = tokenSheetPaths(root, project, tokens);
41194
- const kit = join(root, project, ASSETS_FOLDER, "kit", KIT_SHEET);
41195
- return [
41196
- paths.board,
41197
- paths.project,
41198
- existsSync(kit) ? kit : null
41199
- ].filter((path) => path !== null).map((path) => ({
41200
- css: readFileSync(path, "utf8"),
41201
- origin: "token",
41202
- path,
41203
- offset: 0
41204
- }));
41205
- }
41206
41640
  // src/shared/records/selection.ts
41207
41641
  const hashSchema = string$1().regex(/^[0-9a-f]{64}$/);
41208
41642
  /** More frames than any page holds, so a report cannot grow without bound. */
@@ -41262,7 +41696,7 @@ function elementsRoutes(root, access, selection, tokens = null) {
41262
41696
  const frame = await resolveFrameRef(root, ref, { cwd: root });
41263
41697
  const bytes = await readFile(frame.path);
41264
41698
  const source = readFrame$1(frame);
41265
- const sheets = tokenSheets(root, frame.project, tokens);
41699
+ const sheets = tokenSheets(root, frame.project, tokens, frameKit(frame));
41266
41700
  const elements = elementTree(bytes.toString("utf8"), elementLayouts(source, sheets), elementRounds(source, sheets), elementPlaceFacts(source, sheets));
41267
41701
  if (!Array.isArray(elements)) throw new FrameboardError(elements.reason, elements.detail, { ref });
41268
41702
  return {
@@ -41302,7 +41736,7 @@ function elementsRoutes(root, access, selection, tokens = null) {
41302
41736
  const data = {
41303
41737
  ref: source.ref,
41304
41738
  hash: contentHash(source.html),
41305
- ...frameStyles(source, tokenSheets(root, frame.project, tokens), index)
41739
+ ...frameStyles(source, tokenSheets(root, frame.project, tokens, frameKit(frame)), index)
41306
41740
  };
41307
41741
  return c.json({
41308
41742
  ok: true,
@@ -41615,99 +42049,73 @@ async function boardKitNames(root) {
41615
42049
  }
41616
42050
  // src/server/kits/install.ts
41617
42051
  /**
41618
- * Takes the project's own look out, being its `tokens.css`, its `kit` page,
41619
- * and its `assets/kit/`, each that exists, through the journal where one is
41620
- * given so an undo brings them back, and answers the paths taken.
41621
- */
41622
- async function takeOutLook(root, ref, { journal } = {}) {
41623
- const project = await resolveProject(root, ref);
41624
- const taken = [];
41625
- for (const old of lookPaths(project.path)) {
41626
- if (!existsSync(old)) continue;
41627
- if (journal) await journal.removed(old);
41628
- else await rm(old, { recursive: true });
41629
- taken.push(old);
41630
- }
41631
- return taken;
41632
- }
41633
- /** The project's sheet, kit page, and kit files, the paths an install writes. */
41634
- function lookPaths(projectPath) {
41635
- return [
41636
- join(projectPath, TOKEN_FILE),
41637
- join(projectPath, "kit"),
41638
- join(projectPath, ASSETS_FOLDER, "kit")
41639
- ];
41640
- }
41641
- /**
41642
- * Installs a kit into a project, refusing without `replace` where a sheet
41643
- * already reaches it, so a kit never writes under a chosen look, and writing
41644
- * nothing on any refusal.
42052
+ * Adds a kit to a project as a copy of its folder under `assets/kits/`, so
42053
+ * a frame can name it, touching no token sheet and no page. Refuses
42054
+ * `name-taken` where the project holds a kit by that name, writing nothing.
41645
42055
  */
41646
- async function installKit(root, ref, kit, { tokens, journal, replace = false } = {}) {
42056
+ async function installKit(root, ref, kit, { journal } = {}) {
41647
42057
  const project = await resolveProject(root, ref);
41648
- const sheet = join(project.path, TOKEN_FILE);
41649
- const assets = join(project.path, ASSETS_FOLDER);
41650
- const kitAssets = join(assets, "kit");
41651
- const page = join(project.path, "kit");
41652
- if (!replace) {
41653
- const sheets = tokenSheetPaths(root, project.name, tokens);
41654
- const existing = sheets.project ?? sheets.board;
41655
- if (existing) refuseSheet(project.name, existing);
41656
- for (const taken of [page, kitAssets]) if (existsSync(taken)) throw new FrameboardError("name-taken", `${project.name} already holds ${relative(project.path, taken)}, so no kit was installed.`, {
41657
- project: project.name,
41658
- path: taken
41659
- });
41660
- }
42058
+ assertValidName("kit", kit.name);
42059
+ const held = matchName(await projectKitNames(project.path), kit.name);
42060
+ const target = projectKitDir(project.path, kit.name);
42061
+ 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}\`.`, {
42062
+ project: project.name,
42063
+ kit: held ?? kit.name
42064
+ });
41661
42065
  await readKitFile(kit);
41662
- if (replace) await takeOutLook(root, project.name, { journal });
41663
- try {
41664
- await copyFile(join(kit.path, TOKEN_FILE), sheet, constants.COPYFILE_EXCL);
41665
- } catch (error) {
41666
- if (isCode(error, "EEXIST")) refuseSheet(project.name, sheet);
41667
- throw error;
41668
- }
41669
- await journal?.created(sheet);
41670
- const written = [sheet];
41671
- const assetsMade = !existsSync(assets);
41672
- await mkdir(assets, { recursive: true });
41673
- await cp(kit.path, kitAssets, {
42066
+ const made = topmostMissing(target);
42067
+ await mkdir(dirname(target), { recursive: true });
42068
+ await cp(kit.path, target, {
41674
42069
  recursive: true,
41675
42070
  errorOnExist: true,
41676
42071
  force: false,
41677
- filter: (path) => isKitAsset(kit.path, path)
42072
+ filter: (path) => isKitFile(kit.path, path)
41678
42073
  });
41679
- await journal?.created(assetsMade ? assets : kitAssets);
41680
- written.push(kitAssets);
41681
- const samples = join(kit.path, "kit");
41682
- if (existsSync(samples)) {
41683
- await cp(samples, page, {
41684
- recursive: true,
41685
- errorOnExist: true,
41686
- force: false,
41687
- filter: (path) => isCopied(basename(path))
41688
- });
41689
- await journal?.created(page);
41690
- written.push(page);
41691
- }
42074
+ await journal?.created(made);
41692
42075
  return {
41693
42076
  project: project.name,
41694
42077
  kit: kit.name,
41695
- written
42078
+ written: [target]
41696
42079
  };
41697
42080
  }
41698
- /** Whether a path in the kit folder goes under `assets/kit/`, being anything but the token sheet and the sample page. */
41699
- function isKitAsset(kitPath, path) {
42081
+ /** The highest folder on the way to `path` that does not exist yet, which an undo removes whole. */
42082
+ function topmostMissing(path) {
42083
+ const parent = dirname(path);
42084
+ return existsSync(parent) ? path : topmostMissing(parent);
42085
+ }
42086
+ /** Whether a path in the kit folder is copied, being anything but a dot-named entry or a lock or temp file. */
42087
+ function isKitFile(kitPath, path) {
41700
42088
  const inside = relative(kitPath, path);
41701
42089
  if (inside === "") return true;
41702
- const [top = "", ...rest] = inside.split("/");
41703
- if (rest.length === 0 && (top === "tokens.css" || top === "kit")) return false;
41704
- return !top.startsWith(".") && isCopied(basename(path));
42090
+ return !inside.split("/").some((part) => part.startsWith(".")) && isCopied(basename(path));
41705
42091
  }
41706
- function refuseSheet(project, sheet) {
41707
- throw new FrameboardError("tokens-exist", `${project} already renders with the token sheet ${sheet}, so no kit was installed.`, {
41708
- project,
41709
- sheet
41710
- });
42092
+ // src/server/kits/remove.ts
42093
+ /**
42094
+ * Takes a kit out of a project and clears it from every frame naming it,
42095
+ * under every page's lock, so no frame is left naming a folder that is
42096
+ * gone. Refuses `kit-not-found` for a name the project holds no kit under.
42097
+ */
42098
+ async function removeKit(root, ref, kit, { journal } = {}) {
42099
+ const project = await resolveProject(root, ref);
42100
+ const held = await heldKit(project, kit);
42101
+ const frames = await withLayouts((await listPageFolders(project.path)).map((page) => join(project.path, page)), async (layouts) => {
42102
+ const cleared = [];
42103
+ for (const [page, layout] of layouts) for (const name of layout.names) {
42104
+ const { kit: named, ...rest } = layout.placement(name);
42105
+ if (named !== held) continue;
42106
+ layout.set(name, rest);
42107
+ cleared.push(`${project.name}/${basename(page)}/${name}`);
42108
+ }
42109
+ const folder = projectKitDir(project.path, held);
42110
+ if (journal) await journal.removed(folder);
42111
+ else await rm(folder, { recursive: true });
42112
+ return cleared;
42113
+ }, journal);
42114
+ return {
42115
+ project: project.name,
42116
+ kit: held,
42117
+ frames
42118
+ };
41711
42119
  }
41712
42120
  // src/server/kits/save.ts
41713
42121
  /**
@@ -41728,7 +42136,7 @@ async function saveKit(root, ref, name, { tokens, journal } = {}) {
41728
42136
  await mkdir(staging, { recursive: true });
41729
42137
  try {
41730
42138
  const assets = join(project.path, ASSETS_FOLDER, "kit");
41731
- if (existsSync(assets)) await cp(assets, staging, {
42139
+ if (existsSync(join(assets, "kit.json"))) await cp(assets, staging, {
41732
42140
  recursive: true,
41733
42141
  filter: (from) => isCopied(basename(from))
41734
42142
  });
@@ -41917,7 +42325,9 @@ const CONTENT_TYPES$2 = {
41917
42325
  ".mp3": "audio/mpeg",
41918
42326
  ".wav": "audio/wav",
41919
42327
  ".ogg": "audio/ogg",
41920
- ".m4a": "audio/mp4"
42328
+ ".m4a": "audio/mp4",
42329
+ ".glb": "model/gltf-binary",
42330
+ ".gltf": "model/gltf+json"
41921
42331
  };
41922
42332
  /**
41923
42333
  * Serves the board's frames so relative links resolve unrewritten, its own
@@ -41979,7 +42389,13 @@ function frameRoutes(root, look, version, base = "") {
41979
42389
  if (held === null) return c.notFound();
41980
42390
  bytes = new TextEncoder().encode(held);
41981
42391
  }
41982
- const body = injectHead(bytes, frameHead(sheetUrls(project, look.sheets(project), hasKit(root, project)).map((url) => `${base}${url}`), contentHash(bytes), `${base}${BRIDGE_URL}`));
42392
+ const kit = isFrame ? frameKit({
42393
+ root,
42394
+ project,
42395
+ page,
42396
+ name: name.slice(0, -5)
42397
+ }) : null;
42398
+ const body = injectHead(bytes, frameHead(sheetUrls(project, look.sheets(project), kitSheetFiles(root, project, kit)).map((url) => `${base}${url}`), contentHash(bytes), `${base}${BRIDGE_URL}`));
41983
42399
  return c.body(body, 200, {
41984
42400
  "Content-Type": contentType,
41985
42401
  "Cache-Control": "no-store"
@@ -42031,22 +42447,18 @@ function parseRange(header, size) {
42031
42447
  }
42032
42448
  /**
42033
42449
  * The sheets a frame imports, being every face, then the board's tokens, then
42034
- * the project's, then an installed kit's stylesheet, which reads the tokens
42035
- * and still loses to the frame's own sheets.
42450
+ * the project's, then its kit sheets, which read the tokens and still lose to
42451
+ * the frame's own sheets. `kitFiles` come as `kitSheetFiles` answers them.
42036
42452
  */
42037
- function sheetUrls(project, sheets, kit) {
42453
+ function sheetUrls(project, sheets, kitFiles) {
42038
42454
  const folder = `/frames/${encodeURIComponent(project)}`;
42039
42455
  return [
42040
42456
  ...FACES.map(faceSheetUrl),
42041
42457
  ...sheets.board ? [BOARD_SHEET_URL] : [],
42042
42458
  ...sheets.project ? [`${folder}/${TOKEN_FILE}`] : [],
42043
- ...kit ? [`${folder}/${ASSETS_FOLDER}/kit/${KIT_SHEET}`] : []
42459
+ ...kitFiles.map((file) => `${folder}/${file.split("/").map(encodeURIComponent).join("/")}`)
42044
42460
  ];
42045
42461
  }
42046
- /** Whether a kit is installed in the project, read per request so an install reaches the next load. */
42047
- function hasKit(root, project) {
42048
- return existsSync(join(root, project, ASSETS_FOLDER, "kit", KIT_SHEET));
42049
- }
42050
42462
  function decodeSegments(segments) {
42051
42463
  const decoded = [];
42052
42464
  for (const segment of segments) {
@@ -42101,8 +42513,12 @@ const PREVIEW_POLICY = `script-src 'sha256-${createHash("sha256").update(THEME_S
42101
42513
  const installSchema = object$1({
42102
42514
  project: name$1,
42103
42515
  kit: name$1,
42104
- /** Installs over a look already there, which an undo brings back. */
42105
- replace: boolean$1().default(false)
42516
+ /** Accepted and ignored, since a caller written for the install that replaced a look may still send it. */
42517
+ replace: boolean$1().optional()
42518
+ });
42519
+ const removeSchema = object$1({
42520
+ project: name$1,
42521
+ kit: name$1
42106
42522
  });
42107
42523
  const saveSchema = object$1({
42108
42524
  project: name$1,
@@ -42124,15 +42540,15 @@ const CONTENT_TYPES$1 = {
42124
42540
  */
42125
42541
  function kitRoutes(root, access, history, { tokens, shipped = shippedKitsDir() }) {
42126
42542
  const app = new Hono();
42127
- /** Runs one write with a fresh journal and records it as a step that moves no page. */
42128
- const recorded = async (write) => {
42543
+ /** Runs one write with a fresh journal and records it as a step that moves no page, touching the frames `touched` reads off it. */
42544
+ const recorded = async (write, touched = () => []) => {
42129
42545
  const journal = history.journal();
42130
42546
  const result = await write(journal);
42131
42547
  history.record({
42132
42548
  id: journal.id,
42133
42549
  changes: journal.changes,
42134
42550
  page: null,
42135
- frames: []
42551
+ frames: touched(result)
42136
42552
  });
42137
42553
  return result;
42138
42554
  };
@@ -42143,20 +42559,21 @@ function kitRoutes(root, access, history, { tokens, shipped = shippedKitsDir() }
42143
42559
  app.post("/api/kits/install", requireWriter(access), async (c) => {
42144
42560
  const body = await parseBody$1(c.req.raw, installSchema);
42145
42561
  const kit = findKit(root, body.kit, shipped);
42146
- if (body.replace) {
42147
- await readKitFile(kit);
42148
- await recorded((journal) => takeOutLook(root, body.project, { journal }));
42149
- }
42150
- const installed = await recorded((journal) => installKit(root, body.project, kit, {
42151
- tokens,
42152
- journal,
42153
- replace: body.replace
42154
- }));
42562
+ const installed = await recorded((journal) => installKit(root, body.project, kit, { journal }));
42155
42563
  return c.json({
42156
42564
  ok: true,
42157
42565
  data: installed
42158
42566
  });
42159
42567
  });
42568
+ /** Takes a kit out of a project and off every frame naming it, as one step an undo brings back whole. */
42569
+ app.post("/api/kits/remove", requireWriter(access), async (c) => {
42570
+ const body = await parseBody$1(c.req.raw, removeSchema);
42571
+ const removed = await recorded((journal) => removeKit(root, body.project, body.kit, { journal }), (record) => record.frames);
42572
+ return c.json({
42573
+ ok: true,
42574
+ data: removed
42575
+ });
42576
+ });
42160
42577
  app.post("/api/kits/save", requireWriter(access), async (c) => {
42161
42578
  const body = await parseBody$1(c.req.raw, saveSchema);
42162
42579
  const saved = await recorded((journal) => saveKit(root, body.project, body.name, {
@@ -44475,6 +44892,105 @@ async function waitForImages(timeoutMs) {
44475
44892
  });
44476
44893
  return unsettled;
44477
44894
  }
44895
+ // src/server/capture/model-loads.ts
44896
+ /**
44897
+ * Records each viewer whose load fails, from before the frame's scripts run.
44898
+ * A viewer keeps no failed state to read and can fire its `error` ahead of
44899
+ * `settleModels`, which would then wait on an event already gone.
44900
+ */
44901
+ async function watchModels(page) {
44902
+ await page.addInitScript(recordFailedModels);
44903
+ }
44904
+ function recordFailedModels() {
44905
+ const failed = /* @__PURE__ */ new WeakSet();
44906
+ Object.defineProperty(window, Symbol.for("frameboard.failed-models"), { value: failed });
44907
+ const isViewer = (target) => target instanceof Element && target.localName === "model-viewer";
44908
+ document.addEventListener("error", ({ target }) => {
44909
+ if (isViewer(target)) failed.add(target);
44910
+ }, true);
44911
+ document.addEventListener("load", ({ target }) => {
44912
+ if (isViewer(target)) failed.delete(target);
44913
+ }, true);
44914
+ }
44915
+ /**
44916
+ * Waits for each `<model-viewer>` to draw, holds it at its clip's start, and
44917
+ * hides its loading bar, so two captures match. A model with no picture is
44918
+ * returned, never refused, read from the failures `watchModels` recorded.
44919
+ */
44920
+ async function settleModels(page, timeoutMs) {
44921
+ return page.evaluate(waitForModels, {
44922
+ timeoutMs: Math.max(0, timeoutMs),
44923
+ marker: LOOK_MARKER
44924
+ });
44925
+ }
44926
+ async function waitForModels({ timeoutMs, marker }) {
44927
+ const viewers = [];
44928
+ let index = 0;
44929
+ for (const element of document.querySelectorAll("*")) {
44930
+ if (element.closest("[data-frameboard]")) continue;
44931
+ const own = index;
44932
+ index += 1;
44933
+ if (element.localName !== "model-viewer") continue;
44934
+ const src = element.getAttribute("src") ?? "";
44935
+ if (!src) continue;
44936
+ viewers.push({
44937
+ index: own,
44938
+ viewer: element,
44939
+ src
44940
+ });
44941
+ }
44942
+ if (viewers.length === 0) return [];
44943
+ const bar = document.createElement("style");
44944
+ bar.setAttribute(marker, "");
44945
+ bar.textContent = "model-viewer { --progress-bar-height: 0px !important }";
44946
+ document.head.append(bar);
44947
+ const failed = window[Symbol.for("frameboard.failed-models")];
44948
+ const nextFrame = () => new Promise((done) => requestAnimationFrame(() => done()));
44949
+ const inViewport = (viewer) => new Promise((done) => {
44950
+ const observer = new IntersectionObserver(([entry]) => {
44951
+ observer.disconnect();
44952
+ done(entry?.isIntersecting ?? false);
44953
+ }, { threshold: 1e-5 });
44954
+ observer.observe(viewer);
44955
+ });
44956
+ const settle = async (viewer) => {
44957
+ if (!customElements.get("model-viewer")) return "error";
44958
+ viewer.loading = "eager";
44959
+ if (!viewer.loaded) {
44960
+ if (failed?.has(viewer)) return "error";
44961
+ if (!await new Promise((done) => {
44962
+ viewer.addEventListener("load", () => done(true), { once: true });
44963
+ viewer.addEventListener("error", () => done(false), { once: true });
44964
+ })) return "error";
44965
+ }
44966
+ viewer.pause();
44967
+ viewer.currentTime = 0;
44968
+ if (!await inViewport(viewer)) return "ok";
44969
+ while (!viewer.modelIsVisible && viewer.getAttribute("reveal") !== "manual") await nextFrame();
44970
+ await nextFrame();
44971
+ await nextFrame();
44972
+ return "ok";
44973
+ };
44974
+ const outcomes = viewers.map(({ viewer }) => ({
44975
+ state: "pending",
44976
+ done: settle(viewer)
44977
+ }));
44978
+ for (const outcome of outcomes) outcome.done.then((state) => {
44979
+ outcome.state = state;
44980
+ });
44981
+ await Promise.race([Promise.all(outcomes.map((outcome) => outcome.done)), new Promise((done) => setTimeout(done, timeoutMs))]);
44982
+ const unloaded = [];
44983
+ viewers.forEach(({ index: own, src }, at) => {
44984
+ const state = outcomes[at]?.state;
44985
+ if (state === void 0 || state === "ok") return;
44986
+ unloaded.push({
44987
+ index: own,
44988
+ src,
44989
+ state
44990
+ });
44991
+ });
44992
+ return unloaded;
44993
+ }
44478
44994
  // src/shared/motion.ts
44479
44995
  /**
44480
44996
  * Finds a page's motion timeline. Capture evaluates it by source text, so it
@@ -44508,6 +45024,14 @@ async function readMotionIn(view, timeoutMs) {
44508
45024
  duration: ends.length === 0 ? null : Math.round(Math.max(...ends))
44509
45025
  };
44510
45026
  }
45027
+ const clips = [...view.document.querySelectorAll("model-viewer")].map((viewer) => viewer).filter((viewer) => (viewer.availableAnimations?.length ?? 0) > 0);
45028
+ if (clips.length > 0) {
45029
+ const lengths = clips.map((viewer) => seconds(viewer.duration)).filter((length) => length !== null);
45030
+ return {
45031
+ source: "model",
45032
+ duration: lengths.length === 0 ? null : Math.max(...lengths)
45033
+ };
45034
+ }
44511
45035
  return null;
44512
45036
  };
44513
45037
  await nextFrame();
@@ -44518,8 +45042,8 @@ async function readMotionIn(view, timeoutMs) {
44518
45042
  }
44519
45043
  }
44520
45044
  /**
44521
- * Holds the page at `ms` once painted, converting to the seconds HyperFrames
44522
- * and GSAP take here alone, self-contained as `readMotionIn` is.
45045
+ * Holds the page at `ms` once painted, converting to the seconds HyperFrames,
45046
+ * GSAP, and a model viewer take here alone, self-contained as `readMotionIn` is.
44523
45047
  */
44524
45048
  async function holdMotionIn(view, { motion, ms }) {
44525
45049
  const at = motion.duration === null ? ms : Math.min(Math.max(ms, 0), motion.duration);
@@ -44531,10 +45055,16 @@ async function holdMotionIn(view, { motion, ms }) {
44531
45055
  timeline.pause?.();
44532
45056
  await timeline.seek(at / 1e3);
44533
45057
  }
44534
- } else for (const animation of view.document.getAnimations()) {
45058
+ } else if (motion.source === "css") for (const animation of view.document.getAnimations()) {
44535
45059
  animation.pause();
44536
45060
  animation.currentTime = at;
44537
45061
  }
45062
+ for (const element of view.document.querySelectorAll("model-viewer")) {
45063
+ const viewer = element;
45064
+ if (typeof viewer.pause !== "function") continue;
45065
+ viewer.pause();
45066
+ viewer.currentTime = at / 1e3;
45067
+ }
44538
45068
  await new Promise((done) => view.requestAnimationFrame(() => view.requestAnimationFrame(() => done())));
44539
45069
  return at;
44540
45070
  }
@@ -44689,9 +45219,9 @@ async function waitForVideos(timeoutMs) {
44689
45219
  /** How long a frame has to load, its faces and images included, before its capture fails. */
44690
45220
  const LOAD_TIMEOUT_MS = 1e4;
44691
45221
  /**
44692
- * Loads a frame within one budget for faces, images, and videos, then settles
44693
- * finite animations. A missing face or image refuses, while an unloaded video
44694
- * is returned rather than refused.
45222
+ * Loads a frame within one budget for faces, images, videos, and models, then
45223
+ * settles finite animations. A missing face or image refuses, while an
45224
+ * unloaded video or model is returned rather than refused.
44695
45225
  */
44696
45226
  async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts = "require", timeoutMs = LOAD_TIMEOUT_MS, motion = "settle" }) {
44697
45227
  const context = await browser.newContext({
@@ -44707,6 +45237,7 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
44707
45237
  try {
44708
45238
  const page = await context.newPage();
44709
45239
  if (motion === "hold") await holdAnimationClock(page);
45240
+ if (fonts === "require") await watchModels(page);
44710
45241
  await page.goto(new URL(frameThemeUrl(ref, theme), baseUrl).href, {
44711
45242
  timeout: timeoutMs,
44712
45243
  waitUntil: "domcontentloaded"
@@ -44720,10 +45251,12 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
44720
45251
  if (fonts === "require") await assertFontsPresent(page, ref);
44721
45252
  await settleImages(page, ref, fonts, deadline - Date.now());
44722
45253
  const videos = fonts === "require" ? await settleVideos(page, deadline - Date.now()) : [];
45254
+ const models = fonts === "require" ? await settleModels(page, deadline - Date.now()) : [];
44723
45255
  if (fonts === "require" && motion === "settle") await settleAnimations(page, deadline - Date.now());
44724
45256
  return {
44725
45257
  page,
44726
45258
  videos,
45259
+ models,
44727
45260
  close
44728
45261
  };
44729
45262
  } catch (error) {
@@ -44805,7 +45338,10 @@ function createWarmRenderer({ baseUrl, browser, scale: defaultScale }) {
44805
45338
  } finally {
44806
45339
  await opened.close();
44807
45340
  }
44808
- return device ? drawBezel(open, shot, frame.box, device, scale) : shot;
45341
+ return device ? drawBezel(open, shot, frame.box, {
45342
+ device,
45343
+ pose: frame.pose
45344
+ }, scale) : shot;
44809
45345
  });
44810
45346
  queue = run.catch(() => {});
44811
45347
  return run;
@@ -44843,7 +45379,7 @@ async function shootElement(page, ref, index, scale) {
44843
45379
  * A frame's shot drawn inside a device's body, as the board draws it, on a
44844
45380
  * page the size of the body, so the PNG holds the body and nothing past it.
44845
45381
  */
44846
- async function drawBezel(browser, shot, box, device, scale) {
45382
+ async function drawBezel(browser, shot, box, { device, pose = "closed" }, scale) {
44847
45383
  const outer = bezelBox({
44848
45384
  x: 0,
44849
45385
  y: 0,
@@ -44859,7 +45395,7 @@ async function drawBezel(browser, shot, box, device, scale) {
44859
45395
  });
44860
45396
  try {
44861
45397
  const page = await context.newPage();
44862
- const marks = device === "phone" ? `<span style="${pill(PHONE_ISLAND.width, PHONE_ISLAND.height, BEZEL_COLORS.island)}top:${PHONE_ISLAND.top}px"></span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>` : laptop ? laptopMarks(box) : "";
45398
+ const marks = device === "phone" ? `<span style="${pill(PHONE_ISLAND.width, PHONE_ISLAND.height, BEZEL_COLORS.island)}top:${PHONE_ISLAND.top}px"></span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>` : laptop ? laptopMarks(box) : device === "foldable" ? foldableMarks(pose) : "";
44863
45399
  const radius = screenCorners(device);
44864
45400
  await page.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="display:block;width:100%;height:100%;border-radius:${radius}"><div style="position:absolute;inset:0;border-radius:${radius};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
44865
45401
  return await page.screenshot({
@@ -44879,8 +45415,15 @@ function laptopMarks(box) {
44879
45415
  const edge = `1px solid ${BEZEL_COLORS.edge}`;
44880
45416
  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>`;
44881
45417
  }
44882
- function pill(width, height, color) {
44883
- return `position:absolute;left:50%;transform:translateX(-50%);width:${width}px;height:${height}px;border-radius:${height / 2}px;background:${color};`;
45418
+ /** The foldable's fold band, island, and home bar as the board draws them for a pose. */
45419
+ function foldableMarks(pose) {
45420
+ const band = foldBand(pose);
45421
+ const reach = pose === "half" ? -BEZELS.foldable.border : 0;
45422
+ const island = pill(FOLDABLE_ISLAND.width, FOLDABLE_ISLAND.height, BEZEL_COLORS.island, islandCenter(pose));
45423
+ return (band ? `<span style="position:absolute;left:50%;transform:translateX(-50%);top:${reach}px;bottom:${reach}px;width:${band.width}px;background:${band.background}"></span>` : "") + `<span style="${island}top:${FOLDABLE_ISLAND.top}px"></span><span style="${pill(HOME_BAR.width, HOME_BAR.height, BEZEL_COLORS.homeBar)}bottom:${HOME_BAR.bottom}px"></span>`;
45424
+ }
45425
+ function pill(width, height, color, center = .5) {
45426
+ return `position:absolute;left:${center * 100}%;transform:translateX(-50%);width:${width}px;height:${height}px;border-radius:${height / 2}px;background:${color};`;
44884
45427
  }
44885
45428
  // src/server/capture/fit.ts
44886
45429
  /** The widest a hugging width grows, past which the layout check reports the content clipped. */
@@ -45621,6 +46164,13 @@ const LINK_RULES = [
45621
46164
  }
45622
46165
  ];
45623
46166
  const finding$3 = findingFor(LINK_RULES);
46167
+ /** The attributes a `<model-viewer>` loads a file through, which `docs` states beside the rule. */
46168
+ const MODEL_LOADS = [
46169
+ "src",
46170
+ "poster",
46171
+ "environment-image",
46172
+ "skybox-image"
46173
+ ];
45624
46174
  /**
45625
46175
  * The attributes that load a resource, by element. An `a href` navigates
45626
46176
  * rather than loads, so it is left out.
@@ -45638,8 +46188,11 @@ const RESOURCE_ATTRIBUTES = {
45638
46188
  object: ["data"],
45639
46189
  input: ["src"],
45640
46190
  image: ["href", "xlink:href"],
45641
- use: ["href", "xlink:href"]
46191
+ use: ["href", "xlink:href"],
46192
+ "model-viewer": [...MODEL_LOADS]
45642
46193
  };
46194
+ /** The lighting a viewer builds itself, which `environment-image` names in place of a file. */
46195
+ const BUILT_IN_ENVIRONMENTS = /* @__PURE__ */ new Set(["neutral", "legacy"]);
45643
46196
  /** `outside-link`, `network`, and `missing-file` over every load a frame makes. */
45644
46197
  function checkLinks(source) {
45645
46198
  return frameLoads(source).flatMap((load) => judge(source, load));
@@ -45656,6 +46209,7 @@ function frameLoads(source) {
45656
46209
  for (const name of RESOURCE_ATTRIBUTES[element.name] ?? []) {
45657
46210
  const value = element.attribs[name];
45658
46211
  if (value === void 0) continue;
46212
+ if (name === "environment-image" && BUILT_IN_ENVIRONMENTS.has(value)) continue;
45659
46213
  const urls = name === "srcset" ? srcsetUrls(value) : [value];
45660
46214
  for (const url of urls) loads.push({
45661
46215
  url,
@@ -46024,8 +46578,9 @@ function checkFrame(target) {
46024
46578
  findings: checkFrameIn(target, readProjectContext(target.root, target.project))
46025
46579
  };
46026
46580
  }
46027
- function checkFrameIn(target, { config, tokens }) {
46581
+ function checkFrameIn(target, { config, tokens: tokensFor }) {
46028
46582
  const source = readFrame$1(target);
46583
+ const tokens = tokensFor(frameKit(target));
46029
46584
  const cascade = buildCascade(source, tokens);
46030
46585
  return withoutOff([
46031
46586
  ...checkNaming(target, boardPath(target.root, source.path)),
@@ -46047,9 +46602,16 @@ function checkFrameIn(target, { config, tokens }) {
46047
46602
  * address file names to every other caller.
46048
46603
  */
46049
46604
  function readProjectContext(root, project, boardSheet) {
46605
+ const byKit = /* @__PURE__ */ new Map();
46050
46606
  return {
46051
46607
  config: readConfig(root, project),
46052
- tokens: tokenSheets(root, project, boardSheet)
46608
+ tokens: (kit) => {
46609
+ const held = byKit.get(kit);
46610
+ if (held) return held;
46611
+ const sheets = tokenSheets(root, project, boardSheet, kit);
46612
+ byKit.set(kit, sheets);
46613
+ return sheets;
46614
+ }
46053
46615
  };
46054
46616
  }
46055
46617
  /**
@@ -46446,7 +47008,10 @@ const pasteSchema = object$1({
46446
47008
  });
46447
47009
  const frameDeviceSchema = object$1({
46448
47010
  refs,
46449
- show: boolean$1()
47011
+ /** Absent leaves the device as it stands, but for naming a foldable, which shows it. */
47012
+ show: boolean$1().optional(),
47013
+ foldable: boolean$1().optional(),
47014
+ pose: _enum$1(POSES).optional()
46450
47015
  });
46451
47016
  /** More widths than any device list offers, so a body cannot grow without bound. */
46452
47017
  const widthList = array$1(int$1().min(1)).max(64);
@@ -46476,6 +47041,11 @@ const frameTransitionSchema = object$1({
46476
47041
  refs,
46477
47042
  transition: transition.nullable()
46478
47043
  });
47044
+ /** Null clears each frame's kit, so it draws with the project's sheets alone. */
47045
+ const frameKitSchema = object$1({
47046
+ refs,
47047
+ kit: name.nullable()
47048
+ });
46479
47049
  /**
46480
47050
  * Blank text clears the note, and the setter refuses one past its limit.
46481
47051
  * `expected` is the note the edit began from, so one an agent set since is kept.
@@ -46545,7 +47115,7 @@ const projectTokensSchema = object$1({
46545
47115
  * frame hugs the player's height.
46546
47116
  */
46547
47117
  function mediaMarkup(ref, path, kind, { width, height }) {
46548
- const tag = kind === "video" || kind === "audio" ? kind : "img";
47118
+ const tag = assetTag(kind);
46549
47119
  if (width === void 0 || tag !== "audio" && height === void 0) throw new FrameboardError("usage", `A frame added with an asset takes the media's width${tag === "audio" ? "" : " and height"}.`, {
46550
47120
  ref,
46551
47121
  path
@@ -46731,6 +47301,7 @@ function structureRoutes(root, access, history, measure, tokens = null) {
46731
47301
  await refuseHeld([targetRef]);
46732
47302
  const { asset: path, ...placing } = body;
46733
47303
  let media;
47304
+ let head;
46734
47305
  if (path !== void 0) {
46735
47306
  const asset = await resolveAsset(join(root, target.project), path);
46736
47307
  if (!asset.ok) return c.json({
@@ -46745,10 +47316,15 @@ function structureRoutes(root, access, history, measure, tokens = null) {
46745
47316
  }
46746
47317
  }, 409);
46747
47318
  media = mediaMarkup(targetRef, path, asset.kind, body);
47319
+ if (asset.kind === "model") {
47320
+ await ensureViewer(join(root, target.project));
47321
+ head = VIEWER_SCRIPT;
47322
+ }
46748
47323
  }
46749
47324
  const frame = await recorded((journal) => addFrame(root, body.ref, {
46750
47325
  ...placing,
46751
47326
  body: media,
47327
+ head,
46752
47328
  cwd,
46753
47329
  journal
46754
47330
  }), (added) => onFrames([added.ref]));
@@ -46812,12 +47388,14 @@ function structureRoutes(root, access, history, measure, tokens = null) {
46812
47388
  data: frames
46813
47389
  });
46814
47390
  });
46815
- /** Shows or hides the device each frame's width names, in one step, leaving every frame file alone. */
47391
+ /** Shows or hides each frame's device, names the foldable, or folds it, in one step, leaving every frame file alone. */
46816
47392
  app.post("/api/frame/device", async (c) => {
46817
47393
  const body = await parseBody$1(c.req.raw, frameDeviceSchema);
46818
47394
  const frames = await eachFrame(body.refs, (frame, journal) => setFrameDevice(root, frame, body.show, {
46819
47395
  cwd,
46820
- journal
47396
+ journal,
47397
+ foldable: body.foldable,
47398
+ pose: body.pose
46821
47399
  }), (records) => records.map((record) => record.ref));
46822
47400
  return c.json({
46823
47401
  ok: true,
@@ -46856,6 +47434,18 @@ function structureRoutes(root, access, history, measure, tokens = null) {
46856
47434
  data: frames
46857
47435
  });
46858
47436
  });
47437
+ /** Sets or clears the project kit each frame draws with, in one step, leaving every frame file alone. */
47438
+ app.post("/api/frame/kit", async (c) => {
47439
+ const body = await parseBody$1(c.req.raw, frameKitSchema);
47440
+ const frames = await eachFrame(body.refs, (frame, journal) => setFrameKit(root, frame, body.kit, {
47441
+ cwd,
47442
+ journal
47443
+ }), (records) => records.map((record) => record.ref));
47444
+ return c.json({
47445
+ ok: true,
47446
+ data: frames
47447
+ });
47448
+ });
46859
47449
  /** Sets or clears one frame's speaker note in one step, leaving its file alone. */
46860
47450
  app.post("/api/frame/speaker-notes", async (c) => {
46861
47451
  const body = await parseBody$1(c.req.raw, frameSpeakerNotesSchema);
@@ -47450,16 +48040,22 @@ async function withFrameHost(board, purpose, run) {
47450
48040
  }
47451
48041
  }
47452
48042
  // src/server/capture/images.ts
47453
- /** The `videos` key of an image, left off when every video loaded. */
47454
- function videosKey(videos) {
47455
- return videos.length === 0 ? {} : { videos };
48043
+ /** The `videos` and `models` keys of an image, each left off when every one loaded. */
48044
+ function unloadedKeys(videos, models) {
48045
+ return {
48046
+ ...videos.length === 0 ? {} : { videos },
48047
+ ...models.length === 0 ? {} : { models }
48048
+ };
47456
48049
  }
47457
- function inFrame(ref, videos) {
47458
- return videos.map((video) => ({
48050
+ function inFrame(ref, unloaded) {
48051
+ return unloaded.map((each) => ({
47459
48052
  ref,
47460
- ...video
48053
+ ...each
47461
48054
  }));
47462
48055
  }
48056
+ function keysIn(ref, { videos, models }) {
48057
+ return unloadedKeys(inFrame(ref, videos), inFrame(ref, models));
48058
+ }
47463
48059
  const SCREENSHOT = {
47464
48060
  animations: "disabled",
47465
48061
  caret: "hide"
@@ -47552,7 +48148,7 @@ async function captureFrameImages(browser, { baseUrl, frames, themes, out, scale
47552
48148
  height: view.height,
47553
48149
  scale,
47554
48150
  ...shot.scrollY === void 0 ? {} : { scrollY: shot.scrollY },
47555
- ...videosKey(inFrame(frame.ref, shot.videos)),
48151
+ ...keysIn(frame.ref, shot),
47556
48152
  bytes: shot.bytes
47557
48153
  });
47558
48154
  }
@@ -47577,10 +48173,12 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
47577
48173
  for (const theme of themes) {
47578
48174
  const tiles = [];
47579
48175
  const videos = /* @__PURE__ */ new Map();
48176
+ const models = /* @__PURE__ */ new Map();
47580
48177
  for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths, frame.device)]) {
47581
- const { bytes, videos: unloaded } = await renderFrame(browser, baseUrl, frame, box, theme, scale);
47582
- for (const video of inFrame(frame.ref, unloaded)) videos.set(`${video.ref} ${video.index}`, video);
47583
- tiles.push(`<img src="data:image/png;base64,${bytes.toString("base64")}" style="position:absolute;left:${box.x + bounds.dx}px;top:${box.y + bounds.dy}px;width:${box.width}px;height:${box.height}px">`);
48178
+ const shot = await renderFrame(browser, baseUrl, frame, box, theme, scale);
48179
+ for (const video of inFrame(frame.ref, shot.videos)) videos.set(`${video.ref} ${video.index}`, video);
48180
+ for (const model of inFrame(frame.ref, shot.models)) models.set(`${model.ref} ${model.index}`, model);
48181
+ 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">`);
47584
48182
  }
47585
48183
  rendered.push({
47586
48184
  ref: page.ref,
@@ -47589,7 +48187,7 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
47589
48187
  width: bounds.width,
47590
48188
  height: bounds.height,
47591
48189
  scale,
47592
- ...videosKey([...videos.values()]),
48190
+ ...unloadedKeys([...videos.values()], [...models.values()]),
47593
48191
  bytes: await renderComposite(browser, bounds, theme, tiles, scale)
47594
48192
  });
47595
48193
  }
@@ -47626,7 +48224,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
47626
48224
  height: strip.height,
47627
48225
  scale,
47628
48226
  moments: strip.moments,
47629
- ...videosKey(inFrame(frame.ref, strip.videos)),
48227
+ ...keysIn(frame.ref, strip),
47630
48228
  bytes: strip.bytes
47631
48229
  });
47632
48230
  continue;
@@ -47650,7 +48248,7 @@ async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale
47650
48248
  height: view.height,
47651
48249
  scale,
47652
48250
  at: held,
47653
- ...videosKey(inFrame(frame.ref, shots.videos)),
48251
+ ...keysIn(frame.ref, shots),
47654
48252
  bytes
47655
48253
  });
47656
48254
  });
@@ -47671,7 +48269,7 @@ async function renderFilmstrip(browser, { baseUrl, frame, theme, scale = 1, coun
47671
48269
  height: frame.box.height
47672
48270
  };
47673
48271
  const strip = filmstripBounds(frame.ref, view, count, scale);
47674
- const { motion, held, videos } = await holdShots(browser, {
48272
+ const { motion, held, videos, models } = await holdShots(browser, {
47675
48273
  baseUrl,
47676
48274
  ref: frame.ref,
47677
48275
  view,
@@ -47686,7 +48284,8 @@ async function renderFilmstrip(browser, { baseUrl, frame, theme, scale = 1, coun
47686
48284
  height: strip.height,
47687
48285
  moments: held.map((shot) => shot.held),
47688
48286
  motion,
47689
- videos
48287
+ videos,
48288
+ models
47690
48289
  };
47691
48290
  }
47692
48291
  /**
@@ -47716,7 +48315,8 @@ async function holdShots(browser, { baseUrl, ref, view, theme, scale, motionTime
47716
48315
  return {
47717
48316
  motion,
47718
48317
  held,
47719
- videos: opened.videos
48318
+ videos: opened.videos,
48319
+ models: opened.models
47720
48320
  };
47721
48321
  } finally {
47722
48322
  await opened.close();
@@ -47740,7 +48340,8 @@ async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll)
47740
48340
  return {
47741
48341
  bytes: await opened.page.screenshot(SCREENSHOT),
47742
48342
  scrollY,
47743
- videos: opened.videos
48343
+ videos: opened.videos,
48344
+ models: opened.models
47744
48345
  };
47745
48346
  } finally {
47746
48347
  await opened.close();
@@ -47911,9 +48512,13 @@ async function pageOf(root, ref, options) {
47911
48512
  const { pages } = await readPageOrder(join(root, resolved.project));
47912
48513
  return scanPage(root, resolved.project, resolved.page, pages.indexOf(resolved.page));
47913
48514
  }
47914
- /** One line per image written, and under it one per video it shows with no picture. */
48515
+ /** One line per image written, and under it one per video or model it shows with no picture. */
47915
48516
  function describe$6(images) {
47916
- return images.flatMap((image) => [`Wrote ${image.path}`, ...(image.videos ?? []).map((video) => ` No picture for the video ${video.src} at element ${video.index} of ${video.ref}, which ${video.state === "error" ? "failed to load" : "was still loading when the load budget ran out"}`)]).join("\n");
48517
+ return images.flatMap((image) => [
48518
+ `Wrote ${image.path}`,
48519
+ ...(image.videos ?? []).map((video) => ` No picture for the video ${video.src} at element ${video.index} of ${video.ref}, which ${video.state === "error" ? "failed to load" : "was still loading when the load budget ran out"}`),
48520
+ ...(image.models ?? []).map((model) => ` No model drawn for ${model.src} at element ${model.index} of ${model.ref}, which ${model.state === "error" ? "failed to load" : "was still loading when the load budget ran out"}`)
48521
+ ]).join("\n");
47917
48522
  }
47918
48523
  // src/cli/board-server.ts
47919
48524
  /** How long a running server has to answer before the verb gives up on it. */
@@ -48166,12 +48771,19 @@ const frameRecordSchema = object$1({
48166
48771
  })),
48167
48772
  /** Whether the board draws the frame inside a device, absent when it does not. */
48168
48773
  showDevice: boolean$1().optional(),
48169
- /** The device the frame's width names while it shows one, absent when off or under 320 wide. */
48774
+ /**
48775
+ * The device the frame draws inside while it shows one: `foldable` when the
48776
+ * frame names it, else the one its width picks, absent when off or under 320 wide.
48777
+ */
48170
48778
  device: _enum$1(DEVICES).optional(),
48779
+ /** The pose a frame naming the foldable is folded to, shown or not, absent on every other frame. */
48780
+ pose: _enum$1(POSES).optional(),
48171
48781
  /** The transition the frame arrives with in present mode, over its page's, absent when it holds none. */
48172
48782
  transition: transitionRecordSchema.optional(),
48173
48783
  /** What the presenter means to say over the slide, plain text with its line breaks, absent when it holds none. */
48174
48784
  speakerNotes: string$1().optional(),
48785
+ /** The project kit the frame names, absent when it names none, and still given where the project holds no such kit. */
48786
+ kit: string$1().optional(),
48175
48787
  placed: boolean$1(),
48176
48788
  modifiedAt: string$1()
48177
48789
  });
@@ -48200,6 +48812,15 @@ const pageRecordSchema = object$1({
48200
48812
  /** Bottom first, as frames are. */
48201
48813
  sections: array$1(sectionRecordSchema)
48202
48814
  });
48815
+ /** One kit a project added, a folder under its `assets/kits/`. */
48816
+ const projectKitRecordSchema = object$1({
48817
+ /** The kit's folder, which a frame's `kit` and `frame kit` name it by. */
48818
+ name: string$1(),
48819
+ /** The name a person reads, the folder's where its `kit.json` gives none. */
48820
+ title: string$1(),
48821
+ /** How many of the project's frames name the kit. */
48822
+ frameCount: number()
48823
+ });
48203
48824
  const projectRecordSchema = object$1({
48204
48825
  /** The folder, which every ref, URL, and CLI argument names the project by. */
48205
48826
  name: string$1(),
@@ -48218,6 +48839,8 @@ const projectRecordSchema = object$1({
48218
48839
  transitions: array$1(string$1()),
48219
48840
  /** The rule ids `checks.off` in `project.json` turns off, in the file's order and each once, empty when it holds none. */
48220
48841
  checksOff: array$1(string$1()),
48842
+ /** The kits the project added, by name, empty when it holds none. */
48843
+ kits: array$1(projectKitRecordSchema),
48221
48844
  pages: array$1(pageRecordSchema)
48222
48845
  });
48223
48846
  const listResultSchema = object$1({
@@ -48252,6 +48875,16 @@ const captureResultSchema = object$1({
48252
48875
  src: string$1(),
48253
48876
  /** `error` for a file that failed to load or decode, `pending` for one still loading when the load budget ran out. */
48254
48877
  state: _enum$1(["error", "pending"])
48878
+ })).optional(),
48879
+ /** Each model the image shows undrawn, absent when every model loaded. */
48880
+ models: array$1(object$1({
48881
+ /** The frame holding the model, which a composite needs to tell its frames apart. */
48882
+ ref: string$1(),
48883
+ /** The element's index in document order, as `edit --index` takes it. */
48884
+ index: int$1().min(0),
48885
+ src: string$1(),
48886
+ /** `error` for a model or a viewer script that failed to load, `pending` for one still loading when the load budget ran out. */
48887
+ state: _enum$1(["error", "pending"])
48255
48888
  })).optional()
48256
48889
  })),
48257
48890
  /** The timeline an `--at` or `--filmstrip` capture seeked, absent on any other. */
@@ -48259,7 +48892,8 @@ const captureResultSchema = object$1({
48259
48892
  source: _enum$1([
48260
48893
  "hf",
48261
48894
  "timelines",
48262
- "css"
48895
+ "css",
48896
+ "model"
48263
48897
  ]),
48264
48898
  /** Its length in ms, or null when every animation repeats forever. */
48265
48899
  duration: int$1().min(0).nullable()
@@ -48731,6 +49365,7 @@ function contentFormat() {
48731
49365
  `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.`,
48732
49366
  `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.`,
48733
49367
  `showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side and the tablet's ${BEZELS.tablet.border}, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file, 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.`,
49368
+ `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.`,
48734
49369
  `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.`,
48735
49370
  "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.",
48736
49371
  "Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
@@ -48755,8 +49390,10 @@ function contentFormat() {
48755
49390
  ],
48756
49391
  kits: [
48757
49392
  `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}/.`,
48758
- `kit add copies the kit's ${TOKEN_FILE} as the project's, its kit page as the project's kit page, and every other file into ${ASSETS_FOLDER}/kit/. It refuses tokens-exist where a board, --tokens, or project sheet already reaches the project, and name-taken where the project holds a kit page or ${ASSETS_FOLDER}/kit/, unless --replace is given. kit save refuses name-taken for a name a shipped or saved kit holds, and tokens-not-found for a project no sheet reaches.`,
48759
- `The server imports ${ASSETS_FOLDER}/kit/${KIT_SHEET} into each frame after the project sheet, and check reads it with the token sheets. Read ${ASSETS_FOLDER}/kit/${KIT_NOTE} and the kit page before drawing in a project that holds one.`
49393
+ `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.`,
49394
+ `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.`,
49395
+ `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.`,
49396
+ `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.`
48760
49397
  ],
48761
49398
  images: [
48762
49399
  `image find searches Openverse under ${DEFAULT_LICENSES.join(", ")} alone, and --credited widens it to ${CREDITED_LICENSES.join(", ")}. It lists up to 20 results numbered from 1 and writes nothing. --save <number> runs the search again and saves that result, and --save <id> saves the Openverse image with that id with no search, refusing result-not-found for an id under a license the flags do not allow. Openverse allows an address 200 anonymous requests a day, so save by id.`,
@@ -48765,10 +49402,16 @@ function contentFormat() {
48765
49402
  "image doctor reports the GPU nvidia-smi names, whether a ComfyUI server answers at FRAMEBOARD_COMFYUI_URL or the default address, and each key as set or unset, never its value. It installs and spends nothing.",
48766
49403
  `A frame links a saved image as ../${ASSETS_FOLDER}/<path>, never by its web address, since a frame loads nothing over the network.`
48767
49404
  ],
49405
+ models: [
49406
+ `A frame shows a 3D model through one <${VIEWER_TAG} src="../${ASSETS_FOLDER}/<file>.glb" alt=""> element, sized by its own width and height as an image is. It reads .glb and .gltf alone, and a .gltf carries its buffers and images inside itself. A drop refuses ${FOREIGN_MODELS.join(", ")}, so export any of those from Blender through File, Export, glTF 2.0 as a glTF Binary (.glb).`,
49407
+ `The element draws only in a frame whose head loads the viewer, as ${VIEWER_SCRIPT}. Placing a model on the board copies ${VIEWER_FILE} into the project's ${ASSETS_FOLDER}/ once and adds that tag to a head loading no viewer, and removing the last model leaves both. The file ships with the tool at ${shippedViewerPath()}, so copy it to the project's ${ASSETS_FOLDER}/${VIEWER_FILE} before writing the element in a project that holds none. A frame loads nothing over the network, so never link the viewer from a CDN.`,
49408
+ `Every staging control is an attribute on the element, set with edit --attr. camera-orbit="<theta>deg <phi>deg <radius>" places the camera, across and then down from the top, and defaults to 0deg 75deg auto. The viewer holds the camera inside max-camera-orbit, so state both once the radius passes the model's own framing, as camera-orbit="30deg 70deg 6m" max-camera-orbit="auto auto 6m". orientation="<roll>deg <pitch>deg <yaw>deg" turns the model itself, scale="<x> <y> <z>" sizes it, animation-name picks one of its clips, and autoplay starts it. The board's Model section writes these same attributes, the angle as both orbit attributes in one undo step, and a double-click on a selected model turns it by drag.`,
49409
+ `check reports missing-file at error for a ${VIEWER_TAG} whose ${MODEL_LOADS.join(", ")} names no file, as it does for the viewer script. capture waits for each model to draw inside the frame's load budget and holds its clip at the start, and --at seeks every clip to that moment, so two captures match. A model that fails to load, or is still loading when the budget ends, never refuses: the image lists it under models with state error or pending.`
49410
+ ],
48768
49411
  assets: `A frame links files in its own page folder or in its project's ${ASSETS_FOLDER}/ folder. frame duplicate and frame move carry the ${FRAME_EXTENSION} file alone, so keep files shared between frames or pages in ${ASSETS_FOLDER}/.`,
48769
49412
  look: [
48770
49413
  `The board's ${TOKEN_FILE} holds the design tokens every project shares, and a project's own ${TOKEN_FILE} overrides it. serve --tokens <path> stands in for the board's sheet, resolved against the working folder and recorded as tokens in ${RUN_FOLDER}/${ADDRESS_FILE} while that server runs.`,
48771
- `The server puts one <style ${LOOK_MARKER}> first in each frame's head, importing the faces, then the board sheet, then the project sheet, then an installed kit's stylesheet, so a frame's own sheets win. The file on disk never changes, and a count of a live frame's elements skips elements carrying ${LOOK_MARKER}.`,
49414
+ `The server puts one <style ${LOOK_MARKER}> first in each frame's head, importing the faces, then the board sheet, then the project sheet, then the sheets of the kit the frame names, so a frame's own sheets win. The file on disk never changes, and a count of a live frame's elements skips elements carrying ${LOOK_MARKER}.`,
48772
49415
  `Every frame can use the families ${FACES.map((face) => face.family).join(", ")} with no link of its own. A project adds other faces in its ${ASSETS_FOLDER}/ folder.`,
48773
49416
  "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.",
48774
49417
  `A change to a token sheet reloads every frame it reaches.`,
@@ -48826,6 +49469,8 @@ function formatLines(format) {
48826
49469
  ...format.kits.map((line) => `${INDENT}${line}`),
48827
49470
  "Images",
48828
49471
  ...format.images.map((line) => `${INDENT}${line}`),
49472
+ "Models",
49473
+ ...format.models.map((line) => `${INDENT}${line}`),
48829
49474
  "Assets",
48830
49475
  `${INDENT}${format.assets}`,
48831
49476
  "Look",
@@ -49147,11 +49792,12 @@ const DEVICE_ON = [
49147
49792
  "phone",
49148
49793
  "tablet"
49149
49794
  ];
49150
- /** What `frame device` did, naming the device the frame's width gave it. */
49151
- function deviceHeadline({ ref, box, showDevice, device }) {
49152
- if (!showDevice) return `Hid the device on ${ref}`;
49795
+ /** What `frame device` did, naming the device the frame draws inside and a foldable's pose. */
49796
+ function deviceHeadline({ ref, box, showDevice, device, pose }) {
49797
+ const folded = pose ? `, folded ${pose} at ${box.width} by ${box.height}` : "";
49798
+ if (!showDevice) return `Hid the device on ${ref}${folded}`;
49153
49799
  if (!device) return `Showed the device on ${ref}, though no device fits its ${box.width} px width`;
49154
- return `Showed the ${device} on ${ref}`;
49800
+ return `Showed the ${device} on ${ref}${folded}`;
49155
49801
  }
49156
49802
  const WIDTHS_HELP = "the extra widths the frame also shows at, a comma list such as 834,390, each drawn beside it and hugging or holding its height as the frame does";
49157
49803
  const POSITIVE = parseInteger(1);
@@ -49233,11 +49879,14 @@ function registerFrame(program, context) {
49233
49879
  human: `Deleted frame ${result.deleted}`
49234
49880
  };
49235
49881
  });
49236
- act(verb("device", "Show or hide the device the board draws around a frame, the phone, tablet, or laptop its width names, leaving the frame file and its size as they are").addArgument(new Argument("<on|off>", "on to show the device, off to hide it, with phone and tablet taken as on and none as off").choices(Object.keys(DEVICE_SWITCH))), context, async ([ref = "", value = ""], options) => {
49237
- const show = Object.hasOwn(DEVICE_SWITCH, value) ? DEVICE_SWITCH[value] : false;
49882
+ act(verb("device", "Show or hide the device the board draws around a frame, the phone, tablet, or laptop its width names or the foldable the frame names, and fold a foldable, leaving the frame file as it is").addArgument(new Argument("[on|off]", "on to show the device, off to hide it, with phone and tablet taken as on and none as off, and absent to leave it, which --foldable takes as on").choices(Object.keys(DEVICE_SWITCH))).addOption(new Option("--foldable", "name the foldable over the device the width picks, setting the box to the pose nearest its width")).addOption(new Option("--no-foldable", "hand the pick back to the width, leaving the box at its size")).addOption(new Option("--pose <pose>", "fold a foldable, setting its box to 466 by 678 closed and 890 by 626 half or open").choices(POSES)), context, async ([ref = "", value], { foldable, pose, ...options }) => {
49883
+ if (value === void 0 && foldable === void 0 && pose === void 0) throw new FrameboardError("usage", "frame device takes on or off, --foldable, --no-foldable, or --pose.");
49884
+ const show = value !== void 0 && Object.hasOwn(DEVICE_SWITCH, value) ? DEVICE_SWITCH[value] : void 0;
49238
49885
  const record = await setFrameDevice(await boardOf(options, io), ref, show, {
49239
49886
  ...options,
49240
- cwd: io.cwd
49887
+ cwd: io.cwd,
49888
+ foldable,
49889
+ pose
49241
49890
  });
49242
49891
  return {
49243
49892
  data: record,
@@ -49251,6 +49900,13 @@ function registerFrame(program, context) {
49251
49900
  });
49252
49901
  return done(record, record.transition ? `Set ${transitionLabel(record.transition.name)} on` : "Cleared the transition on");
49253
49902
  });
49903
+ act(verb("kit", `Set the project kit this frame draws with, one \`kit add\` copied into the project, or clear it with ${NO_KIT_WORD} so it draws with the project's sheets alone, writing only layout.json. Refuses kit-not-found for a kit the project holds none under`).argument("<kit>", `a kit the project holds, or ${NO_KIT_WORD}`), context, async ([ref = "", name = ""], options) => {
49904
+ const record = await setFrameKit(await boardOf(options, io), ref, name === "none" ? null : name, {
49905
+ ...options,
49906
+ cwd: io.cwd
49907
+ });
49908
+ return done(record, record.kit ? `Set the kit ${record.kit} on` : "Cleared the kit on");
49909
+ });
49254
49910
  act(verb("speaker-notes", `Print a slide's speaker note, set it to the text given, or remove it with --clear, writing only layout.json and never the frame file. Plain text up to ${SPEAKER_NOTES_MAX} characters with its line breaks kept, and blank text clears it.`).argument("[text]", "the note to set, in place of the one it holds").option("--clear", "remove the note"), context, async ([ref = "", text], { clear, ...options }) => {
49255
49911
  if (clear && text !== void 0) throw new FrameboardError("usage", "Pass the text or --clear, not both.");
49256
49912
  const root = await boardOf(options, io);
@@ -53255,28 +53911,36 @@ function describe$3(result) {
53255
53911
  // src/cli/commands/kit.ts
53256
53912
  function registerKit(program, context) {
53257
53913
  const { io } = context;
53258
- const kit = program.command("kit").description("Install a design kit's tokens, styles, and sample frames into a project, or save a project's look as one");
53259
- act(addVerb(kit, "list", "List the kits a project can install, the shipped ones first and then the board’s own"), context, async (_args, options) => {
53914
+ const kit = program.command("kit").description("Add a design kit to a project for its frames to name, remove one, or save a project's look as a kit");
53915
+ act(addVerb(kit, "list", "List the kits a project can add, the shipped ones first and then the board’s own"), context, async (_args, options) => {
53260
53916
  const kits = await listKits(await boardOf(options, io));
53261
53917
  return {
53262
53918
  data: kits,
53263
53919
  human: kits.map((each) => `${each.name}\t${each.description}`).join("\n")
53264
53920
  };
53265
53921
  });
53266
- act(addVerb(kit, "add", "Install a kit into a project no token sheet reaches, refusing tokens-exist where a board, --tokens, or project sheet does unless --replace is given").argument("<project>", "the project").argument("[kit]", "a kit `kit list` names").option("--from <folder>", "install the kit in this folder instead").option("--replace", "install over the project's own sheet, kit page, and kit files, or over a board sheet"), context, async ([project = "", name], options) => {
53922
+ 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) => {
53267
53923
  if (name === void 0 === (options.from === void 0)) throw new FrameboardError("usage", "Name a kit or pass --from <folder>, not both.");
53268
53924
  const root = await boardOf(options, io);
53269
53925
  const folder = options.from === void 0 ? null : resolve$1(io.cwd, options.from);
53270
53926
  const record = await installKit(root, project, folder === null ? findKit(root, name ?? "") : {
53271
53927
  name: basename(folder),
53272
53928
  path: folder
53273
- }, { replace: options.replace ?? false });
53929
+ });
53930
+ return {
53931
+ data: record,
53932
+ human: `Added ${record.kit} to ${record.project}`
53933
+ };
53934
+ });
53935
+ 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) => {
53936
+ const record = await removeKit(await boardOf(options, io), project, name);
53937
+ const count = record.frames.length;
53274
53938
  return {
53275
53939
  data: record,
53276
- human: `Installed ${record.kit} into ${record.project}`
53940
+ human: `Removed ${record.kit} from ${record.project}, clearing it from ${count} ${count === 1 ? "frame" : "frames"}`
53277
53941
  };
53278
53942
  });
53279
- act(addVerb(kit, "save", "Save a project's tokens, kit files, and kit page as a kit the board's projects can install").argument("<project>", "the project").argument("<name>", "the new kit"), context, async ([project = "", name = ""], options) => {
53943
+ act(addVerb(kit, "save", "Save a project's tokens, kit files, and kit page as a kit the board's projects can add").argument("<project>", "the project").argument("<name>", "the new kit"), context, async ([project = "", name = ""], options) => {
53280
53944
  const record = await saveKit(await boardOf(options, io), project, name);
53281
53945
  return {
53282
53946
  data: record,
@@ -58078,6 +58742,17 @@ function relistedRefs(previous, next) {
58078
58742
  function listed(frame) {
58079
58743
  return frame.widths.map(({ width }) => width).join(",");
58080
58744
  }
58745
+ /**
58746
+ * Frames whose kit changed, reloaded here, since the kit lives in
58747
+ * `layout.json`, which reloads nothing, and the frame route imports its sheets.
58748
+ */
58749
+ function rekittedRefs(previous, next) {
58750
+ const before = new Map(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.map((frame) => [frame.ref, frame.kit ?? null]))));
58751
+ return next.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => {
58752
+ const was = before.get(frame.ref);
58753
+ return was !== void 0 && was !== (frame.kit ?? null);
58754
+ }).map((frame) => frame.ref)));
58755
+ }
58081
58756
  // src/server/live/findings.ts
58082
58757
  /**
58083
58758
  * The board's findings, held between batches so a hello needs no check, and
@@ -59271,6 +59946,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
59271
59946
  let own;
59272
59947
  let placed;
59273
59948
  let relisted = [];
59949
+ let rekitted = [];
59274
59950
  try {
59275
59951
  await landReserved(root, /* @__PURE__ */ new Date()).catch(() => []);
59276
59952
  board = await scanBoard(root);
@@ -59279,6 +59955,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
59279
59955
  own = ownFileRefs(board, paths);
59280
59956
  placed = previous ? placedRefs(previous, board, paths).filter((ref) => !own.includes(ref)) : [];
59281
59957
  relisted = previous ? relistedRefs(previous, board) : [];
59958
+ rekitted = previous ? rekittedRefs(previous, board) : [];
59282
59959
  if (await hug.now(board, [...own, ...placed]).catch(() => false)) {
59283
59960
  const measured = board;
59284
59961
  board = await scanBoard(root);
@@ -59298,7 +59975,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
59298
59975
  });
59299
59976
  const last = shown.board;
59300
59977
  shown.board = board;
59301
- const refs = reloadRefs(root, paths, board, tokens);
59978
+ const refs = [.../* @__PURE__ */ new Set([...reloadRefs(root, paths, board, tokens), ...rekitted])];
59302
59979
  hug.later(board, [.../* @__PURE__ */ new Set([...refs, ...relisted])].filter((ref) => !own.includes(ref) && !placed.includes(ref)));
59303
59980
  if (refs.length > 0) {
59304
59981
  const reloads = unmovedRefs(refs, board, moved(), last);