@slxu/graphsx 0.1.0 → 0.1.2
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 +20 -3
- package/package.json +19 -5
- package/src/renderer.js +18 -3
package/README.md
CHANGED
|
@@ -21,6 +21,13 @@ Install from npm:
|
|
|
21
21
|
npm install @slxu/graphsx
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
Optional integrations use the host app's packages:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install katex markdown-it
|
|
28
|
+
npm install codemirror @codemirror/state @codemirror/view @codemirror/lang-javascript @codemirror/lang-markdown
|
|
29
|
+
```
|
|
30
|
+
|
|
24
31
|
## What It Looks Like
|
|
25
32
|
|
|
26
33
|
### Port Diagram
|
|
@@ -41,7 +48,7 @@ npm install @slxu/graphsx
|
|
|
41
48
|
</Graph>
|
|
42
49
|
```
|
|
43
50
|
|
|
44
|
-

|
|
51
|
+

|
|
45
52
|
|
|
46
53
|
### Parametric Plot
|
|
47
54
|
|
|
@@ -61,7 +68,7 @@ npm install @slxu/graphsx
|
|
|
61
68
|
</Plot>
|
|
62
69
|
```
|
|
63
70
|
|
|
64
|
-

|
|
71
|
+

|
|
65
72
|
|
|
66
73
|
### Reusable Shapes And Repeat
|
|
67
74
|
|
|
@@ -84,7 +91,7 @@ npm install @slxu/graphsx
|
|
|
84
91
|
</Graph>
|
|
85
92
|
```
|
|
86
93
|
|
|
87
|
-

|
|
94
|
+

