code-kg 0.1.10 → 0.1.12
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 +63 -27
- 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: 'fileDeps',
|
|
588
588
|
graph: null,
|
|
589
589
|
graphData: { nodes: [], links: [], nodeById: new Map() },
|
|
590
590
|
graphMeta: null,
|
|
@@ -673,6 +673,22 @@ function renderUiHtml() {
|
|
|
673
673
|
return EDGE_COLORS[key] || '#82cf34';
|
|
674
674
|
}
|
|
675
675
|
|
|
676
|
+
function normalizeEndpointId(raw) {
|
|
677
|
+
if (typeof raw === 'string') {
|
|
678
|
+
return raw;
|
|
679
|
+
}
|
|
680
|
+
if (typeof raw === 'number' && Number.isFinite(raw)) {
|
|
681
|
+
return String(raw);
|
|
682
|
+
}
|
|
683
|
+
if (typeof raw === 'bigint') {
|
|
684
|
+
return String(raw);
|
|
685
|
+
}
|
|
686
|
+
if (raw && typeof raw === 'object' && 'id' in raw) {
|
|
687
|
+
return normalizeEndpointId(raw.id);
|
|
688
|
+
}
|
|
689
|
+
return '';
|
|
690
|
+
}
|
|
691
|
+
|
|
676
692
|
function isQualityMode(value) {
|
|
677
693
|
return value === 'normal' || value === 'degraded' || value === 'extreme';
|
|
678
694
|
}
|
|
@@ -1297,32 +1313,38 @@ function renderUiHtml() {
|
|
|
1297
1313
|
const rawNodes = Array.isArray(apiData && apiData.nodes) ? apiData.nodes : [];
|
|
1298
1314
|
const rawEdges = Array.isArray(apiData && apiData.edges) ? apiData.edges : [];
|
|
1299
1315
|
const degree = Object.create(null);
|
|
1300
|
-
const links =
|
|
1316
|
+
const links = [];
|
|
1317
|
+
const nodeIdSet = new Set();
|
|
1318
|
+
|
|
1319
|
+
for (let i = 0; i < rawNodes.length; i += 1) {
|
|
1320
|
+
const rawNode = rawNodes[i];
|
|
1321
|
+
if (!rawNode || typeof rawNode !== 'object') {
|
|
1322
|
+
continue;
|
|
1323
|
+
}
|
|
1324
|
+
const normalizedNodeId = normalizeEndpointId(rawNode.id);
|
|
1325
|
+
if (normalizedNodeId.length > 0) {
|
|
1326
|
+
nodeIdSet.add(normalizedNodeId);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1301
1329
|
|
|
1302
1330
|
for (let i = 0; i < rawEdges.length; i += 1) {
|
|
1303
1331
|
const edge = rawEdges[i];
|
|
1304
|
-
const sourceRaw = edge.from || edge.source;
|
|
1305
|
-
const targetRaw = edge.to || edge.target;
|
|
1306
|
-
const source =
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
const target = typeof targetRaw === 'string'
|
|
1312
|
-
? targetRaw
|
|
1313
|
-
: targetRaw && targetRaw.id
|
|
1314
|
-
? String(targetRaw.id)
|
|
1315
|
-
: '';
|
|
1316
|
-
|
|
1317
|
-
if (source.length > 0) {
|
|
1318
|
-
degree[source] = (degree[source] || 0) + 1;
|
|
1332
|
+
const sourceRaw = edge.fromId || edge.from_id || edge.from || edge.sourceId || edge.source_id || edge.source;
|
|
1333
|
+
const targetRaw = edge.toId || edge.to_id || edge.to || edge.targetId || edge.target_id || edge.target;
|
|
1334
|
+
const source = normalizeEndpointId(sourceRaw);
|
|
1335
|
+
const target = normalizeEndpointId(targetRaw);
|
|
1336
|
+
|
|
1337
|
+
if (source.length === 0 || target.length === 0) {
|
|
1338
|
+
continue;
|
|
1319
1339
|
}
|
|
1320
|
-
if (
|
|
1321
|
-
|
|
1340
|
+
if (nodeIdSet.size > 0 && (!nodeIdSet.has(source) || !nodeIdSet.has(target))) {
|
|
1341
|
+
continue;
|
|
1322
1342
|
}
|
|
1343
|
+
degree[source] = (degree[source] || 0) + 1;
|
|
1344
|
+
degree[target] = (degree[target] || 0) + 1;
|
|
1323
1345
|
|
|
1324
|
-
links
|
|
1325
|
-
id: edge.id,
|
|
1346
|
+
links.push({
|
|
1347
|
+
id: edge.id || ('edge:' + i + ':' + source + '->' + target),
|
|
1326
1348
|
source,
|
|
1327
1349
|
target,
|
|
1328
1350
|
__sourceId: source,
|
|
@@ -1331,13 +1353,13 @@ function renderUiHtml() {
|
|
|
1331
1353
|
__color: colorForEdge(edge.type),
|
|
1332
1354
|
__highlight: false,
|
|
1333
1355
|
__renderVisible: true
|
|
1334
|
-
};
|
|
1356
|
+
});
|
|
1335
1357
|
}
|
|
1336
1358
|
|
|
1337
1359
|
const nodes = new Array(rawNodes.length);
|
|
1338
1360
|
for (let i = 0; i < rawNodes.length; i += 1) {
|
|
1339
1361
|
const node = rawNodes[i];
|
|
1340
|
-
const nodeId =
|
|
1362
|
+
const nodeId = normalizeEndpointId(node.id);
|
|
1341
1363
|
const d = degree[nodeId] || 0;
|
|
1342
1364
|
const name = node.name || node.id || 'node';
|
|
1343
1365
|
const type = node.type || 'unknown';
|
|
@@ -1594,16 +1616,30 @@ function renderUiHtml() {
|
|
|
1594
1616
|
if (limit > 0) {
|
|
1595
1617
|
graphUrl += '&limit=' + encodeURIComponent(String(limit));
|
|
1596
1618
|
}
|
|
1597
|
-
|
|
1598
|
-
state.graphData = toGraphData(
|
|
1619
|
+
let selectedPayload = await readEnvelope(graphUrl);
|
|
1620
|
+
state.graphData = toGraphData(selectedPayload);
|
|
1621
|
+
|
|
1622
|
+
if (state.graphData.links.length === 0 && state.graphData.nodes.length > 1 && view !== 'fileDeps') {
|
|
1623
|
+
const fallbackData = await readEnvelope('/api/graph?view=fileDeps');
|
|
1624
|
+
const fallbackGraph = toGraphData(fallbackData);
|
|
1625
|
+
if (fallbackGraph.links.length > 0) {
|
|
1626
|
+
state.graphData = fallbackGraph;
|
|
1627
|
+
selectedPayload = fallbackData;
|
|
1628
|
+
state.view = 'fileDeps';
|
|
1629
|
+
if (els.view) {
|
|
1630
|
+
els.view.value = 'fileDeps';
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1599
1634
|
const normalizedMeta = normalizeGraphMeta(
|
|
1600
|
-
|
|
1635
|
+
selectedPayload && selectedPayload.meta ? selectedPayload.meta : null,
|
|
1601
1636
|
state.graphData.nodes.length,
|
|
1602
1637
|
state.graphData.links.length
|
|
1603
1638
|
);
|
|
1604
1639
|
state.graphMeta = normalizedMeta;
|
|
1640
|
+
const layoutSeedView = state.view === 'all' ? 'all' : state.view;
|
|
1605
1641
|
const usedWasm = await applyWasmLayout(
|
|
1606
|
-
|
|
1642
|
+
layoutSeedView + ':' + state.graphData.nodes.length + ':' + state.graphData.links.length
|
|
1607
1643
|
);
|
|
1608
1644
|
if (!usedWasm) {
|
|
1609
1645
|
state.layoutEngine = 'js';
|
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,oCAu+DC;AAz+DD,2DAAmE;AAEnE,SAAgB,YAAY;IAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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