@hypersocial/decks-cli 0.9.28 → 0.9.30

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/README.md CHANGED
@@ -36,26 +36,44 @@ decks activity
36
36
 
37
37
  ```bash
38
38
  npm i -g hyperdecks@latest # or run every command as: npx hyperdecks@latest <command>
39
- hyperdecks whoami # cli: <yours> (latest X, minimum Y)
39
+ hyperdecks whoami # cli: <yours> (latest X, minimum Y); skill: <version> (<agents>)
40
40
  ```
41
41
 
42
- - **Daily notice.** Once a day the CLI asks the server which version is current
43
- (`/api/cli/version`, cached in `~/.hyperdecks/update-check.json`). When a newer
44
- one is out it prints one line on stderr with the upgrade command. Offline or
45
- slow, it says nothing and never holds a command up.
46
- `HYPERDECKS_NO_UPDATE_CHECK=1`, or `CI=true`, turns the line off.
42
+ - **One line, at most.** After a command the CLI prints at most one line on
43
+ stderr from its version checks, the most useful one: a newer CLI is out
44
+ (asked once a day of `/api/cli/version`, cached in
45
+ `~/.hyperdecks/update-check.json`), or this CLI is older than a skill copy a
46
+ newer one installed (no network), or what it did to a skill copy. The "update
47
+ the CLI" lines print once a day. Offline or slow, it says nothing and never
48
+ holds a command up.
49
+ - **`--json` carries `notices`.** The JSON object a command prints gets
50
+ `notices: [{ kind, message, run?, ... }]` when something is behind:
51
+ `cli-behind`, `cli-behind-skill`, `skill-behind`, `skill-link-behind`
52
+ (`targets` names where the link points), `skill-unreadable`. It rides only
53
+ on a JSON object: for a command that prints an array or no JSON, run
54
+ `hyperdecks whoami --json`. The result never waits more than 250 ms for the
55
+ version check; past that it uses the answer already on disk.
56
+ - **Opting out.** `HYPERDECKS_NO_UPDATE_CHECK=1` (or `=true`) and CI (`CI`,
57
+ `GITHUB_ACTIONS`, `GITLAB_CI`, `BUILDKITE`, `JENKINS_URL`, `TF_BUILD`,
58
+ `TEAMCITY_VERSION`) print no update or skill line, add no update notice and
59
+ leave the skill copies alone. They never switch off the minimum: the gated
60
+ commands below still ask the server for it.
47
61
  - **Minimum.** Below the server's minimum version, `narrate`, `check`,
48
62
  `release`, `deck new`, `preview create` and `init` refuse with the upgrade
49
63
  command and exit 1, because an old CLI ships retired templates or since-fixed
50
64
  bugs. Everything else (`whoami`, `deck list`, share links, stats) still runs.
51
65
  `HYPERDECKS_ALLOW_OLD=1` runs them anyway in an emergency, with a warning.
52
66
  - **Skill copies.** After an update, the next command refreshes the hyperdecks
53
- skill copies `skills install` / `init` put in your agents' folders (Claude
54
- Code, Codex, Cursor, ...) from the copy bundled with the CLI, and says so in
55
- one line. A copy you edited by hand is left alone with a warning
56
- (`hyperdecks skills install` replaces it). A copy installed before 0.9.16 is
67
+ skill copies `skill install` / `init` put in your agents' folders (Claude
68
+ Code, Codex, Cursor, ...) from the copy bundled with the CLI. A copy you
69
+ edited by hand, a link, or one whose version isn't a version is left alone
70
+ (`hyperdecks skill install` replaces it). A copy installed before 0.9.16 is
57
71
  saved to `~/.hyperdecks/skill-backups/` before it is refreshed.
58
- - The CLI never installs itself: it only prints the command.
72
+ `skill install` never replaces a newer copy (from a newer CLI) unless you
73
+ pass `--force`, which saves that copy (with any edits) to
74
+ `~/.hyperdecks/skill-backups/` first.
75
+ - The CLI never installs itself: it only prints the command. `whoami` and
76
+ `init` always show the CLI's and the skill's versions.
59
77
 
60
78
  ## Auth
61
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypersocial/decks-cli",
3
- "version": "0.9.28",
3
+ "version": "0.9.30",
4
4
  "description": "Command-line client for Hypersocial Decks live analytics and share management.",
5
5
  "type": "module",
6
6
  "main": "./src/commands.mjs",
@@ -2,12 +2,13 @@
2
2
  name: hyperdecks
3
3
  description: Use when asked to make, narrate, check or ship a deck ("make me a narrated deck", "turn this into a deck and send it"), or when working with Hypersocial Decks, Hyperdecks CLI, production deck analytics, recipient share links, deck activity, MCP deck tools, or real-world/customer-facing deck checks. Prefer production for real activity and analytics; use development only for local implementation/testing when explicitly requested.
4
4
  metadata:
5
- version: "0.9.28"
5
+ version: "0.9.30"
6
6
  ---
7
7
 
8
8
  # Hyperdecks
9
9
 
10
10
  Run `hyperdecks --version`; if it's behind `npx hyperdecks@latest --version`, update before making a deck (`npm i -g hyperdecks@latest`, or run every command as `npx hyperdecks@latest`).
