frameboard 0.33.0 → 0.34.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
@@ -9404,6 +9404,100 @@ function drawnExtent(box, widths, device) {
9404
9404
  height: bottom - top
9405
9405
  };
9406
9406
  }
9407
+ // src/shared/present-transition.ts
9408
+ /**
9409
+ * The transitions present mode draws between slides, in the order the
9410
+ * inspector lists them. The list is the board's own and a project adds
9411
+ * none yet, so a name outside it reads as no transition.
9412
+ */
9413
+ const TRANSITIONS = [
9414
+ "none",
9415
+ "fade",
9416
+ "slide",
9417
+ "push",
9418
+ "zoom",
9419
+ "flip",
9420
+ "dissolve"
9421
+ ];
9422
+ const TRANSITION_LABELS = {
9423
+ none: "None",
9424
+ fade: "Fade",
9425
+ slide: "Slide",
9426
+ push: "Push",
9427
+ zoom: "Zoom",
9428
+ flip: "Flip",
9429
+ dissolve: "Dissolve"
9430
+ };
9431
+ /** The way a directed transition moves the incoming slide, as a slide tool's effect options name it. */
9432
+ const DIRECTIONS = [
9433
+ "left",
9434
+ "right",
9435
+ "up",
9436
+ "down"
9437
+ ];
9438
+ /** The transitions that take a direction. The rest ignore one. */
9439
+ const DIRECTED = ["slide", "push"];
9440
+ /** The shortest and longest transition a record holds, so a typo never freezes a talk. */
9441
+ const TRANSITION_MS = {
9442
+ min: 100,
9443
+ max: 5e3
9444
+ };
9445
+ function takesDirection(name) {
9446
+ return DIRECTED.includes(name);
9447
+ }
9448
+ function transitionNameOf(value) {
9449
+ return TRANSITIONS.find((name) => name === value) ?? null;
9450
+ }
9451
+ /**
9452
+ * A stored transition as a reader takes it, or null for anything but an
9453
+ * object naming a known transition. A direction or a duration no reader
9454
+ * understands reads as absent, so it falls to the default rather than
9455
+ * hiding the transition.
9456
+ */
9457
+ function transitionOf(value) {
9458
+ if (typeof value !== "object" || value === null) return null;
9459
+ const held = value;
9460
+ const name = transitionNameOf(held.name);
9461
+ if (!name) return null;
9462
+ const direction = DIRECTIONS.find((candidate) => candidate === held.direction);
9463
+ const ms = msOf(held.ms);
9464
+ return {
9465
+ name,
9466
+ ...direction ? { direction } : {},
9467
+ ...ms === void 0 ? {} : { ms }
9468
+ };
9469
+ }
9470
+ function msOf(value) {
9471
+ if (typeof value !== "number" || !Number.isInteger(value)) return void 0;
9472
+ if (value < TRANSITION_MS.min || value > TRANSITION_MS.max) return void 0;
9473
+ return value;
9474
+ }
9475
+ /**
9476
+ * The attributes marking an element as a step of its slide. Present mode
9477
+ * alone reads them, so the file shows every step everywhere else.
9478
+ */
9479
+ const STEP_ATTRIBUTES = {
9480
+ step: "data-step",
9481
+ effect: "data-step-effect",
9482
+ start: "data-step-start"
9483
+ };
9484
+ /** The entrances a step takes, a slide tool's first five. */
9485
+ const STEP_EFFECTS = [
9486
+ "appear",
9487
+ "fade",
9488
+ "fly",
9489
+ "wipe",
9490
+ "zoom"
9491
+ ];
9492
+ /**
9493
+ * When a step shows: on its own press, with the step before it, or right
9494
+ * after the step before it finishes.
9495
+ */
9496
+ const STEP_STARTS = [
9497
+ "click",
9498
+ "with",
9499
+ "after"
9500
+ ];
9407
9501
  // src/shared/records/board.ts
9408
9502
  const boardFileSchema = looseObject({ version: literal(1) });
9409
9503
  /** A project's own check rules, absent meaning the built-in rules alone. */
@@ -9438,7 +9532,8 @@ const layoutEntrySchema = looseObject({
9438
9532
  width: int$1().min(1),
9439
9533
  height: int$1().min(1)
9440
9534
  })), unknown()]).optional(),
9441
- device: unknown().optional()
9535
+ device: unknown().optional(),
9536
+ transition: unknown().optional()
9442
9537
  });
9443
9538
  /** A named box grouping the frames whose center it holds, which it never lists. */
