code-kg 0.1.13 → 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 CHANGED
@@ -584,7 +584,7 @@ function renderUiHtml() {
584
584
  const POINTER_INTERACTION_MAX_EDGES = 15000;
585
585
 
586
586
  const state = {
587
- view: 'fileDeps',
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: '#8fe038',
631
- CALLS: '#b66fff',
632
- REFERENCES: '#c889ff',
630
+ DEPENDS_ON: '#97f143',
631
+ CALLS: '#8fe038',
632
+ REFERENCES: '#8ad736',
633
633
  HANDLES_ROUTE: '#73efff',
634
- DEFINES: '#b176ff',
635
- EXPORTS: '#8dd8ff',
636
- CONTAINS: '#82cf34',
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 0.55;
730
+ return 1;
731
731
  }
732
732
  if (mode === 'degraded') {
733
- return 0.72;
733
+ return 1;
734
734
  }
735
- return 1;
735
+ return 1.02;
736
736
  }
737
737
 
738
738
  function isWasmLayoutEngine(value) {
@@ -998,12 +998,14 @@ 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;
@@ -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
 
@@ -1224,14 +1253,14 @@ function renderUiHtml() {
1224
1253
  if (typeof graph.cooldownTicks === 'function') {
1225
1254
  graph.cooldownTicks(
1226
1255
  usingWasmLayout
1227
- ? (mode === 'normal' ? 96 : mode === 'degraded' ? 42 : 20)
1256
+ ? (mode === 'normal' ? 72 : mode === 'degraded' ? 30 : 12)
1228
1257
  : (mode === 'normal' ? 220 : mode === 'degraded' ? 72 : 28)
1229
1258
  );
1230
1259
  }
1231
1260
  if (typeof graph.cooldownTime === 'function') {
1232
1261
  graph.cooldownTime(
1233
1262
  usingWasmLayout
1234
- ? (mode === 'normal' ? 3200 : mode === 'degraded' ? 1700 : 900)
1263
+ ? (mode === 'normal' ? 2600 : mode === 'degraded' ? 1400 : 800)
1235
1264
  : (mode === 'normal' ? 9000 : mode === 'degraded' ? 2200 : 900)
1236
1265
  );
1237
1266
  }
@@ -1253,11 +1282,11 @@ function renderUiHtml() {
1253
1282
  graph.nodeResolution(mode === 'normal' ? 6 : mode === 'degraded' ? 4 : 3);
1254
1283
  }
1255
1284
  if (typeof graph.linkResolution === 'function') {
1256
- graph.linkResolution(mode === 'normal' ? 2 : 1);
1285
+ graph.linkResolution(mode === 'normal' ? 8 : 6);
1257
1286
  }
1258
1287
 
1259
- graph.linkOpacity(mode === 'normal' ? 0.62 : mode === 'degraded' ? 0.5 : 0.38);
1260
- graph.nodeRelSize(mode === 'normal' ? 1.1 : mode === 'degraded' ? 0.95 : 0.82);
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);
1261
1290
 
1262
1291
  const totalNodes = state.graphMeta && typeof state.graphMeta.totalNodes === 'number'
1263
1292
  ? state.graphMeta.totalNodes
@@ -1278,13 +1307,35 @@ function renderUiHtml() {
1278
1307
  }
1279
1308
 
1280
1309
  if (typeof graph.d3Force === 'function') {
1281
- const currentCharge = graph.d3Force('charge');
1282
- const currentLink = graph.d3Force('link');
1283
- if (state.defaultChargeForce && currentCharge == null) {
1310
+ let chargeForce = graph.d3Force('charge');
1311
+ let linkForce = graph.d3Force('link');
1312
+ if (state.defaultChargeForce && chargeForce == null) {
1284
1313
  graph.d3Force('charge', state.defaultChargeForce);
1314
+ chargeForce = graph.d3Force('charge');
1285
1315
  }
1286
- if (state.defaultLinkForce && currentLink == null) {
1316
+ if (state.defaultLinkForce && linkForce == null) {
1287
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);
1330
+ }
1331
+ if (typeof linkForce.strength === 'function') {
1332
+ const strength = mode === 'normal' ? 0.05 : mode === 'degraded' ? 0.048 : 0.045;
1333
+ linkForce.strength(strength);
1334
+ }
1335
+ }
1336
+
1337
+ if (typeof graph.d3ReheatSimulation === 'function') {
1338
+ graph.d3ReheatSimulation();
1288
1339
  }
1289
1340
  }
1290
1341
 
@@ -1296,7 +1347,7 @@ function renderUiHtml() {
1296
1347
  ? Math.min(1.6, deviceRatio)
1297
1348
  : mode === 'degraded'
1298
1349
  ? Math.min(1.2, deviceRatio)
1299
- : Math.min(0.9, deviceRatio);
1350
+ : Math.min(1.0, deviceRatio);
1300
1351
  renderer.setPixelRatio(targetRatio);
1301
1352
  }
1302
1353
  } catch (_error) {
@@ -1413,7 +1464,7 @@ function renderUiHtml() {
1413
1464
  })(els.graphCanvas)
1414
1465
  .backgroundColor('#01040f')
1415
1466
  .showNavInfo(false)
1416
- .nodeOpacity(0.82)
1467
+ .nodeOpacity(0.9)
1417
1468
  .nodeVisibility((node) => node.__renderVisible !== false)
1418
1469
  .nodeLabel((node) => {
1419
1470
  const name = String(node.name || node.id || 'node');
@@ -1438,11 +1489,11 @@ function renderUiHtml() {
1438
1489
  if (link.__highlight) {
1439
1490
  return '#f3ff77';
1440
1491
  }
1441
- return link.__color || '#82cf34';
1492
+ return link.__color || '#9cff3f';
1442
1493
  })
1443
1494
  .linkWidth((link) => {
1444
- const base = state.perfMode === 'normal' ? 0.95 : state.perfMode === 'degraded' ? 0.72 : 0.52;
1445
- const highlight = state.perfMode === 'normal' ? 1.9 : state.perfMode === 'degraded' ? 1.45 : 1.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;
1446
1497
  return link.__highlight ? highlight : base;
1447
1498
  })
1448
1499
  .linkVisibility((link) => link.__renderVisible !== false)
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/server/ui.ts"],"names":[],"mappings":";;AAEA,oCA8+DC;AAh/DD,2DAAmE;AAEnE,SAAgB,YAAY;IAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAu+C3D,CAAC;AACT,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-kg",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Local code knowledge graph CLI with interactive visualization and deterministic analysis APIs",
5
5
  "license": "MIT",
6
6
  "keywords": [