@foxalope/mermaid-render 0.1.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,73 @@
1
+ # mermaid-render
2
+
3
+ Render beautiful Mermaid diagrams to PNG from the command line.
4
+
5
+ A native Rust CLI tool with modern styling using the Flat UI color palette.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g mermaid-render
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ # Basic usage
17
+ mermaid-render -i diagram.mmd -o output.png
18
+
19
+ # With dark theme
20
+ mermaid-render -i diagram.mmd -o output.png --theme dark
21
+
22
+ # With 2x scale (for retina displays)
23
+ mermaid-render -i diagram.mmd -o output.png --scale 2
24
+
25
+ # Show help
26
+ mermaid-render --help
27
+ ```
28
+
29
+ ## Supported Diagram Types
30
+
31
+ ### Flowcharts
32
+
33
+ ```mermaid
34
+ graph TD
35
+ A[Start] --> B{Decision}
36
+ B -->|Yes| C[Action]
37
+ B -->|No| D[End]
38
+ ```
39
+
40
+ Supported node shapes:
41
+ - `[text]` - Rectangle
42
+ - `(text)` - Rounded rectangle
43
+ - `{text}` - Diamond
44
+ - `((text))` - Circle
45
+ - `([text])` - Stadium
46
+ - `[(text)]` - Cylinder
47
+
48
+ Directions: `TD`, `TB`, `BT`, `LR`, `RL`
49
+
50
+ ### Sequence Diagrams
51
+
52
+ ```mermaid
53
+ sequenceDiagram
54
+ Alice->>Bob: Hello
55
+ Bob-->>Alice: Hi there
56
+ ```
57
+
58
+ ## Themes
59
+
60
+ - `default` - Light theme with Flat UI colors
61
+ - `dark` - Dark theme for dark backgrounds
62
+
63
+ ## Features
64
+
65
+ - Native Rust performance (no browser/Node.js runtime needed)
66
+ - Beautiful modern styling with rounded corners and shadows
67
+ - Anti-aliased rendering
68
+ - Embedded Open Sans font
69
+ - Support for flowcharts and sequence diagrams
70
+
71
+ ## License
72
+
73
+ MIT
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+
7
+ // Make binary executable on Unix systems
8
+ if (os.platform() !== 'win32') {
9
+ const binDir = path.join(__dirname, '..', 'binaries');
10
+
11
+ if (fs.existsSync(binDir)) {
12
+ const files = fs.readdirSync(binDir);
13
+ files.forEach(file => {
14
+ const filePath = path.join(binDir, file);
15
+ try {
16
+ fs.chmodSync(filePath, 0o755);
17
+ } catch (err) {
18
+ // Ignore errors
19
+ }
20
+ });
21
+ }
22
+ }
23
+
24
+ console.log('mermaid-render installed successfully!');
25
+ console.log('Run: mermaid-render --help');
package/bin/run.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const fs = require('fs');
7
+
8
+ function getBinaryPath() {
9
+ const platform = os.platform();
10
+ const arch = os.arch();
11
+
12
+ let binaryName;
13
+
14
+ if (platform === 'win32') {
15
+ binaryName = 'mermaid-render-x86_64-pc-windows-msvc.exe';
16
+ } else if (platform === 'darwin') {
17
+ binaryName = arch === 'arm64'
18
+ ? 'mermaid-render-aarch64-apple-darwin'
19
+ : 'mermaid-render-x86_64-apple-darwin';
20
+ } else if (platform === 'linux') {
21
+ binaryName = arch === 'arm64'
22
+ ? 'mermaid-render-aarch64-unknown-linux-gnu'
23
+ : 'mermaid-render-x86_64-unknown-linux-gnu';
24
+ } else {
25
+ console.error(`Unsupported platform: ${platform}-${arch}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const binaryPath = path.join(__dirname, '..', 'binaries', binaryName);
30
+
31
+ if (!fs.existsSync(binaryPath)) {
32
+ console.error(`Binary not found: ${binaryPath}`);
33
+ console.error('Please ensure the binary is available for your platform.');
34
+ process.exit(1);
35
+ }
36
+
37
+ return binaryPath;
38
+ }
39
+
40
+ const binaryPath = getBinaryPath();
41
+ const args = process.argv.slice(2);
42
+
43
+ const child = spawn(binaryPath, args, {
44
+ stdio: 'inherit',
45
+ shell: false
46
+ });
47
+
48
+ child.on('error', (err) => {
49
+ console.error('Failed to start mermaid-render:', err.message);
50
+ process.exit(1);
51
+ });
52
+
53
+ child.on('close', (code) => {
54
+ process.exit(code || 0);
55
+ });
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@foxalope/mermaid-render",
3
+ "version": "0.1.0",
4
+ "description": "Render beautiful Mermaid diagrams to PNG from the command line",
5
+ "keywords": [
6
+ "mermaid",
7
+ "diagram",
8
+ "flowchart",
9
+ "sequence",
10
+ "png",
11
+ "cli",
12
+ "rust"
13
+ ],
14
+ "author": "Steve",
15
+ "license": "UNLICENSED",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/yourusername/mermaid-render"
19
+ },
20
+ "bin": {
21
+ "mermaid-render": "bin/run.js"
22
+ },
23
+ "files": [
24
+ "bin/",
25
+ "binaries/"
26
+ ],
27
+ "os": [
28
+ "darwin",
29
+ "linux",
30
+ "win32"
31
+ ],
32
+ "cpu": [
33
+ "x64",
34
+ "arm64"
35
+ ],
36
+ "engines": {
37
+ "node": ">=14"
38
+ },
39
+ "scripts": {
40
+ "postinstall": "node bin/postinstall.js"
41
+ }
42
+ }