backpack-viewer 0.1.3
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 +94 -0
- package/bin/serve.js +19 -0
- package/index.html +17 -0
- package/package.json +39 -0
- package/src/api.ts +13 -0
- package/src/canvas.ts +409 -0
- package/src/colors.ts +40 -0
- package/src/info-panel.ts +230 -0
- package/src/layout.ts +138 -0
- package/src/main.ts +68 -0
- package/src/sidebar.ts +80 -0
- package/src/style.css +337 -0
- package/tsconfig.json +15 -0
- package/tsconfig.node.json +13 -0
- package/vite.config.ts +75 -0
package/src/style.css
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
* {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body {
|
|
8
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
9
|
+
background: #141414;
|
|
10
|
+
color: #d4d4d4;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#app {
|
|
15
|
+
display: flex;
|
|
16
|
+
height: 100vh;
|
|
17
|
+
width: 100vw;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* --- Sidebar --- */
|
|
21
|
+
|
|
22
|
+
#sidebar {
|
|
23
|
+
width: 280px;
|
|
24
|
+
min-width: 280px;
|
|
25
|
+
background: #1a1a1a;
|
|
26
|
+
border-right: 1px solid #2a2a2a;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
padding: 16px;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#sidebar h2 {
|
|
34
|
+
font-size: 13px;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
letter-spacing: 0.05em;
|
|
38
|
+
color: #737373;
|
|
39
|
+
margin-bottom: 14px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#sidebar input {
|
|
43
|
+
width: 100%;
|
|
44
|
+
padding: 8px 12px;
|
|
45
|
+
border: 1px solid #2a2a2a;
|
|
46
|
+
border-radius: 6px;
|
|
47
|
+
background: #141414;
|
|
48
|
+
color: #d4d4d4;
|
|
49
|
+
font-size: 13px;
|
|
50
|
+
outline: none;
|
|
51
|
+
margin-bottom: 12px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#sidebar input:focus {
|
|
55
|
+
border-color: #d4a27f;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#sidebar input::placeholder {
|
|
59
|
+
color: #525252;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#ontology-list {
|
|
63
|
+
list-style: none;
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: 2px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ontology-item {
|
|
70
|
+
padding: 10px 12px;
|
|
71
|
+
border-radius: 6px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
transition: background 0.15s;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ontology-item:hover {
|
|
77
|
+
background: #222222;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ontology-item.active {
|
|
81
|
+
background: #2a2a2a;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.ontology-item .name {
|
|
85
|
+
display: block;
|
|
86
|
+
font-size: 13px;
|
|
87
|
+
font-weight: 500;
|
|
88
|
+
color: #d4d4d4;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ontology-item .stats {
|
|
92
|
+
display: block;
|
|
93
|
+
font-size: 11px;
|
|
94
|
+
color: #525252;
|
|
95
|
+
margin-top: 2px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* --- Sidebar Footer --- */
|
|
99
|
+
|
|
100
|
+
.sidebar-footer {
|
|
101
|
+
margin-top: auto;
|
|
102
|
+
padding-top: 16px;
|
|
103
|
+
border-top: 1px solid #2a2a2a;
|
|
104
|
+
text-align: center;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.sidebar-footer a {
|
|
108
|
+
display: block;
|
|
109
|
+
font-size: 12px;
|
|
110
|
+
font-weight: 500;
|
|
111
|
+
color: #d4a27f;
|
|
112
|
+
text-decoration: none;
|
|
113
|
+
margin-bottom: 4px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.sidebar-footer a:hover {
|
|
117
|
+
color: #e8b898;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.sidebar-footer span {
|
|
121
|
+
display: block;
|
|
122
|
+
font-size: 10px;
|
|
123
|
+
color: #525252;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* --- Canvas --- */
|
|
127
|
+
|
|
128
|
+
#canvas-container {
|
|
129
|
+
flex: 1;
|
|
130
|
+
position: relative;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#graph-canvas {
|
|
135
|
+
position: absolute;
|
|
136
|
+
top: 0;
|
|
137
|
+
left: 0;
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 100%;
|
|
140
|
+
cursor: grab;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#graph-canvas:active {
|
|
144
|
+
cursor: grabbing;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* --- Info Panel --- */
|
|
148
|
+
|
|
149
|
+
.info-panel {
|
|
150
|
+
position: absolute;
|
|
151
|
+
top: 16px;
|
|
152
|
+
right: 16px;
|
|
153
|
+
width: 360px;
|
|
154
|
+
max-height: calc(100vh - 32px);
|
|
155
|
+
background: #1a1a1a;
|
|
156
|
+
border: 1px solid #2a2a2a;
|
|
157
|
+
border-radius: 10px;
|
|
158
|
+
overflow-y: auto;
|
|
159
|
+
padding: 20px;
|
|
160
|
+
z-index: 10;
|
|
161
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.info-panel.hidden {
|
|
165
|
+
display: none;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.info-close {
|
|
169
|
+
position: absolute;
|
|
170
|
+
top: 12px;
|
|
171
|
+
right: 14px;
|
|
172
|
+
background: none;
|
|
173
|
+
border: none;
|
|
174
|
+
color: #737373;
|
|
175
|
+
font-size: 20px;
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
line-height: 1;
|
|
178
|
+
padding: 4px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.info-close:hover {
|
|
182
|
+
color: #d4d4d4;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* Header */
|
|
186
|
+
|
|
187
|
+
.info-header {
|
|
188
|
+
margin-bottom: 16px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.info-type-badge {
|
|
192
|
+
display: inline-block;
|
|
193
|
+
padding: 3px 10px;
|
|
194
|
+
border-radius: 12px;
|
|
195
|
+
font-size: 11px;
|
|
196
|
+
font-weight: 600;
|
|
197
|
+
color: #141414;
|
|
198
|
+
margin-bottom: 8px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.info-label {
|
|
202
|
+
font-size: 18px;
|
|
203
|
+
font-weight: 600;
|
|
204
|
+
color: #e5e5e5;
|
|
205
|
+
margin-bottom: 4px;
|
|
206
|
+
word-break: break-word;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.info-id {
|
|
210
|
+
display: block;
|
|
211
|
+
font-size: 11px;
|
|
212
|
+
color: #525252;
|
|
213
|
+
font-family: monospace;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* Sections */
|
|
217
|
+
|
|
218
|
+
.info-section {
|
|
219
|
+
margin-bottom: 16px;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.info-section-title {
|
|
223
|
+
font-size: 11px;
|
|
224
|
+
font-weight: 600;
|
|
225
|
+
text-transform: uppercase;
|
|
226
|
+
letter-spacing: 0.05em;
|
|
227
|
+
color: #737373;
|
|
228
|
+
margin-bottom: 8px;
|
|
229
|
+
padding-bottom: 4px;
|
|
230
|
+
border-bottom: 1px solid #2a2a2a;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Properties */
|
|
234
|
+
|
|
235
|
+
.info-props {
|
|
236
|
+
display: grid;
|
|
237
|
+
grid-template-columns: auto 1fr;
|
|
238
|
+
gap: 4px 12px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.info-props dt {
|
|
242
|
+
font-size: 12px;
|
|
243
|
+
color: #737373;
|
|
244
|
+
padding-top: 2px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.info-props dd {
|
|
248
|
+
font-size: 12px;
|
|
249
|
+
color: #d4d4d4;
|
|
250
|
+
word-break: break-word;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.info-value {
|
|
254
|
+
white-space: pre-wrap;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.info-array {
|
|
258
|
+
display: flex;
|
|
259
|
+
flex-wrap: wrap;
|
|
260
|
+
gap: 4px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.info-tag {
|
|
264
|
+
display: inline-block;
|
|
265
|
+
padding: 2px 8px;
|
|
266
|
+
background: #222222;
|
|
267
|
+
border-radius: 4px;
|
|
268
|
+
font-size: 11px;
|
|
269
|
+
color: #a3a3a3;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.info-json {
|
|
273
|
+
font-size: 11px;
|
|
274
|
+
font-family: monospace;
|
|
275
|
+
color: #a3a3a3;
|
|
276
|
+
background: #111111;
|
|
277
|
+
padding: 6px 8px;
|
|
278
|
+
border-radius: 4px;
|
|
279
|
+
overflow-x: auto;
|
|
280
|
+
white-space: pre;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* Connections */
|
|
284
|
+
|
|
285
|
+
.info-connections {
|
|
286
|
+
list-style: none;
|
|
287
|
+
display: flex;
|
|
288
|
+
flex-direction: column;
|
|
289
|
+
gap: 6px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.info-connection {
|
|
293
|
+
display: flex;
|
|
294
|
+
align-items: center;
|
|
295
|
+
gap: 6px;
|
|
296
|
+
padding: 6px 8px;
|
|
297
|
+
background: #1e1e1e;
|
|
298
|
+
border-radius: 6px;
|
|
299
|
+
font-size: 12px;
|
|
300
|
+
flex-wrap: wrap;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.info-target-dot {
|
|
304
|
+
width: 8px;
|
|
305
|
+
height: 8px;
|
|
306
|
+
border-radius: 50%;
|
|
307
|
+
flex-shrink: 0;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.info-arrow {
|
|
311
|
+
color: #525252;
|
|
312
|
+
font-size: 14px;
|
|
313
|
+
flex-shrink: 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.info-edge-type {
|
|
317
|
+
color: #737373;
|
|
318
|
+
font-size: 11px;
|
|
319
|
+
font-weight: 500;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.info-target {
|
|
323
|
+
color: #d4d4d4;
|
|
324
|
+
font-weight: 500;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.info-edge-props {
|
|
328
|
+
width: 100%;
|
|
329
|
+
padding-top: 4px;
|
|
330
|
+
padding-left: 20px;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.info-edge-prop {
|
|
334
|
+
display: block;
|
|
335
|
+
font-size: 11px;
|
|
336
|
+
color: #525252;
|
|
337
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
12
|
+
"types": ["vite/client"]
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*.ts"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"types": ["node"]
|
|
11
|
+
},
|
|
12
|
+
"include": ["vite.config.ts"]
|
|
13
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineConfig, type Plugin } from "vite";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { JsonFileBackend, dataDir } from "backpack-ontology";
|
|
5
|
+
import type { StorageBackend } from "backpack-ontology";
|
|
6
|
+
|
|
7
|
+
function ontologyApiPlugin(): Plugin {
|
|
8
|
+
let storage: StorageBackend;
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
name: "ontology-api",
|
|
12
|
+
|
|
13
|
+
configureServer(server) {
|
|
14
|
+
storage = new JsonFileBackend();
|
|
15
|
+
storage.initialize();
|
|
16
|
+
|
|
17
|
+
// Watch the ontologies directory for live updates from Claude/MCP
|
|
18
|
+
const ontologiesDir = path.join(dataDir(), "ontologies");
|
|
19
|
+
try {
|
|
20
|
+
fs.watch(ontologiesDir, { recursive: true }, () => {
|
|
21
|
+
server.ws.send({
|
|
22
|
+
type: "custom",
|
|
23
|
+
event: "ontology-change",
|
|
24
|
+
data: {},
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
} catch {
|
|
28
|
+
// Directory may not exist yet
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
server.middlewares.use((req, res, next) => {
|
|
32
|
+
if (!req.url?.startsWith("/api/ontologies")) return next();
|
|
33
|
+
|
|
34
|
+
const urlPath = req.url.replace(/\?.*$/, "");
|
|
35
|
+
|
|
36
|
+
// GET /api/ontologies
|
|
37
|
+
if (urlPath === "/api/ontologies") {
|
|
38
|
+
storage
|
|
39
|
+
.listOntologies()
|
|
40
|
+
.then((summaries) => {
|
|
41
|
+
res.setHeader("Content-Type", "application/json");
|
|
42
|
+
res.end(JSON.stringify(summaries));
|
|
43
|
+
})
|
|
44
|
+
.catch(() => {
|
|
45
|
+
res.setHeader("Content-Type", "application/json");
|
|
46
|
+
res.end("[]");
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// GET /api/ontologies/:name
|
|
52
|
+
const name = decodeURIComponent(
|
|
53
|
+
urlPath.replace("/api/ontologies/", "")
|
|
54
|
+
);
|
|
55
|
+
if (!name) return next();
|
|
56
|
+
|
|
57
|
+
storage
|
|
58
|
+
.loadOntology(name)
|
|
59
|
+
.then((data) => {
|
|
60
|
+
res.setHeader("Content-Type", "application/json");
|
|
61
|
+
res.end(JSON.stringify(data));
|
|
62
|
+
})
|
|
63
|
+
.catch(() => {
|
|
64
|
+
res.statusCode = 404;
|
|
65
|
+
res.setHeader("Content-Type", "application/json");
|
|
66
|
+
res.end(JSON.stringify({ error: "Ontology not found" }));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default defineConfig({
|
|
74
|
+
plugins: [ontologyApiPlugin()],
|
|
75
|
+
});
|