Animation Packs
Visual Pack Documentation
Visual Packs (also called Animation Packs) are self-contained interactive modules that embed inside Papyrus articles. They run in sandboxed iframes and communicate with the host article via the postMessage API.
About Papyrus
Papyrus is an interactive research articles platform built by SynaptixLabs. It transforms static academic and technical content into living, explorable experiences — complete with embedded AI assistants, dynamic visualizations, and community engagement tools.
Rich Articles — MDX-powered content with interactive components, code blocks, and embedded media.
AI-Powered — Ask questions about any article and get context-aware answers from an integrated AI assistant.
Community-Driven — Reactions, comments, bookmarks, and feature request voting keep readers engaged.
What Are Visual Packs?
Self-Contained
Each pack is a ZIP containing HTML, CSS, JS, and assets. No external dependencies required.
Sandboxed
Runs in an iframe with security isolation. Cannot access the host page or user data.
Cue-Driven
Responds to article scroll events and user interactions via a simple message protocol.
ZIP Structure
A Visual Pack is uploaded as a ZIP file with the following structure:
my-animation-pack/
├── manifest.json # Pack metadata & cue definitions
├── index.html # Entry point (loaded in iframe)
├── snapshot.svg # Static fallback for print mode
├── styles.css # Optional styles
├── script.js # Optional separate JS
└── assets/ # Optional images, fonts, etc.
└── texture.pngmanifest.json and index.html files are required. The snapshot is optional but strongly recommended for print mode support.manifest.json Schema
The manifest describes your pack and declares which cues it responds to:
{
"name": "particle-sim",
"version": "1.0.0",
"title": "Particle Simulation",
"description": "Interactive particle physics demo",
"entry": "index.html",
"snapshot": "snapshot.svg",
"dimensions": {
"width": 800,
"height": 400
},
"cues": ["start", "pause", "reset"],
"author": "SynaptixLabs"
}| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Unique pack identifier (kebab-case) |
| version | string | Yes | Semantic version (e.g. 1.0.0) |
| title | string | No | Human-readable display name |
| description | string | No | Brief description of the pack |
| entry | string | Yes | Entry HTML file (usually index.html) |
| snapshot | string | No | Static SVG/PNG for print mode |
| dimensions | object | No | Preferred width and height in pixels |
| cues | string[] | No | List of cue names this pack handles |
| author | string | No | Author name or organization |
postMessage API
Visual Packs communicate with the Papyrus article viewer using the browser's postMessage API. The host sends messages to the iframe, and the pack can reply:
Messages from Host → Pack
| type | Payload | When |
|---|---|---|
| cue | { name: string } | Triggered by <Cue> MDX component on scroll/visibility |
| — | Article entered print mode (?print=true) | |
| theme | { mode: "light" | "dark" } | User toggled theme |
Messages from Pack → Host
| type | Purpose |
|---|---|
| ready | Signals the host that the pack finished loading and is interactive |
| resize | Requests a height change: { height: number } |
Example Implementation
// Listen for cues from the host article
window.addEventListener('message', (event) => {
const { type, name } = event.data
if (type === 'cue') {
switch (name) {
case 'start':
startAnimation()
break
case 'pause':
pauseAnimation()
break
case 'reset':
resetState()
break
}
}
if (type === 'print') {
// Render a static snapshot for print mode
renderSnapshot()
}
})
// Signal the host that the pack is ready
window.parent.postMessage({ type: 'ready' }, '*')Embedding in Articles
Once uploaded via the admin dashboard, Visual Packs are embedded in articles using MDX components:
<!-- Embed the visual pack -->
<Visual id="particle-sim" height={400} />
<!-- Trigger the "start" cue when visible -->
<Cue target="particle-sim" when="visible" name="start" />
<!-- Trigger "highlight" cue on button click -->
<Cue target="particle-sim" when="click" name="highlight" /><Visual> Props
id— Pack name (matches manifest)height— Iframe height in pixelsversion— Optional version pin
<Cue> Props
target— Visual Pack id to send towhen— Trigger: visible, click, scrollname— Cue name sent to the pack
Creating a Pack
- 1Create your files
Build your animation with HTML/CSS/JS. Keep it self-contained — all assets must be bundled in the ZIP.
- 2Add manifest.json
Define your pack name, version, entry point, and the cues it responds to.
- 3Add a snapshot
Create an SVG or PNG that represents the static view for print mode. Place it alongside your manifest.
- 4ZIP and upload
Compress all files into a ZIP. Upload via the Visual Packs section in the admin dashboard.
- 5Embed in your article
Use
<Visual id="your-pack" />in your MDX content to embed it.
Example Pack
Starter Animation Pack
A minimal example with manifest.json, index.html, snapshot.svg, and a README. Use it as a template for your own packs.
Notes
- •Visual Packs are created and developed outside the Papyrus platform using your own tools and editor. Papyrus only hosts and embeds them.
- •Packs run inside sandboxed iframes. They have no access to cookies, localStorage, or the parent page DOM.
- •For best performance, keep your pack size under 5 MB. Optimize images and minify JavaScript when possible.
- •The pack versioning system lets you update packs without breaking existing articles that pin a specific version.
- •Need help? Contact us at support@synaptixlabs.ai