@markdy/mdx 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 CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  MDX integration for MarkdyScript with Lighthouse-safe defaults:
4
4
 
5
- - `remarkMarkdy` converts fenced code blocks (` ```markdy `) into a player component.
6
- - `MarkdyPlayer` hydrates only when visible and lazy-loads `@markdy/renderer-dom`.
5
+ - `remarkMarkdy` converts fenced code blocks (` ```markdy `) into a diagram component.
6
+ - `MarkdyDiagram` hydrates only when visible and lazy-loads `@markdy/renderer-dom`.
7
7
  - Rendered diagrams use the same semantic SVG node cards as `@markdy/renderer-dom`.
8
8
 
9
9
  ## Install
@@ -17,7 +17,7 @@ pnpm add @markdy/mdx react react-dom
17
17
  ```text
18
18
  @markdy/core -> @markdy/renderer-dom -> @markdy/mdx
19
19
 
20
- MDX integration transforms fenced markdy blocks into lazy player components.
20
+ MDX integration transforms fenced markdy blocks into lazy diagram components.
21
21
  ```
22
22
 
23
23
  ## Output preview
@@ -33,16 +33,16 @@ MDX integration transforms fenced markdy blocks into lazy player components.
33
33
  import { remarkMarkdy } from "@markdy/mdx";
34
34
 
35
35
  export default {
36
- remarkPlugins: [[remarkMarkdy, { componentName: "MarkdyPlayer" }]],
36
+ remarkPlugins: [[remarkMarkdy, { componentName: "MarkdyDiagram" }]],
37
37
  };
38
38
  ```
39
39
 
40
40
  ```tsx
41
41
  // shared MDX components map
42
- import { MarkdyPlayer } from "@markdy/mdx";
42
+ import { MarkdyDiagram } from "@markdy/mdx";
43
43
 
44
44
  export const mdxComponents = {
45
- MarkdyPlayer,
45
+ MarkdyDiagram,
46
46
  };
