|
| 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