Presentation runtime: lifecycle states, :thisSlide, history #1
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "navi/psslides:slide-runtime"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this PR does
Adds a real presentation runtime to p/slides: the preview now displays the deck, navigation is resilient, and everything is authored in HTML + Less only — no JS to write.
Authoring
<style>tags inside the slide HTML (one editor buffer, no Styles tab). Every<style>in the deck — global slide first, then each slide — contributes to one project stylesheet.<style>tags are the project Less, so variables, nesting, mixins and imports all work. Raw Less never reaches the DOM: the tags are stripped from the markup and the compiled CSS is injected by the runtime.:thisSlidecompiles to the selector of the slide whose stylesheet is being compiled ([data-ps-slide="slide-N"]), so deck styles stay scoped without inventing extra CSS syntax.The global slide is a template:
<?= html ?>/<?= css ?>The runtime injects into the global slide:
<?= html ?>, the compiled stylesheet replaces<?= css ?>(wherever<style><?= css ?></style>sits).<?= html ?>the global slide keeps its old meaning: markup shared by every slide.<?= css ?>the stylesheet falls back to a singledata-ps-slidessheet in<head>— never both, so nothing fights over the rules.Runtime
data-ps-state(idle→entering→current→leaving). CSS owns the animation, JS owns the lifecycle.runtime.goTo(index)/next()/previous(); back/forward and reload restore the slide index (state keypsslides-slide, merged intohistory.state).compile.ts) and runtime (runtime.ts) are separate modules; placeholders are shared via a tinyplaceholders.tsso the runtime never pulls in the Less compiler.Notes / out of scope
Verification
prettier --check,tsc --noEmit,oxlint,npm run buildall green. Browser-tested: template shell render,<?= css ?>injection (frame background compiled from the Less var), slide element identity across recompiles and template switches, head-fallback when there is no<?= css ?>, keyboard navigation + history inside the shell, thumbnails, and the broken-Less error path (last good preview kept).Thumbnails show compiled styles + example HTML
<section data-ps-slide>around the slide, statecurrent), and the global tile mounts example HTML instead of duplicating a real slide's content.code-to-elementnow wrapsstyles[]entries in<style>blocks — previously raw CSS text in the iframe head fell through to<body>and rendered as literal garbage in the snapshot.Less compiles in a worker
less-workercompiles off the main thread;worker-globalsshimswindow/documentand setsonReady: falsebefore the browser build's auto-init runs, so no page stylesheet scan or<body>hiding happens on import.less.renderon the main thread — same output either way.Pull request closed