@markdy/renderer-dom 1.1.7 → 1.2.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
@@ -6,7 +6,7 @@ Web Animations API renderer for [MarkdyScript](../../docs/SYNTAX.md) scenes. Tra
6
6
 
7
7
  - **Browser-native** — Web Animations API + CSS transforms, no Canvas or GSAP (~24 KB minzipped)
8
8
  - **17 Diagram Layout Topologies** — `architecture`, `flowchart`, `tree`, `sequence`, `state`, `layers`, `nested`, `swimlane`, `timeline`, `gantt`, `medallion`, `flywheel`, `constellation`, `quadrant`, `pyramid`, `radar`, `venn`
9
- - **Dynamic Theme Switching** — live runtime switching across 8 semantic themes (`paper`, `editorial`, `midnight`, `blueprint`, `graphite`, `nebula`, `terminal`, `sketchy`)
9
+ - **Dynamic Theme Switching** — live runtime switching across 10 semantic themes (`paper`, `editorial`, `midnight`, `blueprint`, `graphite`, `nebula`, `terminal`, `sketchy`, `ink`, `doodle`)
10
10
  - **Flow edges** — `->` request, `<-` response, `~>` event, `--` dependency, each with its own stroke, plus animated traveling pulse
11
11
  - **Beat-driven cues** — `show`, `hide`, `glow`, `focus`, and `frame` camera zooms, sequenced by named beats
12
12
  - **Media Exporters** — zero-dep animated GIF89a exporter with LZW compression and Figma-ready vector SVG export
package/dist/index.d.ts CHANGED
@@ -1,4 +1,92 @@
1
- import { BeatRange, ThemeTokens, PlayerControlsConfig, Diagnostic, RenderPlan } from '@markdy/core';
1
+ import { RenderPlan, BeatRange, ThemeTokens, PlayerControlsConfig, Diagnostic, PositionedNode } from '@markdy/core';
2
+
3
+ /**
4
+ * packages/renderer-dom/src/export/svg-exporter.ts
5
+ * Standalone Pure Vector SVG & Figma-compatible design token asset export.
6
+ * Zero external dependencies.
7
+ *
8
+ * Produces 100% native vector SVG elements (<rect>, <path>, <text>, <g>, <marker>)
9
+ * that open cleanly in macOS Preview, Figma, Illustrator, GitHub, and all browsers.
10
+ */
11
+
12
+ interface SvgExportOptions {
13
+ includeThemeStyles?: boolean;
14
+ transparentBackground?: boolean;
15
+ scale?: number;
16
+ mode?: "pure" | "foreignObject";
17
+ nodeStates?: Map<string, {
18
+ opacity: number;
19
+ transform?: string;
20
+ }>;
21
+ edgeStates?: Map<string, {
22
+ opacity: number;
23
+ strokeDashoffset?: string;
24
+ }>;
25
+ sequenceMessageStates?: Map<string, {
26
+ opacity: number;
27
+ }>;
28
+ sequenceActivationStates?: Map<number, {
29
+ opacity: number;
30
+ }>;
31
+ flowDots?: {
32
+ x: number;
33
+ y: number;
34
+ r: number;
35
+ fill: string;
36
+ opacity: number;
37
+ }[];
38
+ activeCaption?: {
39
+ text: string;
40
+ opacity: number;
41
+ };
42
+ cameraTransform?: string;
43
+ }
44
+ declare function renderPureVectorSvg(plan: RenderPlan, options?: SvgExportOptions): string;
45
+ /**
46
+ * Serialize a live diagram container into Pure Vector SVG without foreignObject,
47
+ * capturing the active animated states (opacity, transforms, stroke offsets).
48
+ */
49
+ declare function exportLiveSceneAsPureVectorSvg(containerEl: HTMLElement, options?: SvgExportOptions): string;
50
+ /**
51
+ * Main Vector SVG Export Function
52
+ * Accepts a MarkdyScript code string, a RenderPlan, or an HTMLElement container.
53
+ */
54
+ declare function exportDiagramAsVectorSvg(target: HTMLElement | string | RenderPlan, options?: SvgExportOptions): string;
55
+
56
+ /**
57
+ * packages/renderer-dom/src/export/png-exporter.ts
58
+ * High-DPI raster PNG export with 2x retina scaling.
59
+ * Zero external dependencies.
60
+ *
61
+ * Fix: Inline all external resources (images, fonts) as base64 data URIs
62
+ * before drawing the SVG to canvas. A foreignObject-wrapped SVG taints the
63
+ * canvas whenever it references any external URL, so every resource must be
64
+ * inlined first.
65
+ */
66
+
67
+ interface PngExportOptions extends SvgExportOptions {
68
+ pixelRatio?: number;
69
+ }
70
+ declare function exportDiagramAsPng(containerEl: HTMLElement, options?: PngExportOptions): Promise<Blob>;
71
+
72
+ interface TimelineController {
73
+ seek(seconds: number): void;
74
+ currentTime(): number;
75
+ duration(): number;
76
+ isPlaying(): boolean;
77
+ play(): void;
78
+ pause(): void;
79
+ }
80
+ interface GifDiagramExportOptions extends SvgExportOptions {
81
+ fps?: number;
82
+ pixelRatio?: number;
83
+ loop?: boolean;
84
+ dither?: boolean;
85
+ diff?: boolean;
86
+ holdEndMs?: number;
87
+ onProgress?: (progress: number, currentFrame: number, totalFrames: number) => void;
88
+ }
89
+ declare function exportDiagramAsGif(container: HTMLElement, timeline: TimelineController, options?: GifDiagramExportOptions): Promise<Blob>;
2
90
 