47
47
  ```
48
48
 
@@ -62,12 +62,12 @@ beat main:
62
62
  ## Performance Notes
63
63
 
64
64
  - Default transform options set `autoplay=false`, `loop=false`, `progressBar=false`.
65
- - Runtime player does not import renderer code until the block enters viewport.
65
+ - Runtime diagram component does not import renderer code until the block enters viewport.
66
66
  - Placeholder is SSR-safe and keeps stable layout ratio to avoid CLS.
67
67
 
68
68
  ## Fence Metadata
69
69
 
70
- Fenced block metadata is passed as props to `MarkdyPlayer`. Snake-case aliases are normalized for renderer options:
70
+ Fenced block metadata is passed as props to `MarkdyDiagram`. Snake-case aliases are normalized for renderer options:
71
71
 
72
72
  | Metadata | Prop | Description |
73
73
  |---|---|---|
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { Root } from 'mdast';
3
3
 
4
- type MarkdyPlayerProps = {
4
+ type MarkdyDiagramProps = {
5
5
  code: string;
6
6
  width?: number | string;
7
7
  height?: number | string;
@@ -17,7 +17,7 @@ type MarkdyPlayerProps = {
17
17
  title?: string;
18
18
  description?: string;
19
19
  };
20
- declare function MarkdyPlayer({ code, width, height, bg, assets, autoplay, loop, copyright, progressBar, sceneBoundaryProgress, playbackRate, className, title, description, }: MarkdyPlayerProps): react.JSX.Element;
20
+ declare function MarkdyDiagram({ code, width, height, bg, assets, autoplay, loop, copyright, progressBar, sceneBoundaryProgress, playbackRate, className, title, description, }: MarkdyDiagramProps): react.JSX.Element;
21
21
 
22
22
  type MarkdyFenceDefaults = Partial<{
23
23
  width: number;
@@ -36,4 +36,4 @@ type RemarkMarkdyOptions = {
36
36
  };
37
37
  declare function remarkMarkdy(opts?: RemarkMarkdyOptions): (tree: Root) => void;
38
38
 
39
- export { MarkdyPlayer, type MarkdyPlayerProps, type RemarkMarkdyOptions, remarkMarkdy };
39
+ export { MarkdyDiagram, type MarkdyDiagramProps, type RemarkMarkdyOptions, remarkMarkdy };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // src/player.tsx
1
+ // src/diagram.tsx
2
2
  import { useEffect, useRef } from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  function scheduleBackgroundTask(work) {
@@ -28,7 +28,7 @@ function coerceNumber(value, fallback) {
28
28
  }
29
29
  return fallback;
30
30
  }
31
- function MarkdyPlayer({
31
+ function MarkdyDiagram({
32
32
  code,
33
33
  width = 800,
34
34
  height = 400,
@@ -53,7 +53,7 @@ function MarkdyPlayer({
53
53
  const resolvedSceneBoundaryProgress = coerceBoolean(sceneBoundaryProgress, resolvedProgressBar);
54
54
  const resolvedPlaybackRate = coerceNumber(playbackRate, 1);
55
55
  const rootRef = useRef(null);
56
- const playerRef = useRef(null);
56
+ const diagramRef = useRef(null);
57
57
  const hydratedRef = useRef(false);
58
58
  useEffect(() => {
59
59
  if (typeof window === "undefined") return;
@@ -70,9 +70,9 @@ function MarkdyPlayer({
70
70
  try {
71
71
  const renderer = await import("@markdy/renderer-dom");
72
72
  if (disposed) return;
73
- const createPlayer = renderer.createPlayer;
73
+ const createDiagram = renderer.createDiagram;
74
74
  root.innerHTML = "";
75
- playerRef.current = createPlayer({
75
+ diagramRef.current = createDiagram({
76
76
  container: root,
77
77
  code,
78
78
  assets,
@@ -89,7 +89,7 @@ function MarkdyPlayer({
89
89
  hydratedRef.current = false;
90
90
  root.dataset.markdyInit = "error";
91
91
  root.removeAttribute("aria-busy");
92
- console.error("Failed to hydrate MarkdyPlayer", error);
92
+ console.error("Failed to hydrate MarkdyDiagram", error);
93
93
  }
94
94
  })();
95
95
  });
@@ -118,8 +118,8 @@ function MarkdyPlayer({
118
118
  disposed = true;
119
119
  observer?.disconnect();
120
120
  root.removeEventListener("click", onClick);
121
- playerRef.current?.destroy();
122
- playerRef.current = null;
121
+ diagramRef.current?.destroy();
122
+ diagramRef.current = null;
123
123
  };
124
124
  }, [
125
125
  assets,
@@ -254,7 +254,7 @@ function toCodeAttribute(code) {
254
254
  };
255
255
  }
256
256
  function remarkMarkdy(opts = {}) {
257
- const componentName = opts.componentName ?? "MarkdyPlayer";
257
+ const componentName = opts.componentName ?? "MarkdyDiagram";
258
258
  const defaultProps = {
259
259
  autoplay: false,
260
260
  loop: false,
@@ -288,6 +288,6 @@ function remarkMarkdy(opts = {}) {
288
288
  };
289
289
  }
290
290
  export {
291
- MarkdyPlayer,
291
+ MarkdyDiagram,
292
292
  remarkMarkdy
293
293
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markdy/mdx",
3
- "version": "0.8.3",
4
- "description": "MDX plugin and lightweight React player for animated Markdy diagrams.",
3
+ "version": "0.8.5",
4
+ "description": "MDX plugin and lightweight React diagram component for animated Markdy diagrams.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "unist-util-visit": "^5.0.0",
44
- "@markdy/renderer-dom": "0.8.3"
44
+ "@markdy/renderer-dom": "0.8.5"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": ">=18.0.0",