11
+ `hyperdecks whoami` shows the CLI's and this skill's versions. When a `--json` result has `notices` (the CLI or this skill is behind), tell the user each `message` and offer its `run` command, if it has one; never update the CLI without asking. `notices` rides only on a JSON object: when a command prints an array (`deck list --json`) or no JSON, run `hyperdecks whoami --json` to see them.
11
12
 
12
13
  ## Overview
13
14
 
@@ -204,10 +205,13 @@ HTML says. Viewers get a slides/scroll toggle in the player, remembered per
204
205
  link, unless you turn it off (`--toggle off`, `viewToggle: false`). A viewer
205
206
  who already switched keeps their own choice while the toggle is on; turn the
206
207
  toggle off to make every viewer see the deck's view.
207
- Pace is the third: `--pace auto` (`pace: "auto"`, the default) plays itself,
208
- `slide` waits for Next (the Continue pill, →, a swipe) after each slide's
209
- narration, and `step` also stops the narration before each `[reveal]` cue,
210
- so a slide's reveals are the steps the viewer clicks through: group what
208
+ Pace is the third, named in the player and the dashboard as Auto-play, Whole
209
+ slide and Step by step: `--pace auto` (`pace: "auto"`, Auto-play, the default)
210
+ plays by itself, slide after slide; `slide` (Whole slide) waits for Next (the
211
+ Continue pill, →, a swipe) after each slide's narration, so Next goes to the
212
+ next slide; and `step` (Step by step) also stops the narration before each
213
+ `[reveal]` cue, so Next shows a slide part by part:
214
+ a slide's reveals are the steps the viewer clicks through: group what
211
215
  belongs together at one word, so each stop is a meaningful step. At `step`,
212
216
  Next while the narrator is still talking goes to the slide's next step, not
213
217
  the next slide; after the slide's last step it moves on. Viewers can
@@ -301,13 +305,13 @@ The deck contract (`check` enforces or warns on each line):
301
305
  player script. `deck new` still writes `data-silent-presenter="hide"`, which
302
306
  means the same as no attribute; you never need to add it.
303
307
  - Steps for presenting in person: when the person says they will present the