3
91
  /**
4
92
  * Markdy diagram runtime — renders a RenderPlan via WAAPI.
@@ -53,20 +141,26 @@ interface Diagram {
53
141
  nextBeat(): void;
54
142
  prevBeat(): void;
55
143
  setTheme(theme: string | ThemeTokens): void;
144
+ exportSvg(options?: SvgExportOptions): string;
145
+ exportPng(options?: PngExportOptions): Promise<Blob>;
146
+ exportGif(options?: GifDiagramExportOptions): Promise<Blob>;
56
147
  destroy(): void;
57
148
  }
149
+ /**
150
+ * Detects the host environment's theme mode (dark vs light).
151
+ * Universal support for Tailwind, Next.js, Starlight, Docusaurus, Bootstrap 5.3,
152
+ * GitHub Markdown, VS Code webviews, computed background lightness, and OS color schemes.
153
+ * Default light mode is "paper", default dark mode is "nebula".
154
+ */
155
+ declare function detectHostTheme(container?: HTMLElement): "nebula" | "paper";
58
156
  declare function createDiagram(opts: DiagramOptions): Diagram;
59
157
 
60
158
  type SvgSpec = Array<[string, Record<string, string>]>;
61
159
  type IconSpec = SvgSpec;
62
160
  /** Read-only monochrome glyph registry; callers can inspect or choose keys without injecting markup. */
63
161
  declare const ICON_REGISTRY: Readonly<Record<string, IconSpec>>;
162
+ declare function iconKeyForNode(node: PositionedNode): string;
64
163
 
65
- /**
66
- * packages/renderer-dom/src/export/gif-encoder.ts
67
- * Pure TypeScript GIF89a Encoder with LZW Compression & Floyd-Steinberg Dithering.
68
- * Zero external dependencies.
69
- */
70
164
  interface AnimationRecordFrame {
71
165
  imageData: ImageData;
72
166
  delayMs: number;
@@ -74,52 +168,10 @@ interface AnimationRecordFrame {
74
168
  interface GifExportOptions {
75
169
  dither?: boolean;
76
170
  loop?: boolean;
171
+ diff?: boolean;
77
172
  }
78
173
  declare function encodeGifSequence(frames: AnimationRecordFrame[], options?: GifExportOptions): Uint8Array;
79
174
 
80
- /**
81
- * packages/renderer-dom/src/export/svg-exporter.ts
82
- * Standalone Vector SVG & Figma-compatible design token asset export.
83
- * Zero external dependencies.
84
- */
85
- interface SvgExportOptions {
86
- includeThemeStyles?: boolean;
87
- transparentBackground?: boolean;
88
- scale?: number;
89
- }
90
- declare function exportDiagramAsVectorSvg(containerEl: HTMLElement, options?: SvgExportOptions): string;
91
-
92
- interface TimelineController {
93
- seek(seconds: number): void;
94
- currentTime(): number;
95
- duration(): number;
96
- isPlaying(): boolean;
97
- play(): void;
98
- pause(): void;
99
- }
100
- interface GifDiagramExportOptions extends SvgExportOptions {
101
- fps?: number;
102
- pixelRatio?: number;
103
- loop?: boolean;
104
- }
105
- declare function exportDiagramAsGif(container: HTMLElement, timeline: TimelineController, options?: GifDiagramExportOptions): Promise<Blob>;
106
-
107
- /**
108
- * packages/renderer-dom/src/export/png-exporter.ts
109
- * High-DPI raster PNG export with 2x retina scaling.
110
- * Zero external dependencies.
111
- *
112
- * Fix: Inline all external resources (images, fonts) as base64 data URIs
113
- * before drawing the SVG to canvas. A foreignObject-wrapped SVG taints the
114
- * canvas whenever it references any external URL, so every resource must be
115
- * inlined first.
116
- */
117
-
118
- interface PngExportOptions extends SvgExportOptions {
119
- pixelRatio?: number;
120
- }
121
- declare function exportDiagramAsPng(containerEl: HTMLElement, options?: PngExportOptions): Promise<Blob>;
122
-
123
175
  /**
124
176
  * packages/renderer-dom/src/presentation-controller.ts
125
177
  * Interactive Beat Navigation & Keyboard-driven presentation controller.
@@ -147,4 +199,4 @@ declare class DiagramPresentationController {
147
199
  destroy(): void;
148
200
  }
149
201
 
150
- export { type AnimationRecordFrame, type ControllerOptions, type Diagram, type DiagramOptions, DiagramPresentationController, type GifDiagramExportOptions, type GifExportOptions, ICON_REGISTRY, type IconSpec, type PngExportOptions, type SvgExportOptions, type TimelineController, createDiagram, encodeGifSequence, exportDiagramAsGif, exportDiagramAsPng, exportDiagramAsVectorSvg };
202
+ export { type AnimationRecordFrame, type ControllerOptions, type Diagram, type DiagramOptions, DiagramPresentationController, type GifDiagramExportOptions, type GifExportOptions, ICON_REGISTRY, type IconSpec, type PngExportOptions, type SvgExportOptions, type TimelineController, createDiagram, detectHostTheme, encodeGifSequence, exportDiagramAsGif, exportDiagramAsPng, exportDiagramAsVectorSvg, exportLiveSceneAsPureVectorSvg, iconKeyForNode, renderPureVectorSvg };