Skip to content

Commit 54a4460

Browse files
committed
fix(cli): present renders the deck (player sizing + self-driving serve)
Two bugs caused a black slide area: - The <hyperframes-player> had no positioning, so its iframe collapsed to zero size — the (absolutely-positioned) chrome showed but the composition didn't. Add position:absolute; inset:0 (matches demo.html). - The composition was served with the engine runtime injected, which leaves its timelines engine-paused (blank). Slideshow decks self-drive their own timelines (like demo.html / the standalone harness), so serve them raw. Verified end-to-end on registry/examples/airbnb-deck: cover renders, Next advances 1/11 -> 2/11 and slide 2 paints.
1 parent 5ee7b2f commit 54a4460

2 files changed

Lines changed: 225 additions & 19 deletions

File tree

‎packages/cli/src/commands/present.ts‎

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ import {
1919
validateRemoteDebuggingPortDeps,
2020
} from "../utils/openBrowser.js";
2121
import {
22-
resolveRuntimePath,
2322
resolvePlayerPath,
2423
resolveSlideshowPath,
2524
listenOnFreePort,
26-
injectRuntime,
2725
assetContentType,
2826
} from "../utils/compositionServer.js";
2927

@@ -76,12 +74,6 @@ export default defineCommand({
7674
return;
7775
}
7876

79-
const runtimePath = resolveRuntimePath();
80-
if (!runtimePath) {
81-
clack.log.error("HyperFrames runtime not found. Run `bun run build` first.");
82-
process.exitCode = 1;
83-
return;
84-
}
8577
const playerPath = resolvePlayerPath();
8678
const slideshowPath = resolveSlideshowPath();
8779
if (!playerPath || !slideshowPath) {
@@ -125,24 +117,18 @@ export default defineCommand({
125117
"Cache-Control": "no-cache",
126118
}),
127119
);
128-
app.get("/runtime.js", (ctx) =>
129-
ctx.body(readFileSync(runtimePath, "utf-8"), 200, {
130-
"Content-Type": "application/javascript",
131-
"Cache-Control": "no-cache",
132-
}),
133-
);
134-
135-
// Serve composition files (HTML gets the runtime injected; other assets pass through).
120+
// Serve composition files raw. Slideshow compositions self-drive their own
121+
// timelines (no engine runtime injected) — the same model demo.html / the
122+
// standalone harness use; injecting a runtime would leave the composition
123+
// engine-paused and blank.
136124
app.get("/composition/*", (ctx) => {
137125
const reqPath = ctx.req.path.replace("/composition/", "");
138126
const filePath = resolve(project.dir, reqPath);
139127
// Security: canonicalizes symlinks + guards the trailing separator so neither
140128
// an in-project symlink nor a sibling dir sharing the prefix can escape.
141129
if (!isSafePath(project.dir, filePath)) return ctx.text("Forbidden", 403);
142130
if (!existsSync(filePath)) return ctx.text("Not found", 404);
143-
if (filePath.endsWith(".html")) {
144-
return ctx.html(injectRuntime(readFileSync(filePath, "utf-8")));
145-
}
131+
if (filePath.endsWith(".html")) return ctx.html(readFileSync(filePath, "utf-8"));
146132
return ctx.body(readFileSync(filePath), 200, { "Content-Type": assetContentType(filePath) });
147133
});
148134

@@ -193,6 +179,7 @@ function buildPresentPage(projectName: string, islandJson: string): string {
193179
* { margin: 0; padding: 0; box-sizing: border-box; }
194180
html, body { height: 100%; background: #0a0a0a; overflow: hidden; }
195181
hyperframes-slideshow { display: block; position: relative; width: 100vw; height: 100vh; }
182+
hyperframes-player { position: absolute; inset: 0; }
196183
#present-btn {
197184
position: fixed; top: 18px; right: 18px; z-index: 99999;
198185
font: 600 14px/1 system-ui, sans-serif; color: #0d1321;
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Airbnb Deck — Presenter Mode Test</title>
7+
<script src="../../../packages/player/dist/hyperframes-player.global.js"></script>
8+
<script src="../../../packages/player/dist/slideshow/hyperframes-slideshow.global.js"></script>
9+
<style>
10+
*,
11+
*::before,
12+
*::after {
13+
box-sizing: border-box;
14+
margin: 0;
15+
padding: 0;
16+
}
17+
html,
18+
body {
19+
width: 100%;
20+
height: 100%;
21+
overflow: hidden;
22+
background: #111;
23+
}
24+
</style>
25+
</head>
26+
<body>
27+
<!--
28+
NOTE: The <script type="application/hyperframes-slideshow+json"> island below is a
29+
COPY of the island inside index.html. This duplication is intentional: <hyperframes-slideshow>
30+
reads the island from its OWN innerHTML (not from the composition loaded by
31+
<hyperframes-player>). Keep this copy in sync with the island in index.html whenever
32+
slides, fragments, hotspots, or sequences change.
33+
-->
34+
<hyperframes-slideshow tabindex="0" sound style="display: block; position: relative; width: 100vw; height: 100vh">
35+
<hyperframes-player
36+
style="position: absolute; inset: 0"
37+
src="index.html"
38+
></hyperframes-player>
39+
40+
<script type="application/hyperframes-slideshow+json">
41+
{
42+
"slides": [
43+
{
44+
"sceneId": "cover",
45+
"notes": "Open with the tagline. Let the Bélo breathe. This is the belonging company."
46+
},
47+
{
48+
"sceneId": "problem",
49+
"notes": "Two problems, one at a time. Price first — hotels are expensive. Then connection.",
50+
"fragments": [9.3, 9.6]
51+
},
52+
{
53+
"sceneId": "solution",
54+
"notes": "Platform connects hosts and travelers. Belong anywhere. Three value props."
55+
},
56+
{
57+
"sceneId": "validation",
58+
"notes": "Couchsurfing proves demand: 660k members want this. Craigslist shows supply side."
59+
},
60+
{
61+
"sceneId": "market",
62+
"notes": "Bottom-up: trips × take-rate = $2.1B. Use the hotspot for the drill-down math.",
63+
"hotspots": [
64+
{
65+
"id": "mkt-hotspot",
66+
"label": "Show me the math",
67+
"target": "market-math-detail",
68+
"region": { "x": 70, "y": 80, "w": 25, "h": 12 }
69+
}
70+
]
71+
},
72+
{
73+
"sceneId": "product",
74+
"notes": "Three clicks: Search, Book, Travel. Show the booking flow simplicity."
75+
},
76+
{
77+
"sceneId": "business",
78+
"notes": "10% commission. At 80k transactions × $26 avg nightly take = $2.1M revenue."
79+
},
80+
{
81+
"sceneId": "adoption",
82+
"notes": "Events, conferences, Craigslist cross-posting, partnerships. Grass-roots growth."
83+
},
84+
{
85+
"sceneId": "competition",
86+
"notes": "Matrix: cheapest + online + transaction. Airbnb is the only one that hits all three."
87+
},
88+
{
89+
"sceneId": "team",
90+
"notes": "Brian (CEO/design), Joe (design), Nate (engineering). Domain depth: housing + tech."
91+
},
92+
{
93+
"sceneId": "ask",
94+
"notes": "Raising $500K. 12 months runway. Target: 80K transactions ≈ $2M revenue."
95+
}
96+
],
97+
"slideSequences": [
98+
{
99+
"id": "market-math-detail",
100+
"label": "Market sizing methodology",
101+
"slides": [
102+
{
103+
"sceneId": "market-sizing",
104+
"notes": "Bottom-up drill: global trips × budget share × online booking rate × take-rate = $2.1B."
105+
}
106+
]
107+
}
108+
]
109+
}
110+
</script>
111+
</hyperframes-slideshow>
112+
113+
<!--
114+
Sound effects play HERE, in the parent document. The composition (loaded in the
115+
player's iframe) detects slide/fragment/branch transitions and posts
116+
{ type: 'hf-sfx', name } to the parent. Audio must live in the frame that
117+
receives the user's gesture (the parent) — an iframe without its own user
118+
activation is autoplay-blocked. The mp3s are in sfx/ next to this file.
119+
120+
Mute state is owned by <hyperframes-slideshow sound>. Listen for 'hf-sound'
121+
events (or read slideshow.muted / data-hf-muted) to skip playback when muted.
122+
-->
123+
<script>
124+
(function () {
125+
var clips = {
126+
advance: new Audio("sfx/advance.mp3"),
127+
fragment: new Audio("sfx/fragment.mp3"),
128+
"branch-enter": new Audio("sfx/branch-enter.mp3"),
129+
back: new Audio("sfx/back.mp3"),
130+
};
131+
clips.advance.volume = 0.45;
132+
clips.fragment.volume = 0.4;
133+
clips["branch-enter"].volume = 0.4;
134+
clips.back.volume = 0.4;
135+
for (var k in clips) clips[k].preload = "auto";
136+
137+
// Track mute state: updated via 'hf-sound' events from the slideshow chrome.
138+
var muted = false;
139+
var slideshow = document.querySelector("hyperframes-slideshow");
140+
if (slideshow) {
141+
slideshow.addEventListener("hf-sound", function (e) {
142+
muted = e.detail && e.detail.muted === true;
143+
});
144+
}
145+
146+
var unlocked = false;
147+
function unlock() {
148+
if (unlocked) return;
149+
unlocked = true;
150+
// Prime each clip (play muted then reset) so later plays are instant + allowed.
151+
Object.keys(clips).forEach(function (name) {
152+
var el = clips[name];
153+
var v = el.volume;
154+
el.volume = 0;
155+
el.play()
156+
.then(function () {
157+
el.pause();
158+
el.currentTime = 0;
159+
el.volume = v;
160+
})
161+
.catch(function () {
162+
el.volume = v;
163+
});
164+
});
165+
}
166+
window.addEventListener("keydown", unlock, true);
167+
window.addEventListener("pointerdown", unlock, true);
168+
window.addEventListener("click", unlock, true);
169+
170+
window.addEventListener("message", function (e) {
171+
var d = e.data;
172+
if (!d || d.type !== "hf-sfx") return;
173+
// Skip playback when muted — the component owns mute state.
174+
if (muted) return;
175+
var el = clips[d.name];
176+
if (!el || !unlocked) return;
177+
try {
178+
el.currentTime = 0;
179+
el.play().catch(function () {});
180+
} catch (err) {
181+
/* ignore */
182+
}
183+
});
184+
})();
185+
</script>
186+
187+
<!-- ── Presenter test harness: a Present button + 'P' shortcut ── -->
188+
<button id="present-btn" type="button">▶&nbsp; Present</button>
189+
<style>
190+
#present-btn {
191+
position: fixed; top: 18px; right: 18px; z-index: 99999;
192+
font: 600 14px/1 system-ui, sans-serif; color: #0d1321;
193+
background: #f4b740; border: none; border-radius: 999px;
194+
padding: 11px 18px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.45);
195+
}
196+
#present-btn:hover { background: #ffcb5c; }
197+
</style>
198+
<script>
199+
(function () {
200+
var isAudience = new URLSearchParams(location.search).get("mode") === "audience";
201+
var btn = document.getElementById("present-btn");
202+
if (isAudience) { if (btn) btn.remove(); return; }
203+
function present() {
204+
var ss = document.querySelector("hyperframes-slideshow");
205+
if (ss && typeof ss.present === "function") {
206+
ss.present();
207+
if (btn) btn.style.display = "none"; // hide once presenting
208+
} else {
209+
alert("slideshow not ready yet — wait a second and retry");
210+
}
211+
}
212+
if (btn) btn.addEventListener("click", present);
213+
window.addEventListener("keydown", function (e) {
214+
if ((e.key === "p" || e.key === "P") && !e.metaKey && !e.ctrlKey) present();
215+
});
216+
})();
217+
</script>
218+
</body>
219+
</html>

0 commit comments

Comments
 (0)