304
- deck themselves (You present, `/present/<slug>`), put `data-steps` on a
308
+ deck themselves (Present on the deck's own page, `/d/<slug>`), put `data-steps` on a
305
309
  slide's row of cards or list (features' `.cards`, bento's `.tiles`, stack's
306
310
  `.layers`, timeline's `.line`, staircase's `.steps`, scorecard's `.rows`,
307
- lanes, compare's `.cols`…): Next then shows its children one at a time, and
311
+ lanes, compare's `.rows`…): Next then shows its children one at a time, and
308
312
  after the last moves to the next slide. For any other element, `data-step="N"`
309
313
  (from 1, no gaps; the same N shows together). Part 0 shows everything without
310
- a step. `deck new` adds none. Steps hide only when presenting and for a viewer
314
+ a step. `deck new` adds them only to sieve's list. Steps hide only when presenting and for a viewer
311
315
  at pace `step`; every other pace, scroll view, the PDF, video, thumbnails and
312
316
  the poster show everything. On a narrated slide its `[reveal]` cues are the
313
317
  steps, so leave the HTML steps off there; none on a question either, nor on
@@ -587,28 +591,32 @@ read (`check` warns).
587
591
 
588
592
  | Layout | Use it for |
589
593
  |---|---|
590
- | `hero` | the default cover: the subject framed beside the title |
594
+ | `hero` | the default cover: the subject beside the title |
591
595
  | `cover-frame` | a strong picture, framed under the title |
592
596
  | `cover-split` | a big picture: a hard 50/50 |
593
- | `cover-band` | the picture fills the slide, title on a panel |
594
- | `cover-poster` | a wide scene on top, title below |
597
+ | `cover-band` | a full-bleed picture, title on a panel |
598
+ | `cover-poster` | a wide scene above the title |
595
599
  | `cover-type` | no picture: type only |
596
600
  | `number` | one number with its source |
597
601
  | `product` | a screenshot in a browser frame |
598
602
  | `split` | a real picture beside three ticks |
599
- | `phones` | a phone app's flow: a fanned row of phone cards |
603
+ | `phones` | a phone app's flow, phones fanned |
600
604
  | `phone-stage` | one phone screen, notes lit in turn |
601
- | `tap-through` | a prototype viewers tap through |
605
+ | `tap-through` | a prototype to tap through |
602
606
  | `screens` | screens or pictures in order |
603
607
  | `zoom` | a screenshot, one part enlarged |
604
- | `video-full` | a recording fills the slide |
608
+ | `video-full` | a full-slide recording |
605
609
  | `video-beats` | a recording and its moments |
606
610
  | `picture-full` | one photo, words on a panel |
607
611
  | `wall` | 3 to 5 real photos |
608
- | `portrait` | one tall picture beside the title |
612
+ | `portrait` | a tall picture beside the title |
609
613
  | `embed` | a map or booking, live |
610
- | `quote` | a customer in their own words, quoted exactly |
611
- | `compare` | before/after, them/us, three parallel lines each |
614
+ | `quote` | a customer's own words, quoted exactly |
615
+ | `compare` | before/after |
616
+ | `statement` | two halves |
617
+ | `pictures` | two halves, pictured |
618
+ | `scale` | a spectrum |
619
+ | `sieve` | in or out |
612
620
  | `timeline` | four dated milestones |
613
621
  | `features` | three things it does, an icon each |
614
622
  | `sentence` | the point, set large |
@@ -624,8 +632,8 @@ read (`check` warns).
624
632
  | `lanes` | who does what |
625
633
  | `two-bars` | two numbers |
626
634
  | `stack` | layers |
627
- | `chart` | real numbers drawn with `chart`, a takeaway |
628
- | `team` | up to four people, faces only with permission |
635
+ | `chart` | real numbers via `chart`, a takeaway |
636
+ | `team` | up to four faces, only with permission |
629
637
  | `question-choice` | ask: 2 to 4 cards |
630
638
  | `question-text` | ask: a typed line |
631
639
  | `closer` | the end: one line, one action |
@@ -909,11 +917,19 @@ hard-coded gutter (`padding-right: 400px`); override one in
909
917
  glances at whoever speaks, then the narrator goes on. A cue may open a
910
918
  guest's line and fires as it starts. Inside a guest's line, `[nod]`,
911
919
  `[shake]`, `[brow]` and `[gesture]` move the guest's head; the other cues
912
- (`[reveal]`, `[go]`, `[mood]`, `[wave]`…) act on the slide and the presenter. Replay, Per step (each guest line is a
913
- step), mute, You present and video export all include them.
920
+ (`[reveal]`, `[go]`, `[mood]`, `[wave]`…) act on the slide and the presenter. Replay, Step by step (each guest line is a
921
+ step), mute, presenting on the deck's page and video export all include them.
914
922
  - Audio and data files a slide uses itself (a sound effect, a chart's JSON):
915
923
  `hyperdecks asset add` / `upload_deck_asset` take `.mp3`, `.m4a` and
916
924
  `.json` as well as images, video and fonts.
925
+ - A deck's own script files (`.js`, `.mjs`) and stylesheets (`.css`) upload
926
+ the same way, as they are: load a module with `import("<url>")`. Paths
927
+ inside an uploaded file are not rewritten (both routes return the relative
928
+ paths a script or stylesheet names as `refs`, with a warning), so upload
929
+ each file it loads and put that URL in; `import <zip>` is the route that
930
+ rewrites a whole folder. A worker's script must come from the deck's own
931
+ origin: fetch the uploaded text and start it from a blob URL. A name already
932
+ on the deck is replaced and its old URL stops loading (`replaced: true`).
917
933
  - `voice: dash` narrates with D.A.S.H.'s own robot voice, a synthetic
918
934
  character voice (not a clone of anyone) any account may use, for decks that
919
935
  D.A.S.H. presents. It works once the deployment sets `CHARACTER_VOICE_DASH`.
@@ -966,7 +982,33 @@ loading state (`<style data-hd-loading>`).
966
982
 
967
983
  `--layout` lays each slide out in Chromium (needs `hyperdecks preview setup`).
968
984
  At the stage size it warns, without failing, when a slide's presenter would
969
- overlap its title. On a 390×844 phone (the share player's 374×736 slide card)
985
+ overlap its title. It also measures every line of text on the slide (its
986
+ ink, in SVG charts too), at the stage size and on the phone, as the player shows
987
+ it (steps played, phone-stage's notes placed, no presenter on a silent deck), and
988
+ reports text that collides. It fails a slide whose title runs over other text,
989
+ whose text is drawn over other text so neither can be read (more than a third of
990
+ the smaller one), or whose phone-stage side has more notes than fit (under the
991
+ title on the left, keeping a line for a title that wraps once more in another
992
+ browser; clear of the presenter on either side) or more notes bending beside each
993
+ other than the gap to the phone keeps apart; it warns when text only touches
994
+ other text, when text is cut off by the slide's edge or its box, when a
995
+ phone-stage note has a `--y` the browser cannot read or aims off the phone's
996
+ straight edge (its line is held at the edge), on a phone when notes run under
997
+ the presenter's head, and, at the stage size, when the presenter would cover
998
+ any text: what it draws, as the player draws it (a stage head, whose caption
999
+ steps aside from text; a glass panel; a bubble's face and caption; a corner face
1000
+ and caption), not on a question slide, where the player moves the presenter
1001
+ round the answers. Faint decoration (under 30% opacity, such as a big quote mark
1002
+ behind a line: opacity, `filter: opacity()` or a faint colour) and text hidden with
1003
+ `visibility` are not read as text; an outline-only letter (a transparent fill with
1004
+ a stroke) is. Each message names the slide, what collides
1005
+ and the size (`at 1600×900`, `at 390×844 (a phone)`). Every window wider than
1006
+ 650px shows the same stage, scaled, so the stage size stands for a split-screen
1007
+ pane, a tablet and a large screen alike; narrower windows use the phone layout,
1008
+ measured at 390×844. Measured in Chromium only. Not covered: text over a picture
1009
+ (except the cover's title) and text a deck's own script draws or moves. A deck is not done while one
1010
+ of these is open, except an `advice:` line: a phone-stage note that sits over 120px from what it
1011
+ points at is fine when its line reads, and the advice says how to bring it nearer. On a 390×844 phone (the share player's 374×736 slide card)
970
1012
  it fails any slide whose content overflows: the player never scrolls a slide
971
1013
  (one exception: a pick several or Other question that can't fit even at its
972
1014
  smallest type scrolls its cards, under a pinned title and Continue).
@@ -1015,6 +1057,18 @@ with the player's `hyperdecks.ai` script tag. Messages and what to do:
1015
1057
  | ⚠ `slides <a> and <b> are two <layout> slides in a row with the panel on the same side` | put `data-flip` on the second one's section (or, when both have it, take it off one) so the two alternate |
1016
1058
  | ⚠ `slide <id> has data-flip, but <layout> does not flip` | take `data-flip` off; only wall, split, cover-split, picture-full and portrait flip |
1017
1059
  | ⚠ `slide <id> has data-flip="<value>"` | any value flips: write plain `data-flip`, or take it off |
1060
+ | ✖ `slide <id> at <size>: the title "…" runs over "…"` | shorten the title, or move the other text clear of it |
1061
+ | ✖ `slide <id> at <size>: "…" and "…" are drawn over each other, so neither can be read` | move one or shorten it (phone-stage: aim the notes further apart, or copy its `<style>` block from a new deck) |
1062
+ | ✖ `slide <id> at <size>: too many notes on the left: N of M fit …` (or `on the right`) | the message names what takes the room (the title, the presenter or both): cut notes, shorten them, a smaller presenter (`data-presenter-size="s"`), or move one to the other side |
1063
+ | ✖ `slide <id> at <size>: too many notes on the right point away from where they sit …` (or `on the left`) | their lines bend beside each other too close to follow: cut a note, aim them nearer where they sit, or move one to the other side |
1064
+ | ✖ `slide <id> at <size>: notes "…" and "…": their lines into the phone run together …` | two notes aim at one height, so their lines meet the phone as one: aim them further apart (`--y`) or move one to the other side |
1065
+ | ⚠ `slide <id> at <size>: "…" and "…" are drawn over each other` | they touch: move one or shorten it |
1066
+ | ⚠ `slide <id> at <size>: advice: note "…" sits far from what it points at` | advice, not a fault: its line runs over 120px; fine when it reads, or do what it names (shorten the title on the left, a smaller presenter on the right, cut a note, move one across) |
1067
+ | ⚠ `slide <id> at <size>: note "…" aims off the phone's straight edge` | give a `--y` inside the range the message names (the phone's straight edge, between its rounded corners) |
1068
+ | ⚠ `slide <id> at 390×844 (a phone): note "…" sits under the presenter's head` | cut a note or shorten them so the list ends above the head |
1069
+ | ⚠ `slide <id> at <size>: note "…" has a --y the browser cannot read` | give a share of the screen's height, such as `style="--y: 40%"` |
1070
+ | ⚠ `slide <id> at <size>: the … presenter would cover "…"` | move the text out of the presenter's corner, a smaller `data-presenter-size`, or a layout that keeps the corner free |
1071
+ | ⚠ `slide <id> at <size>: "…" is cut off by the slide's edge or its box` | shorten it or give it more room |
1018
1072
  | ⚠ `slide <id>: the … presenter would overlap the title` | move that slide's `.narration-slot`, pad the text away from it, or use `corner` |
1019
1073
 
1020
1074
  **Review before release (required).** After `check` passes and the deck is
@@ -1101,6 +1155,10 @@ hyperdecks activity --deck <slug> --limit 10
1101
1155
  Tell the user who opened it, how far they got and whether the narration
1102
1156
  finished. QA links never count.
1103
1157
 
1158
+ The owner sees the same on the deck's own page (`/d/<slug>`): its **Insights**
1159
+ button opens the deck's Stats (who watched and what they answered) in a new tab.
1160
+ Point the user there when they would rather look than ask.
1161
+
1104
1162
  ### 9. Follow up with a recipient
1105
1163
 
1106
1164
  When the user wants to follow up with someone, read what that person watched:
@@ -1194,7 +1252,7 @@ the hosted MCP (`deck_guide`, `new_deck`, `get_deck_source`, `write_deck_source`
1194
1252
  `upload_deck_asset`, `check_deck`, `release_deck`; see `chat.md`). Move between
1195
1253
  the two with `hyperdecks source pull <slug> [dir]` (the hosted draft into a
1196
1254
  folder) and `hyperdecks source push <slug> [dir]` (a folder's files back to the
1197
- draft), `hyperdecks asset add <slug> <file|url>` for an image, video, audio (.mp3, .m4a), font or JSON file, `hyperdecks guide
1255
+ draft), `hyperdecks asset add <slug> <file|url>` for an image, video, audio (.mp3, .m4a), font, JSON, script (.js, .mjs) or stylesheet (.css), `hyperdecks guide
1198
1256
  [topic]` for these sections, and `--hosted` on `deck new`, `check` and `release`.
1199
1257
 
1200
1258
  ## After you ship: say what cost you
@@ -77,7 +77,7 @@ so no command below needs `--slug`. Read a topic before its step:
77
77
 
78
78
  If narration changed the folder, release stops: check, commit, release again.
79
79
 
80
- 8. **Report who watched.** `hyperdecks deck stats <slug>`, `hyperdecks activity --deck <slug>`.
80
+ 8. **Report who watched.** `hyperdecks deck stats <slug>`, `hyperdecks activity --deck <slug>`; on the deck's own page, the **Insights** button opens the same Stats.
81
81
 
82
82
  9. **Video.** `hyperdecks export <slug> --video --size 720p` records the released
83
83
  copy; `hyperdecks export <dir> --video` records the working copy.
@@ -0,0 +1,165 @@
1
+ // Places phone-stage's aimed notes (a .note with style="--y: …" in a .side) so
2
+ // that, per side, they keep their order by --y, never overlap each other, the
3
+ // title block above them (left), the presenter (`keepOut`, a client rect:
4
+ // presenterKeepOut's box) or the slide's edges, and each sits as near its aim as
5
+ // it can. A note that moves keeps its aim: its tick becomes an elbow, level out
6
+ // of the phone's frame at --y, one vertical run, level into the note's line.
7
+ // Elbows that share a stretch of height run in their own lanes, LANE px apart and
8
+ // ordered so they never cross (the layout draws them from --tw, --mx, --dy and
9
+ // data-tick). An aim is held to the frame's straight edge (not off the phone, not
10
+ // in its rounded corner).
11
+ // A --y is read as the browser resolves it (a percent, px, calc(), var()); a note
12
+ // whose --y does not resolve is left where its CSS puts it, and named in `bad`.
13
+ // Only for a layout whose CSS opts in (--aim-notes: 1 on the slide), so decks made
14
+ // before keep the notes where their CSS puts them; not on phones (the sides are
15
+ // display: contents there). Returns, per side with aimed notes: { notes, fit, room,
16
+ // slack, far, bad, off, aims, by, crowd }: how many it places, how many fit in its
17
+ // room (`slack` px less on the left, for a title one line longer in another
18
+ // browser); the notes placed more than FAR px from their aim, those whose --y did
19
+ // not resolve and those whose aim was held to the frame (their words); the --y
20
+ // range the frame's straight edge takes (percents); what limits the room (`by`:
21
+ // 'title', 'presenter'); when one run of elbows has more than its gap keeps
22
+ // apart, { run, fit }; and pairs of notes whose level parts still run together (`joined`).
23
+ // Uses nothing outside itself: the player runs it, and `check --layout` runs its
24
+ // source in a page with no scripts. Kept the same in
25
+ // packages/player/aimed-notes.js and packages/decks-cli/src/aimedNotes.mjs
26
+ // (a test fails when they differ).
27
+ export function aimNotes(slide, keepOut = null, { slack = 0 } = {}) {
28
+ const out = {};
29
+ if (!slide || getComputedStyle(slide).getPropertyValue('--aim-notes').trim() !== '1') return out;
30
+ const sr = slide.getBoundingClientRect();
31
+ if (!slide.offsetHeight || !sr.height) return out;
32
+ const k = sr.height / slide.offsetHeight; // the stage's scale: client px per layout px
33
+ const GAP = 24, FAR = 120, LANE = 11, CLEAR = 8, words = (n) => { const w = document.createTreeWalker(n, NodeFilter.SHOW_TEXT), parts = []; for (let t; (t = w.nextNode());) parts.push(t.textContent); return parts.join(' ').trim().replace(/\s+/g, ' ').slice(0, 48); };
34
+ const frameEl = slide.querySelector(':scope > .frame'), frame = frameEl?.getBoundingClientRect();
35
+ // The frame's straight edge, between its rounded corners (client px): an aim is held inside it.
36
+ const corner = frameEl ? Math.max(parseFloat(getComputedStyle(frameEl).borderTopRightRadius) || 0, parseFloat(getComputedStyle(frameEl).borderBottomRightRadius) || 0) * k : 0;
37
+ for (const name of ['left', 'right']) {
38
+ const side = slide.querySelector(`:scope > .side.${name}`);
39
+ if (!side) continue;
40
+ const notes = [...side.querySelectorAll(':scope > .note')].filter((n) => n.style.getPropertyValue('--y').trim());
41
+ for (const n of notes) { n.style.removeProperty('top'); for (const v of ['--dy', '--mx', '--tw']) n.style.removeProperty(v); n.removeAttribute('data-tick'); }
42
+ if (!notes.length || getComputedStyle(side).display === 'contents' || !side.offsetHeight) continue;
43
+ const box = side.getBoundingClientRect();
44
+ const H = side.offsetHeight, at = (y) => (y - box.top) / k; // client y → the side's own px
45
+ let lo = Math.max(0, at(sr.top)), hi = Math.min(H, at(sr.bottom));
46
+ const by = new Set(); // what limits the room, for check's message
47
+ const head = slide.querySelector(':scope > .head');
48
+ if (head && name === 'left') { const r = head.getBoundingClientRect(); if (r.height && at(r.bottom) + GAP > lo) { lo = at(r.bottom) + GAP; by.add('title'); } }
49
+ if (keepOut && keepOut.bottom > keepOut.top && Math.min(keepOut.right, box.right) - Math.max(keepOut.left, box.left) > 0) {
50
+ // The presenter stands in this side's column: notes keep above it (or below it, if it stands high).
51
+ const top = at(keepOut.top), bottom = at(keepOut.bottom);
52
+ if (top - lo >= hi - bottom) { if (top - GAP < hi) { hi = top - GAP; by.add('presenter'); } } else if (bottom + GAP > lo) { lo = bottom + GAP; by.add('presenter'); }
53
+ }
54
+ const edge = frame ? [at(frame.top + corner), at(frame.bottom - corner)] : [-Infinity, Infinity];
55
+ // Each note: its aim (its --y as the layout resolves it: the note's own top, in the side's px), its height, and
56
+ // where its tick sits from its top (.65em).
57
+ const bad = [], off = [], items = [];
58
+ notes.forEach((n, i) => {
59
+ // The custom property's computed value has its var()s filled in; a value `top` cannot take (a bare number) leaves
60
+ // the note at its static place, so it is checked before its resolved top is read.
61
+ const cs = getComputedStyle(n), y = cs.getPropertyValue('--y').trim(), aim = parseFloat(cs.top);
62
+ if (!y || !CSS.supports('top', y) || !Number.isFinite(aim) || cs.position !== 'absolute') { bad.push(words(n)); return; }
63
+ const held = Math.min(Math.max(aim, edge[0]), edge[1]);
64
+ if (Math.abs(held - aim) > 2) off.push(words(n));
65
+ items.push({ n, i, aim: held, h: n.offsetHeight, a: (parseFloat(cs.fontSize) || 16) * 0.65 });
66
+ });
67
+ items.sort((p, q) => p.aim - q.aim || p.i - q.i);
68
+ // Tops as near the aims as the room lets: down from the top, then up from the bottom, then down again (a pile
69
+ // that does not fit starts at the top and runs past the bottom: the best it can do, and check fails it).
70
+ const top = items.map((it) => it.aim - it.a);
71
+ for (let j = 0; j < items.length; j++) top[j] = Math.max(top[j], j ? top[j - 1] + items[j - 1].h + GAP : lo);
72
+ for (let j = items.length - 1; j >= 0; j--) top[j] = Math.min(top[j], j < items.length - 1 ? top[j + 1] - GAP - items[j].h : hi - items[j].h);
73
+ for (let j = 0; j < items.length; j++) top[j] = Math.max(top[j], j ? top[j - 1] + items[j - 1].h + GAP : lo);
74
+ // A note's line (its bar out of the note) keeps CLEAR px off every other note's aim (where that note's line meets
75
+ // the frame), so two notes' level parts never draw as one stroke: a note whose line lands that near another's aim
76
+ // moves the least it can, alone within its gaps or with the notes it presses on (those above it, moving up; below
77
+ // it, moving down) inside the room. Two aims that near each other cannot be helped this way (both lines meet the
78
+ // frame there): `joined` names them, below.
79
+ const last = items.length - 1;
80
+ // Tops with note j's top at t, the notes it presses on pushed along (keeping their gaps); null when that leaves the room.
81
+ const push = (j, t) => {
82
+ const next = top.slice();
83
+ next[j] = t;
84
+ for (let q = j - 1; q >= 0; q--) next[q] = Math.min(next[q], next[q + 1] - GAP - items[q].h);
85
+ for (let q = j + 1; q <= last; q++) next[q] = Math.max(next[q], next[q - 1] + items[q - 1].h + GAP);
86
+ return next[0] >= lo - 0.01 && next[last] + items[last].h <= hi + 0.01 ? next : null;
87
+ };
88
+ for (let pass = 0; pass < 4; pass++) {
89
+ for (let j = 0; j <= last; j++) {
90
+ const a = items[j].a, line = top[j] + a;
91
+ const zones = items.filter((o, q) => q !== j && Math.abs(o.aim - items[j].aim) >= CLEAR).map((o) => [o.aim - CLEAR, o.aim + CLEAR]);
92
+ const inZone = (y) => zones.some(([z0, z1]) => y > z0 + 0.01 && y < z1 - 0.01);
93
+ if (!inZone(line)) continue;
94
+ const ways = zones.flat().filter((y) => !inZone(y)).sort((p, q) => Math.abs(p - line) - Math.abs(q - line));
95
+ for (const y of ways) { const next = push(j, y - a); if (next) { top.splice(0, top.length, ...next); break; } }
96
+ }
97
+ }
98
+ // Each tick: from the note's edge to the phone's frame (--tw), its line at `line`, its aim `dy` below that.
99
+ const ticks = items.map((it, j) => {
100
+ const r = it.n.getBoundingClientRect();
101
+ const tw = frame ? Math.max(12, (name === 'left' ? frame.left - r.right : r.left - frame.right) / k) : 52;
102
+ const line = top[j] + it.a, dy = Math.round(it.aim - line);
103
+ return { tw, line, dy, dir: Math.abs(dy) <= 1 ? 0 : Math.sign(dy) };
104
+ });
105
+ // Lanes: elbows bending the same way whose heights overlap (a run) take one lane each, counted from the phone.
106
+ // An elbow bending down (aim below its note) nearer the phone than the ones after it, bending up farther: so
107
+ // no elbow's level part crosses another's vertical run. Elbows bending opposite ways never share a height. Lanes
108
+ // stand LANE px apart (8px clear between 3px lines) so each run can be followed; a run with more than its gap takes
109
+ // is squeezed, and named in `crowd`.
110
+ let crowd = null;
111
+ for (let j = 0; j < ticks.length;) {
112
+ let e = j + 1;
113
+ const span = (t) => [Math.min(t.line, t.line + t.dy), Math.max(t.line, t.line + t.dy)];
114
+ while (ticks[j].dir && e < ticks.length && ticks[e].dir === ticks[j].dir && span(ticks[e])[0] <= span(ticks[e - 1])[1] + 4) e++;
115
+ // A tick starts 12px off the note (the layout's gap); its lanes share what is left, 4px clear of either end.
116
+ const run = ticks.slice(j, e), room = Math.min(...run.map((t) => t.tw)) - 12, mid = 12 + room / 2;
117
+ const step = run.length > 1 ? Math.max(0, Math.min(LANE, (room - 8) / (run.length - 1))) : 0;
118
+ const lanes = Math.max(1, Math.floor((room - 8) / LANE) + 1);
119
+ if (ticks[j].dir && run.length > lanes && (!crowd || run.length - lanes > crowd.run - crowd.fit)) crowd = { run: run.length, fit: lanes };
120
+ run.forEach((t, q) => { const lane = t.dir > 0 ? q : run.length - 1 - q; t.mx = mid + ((run.length - 1) / 2 - lane) * step; });
121
+ j = e;
122
+ }
123
+ // Level parts of two notes that still meet (within CLEAR px of each other's height, overlapping across): drawn as one.
124
+ const segs = ticks.map((t) => (t.dir ? [[t.line, 12, t.mx], [t.line + t.dy, t.mx, t.tw]] : [[t.line, 12, t.tw]]));
125
+ const joined = [];
126
+ for (let p = 0; p < items.length; p++) for (let q = p + 1; q < items.length; q++) {
127
+ if (segs[p].some(([y, x0, x1]) => segs[q].some(([v, u0, u1]) => Math.abs(y - v) < CLEAR - 0.5 && Math.min(x1, u1) - Math.max(x0, u0) > 1))) joined.push([words(items[p].n), words(items[q].n)]);
128
+ }
129
+ items.forEach((it, j) => {
130
+ const t = ticks[j];
131
+ it.n.style.top = `${t.line}px`; // the layout lifts a note by .65em, so its tick's line is at `top`
132
+ it.n.style.setProperty('--dy', `${t.dy}px`);
133
+ it.n.style.setProperty('--tw', `${Math.round(t.tw)}px`);
134
+ if (t.dir) it.n.style.setProperty('--mx', `${Math.round(t.mx)}px`);
135
+ it.n.setAttribute('data-tick', t.dir > 0 ? 'down' : t.dir < 0 ? 'up' : 'level');
136
+ });
137
+ // How many fit: the most notes (in order) whose heights and gaps fit the room.
138
+ const room = hi - lo - (name === 'left' ? slack : 0);
139
+ let used = -GAP, fit = 0;
140
+ for (const it of items) { if (used + GAP + it.h > room) break; used += GAP + it.h; fit++; }
141
+ const far = items.filter((it, j) => Math.abs(ticks[j].dy) > FAR).map((it) => words(it.n));
142
+ const aims = frame ? edge.map((y) => Math.round((y / H) * 100)) : null;
143
+ out[name] = { notes: items.length, fit, room: Math.round(room), slack: name === 'left' ? slack : 0, far, bad, off, aims, by: [...by], ...(crowd ? { crowd } : {}), ...(joined.length ? { joined } : {}) };
144
+ }
145
+ return out;
146
+ }
147
+
148
+ // What the presenter draws where the notes must keep clear of it, as a client rect, from the parts the player (or
149
+ // check's stand-in, the same classes) draws: a stage or corner presenter's face and its caption where it sits at home
150
+ // (a stage caption that stepped aside, --hd-bubble-dx/dy, counted at its home); a glass or bubble presenter's whole
151
+ // box (the glass panel; the bubble's face and caption beside it). Null when nothing is drawn.
152
+ export function presenterKeepOut(presenter, style) {
153
+ if (!presenter) return null;
154
+ const k = presenter.offsetWidth ? presenter.getBoundingClientRect().width / presenter.offsetWidth : 1;
155
+ const own = (n) => {
156
+ const r = n.getBoundingClientRect(), cs = getComputedStyle(n);
157
+ const dx = n.classList.contains('hd-bubble') ? (parseFloat(cs.getPropertyValue('--hd-bubble-dx')) || 0) * k : 0;
158
+ const dy = n.classList.contains('hd-bubble') ? (parseFloat(cs.getPropertyValue('--hd-bubble-dy')) || 0) * k : 0;
159
+ return { left: r.left - dx, top: r.top - dy, right: r.right - dx, bottom: r.bottom - dy, width: r.width };
160
+ };
161
+ const parts = style === 'glass' || style === 'bubble' ? [presenter] : [...presenter.querySelectorAll(':scope > .hd-face, :scope > .hd-bubble')];
162
+ const rs = parts.map(own).filter((r) => r.width > 0 && r.bottom > r.top);
163
+ if (!rs.length) return null;
164
+ return { left: Math.min(...rs.map((r) => r.left)), top: Math.min(...rs.map((r) => r.top)), right: Math.max(...rs.map((r) => r.right)), bottom: Math.max(...rs.map((r) => r.bottom)) };
165
+ }
@@ -0,0 +1,65 @@
1
+ // What a deck may carry as a hosted file, by extension: one table for every route
2
+ // that puts a file on a deck. `hyperdecks asset add` (a file from disk), the
3
+ // server's upload_deck_asset / `asset add <url>` (convex/lib/assetImport.ts) and
4
+ // `import <zip>` (importer.mjs) all read it, and the hosted check's remedy
5
+ // (checkRules.mjs hostedFileRemedy) names an upload for exactly these.
6
+ // A page (.html) is never an asset: it is the deck itself, served by the app.
7
+ export const ASSET_TYPES = {
8
+ png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", webp: "image/webp", avif: "image/avif", svg: "image/svg+xml", ico: "image/x-icon",
9
+ mp4: "video/mp4", m4v: "video/x-m4v", webm: "video/webm", mov: "video/quicktime",
10
+ mp3: "audio/mpeg", m4a: "audio/mp4", aac: "audio/aac", wav: "audio/wav", ogg: "audio/ogg", opus: "audio/opus", flac: "audio/flac",
11
+ woff: "font/woff", woff2: "font/woff2", ttf: "font/ttf", otf: "font/otf", eot: "application/vnd.ms-fontobject",
12
+ json: "application/json",
13
+ // A deck's own scripts and styles: uploaded as they are, never rewritten.
14
+ js: "application/javascript", mjs: "application/javascript", css: "text/css",
15
+ };
16
+
17
+ export const ASSET_EXTENSIONS = Object.keys(ASSET_TYPES);
18
+
19
+ // The content type for a file name's extension, or undefined when a deck can't carry it.
20
+ // A name, not a URL: a zip entry "a#b.png" is a PNG. Give a URL's pathname, never the whole URL.
21
+ // ".js" (a leading dot and nothing else) is a .js file here, as it is to import and the URL route.
22
+ export function assetTypeForPath(path) {
23
+ const ext = /\.([a-z0-9]+)$/i.exec(String(path))?.[1]?.toLowerCase();
24
+ return ext && Object.hasOwn(ASSET_TYPES, ext) ? ASSET_TYPES[ext] : undefined;
25
+ }
26
+
27
+ // Content types a server may declare for a file a deck can carry. Anything else
28
+ // (text/html above all) is refused, whatever the URL's extension says.
29
+ export const ALLOWED_ASSET_TYPE = /^(image\/[\w.+-]+|video\/[\w.+-]+|audio\/[\w.+-]+|font\/[\w.+-]+|application\/(json|font-woff2?|x-font-[\w-]+|vnd\.ms-fontobject|(x-)?javascript|ecmascript)|text\/(javascript|ecmascript|css))$/;
30
+
31
+ // What saveAsset files, by the type the caller names and the type the blob was uploaded with:
32
+ // what a deck can carry, plus untyped bytes (import hosts a .wasm or a model as
33
+ // application/octet-stream, which a browser downloads rather than renders).
34
+ // An allow-list: text/html, xml, a comma-joined or empty type are refused.
35
+ const SAVED_TYPE = (type) => ALLOWED_ASSET_TYPE.test(type) || type === "application/octet-stream";
36
+ const bareType = (type) => String(type).split(";")[0].trim().toLowerCase();
37
+ // Why saveAsset refuses this pair, or null. `stored` is undefined when the upload carried no
38
+ // Content-Type (storage then serves it untyped), which is not a page either.
39
+ export function savedTypeError(named, stored) {
40
+ if (!SAVED_TYPE(bareType(named))) return `an asset can't be ${JSON.stringify(String(named).slice(0, 80))}: a deck's assets are ${ASSET_KINDS}`;
41
+ if (stored !== undefined && stored !== null && !SAVED_TYPE(bareType(stored))) return `the upload is ${JSON.stringify(String(stored).slice(0, 80))}, which a deck can't carry: upload it with the type it is`;
42
+ return null;
43
+ }
44
+
45
+ // What saveAsset takes as a name. The URL route is stricter (ASSET_NAME, one segment);
46
+ // import files a zip's paths ("assets/logo.png"), so "/" is allowed but a name is
47
+ // never absolute, never climbs (".."), and has no backslash or control character.
48
+ export const MAX_SAVED_NAME = 200;
49
+ // The largest file saveAsset files. The URL route stops at 25 MB (MAX_ASSET_BYTES), but an
50
+ // imported zip carries its clips whole, so the bound here is the size of a long clip.
51
+ export const MAX_SAVED_BYTES = 100 * 1024 * 1024;
52
+ export const savedSizeError = (size) => (size > MAX_SAVED_BYTES ? `an asset is at most ${MAX_SAVED_BYTES / 1024 / 1024} MB` : null);
53
+ export function savedNameError(name) {
54
+ const n = String(name);
55
+ if (!n.trim()) return "an asset needs a name";
56
+ if (n.length > MAX_SAVED_NAME) return `an asset name is at most ${MAX_SAVED_NAME} characters`;
57
+ if (/[\u0000-\u001f\u007f\\]/.test(n)) return "an asset name has no backslash or control characters";
58
+ if (n.startsWith("/") || n.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) return "an asset name is a relative path with no empty, . or .. parts";
59
+ return null;
60
+ }
61
+
62
+ export const isScriptType = (type) => /^(application\/(x-)?javascript|application\/ecmascript|text\/(javascript|ecmascript))$/.test(bareType(type));
63
+
64
+ // The table in words, for every message that says what an upload takes.
65
+ export const ASSET_KINDS = "images, video, audio, fonts, JSON, scripts and stylesheets";