@markdy/renderer-dom 0.7.24 → 0.7.26

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
@@ -70,6 +70,9 @@ player.destroy(); // clean up DOM + cancel animations
70
70
  | `loop` | `boolean` | `true` | Loop the animation when it reaches the end |
71
71
  | `copyright` | `boolean` | `true` | Show a small "Powered by Markdy" badge below the animation |
72
72
  | `progressBar` | `boolean` | `true` | Show a rainbow progress bar around the viewport border |
73
+ | `onWarning` | `(warning: ParseWarning) => void` | `console.warn` | Called for each soft parse warning |
74
+ | `onTimeUpdate` | `(seconds: number, durationSeconds: number) => void` | — | Called whenever playback or seek changes the current time |
75
+ | `onPlayStateChange` | `(playing: boolean) => void` | — | Called when playback starts or pauses |
73
76
 
74
77
  ### `Player`
75
78
 
@@ -78,20 +81,50 @@ player.destroy(); // clean up DOM + cancel animations
78
81
  | `play()` | Start or resume playback |
79
82
  | `pause()` | Pause at current position |
80
83
  | `seek(seconds)` | Jump to a specific time |
84
+ | `currentTime()` | Current playback position in seconds |
85
+ | `duration()` | Total scene duration in seconds |
86
+ | `isPlaying()` | Whether the scene is currently playing |
87
+ | `chapters()` | Named `scene "..." { ... }` chapter blocks, in author order (empty if none) |
88
+ | `seekToChapter(name)` | Seek to the start of a named chapter; no-op if the name doesn't match |
81
89
  | `destroy()` | Remove DOM elements and cancel all animations |
82
90
 
83
91
  ## Module Structure
84
92
 
85
93
  ```
86
94
  src/
87
- types.ts — ActorState, FaceSwap, easing utilities
88
- figure.ts — Stick-figure DOM factory (emoji body parts)
89
- actors.ts — Actor element factory (sprite, text, figure, box)
90
- animations.ts — Timeline → WAAPI Animation builder
91
- player.ts — Public API, rAF loop, face-swap engine
92
95
  index.ts — Barrel exports
96
+ player.ts — Public API, rAF loop, face-swap engine
97
+ animations.ts — Timeline walker: dispatches each event to its handler
98
+ actions/
99
+ context.ts — ActionContext: the one argument every handler receives
100
+ registry.ts — Action name → handler table
101
+ transform.ts — move, enter, exit, fade, scale, rotate, shake, jump, bounce
102
+ figure.ts — Figure-only gestures and limb articulation
103
+ speech.ts — say (speech bubbles)
104
+ projectile.ts — throw
105
+ flow.ts — request / response / emit (system-diagram edges)
106
+ geometry/
107
+ rect.ts — Actor bounds and hit-testing (DOM-free, unit tested)
108
+ path.ts — Polyline measurement and obstacle-aware edge routing
109
+ camera.ts — pan / zoom / shake on the scene-content layer
110
+ stage.ts — t=0 staging and off-screen placement
111
+ theme.ts — Scene-adaptive colors for renderer-drawn chrome
112
+ actors.ts — Actor element factory (sprite, text, figure, box, caption)
113
+ figure.ts — Stick-figure DOM factory (emoji body parts)
114
+ types.ts — ActorState, FaceSwap, easing utilities
93
115
  ```
94
116
 
117
+ ### Adding an action
118
+
119
+ 1. Write a handler — a function taking `ActionContext` — in the relevant
120
+ `actions/` module (or a new one).
121
+ 2. Register it by name in `actions/registry.ts`.
122
+ 3. Add the name to the matching list in `@markdy/core`'s `registry.ts` so the
123
+ parser accepts it.
124
+
125
+ Step 3 is enforced: `tests/action-coverage.test.ts` fails the build if the
126
+ parser accepts an action the renderer can't draw, or vice versa.
127
+
95
128
  ## Documentation
96
129
 
97
130
  - **[Syntax Reference](../../docs/SYNTAX.md)** — complete DSL language spec
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SceneAST, ParseWarning } from '@markdy/core';
1
+ import { Chapter, SceneAST, ParseWarning } from '@markdy/core';
2
2
 
3
3
  /**
4
4
  * @markdy/renderer-dom — Player
@@ -46,11 +46,22 @@ interface PlayerOptions {
46
46
  * Pass a no-op to silence; pass a custom collector to surface warnings in a UI.
47
47
  */
48
48
  onWarning?: (warning: ParseWarning) => void;
49
+ /** Invoked whenever playback or seek changes the current timeline time. */
50
+ onTimeUpdate?: (seconds: number, durationSeconds: number) => void;
51
+ /** Invoked when playback starts or pauses. */
52
+ onPlayStateChange?: (playing: boolean) => void;
49
53
  }
50
54
  interface Player {
51
55
  play(): void;
52
56
  pause(): void;
53
57
  seek(seconds: number): void;
58
+ currentTime(): number;
59
+ duration(): number;
60
+ isPlaying(): boolean;
61
+ /** Named `scene "..." { ... }` chapter blocks, in author order. Empty when the scene has none. */
62
+ chapters(): Chapter[];
63
+ /** Seeks to the start of the named chapter. No-op if the name doesn't match a chapter. */
64
+ seekToChapter(name: string): void;
54
65
  destroy(): void;
55
66
  }
56
67
  declare function createPlayer(opts: PlayerOptions): Player;