@markgrafhq/starlight-markgraf 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mark Eibes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # @markgrafhq/starlight-markgraf
2
+
3
+ Astro/Starlight integration for embedding [markgraf](https://github.com/markgrafhq) animations.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @markgrafhq/starlight-markgraf @markgrafhq/markgraf-react @astrojs/react react react-dom
9
+ ```
10
+
11
+ ## Configure
12
+
13
+ ```js
14
+ // astro.config.mjs
15
+ import { defineConfig } from "astro/config";
16
+ import react from "@astrojs/react";
17
+ import starlight from "@astrojs/starlight";
18
+ import markgraf from "@markgrafhq/starlight-markgraf";
19
+
20
+ export default defineConfig({
21
+ integrations: [react(), starlight({ title: "Docs" }), markgraf()],
22
+ });
23
+ ```
24
+
25
+ Import the player CSS in a global stylesheet:
26
+
27
+ ```css
28
+ @import "@markgrafhq/markgraf-react/dist/markgraf-react.css";
29
+ ```
30
+
31
+ ## Use
32
+
33
+ Fenced code blocks with the `markgraf` language render as live players:
34
+
35
+ ````markdown
36
+ ```markgraf
37
+ seed 1
38
+ keyframe v1 {
39
+ +node client "Client"
40
+ +node api "API"
41
+ +edge client api
42
+ client -> api "GET /user/42"
43
+ }
44
+ ```
45
+ ````
46
+
47
+ Or use the component directly in MDX/Astro:
48
+
49
+ ```astro
50
+ ---
51
+ import Markgraf from "@markgrafhq/starlight-markgraf/Markgraf.astro";
52
+ ---
53
+
54
+ <Markgraf src={`seed 1\nkeyframe v1 { +node a "A" }`} />
55
+ ```
@@ -0,0 +1,4 @@
1
+ import type { AstroIntegration } from "astro";
2
+ import remarkMarkgraf from "./remark-markgraf.mjs";
3
+ export { remarkMarkgraf };
4
+ export default function markgrafIntegration(): AstroIntegration;
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import remarkMarkgraf from "./remark-markgraf.mjs";
2
+ export { remarkMarkgraf };
3
+ export default function markgrafIntegration() {
4
+ return {
5
+ name: "markgraf-starlight",
6
+ hooks: {
7
+ "astro:config:setup": ({ updateConfig }) => {
8
+ updateConfig({
9
+ markdown: {
10
+ remarkPlugins: [remarkMarkgraf],
11
+ },
12
+ });
13
+ },
14
+ },
15
+ };
16
+ }
@@ -0,0 +1,51 @@
1
+ import { visit } from "unist-util-visit";
2
+
3
+ const importNode = {
4
+ type: "mdxjsEsm",
5
+ value: 'import Markgraf from "@markgrafhq/starlight-markgraf/Markgraf.astro";',
6
+ data: {
7
+ estree: {
8
+ type: "Program",
9
+ sourceType: "module",
10
+ body: [
11
+ {
12
+ type: "ImportDeclaration",
13
+ specifiers: [
14
+ {
15
+ type: "ImportDefaultSpecifier",
16
+ local: { type: "Identifier", name: "Markgraf" },
17
+ },
18
+ ],
19
+ source: {
20
+ type: "Literal",
21
+ value: "@markgrafhq/starlight-markgraf/Markgraf.astro",
22
+ raw: '"@markgrafhq/starlight-markgraf/Markgraf.astro"',
23
+ },
24
+ },
25
+ ],
26
+ },
27
+ },
28
+ };
29
+
30
+ export default function remarkMarkgraf() {
31
+ return (tree) => {
32
+ let needsImport = false;
33
+
34
+ visit(tree, "code", (node, index, parent) => {
35
+ if (node.lang !== "markgraf" || !parent || index == null) return;
36
+
37
+ needsImport = true;
38
+
39
+ parent.children[index] = {
40
+ type: "mdxJsxFlowElement",
41
+ name: "Markgraf",
42
+ attributes: [
43
+ { type: "mdxJsxAttribute", name: "src", value: node.value },
44
+ ],
45
+ children: [],
46
+ };
47
+ });
48
+
49
+ if (needsImport) tree.children.unshift(importNode);
50
+ };
51
+ }
@@ -0,0 +1,51 @@
1
+ import { visit } from "unist-util-visit";
2
+
3
+ const importNode = {
4
+ type: "mdxjsEsm",
5
+ value: 'import Markgraf from "@markgrafhq/starlight-markgraf/Markgraf.astro";',
6
+ data: {
7
+ estree: {
8
+ type: "Program",
9
+ sourceType: "module",
10
+ body: [
11
+ {
12
+ type: "ImportDeclaration",
13
+ specifiers: [
14
+ {
15
+ type: "ImportDefaultSpecifier",
16
+ local: { type: "Identifier", name: "Markgraf" },
17
+ },
18
+ ],
19
+ source: {
20
+ type: "Literal",
21
+ value: "@markgrafhq/starlight-markgraf/Markgraf.astro",
22
+ raw: '"@markgrafhq/starlight-markgraf/Markgraf.astro"',
23
+ },
24
+ },
25
+ ],
26
+ },
27
+ },
28
+ };
29
+
30
+ export default function remarkMarkgraf() {
31
+ return (tree) => {
32
+ let needsImport = false;
33
+
34
+ visit(tree, "code", (node, index, parent) => {
35
+ if (node.lang !== "markgraf" || !parent || index == null) return;
36
+
37
+ needsImport = true;
38
+
39
+ parent.children[index] = {
40
+ type: "mdxJsxFlowElement",
41
+ name: "Markgraf",
42
+ attributes: [
43
+ { type: "mdxJsxAttribute", name: "src", value: node.value },
44
+ ],
45
+ children: [],
46
+ };
47
+ });
48
+
49
+ if (needsImport) tree.children.unshift(importNode);
50
+ };
51
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@markgrafhq/starlight-markgraf",
3
+ "version": "0.0.26",
4
+ "description": "Starlight/Astro integration for embedding markgraf animations. Transforms ```markgraf fenced code blocks into a live player and exposes a <Markgraf src=\"…\" /> component.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./Markgraf.astro": "./src/Markgraf.astro",
15
+ "./remark": {
16
+ "default": "./dist/remark-markgraf.js"
17
+ },
18
+ "./css": "./node_modules/@markgrafhq/markgraf-react/dist/markgraf-react.css"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "src/Markgraf.astro",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "sideEffects": false,
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json && cp src/remark-markgraf.mjs dist/remark-markgraf.mjs && cp src/remark-markgraf.mjs dist/remark-markgraf.js"
29
+ },
30
+ "peerDependencies": {
31
+ "astro": ">=4",
32
+ "@astrojs/react": ">=3",
33
+ "react": ">=18",
34
+ "react-dom": ">=18"
35
+ },
36
+ "dependencies": {
37
+ "@markgrafhq/markgraf-react": "^0.0.26",
38
+ "unist-util-visit": "^5"
39
+ },
40
+ "devDependencies": {
41
+ "typescript": "^5"
42
+ },
43
+ "keywords": [
44
+ "markgraf",
45
+ "starlight",
46
+ "astro",
47
+ "astro-integration",
48
+ "remark",
49
+ "animation",
50
+ "diagram"
51
+ ],
52
+ "license": "MIT",
53
+ "author": "Mark Eibes <mark.eibes@gmail.com>",
54
+ "homepage": "https://github.com/markgrafhq/starlight-markgraf#readme",
55
+ "bugs": "https://github.com/markgrafhq/starlight-markgraf/issues",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/markgrafhq/starlight-markgraf.git"
59
+ }
60
+ }
@@ -0,0 +1,18 @@
1
+ ---
2
+ import { MarkgrafPlayer } from "@markgrafhq/markgraf-react";
3
+
4
+ interface Props {
5
+ src: string;
6
+ renderer?: "canvas" | "svg";
7
+ class?: string;
8
+ }
9
+
10
+ const { src, renderer = "canvas", class: className } = Astro.props;
11
+ ---
12
+
13
+ <MarkgrafPlayer
14
+ client:visible
15
+ src={src}
16
+ renderer={renderer}
17
+ className={className}
18
+ />