@matdata/yasgui-graph-plugin 1.2.0 โ 1.4.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 +310 -301
- package/dist/yasgui-graph-plugin.cjs.css +103 -0
- package/dist/yasgui-graph-plugin.cjs.css.map +7 -0
- package/dist/yasgui-graph-plugin.cjs.js +456 -756
- package/dist/yasgui-graph-plugin.cjs.js.map +4 -4
- package/dist/yasgui-graph-plugin.css +117 -0
- package/dist/yasgui-graph-plugin.esm.css +103 -0
- package/dist/yasgui-graph-plugin.esm.css.map +7 -0
- package/dist/yasgui-graph-plugin.esm.js +451 -752
- package/dist/yasgui-graph-plugin.esm.js.map +4 -4
- package/dist/yasgui-graph-plugin.min.css +2 -0
- package/dist/yasgui-graph-plugin.min.css.map +7 -0
- package/dist/yasgui-graph-plugin.min.js +17 -17
- package/dist/yasgui-graph-plugin.min.js.map +4 -4
- package/package.json +22 -5
package/README.md
CHANGED
|
@@ -1,301 +1,310 @@
|
|
|
1
|
-
# YASGUI Graph Plugin
|
|
2
|
-
|
|
3
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
-
[](https://www.npmjs.com/package/@matdata/yasgui-graph-plugin)
|
|
5
|
-
|
|
6
|
-
A YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs with nodes (subjects/objects) and edges (predicates).
|
|
7
|
-
|
|
8
|
-
## โจ Features
|
|
9
|
-
|
|
10
|
-
- **๐ท Interactive Graph Visualization**: Automatic force-directed layout with smooth physics-based positioning
|
|
11
|
-
- **๐จ Smart Color Coding**:
|
|
12
|
-
- ๐ต Light Blue (#97C2FC) = URIs
|
|
13
|
-
- ๐ข Light Green (#a6c8a6ff) = Literals
|
|
14
|
-
- โช Light Grey (#c5c5c5ff) = Blank nodes
|
|
15
|
-
- ๐ Orange (#e15b13ff) = rdf:type objects (classes)
|
|
16
|
-
- **๐ Navigation**: Mouse wheel zoom, drag to pan, "Zoom to Fit" button
|
|
17
|
-
- **โ Drag & Drop**: Reorganize nodes by dragging them to new positions
|
|
18
|
-
- **๐ฌ Tooltips**: Hover for full URI/literal details (300ms delay)
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
PREFIX
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
ex:Alice
|
|
79
|
-
ex:Alice ex:
|
|
80
|
-
ex:
|
|
81
|
-
ex:Bob ex:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
- **
|
|
101
|
-
- **
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- **
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
npm
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
- โ
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
-
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
###
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
|
|
234
|
-
###
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
1
|
+
# YASGUI Graph Plugin
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
+
[](https://www.npmjs.com/package/@matdata/yasgui-graph-plugin)
|
|
5
|
+
|
|
6
|
+
A YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs with nodes (subjects/objects) and edges (predicates).
|
|
7
|
+
|
|
8
|
+
## โจ Features
|
|
9
|
+
|
|
10
|
+
- **๐ท Interactive Graph Visualization**: Automatic force-directed layout with smooth physics-based positioning
|
|
11
|
+
- **๐จ Smart Color Coding**:
|
|
12
|
+
- ๐ต Light Blue (#97C2FC) = URIs
|
|
13
|
+
- ๐ข Light Green (#a6c8a6ff) = Literals
|
|
14
|
+
- โช Light Grey (#c5c5c5ff) = Blank nodes
|
|
15
|
+
- ๐ Orange (#e15b13ff) = rdf:type objects (classes)
|
|
16
|
+
- **๐ Navigation**: Mouse wheel zoom, drag to pan, "Zoom to Fit" button
|
|
17
|
+
- **โ Drag & Drop**: Reorganize nodes by dragging them to new positions
|
|
18
|
+
- **๐ฌ Tooltips**: Hover for full URI/literal details (300ms delay)
|
|
19
|
+
- **๐ Theme Support**: Automatic light/dark mode detection and dynamic color switching
|
|
20
|
+
- **โก Performance**: Handles up to 1,000 nodes with <2s render time
|
|
21
|
+
- **โฟ Accessible**: WCAG AA color contrast, keyboard navigation support
|
|
22
|
+
|
|
23
|
+
## ๐ฆ Installation
|
|
24
|
+
|
|
25
|
+
### NPM
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @matdata/yasgui-graph-plugin
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
import Yasgui from '@matdata/yasgui';
|
|
33
|
+
import GraphPlugin from '@matdata/yasgui-graph-plugin';
|
|
34
|
+
|
|
35
|
+
Yasgui.Yasr.registerPlugin('Graph', GraphPlugin);
|
|
36
|
+
|
|
37
|
+
const yasgui = new Yasgui(document.getElementById('yasgui'));
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### CDN (UMD)
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<!-- YASGUI -->
|
|
44
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@matdata/yasgui/build/yasgui.min.css">
|
|
45
|
+
<script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui/build/yasgui.min.js"></script>
|
|
46
|
+
|
|
47
|
+
<!-- Graph Plugin -->
|
|
48
|
+
<script src="https://cdn.jsdelivr.net/npm/@matdata/yasgui-graph-plugin/dist/yasgui-graph-plugin.min.js"></script>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
// Plugin auto-registers as 'graph'
|
|
52
|
+
const yasgui = new Yasgui(document.getElementById('yasgui'));
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## ๐ Quick Start
|
|
57
|
+
|
|
58
|
+
See the complete working example in [`demo/index.html`](./demo/index.html).
|
|
59
|
+
|
|
60
|
+
### Basic Usage
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
const yasgui = new Yasgui(document.getElementById('yasgui'), {
|
|
64
|
+
requestConfig: {
|
|
65
|
+
endpoint: 'https://dbpedia.org/sparql'
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Sample Queries
|
|
71
|
+
|
|
72
|
+
**CONSTRUCT Query:**
|
|
73
|
+
```sparql
|
|
74
|
+
PREFIX ex: <http://example.org/>
|
|
75
|
+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
76
|
+
|
|
77
|
+
CONSTRUCT {
|
|
78
|
+
ex:Alice rdf:type ex:Person .
|
|
79
|
+
ex:Alice ex:knows ex:Bob .
|
|
80
|
+
ex:Alice ex:name "Alice" .
|
|
81
|
+
ex:Bob rdf:type ex:Person .
|
|
82
|
+
ex:Bob ex:name "Bob" .
|
|
83
|
+
}
|
|
84
|
+
WHERE {}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**DESCRIBE Query:**
|
|
88
|
+
```sparql
|
|
89
|
+
PREFIX ex: <http://example.org/>
|
|
90
|
+
|
|
91
|
+
# Returns all triples about the specified resources
|
|
92
|
+
DESCRIBE ex:Alice ex:Bob
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
After running the query, click the **"Graph"** tab to see the visualization.
|
|
96
|
+
|
|
97
|
+
## ๐ฎ User Guide
|
|
98
|
+
|
|
99
|
+
### Navigation
|
|
100
|
+
- **Zoom**: Mouse wheel (scroll up = zoom in, scroll down = zoom out)
|
|
101
|
+
- **Pan**: Click and drag the background
|
|
102
|
+
- **Fit to View**: Click the "Zoom to Fit" button to center the entire graph
|
|
103
|
+
|
|
104
|
+
### Interaction
|
|
105
|
+
- **Drag Nodes**: Click and drag any node to reposition it
|
|
106
|
+
- **Tooltips**: Hover over nodes/edges for 300ms to see full details
|
|
107
|
+
|
|
108
|
+
### Understanding Colors
|
|
109
|
+
|
|
110
|
+
| Color | Meaning | Example |
|
|
111
|
+
|-------|---------|---------||
|
|
112
|
+
| ๐ต Light Blue (#97C2FC) | URI nodes | `ex:Person`, `ex:Alice` |
|
|
113
|
+
| ๐ข Light Green (#a6c8a6ff) | Literal values | `"Alice"`, `"30"^^xsd:integer` |
|
|
114
|
+
| โช Light Grey (#c5c5c5ff) | Blank nodes | `_:b1`, `_:addr1` |
|
|
115
|
+
| ๐ Orange (#e15b13ff) | rdf:type objects (classes) | `ex:Person` in `ex:Alice rdf:type ex:Person` |
|
|
116
|
+
|
|
117
|
+
## โ๏ธ Configuration
|
|
118
|
+
|
|
119
|
+
The plugin uses sensible defaults but can be customized by extending the `GraphPlugin` class:
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
class CustomGraphPlugin extends GraphPlugin {
|
|
123
|
+
constructor(yasr) {
|
|
124
|
+
super(yasr);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Override network options
|
|
128
|
+
getNetworkOptions() {
|
|
129
|
+
return {
|
|
130
|
+
...super.getNetworkOptions(),
|
|
131
|
+
physics: {
|
|
132
|
+
enabled: true,
|
|
133
|
+
stabilization: { iterations: 100 } // Faster but less optimal layout
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
Yasgui.Yasr.registerPlugin('customGraph', CustomGraphPlugin);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## ๐ง Development
|
|
143
|
+
|
|
144
|
+
### Build
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm install
|
|
148
|
+
npm run build
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Output:
|
|
152
|
+
- `dist/yasgui-graph-plugin.esm.js` (ES Module for bundlers)
|
|
153
|
+
- `dist/yasgui-graph-plugin.cjs.js` (CommonJS for Node.js)
|
|
154
|
+
- `dist/yasgui-graph-plugin.min.js` (IIFE for browsers/unpkg)
|
|
155
|
+
- `dist/index.d.ts` (TypeScript declarations)
|
|
156
|
+
|
|
157
|
+
### Local Testing
|
|
158
|
+
|
|
159
|
+
1. Build the plugin: `npm run build`
|
|
160
|
+
2. Open `demo/index.html` in a browser (or run `npm run dev`)
|
|
161
|
+
3. Try the sample queries in different tabs
|
|
162
|
+
|
|
163
|
+
### Code Quality
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm run lint # ESLint check
|
|
167
|
+
npm run format # Prettier format
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## ๐ Documentation
|
|
171
|
+
|
|
172
|
+
- **[Quickstart Guide](./specs/001-construct-graph-viz/quickstart.md)** - Installation, usage, troubleshooting
|
|
173
|
+
- **[Data Model](./specs/001-construct-graph-viz/data-model.md)** - Entity definitions and relationships
|
|
174
|
+
- **[Contracts](./specs/001-construct-graph-viz/contracts/)** - API specifications for YASR plugin and vis-network integration
|
|
175
|
+
- **[Specification](./specs/001-construct-graph-viz/spec.md)** - Complete feature specification
|
|
176
|
+
- **[Constitution](./. specify/memory/constitution.md)** - Project governance and principles
|
|
177
|
+
|
|
178
|
+
## ๐งช Browser Compatibility
|
|
179
|
+
|
|
180
|
+
Tested on latest 2 versions of:
|
|
181
|
+
- โ
Chrome
|
|
182
|
+
- โ
Firefox
|
|
183
|
+
- โ
Safari
|
|
184
|
+
- โ
Edge
|
|
185
|
+
|
|
186
|
+
Requires ES2018+ support and Canvas API.
|
|
187
|
+
|
|
188
|
+
## ๐ค Contributing
|
|
189
|
+
|
|
190
|
+
Contributions welcome! Please follow the project constitution (`.specify/memory/constitution.md`) for governance principles:
|
|
191
|
+
|
|
192
|
+
1. **Plugin-First Architecture** - No YASGUI core modifications
|
|
193
|
+
2. **Visualization Quality** - Performance (<2s for 1k nodes), accessibility (WCAG AA)
|
|
194
|
+
3. **Configuration Flexibility** - Sensible defaults, but customizable
|
|
195
|
+
4. **Browser Compatibility** - ES2018+, latest 2 browser versions
|
|
196
|
+
5. **Documentation** - Keep docs updated with changes
|
|
197
|
+
|
|
198
|
+
## ๐ License
|
|
199
|
+
|
|
200
|
+
[Apache 2.0](./LICENSE)
|
|
201
|
+
|
|
202
|
+
## ๐ Acknowledgments
|
|
203
|
+
|
|
204
|
+
- Built with [vis-network](https://visjs.github.io/vis-network/) for graph rendering
|
|
205
|
+
- Integrates with [YASGUI](https://github.com/matdata/yasgui) SPARQL editor
|
|
206
|
+
- Follows the [yasgui-geo](https://github.com/matdata/yasgui-geo) plugin pattern
|
|
207
|
+
|
|
208
|
+
## ๐ Project Status
|
|
209
|
+
|
|
210
|
+
**Current Version**: 0.1.0 (MVP)
|
|
211
|
+
|
|
212
|
+
**Implemented Features** (v0.1.0):
|
|
213
|
+
- โ
Basic graph visualization (US1)
|
|
214
|
+
- โ
Navigation controls (US2)
|
|
215
|
+
- โ
Color-coded nodes
|
|
216
|
+
- โ
Prefix abbreviation
|
|
217
|
+
- โ
Blank node support
|
|
218
|
+
- โ
Performance optimization
|
|
219
|
+
|
|
220
|
+
**Planned Features** (Future):
|
|
221
|
+
- โณ Enhanced tooltips with datatype display (US4)
|
|
222
|
+
- โณ Manual testing across all browsers (US3 verification)
|
|
223
|
+
- โณ Large graph optimization (>1k nodes)
|
|
224
|
+
- โณ Custom color schemes
|
|
225
|
+
- โณ Layout algorithm selection
|
|
226
|
+
|
|
227
|
+
## ๐ Troubleshooting
|
|
228
|
+
|
|
229
|
+
### Plugin tab not showing
|
|
230
|
+
- Verify plugin is registered correctly
|
|
231
|
+
- Check browser console for errors
|
|
232
|
+
- Ensure you're running a CONSTRUCT or DESCRIBE query
|
|
233
|
+
|
|
234
|
+
### Empty visualization
|
|
235
|
+
- Ensure query type is **CONSTRUCT** or **DESCRIBE**
|
|
236
|
+
- Confirm query returns triples (check "Table" or "Response" tab)
|
|
237
|
+
- Verify results have RDF structure
|
|
238
|
+
|
|
239
|
+
### Performance issues
|
|
240
|
+
- Limit results to <1000 nodes for best performance
|
|
241
|
+
- Disable physics after initial layout
|
|
242
|
+
- Consider using LIMIT clause in SPARQL query
|
|
243
|
+
|
|
244
|
+
For more help, see [Quickstart Guide - Troubleshooting](./specs/001-construct-graph-viz/quickstart.md#troubleshooting).
|
|
245
|
+
|
|
246
|
+
## ๐ ๏ธ Development
|
|
247
|
+
|
|
248
|
+
### Setup
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
git clone https://github.com/yourusername/yasgui-graph-plugin.git
|
|
252
|
+
cd yasgui-graph-plugin
|
|
253
|
+
npm install
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Dev Workflow (Live Reload)
|
|
257
|
+
|
|
258
|
+
The project supports **live development** - edit source files and see changes immediately without rebuilding:
|
|
259
|
+
|
|
260
|
+
1. **Start a local dev server** (any HTTP server will work):
|
|
261
|
+
```bash
|
|
262
|
+
# Using Python
|
|
263
|
+
python -m http.server 8000
|
|
264
|
+
|
|
265
|
+
# Using Node.js (http-server)
|
|
266
|
+
npx http-server -p 8000
|
|
267
|
+
|
|
268
|
+
# Using VS Code Live Server extension
|
|
269
|
+
# Right-click demo/index.html โ "Open with Live Server"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
2. **Open demo in browser**:
|
|
273
|
+
```
|
|
274
|
+
http://localhost:8000/demo/index.html
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
3. **Edit source files** (e.g., `src/colorUtils.js`):
|
|
278
|
+
```javascript
|
|
279
|
+
export function getNodeColor(node) {
|
|
280
|
+
// Change colors here
|
|
281
|
+
if (node.isBlankNode) return '#FF00FF'; // Magenta
|
|
282
|
+
// ...
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
4. **Refresh browser** - changes appear immediately! โก
|
|
287
|
+
|
|
288
|
+
The demo automatically loads ES modules directly from `src/` in development mode, so no rebuild is needed.
|
|
289
|
+
|
|
290
|
+
### Production Build
|
|
291
|
+
|
|
292
|
+
Build all distribution formats:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
npm run build
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Outputs:
|
|
299
|
+
- `dist/yasgui-graph-plugin.esm.js` - ES Module format (bundled with vis-network)
|
|
300
|
+
- `dist/yasgui-graph-plugin.cjs.js` - CommonJS format (bundled with vis-network)
|
|
301
|
+
- `dist/yasgui-graph-plugin.min.js` - IIFE browser bundle (bundled with vis-network)
|
|
302
|
+
- `dist/index.d.ts` - TypeScript type declarations
|
|
303
|
+
|
|
304
|
+
### Testing
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
npm test # Run all tests
|
|
308
|
+
npm run lint # Check code style
|
|
309
|
+
npm run format # Auto-fix formatting
|
|
310
|
+
```
|