rspress-plugin-graph-view 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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Rspress contributors
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,95 @@
1
+ # rspress-plugin-graph-view
2
+
3
+ Interactive graph visualization for [Rspress](https://rspress.dev/) documentation sites. Automatically extracts internal markdown links and renders them as a navigable force-directed graph — like Obsidian's graph view for your docs.
4
+
5
+ ![Version](https://img.shields.io/npm/v/rspress-plugin-graph-view)
6
+ ![License](https://img.shields.io/npm/l/rspress-plugin-graph-view)
7
+
8
+ ## Features
9
+
10
+ - **Automatic link detection** — uses MDAST parsing to extract all markdown link formats (inline, reference, autolinks) while ignoring links inside code blocks
11
+ - **Click to navigate** — click any node to jump to that page
12
+ - **Dark mode** — seamlessly adapts to light and dark themes
13
+ - **Build caching** — incremental rebuilds with mtime-based cache invalidation
14
+ - **Large graph optimization** — automatically disables expensive visual effects for graphs with 80+ nodes
15
+ - **Build profiling** — optional diagnostics to measure graph build performance
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ bun add rspress-plugin-graph-view
21
+ # or
22
+ npm install rspress-plugin-graph-view
23
+ # or
24
+ pnpm add rspress-plugin-graph-view
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Add the plugin to your `rspress.config.ts`:
30
+
31
+ ```ts
32
+ import { defineConfig } from "@rspress/core";
33
+ import graphView from "rspress-plugin-graph-view";
34
+
35
+ export default defineConfig({
36
+ // ...your config
37
+ plugins: [graphView()],
38
+ });
39
+ ```
40
+
41
+ That's it. A floating action button will appear in the bottom-right corner of your docs site. Click it to open the graph view.
42
+
43
+ ### Options
44
+
45
+ ```ts
46
+ graphView({
47
+ // Open the graph panel by default (default: false)
48
+ defaultOpen: true,
49
+
50
+ // Log build timing diagnostics (default: false)
51
+ profileBuild: true,
52
+ })
53
+ ```
54
+
55
+ You can also enable profiling temporarily with the `RSPRESS_GRAPH_VIEW_PROFILE=1` environment variable.
56
+
57
+ ### Peer Dependencies
58
+
59
+ This plugin requires the following peer dependencies, which should already be installed if you're using Rspress:
60
+
61
+ | Package | Version |
62
+ | --- | --- |
63
+ | `@rspress/core` | `^2.0.7` |
64
+ | `react` | `>=19` |
65
+ | `react-dom` | `>=19` |
66
+ | `react-force-graph-2d` | `^1.29.1` |
67
+
68
+ ## How It Works
69
+
70
+ 1. **Build time**: The plugin collects all route metadata, reads each markdown file, parses the content into an MDAST syntax tree, extracts internal link references, and builds a graph data structure.
71
+ 2. **Runtime**: A virtual module (`virtual-graph-data`) injects the graph data into the client. `react-force-graph-2d` renders an interactive force-directed graph with custom canvas drawing.
72
+ 3. **Caching**: File mtime + size signatures enable incremental rebuilds — unchanged files skip parsing entirely.
73
+
74
+ ## Development
75
+
76
+ ```bash
77
+ # Install dependencies
78
+ bun install
79
+
80
+ # Typecheck
81
+ bun run build
82
+
83
+ # Run tests
84
+ bun test
85
+
86
+ # Start docs dev server
87
+ bun run docs:dev
88
+
89
+ # Benchmark graph build performance
90
+ bun run bench:graph --pages=1000 --links=6 --iterations=5
91
+ ```
92
+
93
+ ## License
94
+
95
+ MIT
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "rspress-plugin-graph-view",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Interactive graph visualization for Rspress documentation sites — visualize your knowledge base connections like Obsidian",
6
+ "files": [
7
+ "dist",
8
+ "README.md"
9
+ ],
10
+ "keywords": [
11
+ "rspress",
12
+ "plugin",
13
+ "graphview"
14
+ ],
15
+ "homepage": "https://github.com/Jacob-Valor/rspress-plugin-graph-view",
16
+ "bugs": {
17
+ "url": "https://github.com/Jacob-Valor/rspress-plugin-graph-view/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/Jacob-Valor/rspress-plugin-graph-view.git"
22
+ },
23
+ "license": "MIT",
24
+ "author": "Jacob-Valor <jacob-programmer@tuta.io> (https://github.com/Jacob-Valor)",
25
+ "main": "dist/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./src/index.ts",
30
+ "default": "./src/index.ts"
31
+ },
32
+ "./runtime/*": {
33
+ "import": "./src/runtime/*",
34
+ "default": "./src/runtime/*"
35
+ }
36
+ },
37
+ "scripts": {
38
+ "bench:graph": "bun scripts/bench-graph-build.ts",
39
+ "build": "tsc --declarationMap false",
40
+ "dev": "tsc -w",
41
+ "docs:build": "rspress build",
42
+ "docs:dev": "rspress dev",
43
+ "test": "bun test",
44
+ "prepublishOnly": "bun run build && bun run test"
45
+ },
46
+ "devDependencies": {
47
+ "@types/bun": "latest",
48
+ "@types/react": "^19.2.14",
49
+ "@types/react-dom": "^19.2.3",
50
+ "semantic-release": "^25.0.3",
51
+ "typescript": "^6.0.2"
52
+ },
53
+ "peerDependencies": {
54
+ "@rspress/core": "^2.0.7",
55
+ "react": "^19.2.4",
56
+ "react-dom": "^19.2.4",
57
+ "react-force-graph-2d": "^1.29.1"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "typescript": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "dependencies": {
65
+ "rspress-plugin-devkit": "^1.0.0"
66
+ }
67
+ }