Skip to content

Commit def5462

Browse files
committed
feat(sdk): file-backed fs adapter + setTiming GSAP-script sync; add sdk-playground
1 parent 93e8fcd commit def5462

10 files changed

Lines changed: 2298 additions & 24 deletions

File tree

bun.lock

Lines changed: 23 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk-playground/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.hf-versions/
2+
composition.html
3+
dist/
4+
node_modules/

packages/sdk-playground/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# @hyperframes/sdk-playground
2+
3+
Interactive browser playground for the `@hyperframes/sdk` API. Open a composition, edit it through the full SDK op surface, watch the preview update live.
4+
5+
## Running
6+
7+
```bash
8+
bun run --cwd packages/sdk-playground dev
9+
```
10+
11+
Serves at `http://localhost:5173`. On first load it reads `packages/sdk-playground/composition.html` from disk (if present) or falls back to a built-in demo composition.
12+
13+
## Features
14+
15+
### File persistence
16+
17+
Composition state is persisted to `packages/sdk-playground/composition.html` via a Vite dev-server plugin backed by `@hyperframes/sdk/adapters/fs`. Every save writes a timestamped snapshot to `.hf-versions/composition.html/` (capped at 20). Reload the page and your last state is restored.
18+
19+
### Preview iframe
20+
21+
Full composition rendered in a sandboxed `<iframe>`. Supports:
22+
23+
- **Play / Pause / Seek** via the transport bar
24+
- **Click-to-select** elements (highlights in the tree and properties panel)
25+
- **Drag-to-reposition** — drag any element to a new position; on drop the playground calls `comp.setStyle(id, { left, top })`
26+
27+
### Element tree
28+
29+
Lists all non-root elements. Click any row to select it.
30+
31+
### Properties panel
32+
33+
Editable per-element properties for the selected element:
34+
35+
| Section | SDK op |
36+
| ---------- | --------------------------------------------------------------------------- |
37+
| Content | `comp.setText(id, value)` |
38+
| Typography | `comp.setStyle(id, { fontSize, fontWeight, color, fontFamily })` |
39+
| Box | `comp.setStyle(id, { top, left, width, height })` |
40+
| Attributes | `comp.element(id).setAttribute(name, value)` — shows all non-internal attrs |
41+
| Danger | `comp.element(id).removeElement()` |
42+
| Animations | `comp.setTiming(id, { start, duration })` — inline form per GSAP tween |
43+
44+
### Timeline
45+
46+
DAW-style per-element tween blocks. Drag handles to trim start/end; drag body to move. All edits go through `comp.setTiming(id, { start, duration })` which keeps the GSAP script and DOM attributes in sync.
47+
48+
### Ops panel
49+
50+
Full op surface, grouped by feature:
51+
52+
| Section | SDK op |
53+
| ---------------------------- | --------------------------------------------------------------------------------- |
54+
| PreviewAdapter.select() | `preview.select([id])` |
55+
| setStyle | `comp.setStyle(id, styles)` |
56+
| setText | `comp.setText(id, value)` |
57+
| addGsapTween | `comp.addGsapTween(target, spec)` |
58+
| setTiming | `comp.setTiming(id, { start, duration })` |
59+
| setGsapTween | `comp.setGsapTween(animId, updates)` |
60+
| moveElement | `comp.moveElement(id, { parent, index })` |
61+
| setClassStyle | `comp.dispatch({ type: "setClassStyle", selector, styles })` |
62+
| setAttribute / removeElement | `comp.element(id).setAttribute()` / `.removeElement()` |
63+
| setVariableValue | `comp.setVariableValue(id, value)` |
64+
| find(query) | `comp.find({ tag, text, name, track })` |
65+
| selection() proxy | `comp.selection().setStyle()` / `.removeElement()` |
66+
| listVersions / loadFrom | `adapter.listVersions()` / `adapter.loadFrom()` |
67+
| History / inspect | `comp.undo()`, `comp.redo()`, `comp.can()`, `comp.getOverrides()`, `comp.flush()` |
68+
69+
### Editor modal
70+
71+
Click "Open editor" to view and directly edit the raw composition HTML. Saving re-opens the composition through the SDK.
72+
73+
---
74+
75+
## Planned / not yet wired
76+
77+
- `comp.setTrackVariable(trackId, variableId)` — variable binding per track
78+
- `comp.addElement(spec)` — create new elements from the UI
79+
- `comp.duplicateElement(id)` — duplicate with offset
80+
- Selection multi-select (current: single-select only)
81+
- Timeline zoom and horizontal scroll for long compositions
82+
- Version history browser — list/preview/restore past versions inline (API is implemented; UI shows only list + load-oldest)
83+
- `comp.on('change', cb)` live event log fed from SDK event stream
84+
- Render to video via `@hyperframes/producer` integration

0 commit comments

Comments
 (0)