autovisualizer 0.6.0 → 0.7.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/README.md CHANGED
@@ -88,9 +88,29 @@ export const door = createMachine({ id: "door", initial: "closed", states: { clo
88
88
  | `audio-src` | A recorded clip per step: `audio-src="audio/{step}.wav"`. A clip that can't play falls back to `speak`. |
89
89
  | `counts` | How often each transition was taken, as JSON keyed by state then event: `{"payment":{"PAID":120,"DECLINED":0}}`. Each count shows on its event, and a transition taken 0 times is drawn dashed: a path the code allows that nothing took. Name a state by its key or its full id (`checkout.payment`). |
90
90
  | `direction` | `auto` (default), `right` or `down`. `auto` lays the chart out both ways and keeps the one that shows it larger in its space: a long chain goes top to bottom in a wide column, a wide machine left to right in a short box, and a small machine that fits either way goes right. |
91
+ | `base` | The machine before a change, as MachineJSON or `#id` of an element holding it. The chart shows the change: added states and transitions in green, removed ones dashed and red, and a state the change left unreachable flagged. |
92
+ | `colors` | A colour per state, as JSON keyed by state key or full id: `colors='{"payment":"purple","refund":"#e8a33d"}'`. Any CSS colour; the state gets a wash of it in light and dark themes alike. |
93
+ | `caption` | A line under the chart saying what it shows. Screen readers announce the chart by it. |
91
94
 
92
95
  An event the machine doesn't accept, or a `machine` id it doesn't create, shows an error in the chart.
93
96
 
97
+ A state's `description` (XState's own field) is drawn under its name, wrapped to fit.
98
+
99
+ **Show a change.** Give the earlier version as `base`, and the chart draws the later one with what changed marked:
100
+
101
+ ```html
102
+ <script type="application/json" id="checkout-before">{ ... }</script>
103
+ <auto-visualizer src="/machines/checkout.json" base="#checkout-before"
104
+ caption="RETRY now loops back into payment; refund can no longer be reached."></auto-visualizer>
105
+ ```
106
+
107
+ **Theme it.** Set the chart's colours from your own CSS with `--autoviz-*` properties: each overrides the chart token of the same name (`--autoviz-active` for the active ring and sendable events). They include `--autoviz-canvas`, `--autoviz-grid`, `--autoviz-node`, `--autoviz-node-fg`, `--autoviz-node-border`, `--autoviz-edge`, `--autoviz-pill`, `--autoviz-pill-fg`, `--autoviz-active`, `--autoviz-added` and `--autoviz-removed`; `src/styles.css` lists every `--sc-*` token. One value applies in both themes, so give the dark theme its own:
108
+
109
+ ```css
110
+ auto-visualizer { --autoviz-active: #e11d48; --autoviz-canvas: #fffaf0; }
111
+ @media (prefers-color-scheme: dark) { auto-visualizer { --autoviz-canvas: #1a1410; } }
112
+ ```
113
+
94
114
  **Narrate the walkthrough.** Each step's note is its script. Add `speak` and the browser reads each note aloud, and `autoplay` moves on when the sentence ends:
95
115
 
96
116
  ```html
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autovisualizer",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "See and step through XState v6 and @xstate/effect machines in the browser.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jag Reehal",