@markdy/renderer-dom 0.8.3 → 0.8.5
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 +10 -10
- package/dist/index.d.ts +5 -5
- package/dist/index.js +19 -19
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -37,9 +37,9 @@ This package consumes parsed AST and drives DOM + Web Animations API timelines.
|
|
|
37
37
|
## Usage
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
|
-
import {
|
|
40
|
+
import { createDiagram } from "@markdy/renderer-dom";
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const diagram = createDiagram({
|
|
43
43
|
container: document.getElementById("scene")!,
|
|
44
44
|
code: `
|
|
45
45
|
scene "Request" theme=paper
|
|
@@ -53,15 +53,15 @@ const player = createPlayer({
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
// Playback control
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
diagram.pause();
|
|
57
|
+
diagram.seek(1.5); // jump to 1.5 seconds
|
|
58
|
+
diagram.play();
|
|
59
|
+
diagram.destroy(); // clean up DOM + cancel animations
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## API
|
|
63
63
|
|
|
64
|
-
### `
|
|
64
|
+
### `createDiagram(options: DiagramOptions): Diagram`
|
|
65
65
|
|
|
66
66
|
| Option | Type | Default | Description |
|
|
67
67
|
|---|---|---|---|
|
|
@@ -77,7 +77,7 @@ player.destroy(); // clean up DOM + cancel animations
|
|
|
77
77
|
| `onTimeUpdate` | `(seconds: number, durationSeconds: number) => void` | — | Called whenever playback or seek changes the current time |
|
|
78
78
|
| `onPlayStateChange` | `(playing: boolean) => void` | — | Called when playback starts or pauses |
|
|
79
79
|
|
|
80
|
-
### `
|
|
80
|
+
### `Diagram`
|
|
81
81
|
|
|
82
82
|
| Method | Description |
|
|
83
83
|
|---|---|
|
|
@@ -97,8 +97,8 @@ player.destroy(); // clean up DOM + cancel animations
|
|
|
97
97
|
|
|
98
98
|
```
|
|
99
99
|
src/
|
|
100
|
-
index.ts — Barrel exports (
|
|
101
|
-
|
|
100
|
+
index.ts — Barrel exports (createDiagram)
|
|
101
|
+
diagram.ts — Public API, rAF loop, progress bar, responsive scaling
|
|
102
102
|
nodes.ts — Node element factory + scene title
|
|
103
103
|
edges.ts — Flow-edge SVG runtime, routing, and cue animations
|
|
104
104
|
geometry/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BeatRange, Diagnostic } from '@markdy/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Markdy diagram runtime — renders a RenderPlan via WAAPI.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
interface
|
|
7
|
+
interface DiagramOptions {
|
|
8
8
|
container: HTMLElement;
|
|
9
9
|
code: string;
|
|
10
10
|
autoplay?: boolean;
|
|
@@ -26,7 +26,7 @@ interface PlayerOptions {
|
|
|
26
26
|
onTimeUpdate?: (seconds: number, durationSeconds: number) => void;
|
|
27
27
|
onPlayStateChange?: (playing: boolean) => void;
|
|
28
28
|
}
|
|
29
|
-
interface
|
|
29
|
+
interface Diagram {
|
|
30
30
|
play(): void;
|
|
31
31
|
pause(): void;
|
|
32
32
|
seek(seconds: number): void;
|
|
@@ -39,6 +39,6 @@ interface Player {
|
|
|
39
39
|
seekToBeat(name: string): void;
|
|
40
40
|
destroy(): void;
|
|
41
41
|
}
|
|
42
|
-
declare function
|
|
42
|
+
declare function createDiagram(opts: DiagramOptions): Diagram;
|
|
43
43
|
|
|
44
|
-
export { type
|
|
44
|
+
export { type Diagram, type DiagramOptions, createDiagram };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/diagram.ts
|
|
2
2
|
import { parseAndCompile } from "@markdy/core";
|
|
3
3
|
|
|
4
4
|
// src/geometry/rect.ts
|
|
@@ -810,8 +810,8 @@ function createNodeMediaEl(doc, node, assets) {
|
|
|
810
810
|
}
|
|
811
811
|
function createNodeEl(node, theme, assets) {
|
|
812
812
|
const el = document.createElement("div");
|
|
813
|
-
el.className = "markdy-node markdy-scene-
|
|
814
|
-
el.dataset.
|
|
813
|
+
el.className = "markdy-node markdy-scene-node";
|
|
814
|
+
el.dataset.node = node.id;
|
|
815
815
|
el.dataset.role = node.role;
|
|
816
816
|
el.style.left = `${node.x}px`;
|
|
817
817
|
el.style.top = `${node.y}px`;
|
|
@@ -876,7 +876,7 @@ function ensureSceneStyles(doc) {
|
|
|
876
876
|
opacity: 0.62;
|
|
877
877
|
}
|
|
878
878
|
.markdy-scene-content { z-index: 2; }
|
|
879
|
-
.markdy-scene-
|
|
879
|
+
.markdy-scene-node-layer {
|
|
880
880
|
position: absolute;
|
|
881
881
|
inset: 0;
|
|
882
882
|
overflow: visible;
|
|
@@ -904,8 +904,8 @@ function applyThemeToScene(scene, theme) {
|
|
|
904
904
|
scene.dataset.markdyTheme = theme.name;
|
|
905
905
|
}
|
|
906
906
|
|
|
907
|
-
// src/
|
|
908
|
-
function
|
|
907
|
+
// src/diagram.ts
|
|
908
|
+
function createDiagram(opts) {
|
|
909
909
|
const {
|
|
910
910
|
container,
|
|
911
911
|
code,
|
|
@@ -1000,15 +1000,15 @@ function createPlayer(opts) {
|
|
|
1000
1000
|
sceneContent.className = "markdy-scene-content";
|
|
1001
1001
|
Object.assign(sceneContent.style, { position: "absolute", inset: "0" });
|
|
1002
1002
|
scene.appendChild(sceneContent);
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
sceneContent.appendChild(
|
|
1003
|
+
const nodeLayer = document.createElement("div");
|
|
1004
|
+
nodeLayer.className = "markdy-scene-node-layer";
|
|
1005
|
+
sceneContent.appendChild(nodeLayer);
|
|
1006
1006
|
const titleEl = createTitleEl(plan.title);
|
|
1007
|
-
|
|
1007
|
+
nodeLayer.appendChild(titleEl);
|
|
1008
1008
|
const nodeEls = /* @__PURE__ */ new Map();
|
|
1009
1009
|
for (const node of plan.nodes) {
|
|
1010
1010
|
const el = createNodeEl(node, plan.theme, assets);
|
|
1011
|
-
|
|
1011
|
+
nodeLayer.appendChild(el);
|
|
1012
1012
|
nodeEls.set(node.id, el);
|
|
1013
1013
|
}
|
|
1014
1014
|
function scaleScene() {
|
|
@@ -1054,7 +1054,7 @@ function createPlayer(opts) {
|
|
|
1054
1054
|
if (totalDurationMs > 0) updateProgressBar(sceneMs / totalDurationMs);
|
|
1055
1055
|
rafId = requestAnimationFrame(rafTick);
|
|
1056
1056
|
}
|
|
1057
|
-
const
|
|
1057
|
+
const diagram = {
|
|
1058
1058
|
play() {
|
|
1059
1059
|
if (isPlaying) return;
|
|
1060
1060
|
isPlaying = true;
|
|
@@ -1096,10 +1096,10 @@ function createPlayer(opts) {
|
|
|
1096
1096
|
},
|
|
1097
1097
|
seekToBeat(name) {
|
|
1098
1098
|
const beat = plan.beats.find((b) => b.name === name);
|
|
1099
|
-
if (beat)
|
|
1099
|
+
if (beat) diagram.seek(beat.start);
|
|
1100
1100
|
},
|
|
1101
1101
|
destroy() {
|
|
1102
|
-
|
|
1102
|
+
diagram.pause();
|
|
1103
1103
|
for (const anim of allAnims) anim.cancel();
|
|
1104
1104
|
resizeObserver.disconnect();
|
|
1105
1105
|
if (progressEl?.parentNode === viewport) viewport.removeChild(progressEl);
|
|
@@ -1109,15 +1109,15 @@ function createPlayer(opts) {
|
|
|
1109
1109
|
};
|
|
1110
1110
|
viewport.style.cursor = "pointer";
|
|
1111
1111
|
viewport.addEventListener("click", () => {
|
|
1112
|
-
if (isPlaying)
|
|
1112
|
+
if (isPlaying) diagram.pause();
|
|
1113
1113
|
else {
|
|
1114
1114
|
if (!loop && sceneMs >= totalDurationMs) sceneMs = 0;
|
|
1115
|
-
|
|
1115
|
+
diagram.play();
|
|
1116
1116
|
}
|
|
1117
1117
|
});
|
|
1118
|
-
if (autoplay)
|
|
1119
|
-
return
|
|
1118
|
+
if (autoplay) diagram.play();
|
|
1119
|
+
return diagram;
|
|
1120
1120
|
}
|
|
1121
1121
|
export {
|
|
1122
|
-
|
|
1122
|
+
createDiagram
|
|
1123
1123
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "Browser renderer for animated MarkdyScript architecture diagrams, built on the Web Animations API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@markdy/core": "0.8.
|
|
46
|
+
"@markdy/core": "0.8.5"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"jsdom": "^29.1.1",
|
|
50
50
|
"tsup": "^8.5.1",
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
52
|
"vitest": "^4.1.7",
|
|
53
|
-
"@markdy/stdlib-systems": "0.8.
|
|
53
|
+
"@markdy/stdlib-systems": "0.8.5"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsup",
|