streamdown-beautiful-mermaid 1.0.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 ADDED
@@ -0,0 +1,53 @@
1
+ # streamdown-beautiful-mermaid
2
+
3
+ A beautiful Mermaid diagram rendering plugin for [Streamdown](https://github.com/wan-kong/streamdown), powered by [beautiful-mermaid](https://github.com/shikijs/beautiful-mermaid).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install streamdown-beautiful-mermaid
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Usage in Streamdown
14
+
15
+ ```typescript
16
+ - import { mermaid } from "@streamdown/markdown";
17
+ + import { mermaid } from 'streamdown-beautiful-mermaid';
18
+
19
+ ```
20
+
21
+ ## Theme Variables
22
+
23
+ Configure visual appearance through `themeVariables`:
24
+
25
+ ```typescript
26
+ {
27
+ themeVariables: {
28
+ // Colors
29
+ primaryColor: '#ffffff', // Background color
30
+ primaryTextColor: '#27272A', // Foreground/text color
31
+ lineColor: '#666666', // Edge/connector color
32
+ primaryBorderColor: '#cccccc', // Border color
33
+ secondaryColor: '#f0f0f0', // Surface/fill tint
34
+ tertiaryColor: '#0066cc', // Accent color
35
+ tertiaryTextColor: '#666666', // Secondary text color
36
+
37
+ // Typography
38
+ fontFamily: 'Inter, sans-serif',
39
+
40
+ // Spacing (in pixels)
41
+ padding: 40,
42
+ nodeSpacing: 24,
43
+ layerSpacing: 40,
44
+
45
+ // Rendering
46
+ transparent: false
47
+ }
48
+ }
49
+ ```
50
+
51
+ ## License
52
+
53
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ 'use strict';var beautifulMermaid=require('beautiful-mermaid');var a={};function m(i){let e={};if(!i.themeVariables)return e;let r=i.themeVariables;return r.primaryColor&&(e.bg=r.primaryColor),r.primaryTextColor&&(e.fg=r.primaryTextColor),r.lineColor&&(e.line=r.lineColor),r.primaryBorderColor&&(e.border=r.primaryBorderColor),r.secondaryColor&&(e.surface=r.secondaryColor),r.tertiaryColor&&(e.accent=r.tertiaryColor),r.tertiaryTextColor&&(e.muted=r.tertiaryTextColor),r.fontFamily&&(e.font=r.fontFamily),r.padding!==void 0&&(e.padding=Number(r.padding)),r.nodeSpacing!==void 0&&(e.nodeSpacing=Number(r.nodeSpacing)),r.layerSpacing!==void 0&&(e.layerSpacing=Number(r.layerSpacing)),r.transparent!==void 0&&(e.transparent=!!r.transparent),e}function g(i={}){let e={...a,...i.config},r={initialize(n){e={...a,...i.config,...n};},async render(n,o){let t=m(e);return {svg:await beautifulMermaid.renderMermaid(o,t)}}};return {name:"mermaid",type:"diagram",language:"mermaid",getMermaid(n){return n&&r.initialize(n),r}}}var l=g();exports.createMermaidPlugin=g;exports.mergeConfig=m;exports.mermaid=l;
@@ -0,0 +1,51 @@
1
+ import { RenderOptions } from 'beautiful-mermaid';
2
+ import { MermaidConfig } from 'mermaid';
3
+
4
+ /**
5
+ * Mermaid instance interface
6
+ */
7
+ interface MermaidInstance {
8
+ initialize: (config: MermaidConfig) => void;
9
+ render: (id: string, source: string) => Promise<{
10
+ svg: string;
11
+ }>;
12
+ }
13
+ /**
14
+ * Plugin for diagram rendering (Mermaid)
15
+ */
16
+ interface DiagramPlugin {
17
+ name: "mermaid";
18
+ type: "diagram";
19
+ /**
20
+ * Language identifier for code blocks
21
+ */
22
+ language: string;
23
+ /**
24
+ * Get the mermaid instance (initialized with optional config)
25
+ */
26
+ getMermaid: (config?: MermaidConfig) => MermaidInstance;
27
+ }
28
+ /**
29
+ * Options for creating a Mermaid plugin
30
+ */
31
+ interface MermaidPluginOptions {
32
+ /**
33
+ * Default beautiful-mermaid configuration
34
+ */
35
+ config?: MermaidConfig;
36
+ }
37
+ /**
38
+ * Convert MermaidConfig.themeVariables to RenderOptions
39
+ * Maps Mermaid theme variables to beautiful-mermaid color and layout settings
40
+ */
41
+ declare function mergeConfig(config: MermaidConfig): RenderOptions;
42
+ /**
43
+ * Create a Mermaid plugin with optional configuration
44
+ */
45
+ declare function createMermaidPlugin(options?: MermaidPluginOptions): DiagramPlugin;
46
+ /**
47
+ * Pre-configured Mermaid plugin with default settings
48
+ */
49
+ declare const mermaid: DiagramPlugin;
50
+
51
+ export { type DiagramPlugin, type MermaidInstance, type MermaidPluginOptions, createMermaidPlugin, mergeConfig, mermaid };
@@ -0,0 +1,51 @@
1
+ import { RenderOptions } from 'beautiful-mermaid';
2
+ import { MermaidConfig } from 'mermaid';
3
+
4
+ /**
5
+ * Mermaid instance interface
6
+ */
7
+ interface MermaidInstance {
8
+ initialize: (config: MermaidConfig) => void;
9
+ render: (id: string, source: string) => Promise<{
10
+ svg: string;
11
+ }>;
12
+ }
13
+ /**
14
+ * Plugin for diagram rendering (Mermaid)
15
+ */
16
+ interface DiagramPlugin {
17
+ name: "mermaid";
18
+ type: "diagram";
19
+ /**
20
+ * Language identifier for code blocks
21
+ */
22
+ language: string;
23
+ /**
24
+ * Get the mermaid instance (initialized with optional config)
25
+ */
26
+ getMermaid: (config?: MermaidConfig) => MermaidInstance;
27
+ }
28
+ /**
29
+ * Options for creating a Mermaid plugin
30
+ */
31
+ interface MermaidPluginOptions {
32
+ /**
33
+ * Default beautiful-mermaid configuration
34
+ */
35
+ config?: MermaidConfig;
36
+ }
37
+ /**
38
+ * Convert MermaidConfig.themeVariables to RenderOptions
39
+ * Maps Mermaid theme variables to beautiful-mermaid color and layout settings
40
+ */
41
+ declare function mergeConfig(config: MermaidConfig): RenderOptions;
42
+ /**
43
+ * Create a Mermaid plugin with optional configuration
44
+ */
45
+ declare function createMermaidPlugin(options?: MermaidPluginOptions): DiagramPlugin;
46
+ /**
47
+ * Pre-configured Mermaid plugin with default settings
48
+ */
49
+ declare const mermaid: DiagramPlugin;
50
+
51
+ export { type DiagramPlugin, type MermaidInstance, type MermaidPluginOptions, createMermaidPlugin, mergeConfig, mermaid };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import {renderMermaid}from'beautiful-mermaid';var a={};function m(i){let e={};if(!i.themeVariables)return e;let r=i.themeVariables;return r.primaryColor&&(e.bg=r.primaryColor),r.primaryTextColor&&(e.fg=r.primaryTextColor),r.lineColor&&(e.line=r.lineColor),r.primaryBorderColor&&(e.border=r.primaryBorderColor),r.secondaryColor&&(e.surface=r.secondaryColor),r.tertiaryColor&&(e.accent=r.tertiaryColor),r.tertiaryTextColor&&(e.muted=r.tertiaryTextColor),r.fontFamily&&(e.font=r.fontFamily),r.padding!==void 0&&(e.padding=Number(r.padding)),r.nodeSpacing!==void 0&&(e.nodeSpacing=Number(r.nodeSpacing)),r.layerSpacing!==void 0&&(e.layerSpacing=Number(r.layerSpacing)),r.transparent!==void 0&&(e.transparent=!!r.transparent),e}function g(i={}){let e={...a,...i.config},r={initialize(n){e={...a,...i.config,...n};},async render(n,o){let t=m(e);return {svg:await renderMermaid(o,t)}}};return {name:"mermaid",type:"diagram",language:"mermaid",getMermaid(n){return n&&r.initialize(n),r}}}var l=g();export{g as createMermaidPlugin,m as mergeConfig,l as mermaid};
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "streamdown-beautiful-mermaid",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "test": "vitest run",
21
+ "test:coverage": "vitest --coverage run"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^18.0.0 || ^19.0.0"
25
+ },
26
+ "dependencies": {
27
+ "beautiful-mermaid": "^0.1.3"
28
+ },
29
+ "devDependencies": {
30
+ "mermaid": "^11.12.2",
31
+ "@vitest/coverage-v8": "^4.0.15",
32
+ "jsdom": "^27.3.0",
33
+ "tsup": "^8.5.1",
34
+ "typescript": "^5.9.3",
35
+ "vitest": "^4.0.15"
36
+ },
37
+ "author": "wankong <1549072621@qq.com>",
38
+ "license": "MIT",
39
+ "description": "beautiful-mermaid plugin for Streamdown",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/wan-kong/streamdown-beautiful-mermaid.git"
43
+ }
44
+ }