code-kg 0.1.11 → 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 +43 -18
- package/dist/server/ui.js.map +1 -1
- package/package.json +1 -1
package/dist/server/ui.js
CHANGED
|
@@ -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
|
}
|
|
@@ -1298,30 +1314,37 @@ function renderUiHtml() {
|
|
|
1298
1314
|
const rawEdges = Array.isArray(apiData && apiData.edges) ? apiData.edges : [];
|
|
1299
1315
|
const degree = Object.create(null);
|
|
1300
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.fromId || edge.from || edge.source;
|
|
1305
|
-
const targetRaw = edge.toId || edge.to || edge.target;
|
|
1306
|
-
const source =
|
|
1307
|
-
|
|
1308
|
-
: sourceRaw && sourceRaw.id
|
|
1309
|
-
? String(sourceRaw.id)
|
|
1310
|
-
: '';
|
|
1311
|
-
const target = typeof targetRaw === 'string'
|
|
1312
|
-
? targetRaw
|
|
1313
|
-
: targetRaw && targetRaw.id
|
|
1314
|
-
? String(targetRaw.id)
|
|
1315
|
-
: '';
|
|
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);
|
|
1316
1336
|
|
|
1317
1337
|
if (source.length === 0 || target.length === 0) {
|
|
1318
1338
|
continue;
|
|
1319
1339
|
}
|
|
1340
|
+
if (nodeIdSet.size > 0 && (!nodeIdSet.has(source) || !nodeIdSet.has(target))) {
|
|
1341
|
+
continue;
|
|
1342
|
+
}
|
|
1320
1343
|
degree[source] = (degree[source] || 0) + 1;
|
|
1321
1344
|
degree[target] = (degree[target] || 0) + 1;
|
|
1322
1345
|
|
|
1323
1346
|
links.push({
|
|
1324
|
-
id: edge.id,
|
|
1347
|
+
id: edge.id || ('edge:' + i + ':' + source + '->' + target),
|
|
1325
1348
|
source,
|
|
1326
1349
|
target,
|
|
1327
1350
|
__sourceId: source,
|
|
@@ -1336,7 +1359,7 @@ function renderUiHtml() {
|
|
|
1336
1359
|
const nodes = new Array(rawNodes.length);
|
|
1337
1360
|
for (let i = 0; i < rawNodes.length; i += 1) {
|
|
1338
1361
|
const node = rawNodes[i];
|
|
1339
|
-
const nodeId =
|
|
1362
|
+
const nodeId = normalizeEndpointId(node.id);
|
|
1340
1363
|
const d = degree[nodeId] || 0;
|
|
1341
1364
|
const name = node.name || node.id || 'node';
|
|
1342
1365
|
const type = node.type || 'unknown';
|
|
@@ -1593,14 +1616,15 @@ function renderUiHtml() {
|
|
|
1593
1616
|
if (limit > 0) {
|
|
1594
1617
|
graphUrl += '&limit=' + encodeURIComponent(String(limit));
|
|
1595
1618
|
}
|
|
1596
|
-
|
|
1597
|
-
state.graphData = toGraphData(
|
|
1619
|
+
let selectedPayload = await readEnvelope(graphUrl);
|
|
1620
|
+
state.graphData = toGraphData(selectedPayload);
|
|
1598
1621
|
|
|
1599
1622
|
if (state.graphData.links.length === 0 && state.graphData.nodes.length > 1 && view !== 'fileDeps') {
|
|
1600
1623
|
const fallbackData = await readEnvelope('/api/graph?view=fileDeps');
|
|
1601
1624
|
const fallbackGraph = toGraphData(fallbackData);
|
|
1602
1625
|
if (fallbackGraph.links.length > 0) {
|
|
1603
1626
|
state.graphData = fallbackGraph;
|
|
1627
|
+
selectedPayload = fallbackData;
|
|
1604
1628
|
state.view = 'fileDeps';
|
|
1605
1629
|
if (els.view) {
|
|
1606
1630
|
els.view.value = 'fileDeps';
|
|
@@ -1608,13 +1632,14 @@ function renderUiHtml() {
|
|
|
1608
1632
|
}
|
|
1609
1633
|
}
|
|
1610
1634
|
const normalizedMeta = normalizeGraphMeta(
|
|
1611
|
-
|
|
1635
|
+
selectedPayload && selectedPayload.meta ? selectedPayload.meta : null,
|
|
1612
1636
|
state.graphData.nodes.length,
|
|
1613
1637
|
state.graphData.links.length
|
|
1614
1638
|
);
|
|
1615
1639
|
state.graphMeta = normalizedMeta;
|
|
1640
|
+
const layoutSeedView = state.view === 'all' ? 'all' : state.view;
|
|
1616
1641
|
const usedWasm = await applyWasmLayout(
|
|
1617
|
-
|
|
1642
|
+
layoutSeedView + ':' + state.graphData.nodes.length + ':' + state.graphData.links.length
|
|
1618
1643
|
);
|
|
1619
1644
|
if (!usedWasm) {
|
|
1620
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAqjBkB,gDAA4B,CAAC,aAAa;2BAC1C,gDAA4B,CAAC,aAAa;0BAC3C,gDAA4B,CAAC,YAAY;0BACzC,gDAA4B,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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