storyink 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ - **Animated SVG (SMIL):** the story plays inside a plain `<img>`, so in GitHub READMEs and PR
6
+ comments (camo), docs and chat previews, where no script runs.
7
+ - `renderAnimatedSvg(spec, { theme, once, font, hold, reset, fps })` / `animatedSvg()` in
8
+ `storyink/core`; `writeAnimatedSvg()` and `pictureSnippet()` in `storyink/node`.
9
+ - CLI: `storyink render x.json --animated-svg x.svg [--theme light|dark|both] [--once] [--font system|embed]`;
10
+ `both` writes `.light.svg` + `.dark.svg` and prints the `<picture>` snippet. Specs without a
11
+ story use the auto story (with a warning).
12
+ - Plugin: `storyink_render` takes `animatedSvg: true | "both"`, `animatedSvgPath`, `once`, `font`.
13
+ - Built by sampling `storyState(t)` (the viewer's frame function) and compressing each track
14
+ to SMIL keyframes; one shared cycle (story, 3 s hold, 0.4 s reset) or `once` (freeze).
15
+ Base values are the final frame. Theme-pinned, no custom properties, deterministic.
16
+ - `bun run gallery:animated`, `bun run verify:smil` (frame parity PSNR, `<img>` playback, font).
17
+ - `Frame` pulse trail segments carry `k`, `s0`, `s1`; captions carry their index `i`.
18
+ - `screenshotPage()` in `storyink/node`: screenshot any local page.
19
+
3
20
  ## 0.2.1
4
21
 
5
22
  - **Fix:** `storyink_snapshot` no longer inlines the full-resolution contact sheet. Tall beat
package/README.md CHANGED
@@ -6,6 +6,19 @@ Mermaid) into **one offline HTML file** (a React + Motion viewer over server-ren
6
6
 
7
7
  One package, four ways to use it: library, CLI, OpenCode plugin, and a skill for other agents.
8
8
 
9
+ <picture>
10
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/grenaad/storyink/main/docs/gallery/checkout.architecture.animated.dark.svg">
11
+ <img alt="Checkout platform, animated story" src="https://raw.githubusercontent.com/grenaad/storyink/main/docs/gallery/checkout.architecture.animated.light.svg">
12
+ </picture>
13
+
14
+ <picture>
15
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/grenaad/storyink@main/docs/gallery/oauth.sequence.animated.dark.svg">
16
+ <img alt="OAuth sequence, animated story" src="https://cdn.jsdelivr.net/gh/grenaad/storyink@main/docs/gallery/oauth.sequence.animated.light.svg">
17
+ </picture>
18
+
19
+ *Animated SVGs (SMIL, no script): they play inside a plain `<img>`, so in a README or a PR
20
+ comment too. See [Animated SVG](#animated-svg-readmes-and-prs).*
21
+
9
22
  ```sh
10
23
  npx storyink render examples/checkout.architecture.json -o checkout.html --svg checkout.svg
11
24
  ```
@@ -35,6 +48,7 @@ both and has the OpenCode plugin as its default export. Runs on Node ≥ 20 and
35
48
 
36
49
  ```
37
50
  storyink render <in.json|in.mmd|-> [-o out.html] [--svg out.svg] [--theme light|dark] [--story auto]
51
+ [--animated-svg out.svg [--theme light|dark|both] [--once] [--font system|embed]]
38
52
  storyink mermaid <in.mmd> [-o out.json]
39
53
  storyink validate <in> [--json]
40
54
  storyink snapshot <out.html> [--theme light,dark] [--width N] [--sheet [themes|beats]|--no-sheet] [--at 0.5,1.2,end] [--scale 2] [-o dir] [--json]
@@ -118,10 +132,41 @@ receipt gates check that the end frame and the reduced-motion page match the sta
118
132
 
119
133
  ![Checkout beats](docs/gallery/checkout.architecture.beats.light.png)
120
134
 
135
+ ## Animated SVG (READMEs and PRs)
136
+
137
+ GitHub shows images in READMEs and PR comments as a plain `<img>` through its camo proxy, so no
138
+ script runs and nothing outside the file loads. `--animated-svg` compiles the story into **SMIL**
139
+ inside one self-contained SVG that plays there:
140
+
141
+ ```sh
142
+ storyink render examples/checkout.architecture.json --animated-svg docs/checkout.svg --theme both
143
+ # wrote docs/checkout.light.svg, docs/checkout.dark.svg and prints:
144
+ ```
145
+
146
+ ```html
147
+ <picture>
148
+ <source media="(prefers-color-scheme: dark)" srcset="docs/checkout.dark.svg">
149
+ <img alt="Checkout platform" src="docs/checkout.light.svg">
150
+ </picture>
151
+ ```
152
+
153
+ - An SVG image doesn't follow the page theme, so each file is **pinned** to one theme; the
154
+ `<picture>` picks one. `--theme light|dark` writes a single file.
155
+ - It loops: story, a 3 s hold on the final frame, a 0.4 s reset. `--once` plays once and freezes.
156
+ - The attributes' base values are the final frame, so viewers without SMIL show the static diagram.
157
+ - Fonts: `--font system` (default) uses the system mono stack; `--font embed` embeds Commit Mono
158
+ (+~127 KB) for the exact look. See the size table in [docs/spec.md](docs/spec.md#animated-svg).
159
+ - No story in the spec? The auto story is used (with a warning).
160
+ - Library: `renderAnimatedSvg(spec, { theme, once, font })` from `storyink/core`; plugin:
161
+ `storyink_render` with `animatedSvg: true | "both"`, `once`, `font`.
162
+ - GitHub's image proxy caches by URL: when a diagram changes, give it a new file name (or URL).
163
+
121
164
  ## Gallery
122
165
 
123
166
  `bun run gallery` renders every example and Mermaid sample and writes one light and one dark PNG per
124
- example to `docs/gallery/`.
167
+ example to `docs/gallery/`. `bun run gallery:animated` writes the animated SVGs of the story
168
+ examples (`*.animated.light.svg` / `*.animated.dark.svg`); `bun run verify:smil` checks them in
169
+ headless Chrome (frame parity with the viewer's frames, `<img>` playback, embedded font).
125
170
 
126
171
  | | |
127
172
  | --- | --- |
@@ -48,3 +48,10 @@ site are included. Serif headings use system fonts ("Iowan Old Style", Charter,
48
48
 
49
49
  storyink parses a subset of Mermaid syntax with its own hand-written parsers; no Mermaid
50
50
  or merman code is included.
51
+
52
+ ## PR Lens (patterns only)
53
+
54
+ The animated SVG export follows the constraints and SMIL patterns of PR Lens's GitHub-safe SVG
55
+ renderer (<https://github.com/coldteadotai/pr-lens>, MIT License, Copyright (c) 2026 Coldtea AI):
56
+ self-contained files, no script or custom properties, animation as SMIL so it plays inside an
57
+ `<img>` behind GitHub's image proxy. No PR Lens code is included.