|
|
88
95
|
|
|
89
96
|
## Quick Example
|
|
90
97
|
|
|
@@ -564,6 +571,16 @@ new EditorView({
|
|
|
564
571
|
|
|
565
572
|
When the cursor is outside a `graphsx` fence, the fence renders as an SVG widget. Clicking the widget moves the cursor into the original fenced code. `graphsx-defs` fences render as compact library markers and feed reusable shapes/styles to later fences.
|
|
566
573
|
|
|
574
|
+
## VS Code Markdown Preview
|
|
575
|
+
|
|
576
|
+
This repo also contains a VS Code extension scaffold in `packages/vscode-graphsx`. It teaches VS Code's built-in Markdown preview to render `graphsx` fenced blocks.
|
|
577
|
+
|
|
578
|
+
Build the extension bundle from the repo root:
|
|
579
|
+
|
|
580
|
+
```bash
|
|
581
|
+
npm run build:vscode
|
|
582
|
+
```
|
|
583
|
+
|
|
567
584
|
## Development
|
|
568
585
|
|
|
569
586
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slxu/graphsx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A small React-like inline graph DSL parser and model builder.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "vite build",
|
|
33
33
|
"build:pages": "vite build --base=/graphsx/",
|
|
34
|
+
"build:vscode": "node scripts/build-vscode-extension.js",
|
|
34
35
|
"dev": "vite --host 127.0.0.1",
|
|
35
36
|
"generate:readme-assets": "node scripts/generate-readme-assets.js",
|
|
36
37
|
"playground": "vite --host 127.0.0.1",
|
|
@@ -43,14 +44,27 @@
|
|
|
43
44
|
"diagram"
|
|
44
45
|
],
|
|
45
46
|
"license": "MIT",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@codemirror/state": "^6.6.0",
|
|
49
|
+
"@codemirror/view": "^6.43.1"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"@codemirror/state": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"@codemirror/view": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
48
58
|
},
|
|
49
|
-
"
|
|
59
|
+
"devDependencies": {
|
|
50
60
|
"@codemirror/lang-javascript": "^6.2.5",
|
|
51
61
|
"@codemirror/lang-markdown": "^6.5.0",
|
|
62
|
+
"@codemirror/state": "^6.6.0",
|
|
63
|
+
"@codemirror/view": "^6.43.1",
|
|
52
64
|
"codemirror": "^6.0.2",
|
|
65
|
+
"esbuild": "^0.27.7",
|
|
53
66
|
"katex": "^0.17.0",
|
|
54
|
-
"markdown-it": "^14.2.0"
|
|
67
|
+
"markdown-it": "^14.2.0",
|
|
68
|
+
"vite": "^7.0.0"
|
|
55
69
|
}
|
|
56
70
|
}
|
package/src/renderer.js
CHANGED
|
@@ -163,6 +163,9 @@ function drawShape(context, node, offsetX, offsetY) {
|
|
|
163
163
|
cx: node.transform ? node.x : node.x + offsetX,
|
|
164
164
|
cy: node.transform ? node.y : node.y + offsetY,
|
|
165
165
|
r,
|
|
166
|
+
fill: "#ffffff",
|
|
167
|
+
stroke: "#26312d",
|
|
168
|
+
"stroke-width": 2,
|
|
166
169
|
...(transform ? { transform } : {})
|
|
167
170
|
});
|
|
168
171
|
}
|
|
@@ -174,6 +177,9 @@ function drawShape(context, node, offsetX, offsetY) {
|
|
|
174
177
|
width: Number(node.attrs.w ?? 100),
|
|
175
178
|
height: Number(node.attrs.h ?? 60),
|
|
176
179
|
rx: Number(node.attrs.corner ?? node.attrs.rx ?? 6),
|
|
180
|
+
fill: "#ffffff",
|
|
181
|
+
stroke: "#26312d",
|
|
182
|
+
"stroke-width": 2,
|
|
177
183
|
...(transform ? { transform } : {})
|
|
178
184
|
});
|
|
179
185
|
}
|
|
@@ -189,7 +195,10 @@ function drawGroupBox(context, node, offsetX, offsetY) {
|
|
|
189
195
|
y: bounds.minY + offsetY - padding,
|
|
190
196
|
width: Math.max(80, bounds.maxX - bounds.minX + padding * 2),
|
|
191
197
|
height: Math.max(54, bounds.maxY - bounds.minY + padding * 2),
|
|
192
|
-
rx: 8
|
|
198
|
+
rx: 8,
|
|
199
|
+
fill: "rgba(45, 108, 223, 0.05)",
|
|
200
|
+
stroke: "rgba(45, 108, 223, 0.45)",
|
|
201
|
+
"stroke-dasharray": "6 5"
|
|
193
202
|
}));
|
|
194
203
|
appendMaybe(box, drawNodeLabel(context, node, offsetX, offsetY, {
|
|
195
204
|
x: node.x,
|
|
@@ -217,7 +226,10 @@ function drawLeg(context, leg, offsetX, offsetY) {
|
|
|
217
226
|
class: "leg-dot",
|
|
218
227
|
cx: leg.x + offsetX,
|
|
219
228
|
cy: leg.y + offsetY,
|
|
220
|
-
r: Number(leg.attrs.r ?? 5)
|
|
229
|
+
r: Number(leg.attrs.r ?? 5),
|
|
230
|
+
fill: "#16846f",
|
|
231
|
+
stroke: "#ffffff",
|
|
232
|
+
"stroke-width": 2
|
|
221
233
|
}));
|
|
222
234
|
if (leg.attrs.label != null) {
|
|
223
235
|
group.append(drawLabel(context, leg.attrs.label, leg.x + offsetX + 10, leg.y + offsetY - 10, "leg-label", "start"));
|
|
@@ -228,6 +240,9 @@ function drawLeg(context, leg, offsetX, offsetY) {
|
|
|
228
240
|
function drawEdge(context, edge, from, to, offsetX, offsetY) {
|
|
229
241
|
return styledEl(context, "path", edge.attrs.style, {
|
|
230
242
|
class: "edge",
|
|
243
|
+
fill: "none",
|
|
244
|
+
stroke: "#2d6cdf",
|
|
245
|
+
"stroke-width": 2.5,
|
|
231
246
|
...arrowMarkerAttrs(context, edge.attrs),
|
|
232
247
|
d: edgePathData(edge, from, to, offsetX, offsetY, context)
|
|
233
248
|
});
|
|
@@ -238,7 +253,7 @@ function drawPath(context, path, offsetX, offsetY) {
|
|
|
238
253
|
class: "path",
|
|
239
254
|
fill: "none",
|
|
240
255
|
stroke: "#111111",
|
|
241
|
-
|
|
256
|
+
"stroke-width": 2,
|
|
242
257
|
...arrowMarkerAttrs(context, path.attrs),
|
|
243
258
|
d: explicitPathData(path, offsetX, offsetY)
|
|
244
259
|
};
|