9444
9539
  const sectionEntrySchema = looseObject({
@@ -9451,7 +9546,8 @@ const sectionEntrySchema = looseObject({
9451
9546
  const layoutFileSchema = looseObject({
9452
9547
  version: literal(1),
9453
9548
  frames: record(string$1(), layoutEntrySchema),
9454
- sections: record(string$1(), sectionEntrySchema).optional()
9549
+ sections: record(string$1(), sectionEntrySchema).optional(),
9550
+ present: unknown().optional()
9455
9551
  });
9456
9552
  // src/shared/sections.ts
9457
9553
  /**
@@ -9570,6 +9666,7 @@ function placeFrames(frames, names) {
9570
9666
  }
9571
9667
  const scroll = entry.scroll ?? false;
9572
9668
  const device = deviceOf(entry.device);
9669
+ const transition = transitionOf(entry.transition);
9573
9670
  placements.set(name, {
9574
9671
  box: {
9575
9672
  x: entry.x,
@@ -9585,6 +9682,7 @@ function placeFrames(frames, names) {
9585
9682
  scroll,
9586
9683
  widths: widthsOf(entry.widths),
9587
9684
  ...device ? { device } : {},
9685
+ ...transition ? { transition } : {},
9588
9686
  placed: true
9589
9687
  });
9590
9688
  }
@@ -9661,10 +9759,12 @@ async function scanPage(root, project, name, index) {
9661
9759
  let frames = {};
9662
9760
  let sections = {};
9663
9761
  let layoutError = null;
9762
+ let transition = null;
9664
9763
  try {
9665
9764
  const file = await readRecord(layoutPath, layoutSpec);
9666
9765
  frames = file.frames;
9667
9766
  sections = file.sections ?? {};
9767
+ transition = pageTransitionOf(file);
9668
9768
  } catch (error) {
9669
9769
  if (!(error instanceof FrameboardError)) throw error;
9670
9770
  layoutError = {
@@ -9694,10 +9794,17 @@ async function scanPage(root, project, name, index) {
9694
9794
  path,
9695
9795
  index,
9696
9796
  layoutError,
9797
+ ...transition ? { transition } : {},
9697
9798
  frames: stacked,
9698
9799
  sections: sectionRecords(sections, stacked)
9699
9800
  };
9700
9801
  }
9802
+ /** The transition a layout's `present` key holds, null for none or one no reader knows. */
9803
+ function pageTransitionOf(file) {
9804
+ const present = file.present;
9805
+ if (typeof present !== "object" || present === null) return null;
9806
+ return transitionOf(present.transition);
9807
+ }
9701
9808
  /** The page's sections bottom first, each naming its members in stacking order. */
9702
9809
  function sectionRecords(entries, frames) {
9703
9810
  const sections = Object.entries(entries).map(([name, { x, y, width, height, order }]) => ({
@@ -9789,7 +9896,7 @@ async function isDirectory(path) {
9789
9896
  }
9790
9897
  }
9791
9898
  // package.json
9792
- var version$1 = "0.33.0";
9899
+ var version$1 = "0.34.0";
9793
9900
  var dependencies = { "playwright-core": "1.65.0" };
9794
9901
  var peerDependencies = { "oxfmt": "0.77.0" };
9795
9902
  // src/shared/version.ts
@@ -10506,7 +10613,8 @@ function fittedPlacement(placement, height, widths) {
10506
10613
  * Sets how each frame holds its height in one write under one lock, all of
10507
10614
  * them or none. `fixed` keeps the box and clears hugging and scroll. `fit`
10508
10615
  * takes the measured height and hugs it, clearing scroll. `scroll` fixes both
10509
- * axes as `frame resize --scroll` does. Every frame is checked before any is
10616
+ * axes as `frame resize --scroll` does, at the target's `height` when it
10617
+ * gives one. Every frame is checked before any is
10510
10618
  * set: one moved or sized since its `expected` refuses `stale-layout`, leaving
10511
10619
  * out an axis the frame hugs, since the server measures that one, and a `fit`
10512
10620
  * without `measured` refuses `usage`.
@@ -10525,15 +10633,15 @@ async function setHeightModes(root, targets, mode, options) {
10525
10633
  return {
10526
10634
  layout,
10527
10635
  name: frame.name,
10528
- placement: heightPlacement(placement, frameRef, mode, target.measured)
10636
+ placement: heightPlacement(placement, frameRef, mode, target)
10529
10637
  };
10530
10638
  });
10531
10639
  for (const { layout, name, placement } of next) layout.set(name, placement);
10532
10640
  }, options.journal);
10533
10641
  return Promise.all(frames.map(({ frame }) => frameRecord(root, frame.project, frame.page, frame.name)));
10534
10642
  }
10535
- function heightPlacement(placement, frameRef, mode, measured) {
10536
- if (mode === "scroll") return resizedPlacement(placement, frameRef, {}, { scroll: true });
10643
+ function heightPlacement(placement, frameRef, mode, { measured, height }) {
10644
+ if (mode === "scroll") return resizedPlacement(placement, frameRef, height === void 0 ? {} : { height }, { scroll: true });
10537
10645
  if (mode === "fixed") return {
10538
10646
  ...placement,
10539
10647
  hugHeight: false,
@@ -10726,6 +10834,20 @@ async function setFrameDevice(root, ref, device, options) {
10726
10834
  } : rest;
10727
10835
  });
10728
10836
  }
10837
+ /**
10838
+ * Sets the transition a frame arrives with in present mode, over its page's,
10839
+ * or clears it with null so the frame takes its page's. The frame's file and
10840
+ * box are left as they stand.
10841
+ */
10842
+ async function setFrameTransition(root, ref, transition, options) {
10843
+ return updatePlacement(root, ref, options, (placement) => {
10844
+ const { transition: _held, ...rest } = placement;
10845
+ return transition ? {
10846
+ ...rest,
10847
+ transition
10848
+ } : rest;
10849
+ });
10850
+ }
10729
10851
  async function deleteFrame(root, ref, options) {
10730
10852
  const { journal } = options;
10731
10853
  const frame = await resolveFrameRef(root, ref, options);
@@ -10821,9 +10943,10 @@ var PageLayout = class {
10821
10943
  * written while it lists one and removed once it lists none, and a held
10822
10944
  * value no reader understands is left as it stands. `device` is written
10823
10945
  * while the frame holds one and removed once it is cleared, leaving a held
10824
- * value no reader understands as `widths` does.
10946
+ * value no reader understands as `widths` does. `transition` is written
10947
+ * the same way as `device`.
10825
10948
  */
10826
- set(name, { box, order, hidden, locked, scroll, widths, device, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
10949
+ set(name, { box, order, hidden, locked, scroll, widths, device, transition, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
10827
10950
  const hugWidth = hugsWidth && !scroll;
10828
10951
  const hugHeight = hugsHeight && !scroll;
10829
10952
  const held = this.file.frames[name];
@@ -10843,13 +10966,28 @@ var PageLayout = class {
10843
10966
  width,
10844
10967
  height
10845
10968
  })) } : {},
10846
- ...device ? { device } : {}
10969
+ ...device ? { device } : {},
10970
+ ...transition ? { transition: { ...transition } } : {}
10847
10971
  };
10848
10972
  if (widths.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
10849
10973
  if (!device && deviceOf(held?.device)) delete entry.device;
10974
+ if (!transition && transitionOf(held?.transition)) delete entry.transition;
10850
10975
  this.file.frames[name] = entry;
10851
10976
  this.changed = true;
10852
10977
  }
10978
+ /**
10979
+ * Sets the page's transition on the `present` key, or clears it with null,
10980
+ * keeping any other key `present` holds and dropping `present` once empty.
10981
+ */
10982
+ setTransition(transition) {
10983
+ const held = this.file.present;
10984
+ const present = typeof held === "object" && held !== null && !Array.isArray(held) ? { ...held } : {};
10985
+ if (transition) present.transition = { ...transition };
10986
+ else delete present.transition;
10987
+ if (Object.keys(present).length > 0) this.file.present = present;
10988
+ else delete this.file.present;
10989
+ this.changed = true;
10990
+ }
10853
10991
  remove(name) {
10854
10992
  delete this.file.frames[name];
10855
10993
  this.changed = true;
@@ -10933,6 +11071,7 @@ function reportEntries(journal, page, before, after) {
10933
11071
  const to = nowSections[section];
10934
11072
  if (!isDeepStrictEqual(from, to)) journal.section(page, section, from, to);
10935
11073
  }
11074
+ if (!isDeepStrictEqual(before?.present, after.present)) journal.present(page, before?.present, after.present);
10936
11075
  }
10937
11076
  function layoutAt(layouts, page) {
10938
11077
  const layout = layouts.get(page);
@@ -30748,12 +30887,12 @@ function swapSpan(source, span, side) {
30748
30887
  if (!found) return void 0;
30749
30888
  const [start, end] = found.range;
30750
30889
  const html = source.slice(0, start) + span[OTHER$1[side]] + source.slice(end);
30890
+ const written = parseFrame(html);
30751
30891
  const moved = {
30752
30892
  ...span,
30753
30893
  index: found.index,
30754
- count: tree.elements.length
30894
+ count: span.scope === "element" ? written.elements.length : tree.elements.length
30755
30895
  };
30756
- const written = parseFrame(html);
30757
30896
  if (written.elements.length !== moved.count || !matches(html, written.elements[moved.index], span.scope, span[OTHER$1[side]])) return;
30758
30897
  return {
30759
30898
  html,
@@ -36751,7 +36890,7 @@ function attribute(text) {
36751
36890
  function startTag(source, element) {
36752
36891
  return spanText(source, element, "start-tag");
36753
36892
  }
36754
- function children(element) {
36893
+ function children$1(element) {
36755
36894
  return element.childNodes.filter(hasTag);
36756
36895
  }
36757
36896
  /** The source offset the gap sits at, or a refusal when the file states none. */
@@ -36805,7 +36944,7 @@ function insertElement(source, placement, markup, lead = "") {
36805
36944
  const index = after.elements.findIndex((element) => element.sourceCodeLocation?.startOffset === offset);
36806
36945
  const added = after.elements[index];
36807
36946
  if (!added || after.elements.length !== before.elements.length + 1 + descendants(added) || added.parentNode !== after.elements[placement.parent] || spanText(written, added, "element") !== markup || !addsOnly(before, after, added)) return refuse$2("verify-failed", `a <${added?.tagName ?? "new element"}> there would change more than the <${parent.tagName}> it goes in, so nothing was written`);
36808
- const next = children(parent).find((child) => child.sourceCodeLocation?.startOffset === gap.offset);
36947
+ const next = children$1(parent).find((child) => child.sourceCodeLocation?.startOffset === gap.offset);
36809
36948
  return {
36810
36949
  ok: true,
36811
36950
  html: written,
@@ -36826,7 +36965,7 @@ function insertElement(source, placement, markup, lead = "") {
36826
36965
  }
36827
36966
  /** How many elements `element` holds, at any depth. */
36828
36967
  function descendants(element) {
36829
- return children(element).reduce((count, child) => count + 1 + descendants(child), 0);
36968
+ return children$1(element).reduce((count, child) => count + 1 + descendants(child), 0);
36830
36969
  }
36831
36970
  /** Whether `after` is `before` with `added` alone added, compared once it is taken out. */
36832
36971
  function addsOnly(before, after, added) {
@@ -36862,7 +37001,7 @@ function locateGap(source, tree, span) {
36862
37001
  parent: parentIndex,
36863
37002
  before: span.placement.before
36864
37003
  };
36865
- const next = children(parent).filter((child) => startTag(source, child) === span.next);
37004
+ const next = children$1(parent).filter((child) => startTag(source, child) === span.next);
36866
37005
  const [sibling] = next;
36867
37006
  return next.length === 1 && sibling ? {
36868
37007
  parent: parentIndex,
@@ -36901,7 +37040,7 @@ function takeOut$1(source, tree, index) {
36901
37040
  const parent = element?.parentNode;
36902
37041
  if (!element || !at?.startTag || !parent || !hasTag(parent)) return void 0;
36903
37042
  const removed = source.slice(0, at.startOffset) + source.slice(at.endOffset);
36904
- const next = children(parent)[children(parent).indexOf(element) + 1];
37043
+ const next = children$1(parent)[children$1(parent).indexOf(element) + 1];
36905
37044
  const placement = {
36906
37045
  parent: tree.elements.indexOf(parent),
36907
37046
  before: next ? index : null
@@ -36935,7 +37074,7 @@ function removeElement(source, index) {
36935
37074
  const parent = element.parentNode;
36936
37075
  if (!at || !parent || !hasTag(parent)) return refuse$2("address-mismatch", `the <${element.tagName}> at ${index} is not stated in the file`);
36937
37076
  const removed = source.slice(0, at.startOffset) + source.slice(at.endOffset);
36938
- const next = children(parent)[children(parent).indexOf(element) + 1];
37077
+ const next = children$1(parent)[children$1(parent).indexOf(element) + 1];
36939
37078
  const back = insertElement(removed, {
36940
37079
  parent: tree.elements.indexOf(parent),
36941
37080
  before: next ? index : null
@@ -37031,7 +37170,7 @@ function isStatic(facts) {
37031
37170
  const position = facts?.position?.trim().toLowerCase();
37032
37171
  return position === void 0 || position === "static";
37033
37172
  }
37034
- function px(value) {
37173
+ function px$1(value) {
37035
37174
  return `${Math.round(value * 100) / 100}px`;
37036
37175
  }
37037
37176
  /**
@@ -37107,15 +37246,15 @@ function placeElement(source, index, spot, facts, drop = []) {
37107
37246
  },
37108
37247
  {
37109
37248
  property: "left",
37110
- value: px(spot.left)
37249
+ value: px$1(spot.left)
37111
37250
  },
37112
37251
  {
37113
37252
  property: "top",
37114
- value: px(spot.top)
37253
+ value: px$1(spot.top)
37115
37254
  },
37116
37255
  ...sized.map((axis) => ({
37117
37256
  property: axis,
37118
- value: px(spot[axis] ?? 0)
37257
+ value: px$1(spot[axis] ?? 0)
37119
37258
  }))
37120
37259
  ] : [
37121
37260
  {
@@ -37628,6 +37767,107 @@ function within(element, root) {
37628
37767
  }
37629
37768
  return false;
37630
37769
  }
37770
+ // src/server/edit/wrap.ts
37771
+ /** The wrappers a container cannot sit in, or be made from. */
37772
+ const ROOTS = /* @__PURE__ */ new Set([
37773
+ "html",
37774
+ "head",
37775
+ "body"
37776
+ ]);
37777
+ function px(value) {
37778
+ return `${Math.round(value * 100) / 100}px`;
37779
+ }
37780
+ function children(element) {
37781
+ return element.childNodes.filter(hasTag);
37782
+ }
37783
+ function subtree(element) {
37784
+ return children(element).reduce((count, child) => count + subtree(child), 1);
37785
+ }
37786
+ function isFree(facts) {
37787
+ const position = facts?.position?.trim().toLowerCase();
37788
+ return position === "absolute" || position === "fixed";
37789
+ }
37790
+ /**
37791
+ * Wraps the sibling elements `indexes` names in one new `div` laid out as
37792
+ * `flow`, written at the first one's place, with every one moved into it in
37793
+ * document order. A free member leaves the flow it is wrapped in otherwise,
37794
+ * so each puts back `position`, `left`, and `top` as back in flow does, and
37795
+ * the container takes `spot` instead, placed freely where the group sat, or
37796
+ * sits in the flow when `spot` is null. `facts` is the static cascade read
37797
+ * by the same index. Elements that are not siblings, the document's own
37798
+ * wrappers, and a parent the file does not state are refused, and the
37799
+ * output is parsed again and refused as `verify-failed` unless only the
37800
+ * parent's contents changed, holding the container and its members.
37801
+ */
37802
+ function wrapElements(source, indexes, flow, spot, facts) {
37803
+ const tree = parseFrame(source);
37804
+ const named = [...new Set(indexes)].toSorted((a, b) => a - b);
37805
+ const members = named.map((index) => Number.isInteger(index) ? tree.elements[index] : void 0);
37806
+ const [first] = members;
37807
+ const parent = first?.parentNode;
37808
+ if (named.length !== indexes.length || named.length === 0 || !first || !parent || !hasTag(parent) || members.some((member) => !member?.sourceCodeLocation?.startTag || ROOTS.has(member.tagName) || member.parentNode !== parent)) return refuse$2("invalid-address", "a wrap takes stated sibling elements of one parent, each named once");
37809
+ const stated = parent.sourceCodeLocation;
37810
+ if (parent.tagName === "html" || !stated?.startTag) return refuse$2("invalid-container", `the <${parent.tagName}> holding them is not stated in the file, so nothing was written`);
37811
+ const parentIndex = tree.elements.indexOf(parent);
37812
+ let html = source;
37813
+ for (const index of named) {
37814
+ if (!isFree(facts[index])) continue;
37815
+ const placed = placeElement(html, index, null, facts);
37816
+ if (!placed.ok) return placed;
37817
+ html = placed.html;
37818
+ }
37819
+ const flowed = parseFrame(html);
37820
+ const ranges = named.map((index) => flowed.elements[index]).map((member) => {
37821
+ const location = member?.sourceCodeLocation;
37822
+ return location ? [location.startOffset, location.endOffset] : null;
37823
+ });
37824
+ const [start] = ranges;
37825
+ if (!start || ranges.some((range) => !range)) return refuse$2("verify-failed", "a member lost its place in the file, so nothing was written");
37826
+ const indent = /\n[ \t]*$/.exec(html.slice(0, start[0]))?.[0] ?? "";
37827
+ const inner = indent === "" ? "" : `${indent} `;
37828
+ const container = `<div style="${[
37829
+ "display: flex",
37830
+ `flex-direction: ${flow.direction}`,
37831
+ `gap: ${px(flow.gap)}`,
37832
+ ...spot ? [
37833
+ "position: absolute",
37834
+ `left: ${px(spot.left)}`,
37835
+ `top: ${px(spot.top)}`
37836
+ ] : []
37837
+ ].join("; ")}">${ranges.map((range) => `${inner}${html.slice(range?.[0], range?.[1])}`).join("")}${indent}</div>`;
37838
+ let wrapped = html;
37839
+ for (const range of ranges.slice(1).toReversed()) {
37840
+ if (!range) continue;
37841
+ const lead = /\s*$/.exec(wrapped.slice(0, range[0]))?.[0].length ?? 0;
37842
+ wrapped = wrapped.slice(0, range[0] - lead) + wrapped.slice(range[1]);
37843
+ }
37844
+ wrapped = wrapped.slice(0, start[0]) + container + wrapped.slice(start[1]);
37845
+ const order = [...tree.elements.slice(0, named[0]), ...members.flatMap((member) => member ? tree.elements.slice(tree.elements.indexOf(member), tree.elements.indexOf(member) + subtree(member)) : [])];
37846
+ const moved = new Set(order);
37847
+ order.push(...tree.elements.filter((element) => !moved.has(element)));
37848
+ const at = new Map(order.map((element, place) => [tree.elements.indexOf(element), place < (named[0] ?? 0) ? place : place + 1]));
37849
+ const index = named[0] ?? 0;
37850
+ const written = parseFrame(wrapped);
37851
+ const box = written.elements[index];
37852
+ const after = written.elements[parentIndex];
37853
+ const end = stated.endOffset;
37854
+ const unchanged = written.elements.length === tree.elements.length + 1 && box?.tagName === "div" && box.parentNode === after && children(box).map(({ tagName }) => tagName).join() === members.map((member) => member?.tagName).join() && wrapped.slice(0, stated.startTag.endOffset) === source.slice(0, stated.startTag.endOffset) && wrapped.slice(wrapped.length - (source.length - end)) === source.slice(end);
37855
+ if (!after || !unchanged) return refuse$2("verify-failed", "the wrap would change more than its parent’s contents, so nothing was written");
37856
+ return {
37857
+ ok: true,
37858
+ html: wrapped,
37859
+ index,
37860
+ members: indexes.map((named) => at.get(named) ?? named),
37861
+ span: {
37862
+ scope: "element",
37863
+ index: parentIndex,
37864
+ count: written.elements.length,
37865
+ before: spanText(source, parent, "element"),
37866
+ after: spanText(wrapped, after, "element")
37867
+ },
37868
+ remap: (old) => at.get(old) ?? null
37869
+ };
37870
+ }
37631
37871
  // src/server/edit/frame-file.ts
37632
37872
  const identity = (index) => index;
37633
37873
  function stale$1(path) {
@@ -37927,6 +38167,28 @@ function placeFrameFileAll(path, hash, places, factsOf) {
37927
38167
  };
37928
38168
  }
37929
38169
  /**
38170
+ * Wraps sibling elements of a frame file in one flow container, written as
38171
+ * `moveFrameFile` writes and refused as stale on a hash the file no longer
38172
+ * has, since the indices name nothing once the file moved. `facts` is the
38173
+ * static cascade read from the bytes `hash` names.
38174
+ */
38175
+ function wrapFrameFile(path, hash, indexes, flow, spot, facts) {
38176
+ const read = readSource(path);
38177
+ if (!read.ok) return read;
38178
+ if (read.hash !== hash) return stale$1(path);
38179
+ const wrapped = wrapElements(read.source, indexes, flow, spot, facts);
38180
+ if (!wrapped.ok) return wrapped;
38181
+ if (!replaceFile(path, hash, wrapped.html)) return stale$1(path);
38182
+ return {
38183
+ ok: true,
38184
+ hash: contentHash(wrapped.html),
38185
+ index: wrapped.index,
38186
+ members: wrapped.members,
38187
+ span: wrapped.span,
38188
+ remap: wrapped.remap
38189
+ };
38190
+ }
38191
+ /**
37930
38192
  * Replaces a raw color with a token across the subtree `root` names, or the
37931
38193
  * frame's body when undefined, written as `placeFrameFile` writes and refused
37932
38194
  * as stale on a hash the file no longer has, so a retried replace lands once.
@@ -38116,6 +38378,17 @@ async function movePage(root, ref, { index, ...options }) {
38116
38378
  const page = await resolvePageRef(root, ref, options);
38117
38379
  return recordOf(root, page, await reorder(root, page, async (order) => insert(order.filter((name) => name !== page.name), page.name, index), options.journal));
38118
38380
  }
38381
+ /**
38382
+ * Sets the transition present mode draws between the page's slides, or
38383
+ * clears it with null, writing only the `present` key of its `layout.json`
38384
+ * and leaving every frame file as it stands.
38385
+ */
38386
+ async function setPageTransition(root, ref, transition, { journal, ...options }) {
38387
+ const page = await resolvePageRef(root, ref, options);
38388
+ await withLayouts([page.path], async (layouts) => layoutAt(layouts, page.path).setTransition(transition), journal);
38389
+ const { pages } = await readPageOrder(join(root, page.project));
38390
+ return scanPage(root, page.project, page.name, pages.indexOf(page.name));
38391
+ }
38119
38392
  async function deletePage(root, ref, { journal, ...options }) {
38120
38393
  const page = await resolvePageRef(root, ref, options);
38121
38394
  await reorder(root, page, async (order) => {
@@ -38586,7 +38859,7 @@ async function emptyTrash(root) {
38586
38859
  // src/server/history/changes.ts
38587
38860
  /** The records a change writes, whose locks are held while it is checked and written. */
38588
38861
  function lockPaths(change) {
38589
- if (change.kind === "entry" || change.kind === "section") return [change.layout];
38862
+ if (change.kind === "entry" || change.kind === "section" || change.kind === "present") return [change.layout];
38590
38863
  if (change.kind === "pages" || change.kind === "project") return [change.file];
38591
38864
  return [];
38592
38865
  }
@@ -38615,6 +38888,10 @@ async function reads(change, side) {
38615
38888
  const file = await readRecord(change.layout, layoutSpec);
38616
38889
  return isDeepStrictEqual(file.sections?.[change.section], change[side]);
38617
38890
  }
38891
+ case "present": {
38892
+ const file = await readRecord(change.layout, layoutSpec);
38893
+ return isDeepStrictEqual(file.present, change[side]);
38894
+ }
38618
38895
  case "pages": {
38619
38896
  const file = await readRecord(change.file, {
38620
38897
  ...projectSpec,
@@ -38687,6 +38964,15 @@ async function restore(change, side) {
38687
38964
  });
38688
38965
  return;
38689
38966
  }
38967
+ case "present": {
38968
+ const { present: _held, ...file } = await readRecord(change.layout, layoutSpec);
38969
+ const present = change[side];
38970
+ await writeRecord(change.layout, present === void 0 ? file : {
38971
+ ...file,
38972
+ present
38973
+ });
38974
+ return;
38975
+ }
38690
38976
  case "pages": {
38691
38977
  const file = await readRecord(change.file, {
38692
38978
  ...projectSpec,
@@ -38856,6 +39142,15 @@ var StepJournal = class {
38856
39142
  after
38857
39143
  });
38858
39144
  }
39145
+ present(page, before, after) {
39146
+ const layout = join(page, LAYOUT_FILE);
39147
+ this.changes.push({
39148
+ kind: "present",
39149
+ layout,
39150
+ before,
39151
+ after
39152
+ });
39153
+ }
38859
39154
  pages(project, before, after) {
38860
39155
  const file = join(project, PROJECT_FILE);
38861
39156
  this.changes.push({
@@ -39117,11 +39412,12 @@ var History = class {
39117
39412
  return run;
39118
39413
  }
39119
39414
  };
39120
- /** What a refusal names as overtaken, being a frame, a section, a page, the page order, or a filed project. */
39415
+ /** What a refusal names as overtaken, being a frame, a section, a page, the slide transition, the page order, or a filed project. */
39121
39416
  function nameOf(change) {
39122
39417
  if (change.kind === "entry") return change.frame;
39123
39418
  if (change.kind === "section") return `section ${change.section}`;
39124
39419
  if (change.kind === "pages") return "the page order";
39420
+ if (change.kind === "present") return "the slide transition";
39125
39421
  if (change.kind === "project") return basename(dirname(change.file));
39126
39422
  if (change.kind === "token") return change.name;
39127
39423
  const path = change.kind === "moved" ? change.to : change.path;
@@ -39497,6 +39793,12 @@ object$1({
39497
39793
  sized: array$1(placedSizeSchema)
39498
39794
  })).optional()
39499
39795
  });
39796
+ object$1({
39797
+ ref: string$1(),
39798
+ index: int$1().min(0),
39799
+ members: array$1(int$1().min(0)),
39800
+ hash
39801
+ });
39500
39802
  object$1({
39501
39803
  ref: string$1(),
39502
39804
  hash,
@@ -39652,6 +39954,21 @@ const placeSchema = union([object$1({
39652
39954
  ...spotFields
39653
39955
  })).min(1).max(BATCH)
39654
39956
  })]);
39957
+ const wrapSchema = object$1({
39958
+ ref: string$1().min(1).max(1024),
39959
+ hash: string$1().regex(/^[0-9a-f]{64}$/),
39960
+ /** The sibling elements to wrap, by their index in the bytes `hash` names. */
39961
+ indexes: array$1(int$1().min(0)).min(1).max(BATCH),
39962
+ flow: object$1({
39963
+ direction: _enum$1(["row", "column"]),
39964
+ gap: number().min(0).max(1e4)
39965
+ }),
39966
+ /** Where the container sits when every member was placed freely, null to sit in the flow. */
39967
+ spot: object$1({
39968
+ left: offset,
39969
+ top: offset
39970
+ }).nullable()
39971
+ });
39655
39972
  const recolorSchema = object$1({
39656
39973
  ref: string$1().min(1).max(1024),
39657
39974
  hash: string$1().regex(/^[0-9a-f]{64}$/),
@@ -40084,6 +40401,45 @@ function editRoutes(root, access, history, version, sheets) {
40084
40401
  data
40085
40402
  });
40086
40403
  });
40404
+ app.post("/api/frames/wrap", requireWriter(access), async (c) => {
40405
+ const body = await parseBody$1(c.req.raw, wrapSchema);
40406
+ const frame = await resolveFrameRef(root, body.ref, { cwd: root });
40407
+ const ref = `${frame.project}/${frame.page}/${frame.name}`;
40408
+ await refuseClaimed(root, [ref], /* @__PURE__ */ new Date());
40409
+ const source = readFrame(frame);
40410
+ const facts = contentHash(source.html) === body.hash ? elementPlaceFacts(source, tokenSheets(frame.project)) : [];
40411
+ const result = wrapFrameFile(frame.path, body.hash, body.indexes, body.flow, body.spot, facts);
40412
+ if (!result.ok) return c.json({
40413
+ ok: false,
40414
+ error: {
40415
+ code: result.reason,
40416
+ message: result.detail,
40417
+ details: {
40418
+ ref,
40419
+ indexes: body.indexes
40420
+ }
40421
+ }
40422
+ }, 409);
40423
+ const journal = history.journal();
40424
+ journal.element(frame.path, ref, result.span);
40425
+ history.record({
40426
+ id: journal.id,
40427
+ changes: journal.changes,
40428
+ page: null,
40429
+ frames: [ref]
40430
+ });
40431
+ await follow(frame, body.hash, result.hash, result.remap);
40432
+ const data = {
40433
+ ref,
40434
+ index: result.index,
40435
+ members: [...result.members],
40436
+ hash: result.hash
40437
+ };
40438
+ return c.json({
40439
+ ok: true,
40440
+ data
40441
+ });
40442
+ });
40087
40443
  app.post("/api/frames/recolor", requireWriter(access), async (c) => {
40088
40444
  const body = await parseBody$1(c.req.raw, recolorSchema);
40089
40445
  const frame = await resolveFrameRef(root, body.ref, { cwd: root });
@@ -41673,7 +42029,8 @@ const frameHeightSchema = object$1({
41673
42029
  y: coordinate,
41674
42030
  width: int$1().min(1),
41675
42031
  height: int$1().min(1)
41676
- })).refine((boxes) => Object.keys(boxes).length <= 1e3)
42032
+ })).refine((boxes) => Object.keys(boxes).length <= 1e3),
42033
+ heights: record(ref, int$1().min(1)).refine((heights) => Object.keys(heights).length <= 1e3).optional()
41677
42034
  });
41678
42035
  const pasteSchema = object$1({
41679
42036
  ref,
@@ -41686,6 +42043,21 @@ const frameDeviceSchema = object$1({
41686
42043
  refs,
41687
42044
  device: _enum$1(DEVICES).nullable()
41688
42045
  });
42046
+ const transition = object$1({
42047
+ name: _enum$1(TRANSITIONS),
42048
+ direction: _enum$1(DIRECTIONS).optional(),
42049
+ ms: int$1().min(TRANSITION_MS.min).max(TRANSITION_MS.max).optional()
42050
+ });
42051
+ /** Null clears the page's transition, so its slides cut. */
42052
+ const pageTransitionSchema = object$1({
42053
+ ref,
42054
+ transition: transition.nullable()
42055
+ });
42056
+ /** Null clears each frame's override, so it takes its page's. */
42057
+ const frameTransitionSchema = object$1({
42058
+ refs,
42059
+ transition: transition.nullable()
42060
+ });
41689
42061
  const frameFlagSchema = object$1({
41690
42062
  refs,
41691
42063
  flag: _enum$1(["hidden", "locked"]),
@@ -41850,6 +42222,21 @@ function structureRoutes(root, access, history, measure, tokens = null) {
41850
42222
  data: page
41851
42223
  });
41852
42224
  });
42225
+ /** Sets or clears a page's slide transition as one step, leaving every frame file alone. */
42226
+ app.post("/api/page/transition", async (c) => {
42227
+ const body = await parseBody$1(c.req.raw, pageTransitionSchema);
42228
+ const page = await recorded((journal) => setPageTransition(root, body.ref, body.transition, {
42229
+ cwd,
42230
+ journal
42231
+ }), async () => ({
42232
+ page: null,
42233
+ frames: []
42234
+ }));
42235
+ return c.json({
42236
+ ok: true,
42237
+ data: page
42238
+ });
42239
+ });
41853
42240
  app.post("/api/page/delete", async (c) => {
41854
42241
  const body = await parseBody$1(c.req.raw, deleteSchema);
41855
42242
  const source = await resolvePageRef(root, body.ref, { cwd });
@@ -41972,22 +42359,42 @@ function structureRoutes(root, access, history, measure, tokens = null) {
41972
42359
  data: frames
41973
42360
  });
41974
42361
  });
42362
+ /** Sets or clears each frame's transition override, in one step, leaving every frame file alone. */
42363
+ app.post("/api/frame/transition", async (c) => {
42364
+ const body = await parseBody$1(c.req.raw, frameTransitionSchema);
42365
+ const frames = await eachFrame(body.refs, (frame, journal) => setFrameTransition(root, frame, body.transition, {
42366
+ cwd,
42367
+ journal
42368
+ }), (records) => records.map((record) => record.ref));
42369
+ return c.json({
42370
+ ok: true,
42371
+ data: frames
42372
+ });
42373
+ });
41975
42374
  /**
41976
42375
  * Sets how each frame holds its height, `fixed`, `fit`, or `scroll`, in one
41977
42376
  * step. `expected` holds each frame's box as the caller saw it, keyed by the
41978
42377
  * ref the body names, and a frame changed since refuses `stale-layout`
41979
- * before any frame is written. A locked or claimed frame refuses the whole
42378
+ * before any frame is written. `heights` gives a `scroll` write the screen
42379
+ * height each named frame takes, and refuses `usage` with any other mode. A
42380
+ * locked or claimed frame refuses the whole
41980
42381
  * write, and `fit` measures each frame and its linked widths on the warm
41981
42382
  * browser first, refusing `browser-not-found` where none runs.
41982
42383
  */
41983
42384
  app.post("/api/frame/height", async (c) => {
41984
42385
  const body = await parseBody$1(c.req.raw, frameHeightSchema);
42386
+ if (body.heights && body.mode !== "scroll") throw new FrameboardError("usage", `The body gives heights to a ${body.mode} write, which takes them only with scroll.`);
41985
42387
  const targets = body.refs.map((ref) => {
41986
42388
  const expected = body.expected[ref];
41987
42389
  if (!expected) throw new FrameboardError("usage", `The body gives ${ref} no expected box.`, { ref });
41988
- return {
42390
+ const height = body.heights?.[ref];
42391
+ return height === void 0 ? {
41989
42392
  ref,
41990
42393
  expected
42394
+ } : {
42395
+ ref,
42396
+ expected,
42397
+ height
41991
42398
  };
41992
42399
  });
41993
42400
  await refuseLocked(body.refs);
@@ -45610,6 +46017,12 @@ const recordErrorSchema = object$1({
45610
46017
  path: string$1(),
45611
46018
  message: string$1()
45612
46019
  }).nullable();
46020
+ /** A transition as present mode reads it, `direction` and `ms` absent at their default. */
46021
+ const transitionRecordSchema = object$1({
46022
+ name: _enum$1(TRANSITIONS),
46023
+ direction: _enum$1(DIRECTIONS).optional(),
46024
+ ms: int$1().optional()
46025
+ });
45613
46026
  const frameRecordSchema = object$1({
45614
46027
  ref: string$1(),
45615
46028
  project: string$1(),
@@ -45637,6 +46050,8 @@ const frameRecordSchema = object$1({
45637
46050
  })),
45638
46051
  /** The device the board draws around the frame, absent when it has none. */
45639
46052
  device: _enum$1(DEVICES).optional(),
46053
+ /** The transition the frame arrives with in present mode, over its page's, absent when it holds none. */
46054
+ transition: transitionRecordSchema.optional(),
45640
46055
  placed: boolean$1(),
45641
46056
  modifiedAt: string$1()
45642
46057
  });
@@ -45659,6 +46074,8 @@ const pageRecordSchema = object$1({
45659
46074
  path: string$1(),
45660
46075
  index: number(),
45661
46076
  layoutError: recordErrorSchema,
46077
+ /** The transition present mode draws between the page's slides, absent when it holds none. */
46078
+ transition: transitionRecordSchema.optional(),
45662
46079
  frames: array$1(frameRecordSchema),
45663
46080
  /** Bottom first, as frames are. */
45664
46081
  sections: array$1(sectionRecordSchema)
@@ -46184,6 +46601,11 @@ function contentFormat() {
46184
46601
  `Moving or resizing a frame writes ${LAYOUT_FILE} alone and never the frame file.`,
46185
46602
  "sections, when present, maps a section name to its x, y, width, height, and order. A frame belongs to the topmost section holding its center, left and top edges inside, and is never listed in it, so list --json names each section's frames and an agent moving a frame out of the box takes it out of the section. The developer writes sections by hand on the board."
46186
46603
  ],
46604
+ present: [
46605
+ `A page's slide transition sits on the present key of its ${LAYOUT_FILE} as { transition: { name, direction, ms } }, and a frame's entry may hold its own transition, which wins as that slide arrives. name is one of ${TRANSITIONS.join(", ")}. direction is one of ${DIRECTIONS.join(", ")}, taken by ${DIRECTED.join(" and ")} alone and defaulting to left. ms runs ${TRANSITION_MS.min} to ${TRANSITION_MS.max}, a frame's taking its page's when absent and the page's defaulting to 500. Any other value reads as none and is kept on write. The board draws a transition itself and never writes it into a frame file.`,
46606
+ "page transition <page-ref> <name> sets the page's, and none clears it so slides cut. frame transition <frame-ref> <name> sets a frame's, and page clears it so the frame takes its page's. Both take --ms and --direction and write only layout.json.",
46607
+ `A step is an element present mode holds back until a press reveals it, marked by three attributes on that element and nothing else. ${STEP_ATTRIBUTES.step}="<n>" is a positive integer, and steps show in number order with equal numbers together and gaps closed. ${STEP_ATTRIBUTES.effect} is one of ${STEP_EFFECTS.join(", ")}, defaulting to appear. ${STEP_ATTRIBUTES.start} is one of ${STEP_STARTS.join(", ")}, defaulting to click, where with shows the step beside the one before it and after shows it once that one finishes. Set them with edit --attr. Edit, Play, capture, and an exported PNG show every step.`
46608
+ ],
46187
46609
  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}/.`,
46188
46610
  look: [
46189
46611
  `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.`,
@@ -46237,6 +46659,8 @@ function formatLines(format) {
46237
46659
  `${INDENT}${sizes.join(", ")}, defaulting to ${format.defaultFrameSize}`,
46238
46660
  "Layout",
46239
46661
  ...format.layout.map((line) => `${INDENT}${line}`),
46662
+ "Present",
46663
+ ...format.present.map((line) => `${INDENT}${line}`),
46240
46664
  "Assets",
46241
46665
  `${INDENT}${format.assets}`,
46242
46666
  "Look",
@@ -46510,6 +46934,27 @@ function describe$4(claims, now) {
46510
46934
  return `${each.frame} ${each.tag} ${state} ${seconds}s ${each.session}`;
46511
46935
  }).join("\n");
46512
46936
  }
46937
+ // src/cli/commands/transition-flags.ts
46938
+ /** Adds `--ms` and `--direction`, which `page transition` and `frame transition` share. */
46939
+ function withTransitionFlags(command) {
46940
+ return command.option("--ms <n>", `the transition's length, ${TRANSITION_MS.min} to ${TRANSITION_MS.max}, defaulting to the page's or 500`, parseInteger(TRANSITION_MS.min)).addOption(new Option("--direction <direction>", `the way ${DIRECTED.join(" and ")} move the incoming slide, defaulting to left`).choices(DIRECTIONS));
46941
+ }
46942
+ /**
46943
+ * The transition a verb stores, refusing `usage` before anything is written
46944
+ * on a duration past the ceiling or a direction on a transition taking none.
46945
+ */
46946
+ function transitionFrom(name, { ms, direction }) {
46947
+ if (ms !== void 0 && ms > TRANSITION_MS.max) throw new FrameboardError("usage", `--ms takes at most ${TRANSITION_MS.max}.`, { ms });
46948
+ if (direction !== void 0 && !takesDirection(name)) throw new FrameboardError("usage", `${name} takes no direction. Only ${DIRECTED.join(" and ")} do.`, {
46949
+ transition: name,
46950
+ direction
46951
+ });
46952
+ return {
46953
+ name,
46954
+ ...direction ? { direction } : {},
46955
+ ...ms === void 0 ? {} : { ms }
46956
+ };
46957
+ }
46513
46958
  // src/cli/commands/frame.ts
46514
46959
  const FRAME_REF = "a frame ref, <page>/<frame> or <project>/<page>/<frame>, or a path to its .html file";
46515
46960
  const ANY_INTEGER = parseInteger(Number.MIN_SAFE_INTEGER);
@@ -46521,6 +46966,11 @@ function parseWidths(value) {
46521
46966
  return value.split(",").map((part) => POSITIVE(part.trim()));
46522
46967
  }
46523
46968
  const SCROLL_HELP = "hold a fixed screen height and scroll past it, fixing both axes, at the reference height of the width when no height is given";
46969
+ /** The override `frame transition` stores, null for `page`, which clears it. */
46970
+ function transitionOrPage(name, flags) {
46971
+ const chosen = transitionNameOf(name);
46972
+ return chosen ? transitionFrom(chosen, flags) : null;
46973
+ }
46524
46974
  const RESIZE_SCROLL_HELP = "hold a fixed screen height and scroll past it, fixing both axes, dropping a hugging height to the reference height of the width and keeping a fixed one";
46525
46975
  function registerFrame(program, context) {
46526
46976
  const { io } = context;
@@ -46596,6 +47046,13 @@ function registerFrame(program, context) {
46596
47046
  });
46597
47047
  return done(record, record.device ? `Set ${record.device} on` : "Cleared the device on");
46598
47048
  });
47049
+ act(withTransitionFlags(verb("transition", "Set the transition present mode draws as this slide arrives, over its page’s, or clear it with page so it takes the page’s, writing only layout.json").addArgument(new Argument("<transition>", "the transition, page to take the page’s").choices([...TRANSITIONS, "page"]))), context, async ([ref = "", name = ""], options) => {
47050
+ const record = await setFrameTransition(await boardOf(options, io), ref, transitionOrPage(name, options), {
47051
+ ...options,
47052
+ cwd: io.cwd
47053
+ });
47054
+ return done(record, record.transition ? `Set ${TRANSITION_LABELS[record.transition.name]} on` : "Cleared the transition on");
47055
+ });
46599
47056
  for (const [name, flag] of [["hide", "hidden"], ["lock", "locked"]]) act(verb(name, `Set a frame ${flag}, or clear it with --off`).option("--off", `clear ${flag}`), context, async ([ref = ""], options) => done(await setFrameFlag(await boardOf(options, io), ref, flag, {
46600
47057
  ...options,
46601
47058
  on: !options.off,
@@ -50609,6 +51066,17 @@ function registerPage(program, context) {
50609
51066
  human: `Moved ${record.ref} to ${record.index}`
50610
51067
  };
50611
51068
  });
51069
+ act(withTransitionFlags(verb("transition", "Set the transition present mode draws between the page’s slides, or clear it with none so they cut, writing only layout.json").addArgument(new Argument("<transition>", "the transition, none to clear it").choices(TRANSITIONS))), context, async ([ref = "", name = ""], options) => {
51070
+ const chosen = transitionNameOf(name) ?? "none";
51071
+ const record = await setPageTransition(await boardOf(options, io), ref, chosen === "none" ? null : transitionFrom(chosen, options), {
51072
+ ...options,
51073
+ cwd: io.cwd
51074
+ });
51075
+ return {
51076
+ data: record,
51077
+ human: record.transition ? `Set ${TRANSITION_LABELS[record.transition.name]} on ${record.ref}` : `Cleared the transition on ${record.ref}`
51078
+ };
51079
+ });
50612
51080
  act(verb("delete", "Delete a page and its frames"), context, async ([ref = ""], options) => {
50613
51081
  const result = await deletePage(await boardOf(options, io), ref, {
50614
51082
  ...options,