code-kg 0.1.12 → 0.1.14
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/dist/server/ui.js +101 -43
- package/dist/server/ui.js.map +1 -1
- package/package.json +1 -1
package/dist/server/ui.js
CHANGED
|
@@ -584,7 +584,7 @@ function renderUiHtml() {
|
|
|
584
584
|
const POINTER_INTERACTION_MAX_EDGES = 15000;
|
|
585
585
|
|
|
586
586
|
const state = {
|
|
587
|
-
view: '
|
|
587
|
+
view: 'all',
|
|
588
588
|
graph: null,
|
|
589
589
|
graphData: { nodes: [], links: [], nodeById: new Map() },
|
|
590
590
|
graphMeta: null,
|
|
@@ -601,6 +601,7 @@ function renderUiHtml() {
|
|
|
601
601
|
wasmWorkerSeq: 0,
|
|
602
602
|
wasmWorkerPending: new Map(),
|
|
603
603
|
graphChunkTimer: null,
|
|
604
|
+
graphFitTimer: null,
|
|
604
605
|
graphChunkToken: 0,
|
|
605
606
|
sidePanelToken: 0,
|
|
606
607
|
layoutEngine: 'js',
|
|
@@ -612,7 +613,6 @@ function renderUiHtml() {
|
|
|
612
613
|
lastRoutes: [],
|
|
613
614
|
lastInsights: null
|
|
614
615
|
};
|
|
615
|
-
|
|
616
616
|
const NODE_COLORS = {
|
|
617
617
|
file: '#9cff3f',
|
|
618
618
|
function: '#bf84ff',
|
|
@@ -627,13 +627,13 @@ function renderUiHtml() {
|
|
|
627
627
|
|
|
628
628
|
const EDGE_COLORS = {
|
|
629
629
|
IMPORTS: '#9cff3f',
|
|
630
|
-
DEPENDS_ON: '#
|
|
631
|
-
CALLS: '#
|
|
632
|
-
REFERENCES: '#
|
|
630
|
+
DEPENDS_ON: '#97f143',
|
|
631
|
+
CALLS: '#8fe038',
|
|
632
|
+
REFERENCES: '#8ad736',
|
|
633
633
|
HANDLES_ROUTE: '#73efff',
|
|
634
|
-
DEFINES: '#
|
|
635
|
-
EXPORTS: '#
|
|
636
|
-
CONTAINS: '#
|
|
634
|
+
DEFINES: '#90df3a',
|
|
635
|
+
EXPORTS: '#8edd3b',
|
|
636
|
+
CONTAINS: '#85d433',
|
|
637
637
|
MODULE_DEPENDS_ON: '#9cff3f'
|
|
638
638
|
};
|
|
639
639
|
|
|
@@ -727,12 +727,12 @@ function renderUiHtml() {
|
|
|
727
727
|
|
|
728
728
|
function modeScale(mode) {
|
|
729
729
|
if (mode === 'extreme') {
|
|
730
|
-
return
|
|
730
|
+
return 1;
|
|
731
731
|
}
|
|
732
732
|
if (mode === 'degraded') {
|
|
733
|
-
return
|
|
733
|
+
return 1;
|
|
734
734
|
}
|
|
735
|
-
return 1;
|
|
735
|
+
return 1.02;
|
|
736
736
|
}
|
|
737
737
|
|
|
738
738
|
function isWasmLayoutEngine(value) {
|
|
@@ -998,18 +998,20 @@ function renderUiHtml() {
|
|
|
998
998
|
if (positions.length < expected) {
|
|
999
999
|
return false;
|
|
1000
1000
|
}
|
|
1001
|
+
const nodeCount = state.graphData.nodes.length;
|
|
1002
|
+
const spreadScale = nodeCount >= 60000 ? 220 : nodeCount >= 30000 ? 180 : nodeCount >= 12000 ? 140 : 110;
|
|
1001
1003
|
for (let index = 0; index < state.graphData.nodes.length; index += 1) {
|
|
1002
1004
|
const node = state.graphData.nodes[index];
|
|
1003
1005
|
const base = index * 3;
|
|
1004
|
-
const x = positions[base];
|
|
1005
|
-
const y = positions[base + 1];
|
|
1006
|
-
const z = positions[base + 2];
|
|
1006
|
+
const x = positions[base] * spreadScale;
|
|
1007
|
+
const y = positions[base + 1] * spreadScale;
|
|
1008
|
+
const z = positions[base + 2] * spreadScale;
|
|
1007
1009
|
node.x = x;
|
|
1008
1010
|
node.y = y;
|
|
1009
1011
|
node.z = z;
|
|
1010
|
-
node.fx =
|
|
1011
|
-
node.fy =
|
|
1012
|
-
node.fz =
|
|
1012
|
+
node.fx = undefined;
|
|
1013
|
+
node.fy = undefined;
|
|
1014
|
+
node.fz = undefined;
|
|
1013
1015
|
node.__renderVisible = true;
|
|
1014
1016
|
nodeById.set(node.id, node);
|
|
1015
1017
|
}
|
|
@@ -1170,6 +1172,31 @@ function renderUiHtml() {
|
|
|
1170
1172
|
window.clearTimeout(state.graphChunkTimer);
|
|
1171
1173
|
state.graphChunkTimer = null;
|
|
1172
1174
|
}
|
|
1175
|
+
if (state.graphFitTimer) {
|
|
1176
|
+
window.clearTimeout(state.graphFitTimer);
|
|
1177
|
+
state.graphFitTimer = null;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
function scheduleZoomToFit(delayMs) {
|
|
1182
|
+
if (!state.graph || typeof state.graph.zoomToFit !== 'function') {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
if (state.graphFitTimer) {
|
|
1186
|
+
window.clearTimeout(state.graphFitTimer);
|
|
1187
|
+
state.graphFitTimer = null;
|
|
1188
|
+
}
|
|
1189
|
+
state.graphFitTimer = window.setTimeout(() => {
|
|
1190
|
+
state.graphFitTimer = null;
|
|
1191
|
+
if (!state.graph || typeof state.graph.zoomToFit !== 'function') {
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
try {
|
|
1195
|
+
state.graph.zoomToFit(700, 56);
|
|
1196
|
+
} catch (_error) {
|
|
1197
|
+
// Best effort only.
|
|
1198
|
+
}
|
|
1199
|
+
}, Math.max(0, delayMs || 0));
|
|
1173
1200
|
}
|
|
1174
1201
|
|
|
1175
1202
|
function bindGraphData() {
|
|
@@ -1181,6 +1208,7 @@ function renderUiHtml() {
|
|
|
1181
1208
|
const totalEdges = Array.isArray(state.graphData.links) ? state.graphData.links.length : 0;
|
|
1182
1209
|
if (totalEdges <= EDGE_CHUNK_THRESHOLD) {
|
|
1183
1210
|
state.graph.graphData(state.graphData);
|
|
1211
|
+
scheduleZoomToFit(180);
|
|
1184
1212
|
return;
|
|
1185
1213
|
}
|
|
1186
1214
|
|
|
@@ -1203,6 +1231,7 @@ function renderUiHtml() {
|
|
|
1203
1231
|
state.graphChunkTimer = window.setTimeout(pump, 0);
|
|
1204
1232
|
} else {
|
|
1205
1233
|
state.graphChunkTimer = null;
|
|
1234
|
+
scheduleZoomToFit(220);
|
|
1206
1235
|
}
|
|
1207
1236
|
};
|
|
1208
1237
|
|
|
@@ -1222,26 +1251,42 @@ function renderUiHtml() {
|
|
|
1222
1251
|
|
|
1223
1252
|
const usingWasmLayout = isWasmLayoutEngine(state.layoutEngine);
|
|
1224
1253
|
if (typeof graph.cooldownTicks === 'function') {
|
|
1225
|
-
graph.cooldownTicks(
|
|
1254
|
+
graph.cooldownTicks(
|
|
1255
|
+
usingWasmLayout
|
|
1256
|
+
? (mode === 'normal' ? 72 : mode === 'degraded' ? 30 : 12)
|
|
1257
|
+
: (mode === 'normal' ? 220 : mode === 'degraded' ? 72 : 28)
|
|
1258
|
+
);
|
|
1226
1259
|
}
|
|
1227
1260
|
if (typeof graph.cooldownTime === 'function') {
|
|
1228
|
-
graph.cooldownTime(
|
|
1261
|
+
graph.cooldownTime(
|
|
1262
|
+
usingWasmLayout
|
|
1263
|
+
? (mode === 'normal' ? 2600 : mode === 'degraded' ? 1400 : 800)
|
|
1264
|
+
: (mode === 'normal' ? 9000 : mode === 'degraded' ? 2200 : 900)
|
|
1265
|
+
);
|
|
1229
1266
|
}
|
|
1230
1267
|
if (typeof graph.warmupTicks === 'function') {
|
|
1231
|
-
graph.warmupTicks(
|
|
1268
|
+
graph.warmupTicks(
|
|
1269
|
+
usingWasmLayout
|
|
1270
|
+
? (mode === 'normal' ? 14 : mode === 'degraded' ? 7 : 4)
|
|
1271
|
+
: (mode === 'normal' ? 60 : mode === 'degraded' ? 12 : 4)
|
|
1272
|
+
);
|
|
1232
1273
|
}
|
|
1233
1274
|
if (typeof graph.d3VelocityDecay === 'function') {
|
|
1234
|
-
graph.d3VelocityDecay(
|
|
1275
|
+
graph.d3VelocityDecay(
|
|
1276
|
+
usingWasmLayout
|
|
1277
|
+
? (mode === 'normal' ? 0.36 : mode === 'degraded' ? 0.46 : 0.58)
|
|
1278
|
+
: (mode === 'normal' ? 0.28 : mode === 'degraded' ? 0.4 : 0.58)
|
|
1279
|
+
);
|
|
1235
1280
|
}
|
|
1236
1281
|
if (typeof graph.nodeResolution === 'function') {
|
|
1237
1282
|
graph.nodeResolution(mode === 'normal' ? 6 : mode === 'degraded' ? 4 : 3);
|
|
1238
1283
|
}
|
|
1239
1284
|
if (typeof graph.linkResolution === 'function') {
|
|
1240
|
-
graph.linkResolution(mode === 'normal' ?
|
|
1285
|
+
graph.linkResolution(mode === 'normal' ? 8 : 6);
|
|
1241
1286
|
}
|
|
1242
1287
|
|
|
1243
|
-
graph.linkOpacity(mode === 'normal' ? 0.
|
|
1244
|
-
graph.nodeRelSize(mode === 'normal' ? 1.
|
|
1288
|
+
graph.linkOpacity(mode === 'normal' ? 0.82 : mode === 'degraded' ? 0.84 : 0.86);
|
|
1289
|
+
graph.nodeRelSize(mode === 'normal' ? 1.75 : mode === 'degraded' ? 1.8 : 1.8);
|
|
1245
1290
|
|
|
1246
1291
|
const totalNodes = state.graphMeta && typeof state.graphMeta.totalNodes === 'number'
|
|
1247
1292
|
? state.graphMeta.totalNodes
|
|
@@ -1262,23 +1307,36 @@ function renderUiHtml() {
|
|
|
1262
1307
|
}
|
|
1263
1308
|
|
|
1264
1309
|
if (typeof graph.d3Force === 'function') {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
if (
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1310
|
+
let chargeForce = graph.d3Force('charge');
|
|
1311
|
+
let linkForce = graph.d3Force('link');
|
|
1312
|
+
if (state.defaultChargeForce && chargeForce == null) {
|
|
1313
|
+
graph.d3Force('charge', state.defaultChargeForce);
|
|
1314
|
+
chargeForce = graph.d3Force('charge');
|
|
1315
|
+
}
|
|
1316
|
+
if (state.defaultLinkForce && linkForce == null) {
|
|
1317
|
+
graph.d3Force('link', state.defaultLinkForce);
|
|
1318
|
+
linkForce = graph.d3Force('link');
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
if (chargeForce && typeof chargeForce.strength === 'function') {
|
|
1322
|
+
const strength = mode === 'normal' ? -58 : mode === 'degraded' ? -68 : -78;
|
|
1323
|
+
chargeForce.strength(strength);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
if (linkForce) {
|
|
1327
|
+
if (typeof linkForce.distance === 'function') {
|
|
1328
|
+
const distance = mode === 'normal' ? 15 : mode === 'degraded' ? 20 : 24;
|
|
1329
|
+
linkForce.distance(distance);
|
|
1277
1330
|
}
|
|
1278
|
-
if (
|
|
1279
|
-
|
|
1331
|
+
if (typeof linkForce.strength === 'function') {
|
|
1332
|
+
const strength = mode === 'normal' ? 0.05 : mode === 'degraded' ? 0.048 : 0.045;
|
|
1333
|
+
linkForce.strength(strength);
|
|
1280
1334
|
}
|
|
1281
1335
|
}
|
|
1336
|
+
|
|
1337
|
+
if (typeof graph.d3ReheatSimulation === 'function') {
|
|
1338
|
+
graph.d3ReheatSimulation();
|
|
1339
|
+
}
|
|
1282
1340
|
}
|
|
1283
1341
|
|
|
1284
1342
|
try {
|
|
@@ -1289,7 +1347,7 @@ function renderUiHtml() {
|
|
|
1289
1347
|
? Math.min(1.6, deviceRatio)
|
|
1290
1348
|
: mode === 'degraded'
|
|
1291
1349
|
? Math.min(1.2, deviceRatio)
|
|
1292
|
-
: Math.min(0
|
|
1350
|
+
: Math.min(1.0, deviceRatio);
|
|
1293
1351
|
renderer.setPixelRatio(targetRatio);
|
|
1294
1352
|
}
|
|
1295
1353
|
} catch (_error) {
|
|
@@ -1406,7 +1464,7 @@ function renderUiHtml() {
|
|
|
1406
1464
|
})(els.graphCanvas)
|
|
1407
1465
|
.backgroundColor('#01040f')
|
|
1408
1466
|
.showNavInfo(false)
|
|
1409
|
-
.nodeOpacity(0.
|
|
1467
|
+
.nodeOpacity(0.9)
|
|
1410
1468
|
.nodeVisibility((node) => node.__renderVisible !== false)
|
|
1411
1469
|
.nodeLabel((node) => {
|
|
1412
1470
|
const name = String(node.name || node.id || 'node');
|
|
@@ -1431,11 +1489,11 @@ function renderUiHtml() {
|
|
|
1431
1489
|
if (link.__highlight) {
|
|
1432
1490
|
return '#f3ff77';
|
|
1433
1491
|
}
|
|
1434
|
-
return link.__color || '#
|
|
1492
|
+
return link.__color || '#9cff3f';
|
|
1435
1493
|
})
|
|
1436
1494
|
.linkWidth((link) => {
|
|
1437
|
-
const base = state.perfMode === 'normal' ? 0.
|
|
1438
|
-
const highlight = state.perfMode === 'normal' ? 1.
|
|
1495
|
+
const base = state.perfMode === 'normal' ? 0.9 : state.perfMode === 'degraded' ? 0.95 : 1.0;
|
|
1496
|
+
const highlight = state.perfMode === 'normal' ? 1.8 : state.perfMode === 'degraded' ? 1.9 : 2.0;
|
|
1439
1497
|
return link.__highlight ? highlight : base;
|
|
1440
1498
|
})
|
|
1441
1499
|
.linkVisibility((link) => link.__renderVisible !== false)
|
package/dist/server/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/server/ui.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/server/ui.ts"],"names":[],"mappings":";;AAEA,oCAiiEC;AAniED,2DAAmE;AAEnE,SAAgB,YAAY;IAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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