code-kg 0.1.9 → 0.1.11
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 +53 -40
- package/dist/server/ui.js.map +1 -1
- package/package.json +1 -1
package/dist/server/ui.js
CHANGED
|
@@ -577,14 +577,14 @@ function renderUiHtml() {
|
|
|
577
577
|
const WASM_LAYOUT_ASSET = '/assets/vendor/graph-layout.wasm';
|
|
578
578
|
const WASM_LAYOUT_ITERATIONS = 56;
|
|
579
579
|
const WASM_WORKER_TIMEOUT_MS = 9000;
|
|
580
|
-
const EDGE_CHUNK_THRESHOLD =
|
|
581
|
-
const EDGE_CHUNK_SIZE =
|
|
580
|
+
const EDGE_CHUNK_THRESHOLD = 50000;
|
|
581
|
+
const EDGE_CHUNK_SIZE = 15000;
|
|
582
582
|
const AUX_LOAD_DELAY_MS = 120;
|
|
583
|
-
const POINTER_INTERACTION_MAX_NODES =
|
|
584
|
-
const POINTER_INTERACTION_MAX_EDGES =
|
|
583
|
+
const POINTER_INTERACTION_MAX_NODES = 6000;
|
|
584
|
+
const POINTER_INTERACTION_MAX_EDGES = 15000;
|
|
585
585
|
|
|
586
586
|
const state = {
|
|
587
|
-
view: '
|
|
587
|
+
view: 'fileDeps',
|
|
588
588
|
graph: null,
|
|
589
589
|
graphData: { nodes: [], links: [], nodeById: new Map() },
|
|
590
590
|
graphMeta: null,
|
|
@@ -1221,10 +1221,10 @@ function renderUiHtml() {
|
|
|
1221
1221
|
graph.nodeResolution(mode === 'normal' ? 6 : mode === 'degraded' ? 4 : 3);
|
|
1222
1222
|
}
|
|
1223
1223
|
if (typeof graph.linkResolution === 'function') {
|
|
1224
|
-
graph.linkResolution(mode === 'normal' ?
|
|
1224
|
+
graph.linkResolution(mode === 'normal' ? 2 : 1);
|
|
1225
1225
|
}
|
|
1226
1226
|
|
|
1227
|
-
graph.linkOpacity(mode === 'normal' ? 0.
|
|
1227
|
+
graph.linkOpacity(mode === 'normal' ? 0.62 : mode === 'degraded' ? 0.5 : 0.38);
|
|
1228
1228
|
graph.nodeRelSize(mode === 'normal' ? 1.1 : mode === 'degraded' ? 0.95 : 0.82);
|
|
1229
1229
|
|
|
1230
1230
|
const totalNodes = state.graphMeta && typeof state.graphMeta.totalNodes === 'number'
|
|
@@ -1270,10 +1270,10 @@ function renderUiHtml() {
|
|
|
1270
1270
|
if (renderer && typeof renderer.setPixelRatio === 'function') {
|
|
1271
1271
|
const deviceRatio = window.devicePixelRatio || 1;
|
|
1272
1272
|
const targetRatio = mode === 'normal'
|
|
1273
|
-
? Math.min(1.
|
|
1273
|
+
? Math.min(1.6, deviceRatio)
|
|
1274
1274
|
: mode === 'degraded'
|
|
1275
|
-
? Math.min(1.
|
|
1276
|
-
: 0.
|
|
1275
|
+
? Math.min(1.2, deviceRatio)
|
|
1276
|
+
: Math.min(0.9, deviceRatio);
|
|
1277
1277
|
renderer.setPixelRatio(targetRatio);
|
|
1278
1278
|
}
|
|
1279
1279
|
} catch (_error) {
|
|
@@ -1297,12 +1297,12 @@ function renderUiHtml() {
|
|
|
1297
1297
|
const rawNodes = Array.isArray(apiData && apiData.nodes) ? apiData.nodes : [];
|
|
1298
1298
|
const rawEdges = Array.isArray(apiData && apiData.edges) ? apiData.edges : [];
|
|
1299
1299
|
const degree = Object.create(null);
|
|
1300
|
-
const links =
|
|
1300
|
+
const links = [];
|
|
1301
1301
|
|
|
1302
1302
|
for (let i = 0; i < rawEdges.length; i += 1) {
|
|
1303
1303
|
const edge = rawEdges[i];
|
|
1304
|
-
const sourceRaw = edge.from || edge.source;
|
|
1305
|
-
const targetRaw = edge.to || edge.target;
|
|
1304
|
+
const sourceRaw = edge.fromId || edge.from || edge.source;
|
|
1305
|
+
const targetRaw = edge.toId || edge.to || edge.target;
|
|
1306
1306
|
const source = typeof sourceRaw === 'string'
|
|
1307
1307
|
? sourceRaw
|
|
1308
1308
|
: sourceRaw && sourceRaw.id
|
|
@@ -1314,14 +1314,13 @@ function renderUiHtml() {
|
|
|
1314
1314
|
? String(targetRaw.id)
|
|
1315
1315
|
: '';
|
|
1316
1316
|
|
|
1317
|
-
if (source.length
|
|
1318
|
-
|
|
1319
|
-
}
|
|
1320
|
-
if (target.length > 0) {
|
|
1321
|
-
degree[target] = (degree[target] || 0) + 1;
|
|
1317
|
+
if (source.length === 0 || target.length === 0) {
|
|
1318
|
+
continue;
|
|
1322
1319
|
}
|
|
1320
|
+
degree[source] = (degree[source] || 0) + 1;
|
|
1321
|
+
degree[target] = (degree[target] || 0) + 1;
|
|
1323
1322
|
|
|
1324
|
-
links
|
|
1323
|
+
links.push({
|
|
1325
1324
|
id: edge.id,
|
|
1326
1325
|
source,
|
|
1327
1326
|
target,
|
|
@@ -1331,7 +1330,7 @@ function renderUiHtml() {
|
|
|
1331
1330
|
__color: colorForEdge(edge.type),
|
|
1332
1331
|
__highlight: false,
|
|
1333
1332
|
__renderVisible: true
|
|
1334
|
-
};
|
|
1333
|
+
});
|
|
1335
1334
|
}
|
|
1336
1335
|
|
|
1337
1336
|
const nodes = new Array(rawNodes.length);
|
|
@@ -1376,7 +1375,12 @@ function renderUiHtml() {
|
|
|
1376
1375
|
return false;
|
|
1377
1376
|
}
|
|
1378
1377
|
|
|
1379
|
-
const graph = window.ForceGraph3D(
|
|
1378
|
+
const graph = window.ForceGraph3D({
|
|
1379
|
+
rendererConfig: {
|
|
1380
|
+
antialias: false,
|
|
1381
|
+
powerPreference: 'high-performance'
|
|
1382
|
+
}
|
|
1383
|
+
})(els.graphCanvas)
|
|
1380
1384
|
.backgroundColor('#01040f')
|
|
1381
1385
|
.showNavInfo(false)
|
|
1382
1386
|
.nodeOpacity(0.92)
|
|
@@ -1407,10 +1411,10 @@ function renderUiHtml() {
|
|
|
1407
1411
|
return link.__color || '#82cf34';
|
|
1408
1412
|
})
|
|
1409
1413
|
.linkWidth((link) => {
|
|
1410
|
-
const base = state.perfMode === 'normal' ? 0.
|
|
1411
|
-
const highlight = state.perfMode === 'normal' ? 1.
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
+
const base = state.perfMode === 'normal' ? 0.95 : state.perfMode === 'degraded' ? 0.72 : 0.52;
|
|
1415
|
+
const highlight = state.perfMode === 'normal' ? 1.9 : state.perfMode === 'degraded' ? 1.45 : 1.1;
|
|
1416
|
+
return link.__highlight ? highlight : base;
|
|
1417
|
+
})
|
|
1414
1418
|
.linkVisibility((link) => link.__renderVisible !== false)
|
|
1415
1419
|
.linkDirectionalParticles((link) => {
|
|
1416
1420
|
return link.__highlight ? (state.perfMode === 'normal' ? 2 : 1) : 0;
|
|
@@ -1557,6 +1561,17 @@ function renderUiHtml() {
|
|
|
1557
1561
|
if (view === 'moduleGraph' || view === 'symbolGraph') {
|
|
1558
1562
|
return 0;
|
|
1559
1563
|
}
|
|
1564
|
+
if (view === 'all' || view === 'fileDeps') {
|
|
1565
|
+
const counts = state.lastMeta && state.lastMeta.counts ? state.lastMeta.counts : null;
|
|
1566
|
+
const totalNodes = counts && typeof counts.nodes === 'number' ? counts.nodes : 0;
|
|
1567
|
+
if (totalNodes >= 260000) {
|
|
1568
|
+
return 52000;
|
|
1569
|
+
}
|
|
1570
|
+
if (totalNodes >= 180000) {
|
|
1571
|
+
return 76000;
|
|
1572
|
+
}
|
|
1573
|
+
return 0;
|
|
1574
|
+
}
|
|
1560
1575
|
const counts = state.lastMeta && state.lastMeta.counts ? state.lastMeta.counts : null;
|
|
1561
1576
|
const totalNodes = counts && typeof counts.nodes === 'number' ? counts.nodes : 0;
|
|
1562
1577
|
if (totalNodes >= 120000) {
|
|
@@ -1580,26 +1595,24 @@ function renderUiHtml() {
|
|
|
1580
1595
|
}
|
|
1581
1596
|
const data = await readEnvelope(graphUrl);
|
|
1582
1597
|
state.graphData = toGraphData(data);
|
|
1598
|
+
|
|
1599
|
+
if (state.graphData.links.length === 0 && state.graphData.nodes.length > 1 && view !== 'fileDeps') {
|
|
1600
|
+
const fallbackData = await readEnvelope('/api/graph?view=fileDeps');
|
|
1601
|
+
const fallbackGraph = toGraphData(fallbackData);
|
|
1602
|
+
if (fallbackGraph.links.length > 0) {
|
|
1603
|
+
state.graphData = fallbackGraph;
|
|
1604
|
+
state.view = 'fileDeps';
|
|
1605
|
+
if (els.view) {
|
|
1606
|
+
els.view.value = 'fileDeps';
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1583
1610
|
const normalizedMeta = normalizeGraphMeta(
|
|
1584
1611
|
data && data.meta ? data.meta : null,
|
|
1585
1612
|
state.graphData.nodes.length,
|
|
1586
1613
|
state.graphData.links.length
|
|
1587
1614
|
);
|
|
1588
|
-
|
|
1589
|
-
? state.lastMeta.counts.nodes
|
|
1590
|
-
: normalizedMeta.totalNodes;
|
|
1591
|
-
const totalEdges = state.lastMeta && state.lastMeta.counts && typeof state.lastMeta.counts.edges === 'number'
|
|
1592
|
-
? state.lastMeta.counts.edges
|
|
1593
|
-
: normalizedMeta.totalEdges;
|
|
1594
|
-
state.graphMeta = {
|
|
1595
|
-
totalNodes: Math.max(normalizedMeta.totalNodes, totalNodes),
|
|
1596
|
-
totalEdges: Math.max(normalizedMeta.totalEdges, totalEdges),
|
|
1597
|
-
queryMs: normalizedMeta.queryMs,
|
|
1598
|
-
recommendedQualityMode: inferQualityMode(
|
|
1599
|
-
Math.max(normalizedMeta.totalNodes, totalNodes),
|
|
1600
|
-
Math.max(normalizedMeta.totalEdges, totalEdges)
|
|
1601
|
-
)
|
|
1602
|
-
};
|
|
1615
|
+
state.graphMeta = normalizedMeta;
|
|
1603
1616
|
const usedWasm = await applyWasmLayout(
|
|
1604
1617
|
view + ':' + state.graphData.nodes.length + ':' + state.graphData.links.length
|
|
1605
1618
|
);
|
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/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