@trebired/code-insights 0.0.0-stage → 0.1.0
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/.trebired/logger/config.ts +4 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE +661 -0
- package/README.md +139 -2
- package/dist/client/controller.d.ts +31 -0
- package/dist/client/controller.d.ts.map +1 -0
- package/dist/client/controller.js +136 -0
- package/dist/client/controller.js.map +1 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +59 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/layout.d.ts +8 -0
- package/dist/client/layout.d.ts.map +1 -0
- package/dist/client/layout.js +30 -0
- package/dist/client/layout.js.map +1 -0
- package/dist/client/model.d.ts +27 -0
- package/dist/client/model.d.ts.map +1 -0
- package/dist/client/model.js +57 -0
- package/dist/client/model.js.map +1 -0
- package/dist/client/render.d.ts +20 -0
- package/dist/client/render.d.ts.map +1 -0
- package/dist/client/render.js +95 -0
- package/dist/client/render.js.map +1 -0
- package/dist/client/viewport.d.ts +12 -0
- package/dist/client/viewport.d.ts.map +1 -0
- package/dist/client/viewport.js +70 -0
- package/dist/client/viewport.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/react/code_map.d.ts +17 -0
- package/dist/react/code_map.d.ts.map +1 -0
- package/dist/react/code_map.js +36 -0
- package/dist/react/code_map.js.map +1 -0
- package/dist/react/hotspots.d.ts +12 -0
- package/dist/react/hotspots.d.ts.map +1 -0
- package/dist/react/hotspots.js +28 -0
- package/dist/react/hotspots.js.map +1 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -0
- package/dist/server/binary.d.ts +4 -0
- package/dist/server/binary.d.ts.map +1 -0
- package/dist/server/binary.js +46 -0
- package/dist/server/binary.js.map +1 -0
- package/dist/server/detect.d.ts +13 -0
- package/dist/server/detect.d.ts.map +1 -0
- package/dist/server/detect.js +15 -0
- package/dist/server/detect.js.map +1 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +6 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/logging.d.ts +4 -0
- package/dist/server/logging.d.ts.map +1 -0
- package/dist/server/logging.js +12 -0
- package/dist/server/logging.js.map +1 -0
- package/dist/server/map.d.ts +8 -0
- package/dist/server/map.d.ts.map +1 -0
- package/dist/server/map.js +81 -0
- package/dist/server/map.js.map +1 -0
- package/dist/server/process.d.ts +13 -0
- package/dist/server/process.d.ts.map +1 -0
- package/dist/server/process.js +58 -0
- package/dist/server/process.js.map +1 -0
- package/dist/server/scan.d.ts +30 -0
- package/dist/server/scan.d.ts.map +1 -0
- package/dist/server/scan.js +63 -0
- package/dist/server/scan.js.map +1 -0
- package/dist/shared/constants.d.ts +5 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +5 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/copy.d.ts +40 -0
- package/dist/shared/copy.d.ts.map +1 -0
- package/dist/shared/copy.js +56 -0
- package/dist/shared/copy.js.map +1 -0
- package/dist/shared/types.d.ts +138 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +2 -0
- package/dist/shared/types.js.map +1 -0
- package/native/linux-arm64-gnu/code-insights +0 -0
- package/native/linux-x64-gnu/code-insights +0 -0
- package/native/vendor/hyperpolyglot/LICENSE-MIT +21 -0
- package/package.json +107 -4
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { radius } from "./layout.js";
|
|
2
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
3
|
+
function svg(tag, attrs) {
|
|
4
|
+
const element = document.createElementNS(SVG_NS, tag);
|
|
5
|
+
for (const [name, value] of Object.entries(attrs))
|
|
6
|
+
element.setAttribute(name, String(value));
|
|
7
|
+
return element;
|
|
8
|
+
}
|
|
9
|
+
function hue(group) {
|
|
10
|
+
let hash = 0;
|
|
11
|
+
for (let index = 0; index < group.length; index += 1)
|
|
12
|
+
hash = (hash * 31 + group.charCodeAt(index)) >>> 0;
|
|
13
|
+
return hash % 360;
|
|
14
|
+
}
|
|
15
|
+
function nodeColor(node) {
|
|
16
|
+
return `hsl(${hue(node.group)} 32% ${node.cluster ? 46 : 56}%)`;
|
|
17
|
+
}
|
|
18
|
+
function edgeElements(graph, byId, layer) {
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const edge of graph.edges) {
|
|
21
|
+
const source = byId.get(edge.source);
|
|
22
|
+
const target = byId.get(edge.target);
|
|
23
|
+
if (!source || !target)
|
|
24
|
+
continue;
|
|
25
|
+
const element = svg("line", {
|
|
26
|
+
"stroke-opacity": 0.22,
|
|
27
|
+
"stroke-width": Math.min(4, 0.8 + Math.log2(1 + edge.weight) * 0.6),
|
|
28
|
+
stroke: "currentColor",
|
|
29
|
+
x1: source.x, x2: target.x, y1: source.y, y2: target.y,
|
|
30
|
+
});
|
|
31
|
+
layer.appendChild(element);
|
|
32
|
+
out.push({ element, source: edge.source, target: edge.target });
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
function nodeElement(node, showLabel) {
|
|
37
|
+
const group = svg("g", { "data-code-map-node": node.id, style: "cursor:pointer", transform: `translate(${node.x},${node.y})` });
|
|
38
|
+
const size = radius(node);
|
|
39
|
+
group.appendChild(svg("circle", { fill: nodeColor(node), r: size, stroke: "var(--background-page, transparent)", "stroke-width": 1.5 }));
|
|
40
|
+
const label = svg("text", {
|
|
41
|
+
"font-size": node.cluster ? 12 : 10,
|
|
42
|
+
fill: "currentColor",
|
|
43
|
+
"fill-opacity": node.cluster ? 0.9 : 0.75,
|
|
44
|
+
"paint-order": "stroke",
|
|
45
|
+
stroke: "var(--background-page, transparent)",
|
|
46
|
+
"stroke-width": 3,
|
|
47
|
+
"text-anchor": "middle",
|
|
48
|
+
visibility: showLabel ? "visible" : "hidden",
|
|
49
|
+
y: size + 12,
|
|
50
|
+
});
|
|
51
|
+
label.textContent = node.cluster ? `${node.label} (${node.count})` : node.label;
|
|
52
|
+
const title = svg("title", {});
|
|
53
|
+
title.textContent = node.cluster ? node.label : `${node.path}${node.line ? `:${node.line}` : ""}`;
|
|
54
|
+
group.append(label, title);
|
|
55
|
+
return { group, label };
|
|
56
|
+
}
|
|
57
|
+
function render(canvas, graph) {
|
|
58
|
+
canvas.replaceChildren();
|
|
59
|
+
canvas.style.color = "var(--text-color, currentColor)";
|
|
60
|
+
const viewport = svg("g", { "data-code-map-viewport": "" });
|
|
61
|
+
const edgeLayer = svg("g", {});
|
|
62
|
+
const nodeLayer = svg("g", {});
|
|
63
|
+
viewport.append(edgeLayer, nodeLayer);
|
|
64
|
+
canvas.appendChild(viewport);
|
|
65
|
+
const byId = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
66
|
+
const edges = edgeElements(graph, byId, edgeLayer);
|
|
67
|
+
const nodes = new Map();
|
|
68
|
+
const labelAll = graph.nodes.filter((node) => !node.cluster).length <= 60;
|
|
69
|
+
for (const node of graph.nodes) {
|
|
70
|
+
const { group, label } = nodeElement(node, node.cluster || labelAll);
|
|
71
|
+
nodeLayer.appendChild(group);
|
|
72
|
+
nodes.set(node.id, { element: group, label, node });
|
|
73
|
+
}
|
|
74
|
+
return { edges, nodes, viewport };
|
|
75
|
+
}
|
|
76
|
+
function highlight(rendered, focus, labelAll) {
|
|
77
|
+
for (const [id, entry] of rendered.nodes) {
|
|
78
|
+
const active = !focus || focus.has(id);
|
|
79
|
+
entry.element.setAttribute("opacity", active ? "1" : "0.15");
|
|
80
|
+
entry.label.setAttribute("visibility", entry.node.cluster || labelAll || (focus && focus.has(id)) ? "visible" : "hidden");
|
|
81
|
+
}
|
|
82
|
+
for (const edge of rendered.edges) {
|
|
83
|
+
const active = !focus || (focus.has(edge.source) && focus.has(edge.target));
|
|
84
|
+
edge.element.setAttribute("stroke-opacity", active ? (focus ? "0.7" : "0.22") : "0.04");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function scaleLabels(rendered, zoom) {
|
|
88
|
+
const factor = 1 / Math.max(0.55, Math.min(1, zoom));
|
|
89
|
+
for (const entry of rendered.nodes.values()) {
|
|
90
|
+
entry.label.setAttribute("font-size", String((entry.node.cluster ? 12 : 10) * factor));
|
|
91
|
+
entry.label.setAttribute("stroke-width", String(3 * factor));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export { highlight, render, scaleLabels };
|
|
95
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/client/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,MAAM,MAAM,GAAG,4BAA4B,CAAC;AAQ5C,SAAS,GAAG,CAAuC,GAAM,EAAE,KAAoC;IAC7F,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7F,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,GAAG,CAAC,KAAa;IACxB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC;QAAE,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;IACzG,OAAO,IAAI,GAAG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C5E,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,QAAkB,EAAE,IAAY;IACnD,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IACrD,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5C,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACvF,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ViewGraph } from "./model.js";
|
|
2
|
+
type Transform = {
|
|
3
|
+
k: number;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
declare function fit(canvas: SVGSVGElement, graph: ViewGraph): Transform;
|
|
8
|
+
declare function apply(viewport: SVGGElement, transform: Transform): void;
|
|
9
|
+
declare function bindZoomPan(canvas: SVGSVGElement, get: () => Transform, set: (next: Transform) => void): () => void;
|
|
10
|
+
export { apply, bindZoomPan, fit };
|
|
11
|
+
export type { Transform };
|
|
12
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/client/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,KAAK,SAAS,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAmBrD,iBAAS,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,CAY/D;AAED,iBAAS,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,QAEzD;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CA+B5G;AAED,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;AACnC,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { radius } from "./layout.js";
|
|
2
|
+
function bounds(graph, labelScale) {
|
|
3
|
+
let minX = Infinity;
|
|
4
|
+
let minY = Infinity;
|
|
5
|
+
let maxX = -Infinity;
|
|
6
|
+
let maxY = -Infinity;
|
|
7
|
+
for (const node of graph.nodes) {
|
|
8
|
+
const label = node.cluster ? `${node.label} (${node.count})` : node.label;
|
|
9
|
+
const halfWidth = Math.max(radius(node), label.length * (node.cluster ? 3.6 : 3) * labelScale) + 8;
|
|
10
|
+
const height = radius(node) + 24 * labelScale;
|
|
11
|
+
minX = Math.min(minX, (node.x || 0) - halfWidth);
|
|
12
|
+
maxX = Math.max(maxX, (node.x || 0) + halfWidth);
|
|
13
|
+
minY = Math.min(minY, (node.y || 0) - height);
|
|
14
|
+
maxY = Math.max(maxY, (node.y || 0) + height);
|
|
15
|
+
}
|
|
16
|
+
return { maxX, maxY, minX, minY };
|
|
17
|
+
}
|
|
18
|
+
function fit(canvas, graph) {
|
|
19
|
+
const box = canvas.getBoundingClientRect();
|
|
20
|
+
const width = box.width || 800;
|
|
21
|
+
const height = box.height || 500;
|
|
22
|
+
if (!graph.nodes.length)
|
|
23
|
+
return { k: 1, x: width / 2, y: height / 2 };
|
|
24
|
+
let scale = 1;
|
|
25
|
+
let area = bounds(graph, 1);
|
|
26
|
+
for (let pass = 0; pass < 2; pass += 1) {
|
|
27
|
+
area = bounds(graph, 1 / Math.max(0.55, Math.min(1, scale)));
|
|
28
|
+
scale = Math.min(2, Math.min(width / (area.maxX - area.minX), height / (area.maxY - area.minY)));
|
|
29
|
+
}
|
|
30
|
+
return { k: scale, x: width / 2 - ((area.minX + area.maxX) / 2) * scale, y: height / 2 - ((area.minY + area.maxY) / 2) * scale };
|
|
31
|
+
}
|
|
32
|
+
function apply(viewport, transform) {
|
|
33
|
+
viewport.setAttribute("transform", `translate(${transform.x},${transform.y}) scale(${transform.k})`);
|
|
34
|
+
}
|
|
35
|
+
function bindZoomPan(canvas, get, set) {
|
|
36
|
+
let drag = null;
|
|
37
|
+
const onWheel = (event) => {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
const box = canvas.getBoundingClientRect();
|
|
40
|
+
const current = get();
|
|
41
|
+
const scale = Math.max(0.2, Math.min(6, current.k * Math.exp(-event.deltaY * 0.0015)));
|
|
42
|
+
const px = event.clientX - box.left;
|
|
43
|
+
const py = event.clientY - box.top;
|
|
44
|
+
set({ k: scale, x: px - ((px - current.x) / current.k) * scale, y: py - ((py - current.y) / current.k) * scale });
|
|
45
|
+
};
|
|
46
|
+
const onDown = (event) => {
|
|
47
|
+
if (event.target.closest("[data-code-map-node]"))
|
|
48
|
+
return;
|
|
49
|
+
drag = { start: get(), x: event.clientX, y: event.clientY };
|
|
50
|
+
canvas.setPointerCapture(event.pointerId);
|
|
51
|
+
};
|
|
52
|
+
const onMove = (event) => {
|
|
53
|
+
if (!drag)
|
|
54
|
+
return;
|
|
55
|
+
set({ ...drag.start, x: drag.start.x + event.clientX - drag.x, y: drag.start.y + event.clientY - drag.y });
|
|
56
|
+
};
|
|
57
|
+
const onUp = () => { drag = null; };
|
|
58
|
+
canvas.addEventListener("wheel", onWheel, { passive: false });
|
|
59
|
+
canvas.addEventListener("pointerdown", onDown);
|
|
60
|
+
canvas.addEventListener("pointermove", onMove);
|
|
61
|
+
canvas.addEventListener("pointerup", onUp);
|
|
62
|
+
return () => {
|
|
63
|
+
canvas.removeEventListener("wheel", onWheel);
|
|
64
|
+
canvas.removeEventListener("pointerdown", onDown);
|
|
65
|
+
canvas.removeEventListener("pointermove", onMove);
|
|
66
|
+
canvas.removeEventListener("pointerup", onUp);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export { apply, bindZoomPan, fit };
|
|
70
|
+
//# sourceMappingURL=viewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../../src/client/viewport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,SAAS,MAAM,CAAC,KAAgB,EAAE,UAAkB;IAClD,IAAI,IAAI,GAAG,QAAQ,CAAC;IACpB,IAAI,IAAI,GAAG,QAAQ,CAAC;IACpB,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC;IACrB,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MA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AAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { CodeMapLevel } from "../shared/types.d.ts";
|
|
3
|
+
type CodeMapProps = {
|
|
4
|
+
dataUrl: string;
|
|
5
|
+
extendGroup?: string;
|
|
6
|
+
extendId?: string;
|
|
7
|
+
hrefTemplate?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
lang?: string;
|
|
10
|
+
level?: CodeMapLevel;
|
|
11
|
+
title?: ReactNode;
|
|
12
|
+
toolbar?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
declare function code_map(props: CodeMapProps): import("react").JSX.Element;
|
|
15
|
+
export { code_map };
|
|
16
|
+
export type { CodeMapProps };
|
|
17
|
+
//# sourceMappingURL=code_map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code_map.d.ts","sourceRoot":"","sources":["../../../src/react/code_map.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,CAAC;AAaF,iBAAS,QAAQ,CAAC,KAAK,EAAE,YAAY,+BA2CpC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { button, canvas_panel, input } from "@trebired/frontend/react";
|
|
3
|
+
import { copyFor } from "../shared/copy.js";
|
|
4
|
+
function levelButton(level, current, label) {
|
|
5
|
+
return button({
|
|
6
|
+
"aria-pressed": level === current ? "true" : "false",
|
|
7
|
+
children: label,
|
|
8
|
+
"data-code-map-switch": level,
|
|
9
|
+
size: "sm",
|
|
10
|
+
type: "button",
|
|
11
|
+
variant: "chrome",
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function code_map(props) {
|
|
15
|
+
const copy = copyFor(props.lang);
|
|
16
|
+
const level = props.level === "function" ? "function" : "file";
|
|
17
|
+
const toolbar = (_jsxs(_Fragment, { children: [levelButton("file", level, copy("files")), levelButton("function", level, copy("functions")), props.toolbar] }));
|
|
18
|
+
const content = (_jsxs("div", { className: "tbf-column tbf-gap-sm", "data-code-map-root": "", "data-code-map-url": props.dataUrl, "data-code-map-level": level, "data-code-map-href": props.hrefTemplate || "", "data-code-map-lang": props.lang || "en", id: props.id, children: [input({
|
|
19
|
+
"aria-label": copy("filter"),
|
|
20
|
+
autoComplete: "off",
|
|
21
|
+
"data-code-map-filter": "",
|
|
22
|
+
placeholder: copy("filter"),
|
|
23
|
+
size: "sm",
|
|
24
|
+
type: "search",
|
|
25
|
+
}), _jsx("svg", { "data-code-map-canvas": "", role: "img", "aria-label": copy("codeMap"), style: { display: "block", height: "32rem", maxHeight: "70vh", touchAction: "none", width: "100%" } }), _jsx("div", { className: "tbf-text-muted tbf-text-sm", "data-code-map-status": "", children: copy("loading") }), _jsx("div", { className: "tbf-text-muted tbf-text-xs", children: copy("hint") })] }));
|
|
26
|
+
return canvas_panel({
|
|
27
|
+
content,
|
|
28
|
+
contentClassName: "tbf-column tbf-gap-sm",
|
|
29
|
+
extendGroup: props.extendGroup,
|
|
30
|
+
extendId: props.extendId,
|
|
31
|
+
title: props.title ?? copy("codeMap"),
|
|
32
|
+
toolbarContent: toolbar,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export { code_map };
|
|
36
|
+
//# sourceMappingURL=code_map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code_map.js","sourceRoot":"","sources":["../../../src/react/code_map.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGvE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAexC,SAAS,WAAW,CAAC,KAAmB,EAAE,OAAqB,EAAE,KAAa;IAC5E,OAAO,MAAM,CAAC;QACV,cAAc,EAAE,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QACpD,QAAQ,EAAE,KAAK;QACf,sBAAsB,EAAE,KAAK;QAC7B,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,QAAQ;KACX,CAAC,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,KAAmB;IACnC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,KAAK,GAAiB,KAAK,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7E,MAAM,OAAO,GAAG,CACd,8BACC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EACzC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,EACj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|
2
|
+
type HotspotListProps = {
|
|
3
|
+
hotspots: Hotspot[];
|
|
4
|
+
hrefFor?: (path: string) => string;
|
|
5
|
+
lang?: string;
|
|
6
|
+
limit?: number;
|
|
7
|
+
title?: string;
|
|
8
|
+
};
|
|
9
|
+
declare function hotspot_list(props: HotspotListProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode>>;
|
|
10
|
+
export { hotspot_list };
|
|
11
|
+
export type { HotspotListProps };
|
|
12
|
+
//# sourceMappingURL=hotspots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotspots.d.ts","sourceRoot":"","sources":["../../../src/react/hotspots.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkCF,iBAAS,YAAY,CAAC,KAAK,EAAE,gBAAgB,yTAmBxC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { actionTrigger, card, Title } from "@trebired/frontend/react";
|
|
3
|
+
import { copyFor, countFor } from "../shared/copy.js";
|
|
4
|
+
const TRACK_STYLE = {
|
|
5
|
+
background: "var(--border-surface-1)",
|
|
6
|
+
borderRadius: "999px",
|
|
7
|
+
display: "block",
|
|
8
|
+
flex: "1 1 auto",
|
|
9
|
+
height: "6px",
|
|
10
|
+
minWidth: "3rem",
|
|
11
|
+
overflow: "hidden",
|
|
12
|
+
};
|
|
13
|
+
function hotspotRow(hotspot, props) {
|
|
14
|
+
const count = countFor(props.lang);
|
|
15
|
+
const row = (_jsxs("div", { className: "tbfm-line-card", "data-code-insights-hotspot": "", children: [_jsx("span", { className: "tbfm-line-card__lead tbfm-line-card__text", title: hotspot.path, children: hotspot.path }), _jsx("span", { className: "tbfm-line-card__main", children: _jsx("span", { "aria-hidden": "true", style: TRACK_STYLE, children: _jsx("span", { style: { background: "var(--text-color-muted)", display: "block", height: "100%", width: `${Math.max(2, Math.min(100, hotspot.score))}%` } }) }) }), _jsxs("span", { className: "tbfm-line-card__end tbf-text-muted tbf-text-sm", children: [count(hotspot.commits, "commits"), " \u00B7 ", count(hotspot.lines, "lines")] })] }));
|
|
16
|
+
const href = props.hrefFor ? props.hrefFor(hotspot.path) : "";
|
|
17
|
+
return href ? actionTrigger(row, { href }) : row;
|
|
18
|
+
}
|
|
19
|
+
function hotspot_list(props) {
|
|
20
|
+
const copy = copyFor(props.lang);
|
|
21
|
+
const hotspots = (Array.isArray(props.hotspots) ? props.hotspots : []).slice(0, Math.max(1, props.limit || 10));
|
|
22
|
+
return card({
|
|
23
|
+
className: "tbf-column tbf-gap-sm",
|
|
24
|
+
children: (_jsxs(_Fragment, { children: [_jsxs("div", { className: "tbf-column tbf-gap-xs", children: [_jsx(Title, { children: props.title || copy("hotspots") }), _jsx("span", { className: "tbf-text-muted tbf-text-sm", children: copy("hotspotsDescription") })] }), hotspots.length ? (_jsx("div", { className: "tbf-column", children: hotspots.map((hotspot) => _jsx("div", { children: hotspotRow(hotspot, props) }, hotspot.path)) })) : (_jsx("span", { className: "tbf-text-muted", children: copy("hotspotsEmpty") }))] })),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { hotspot_list };
|
|
28
|
+
//# sourceM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;KACJ,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../../src/server/binary.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU,kCAAkC,CAAC;AAmCnD,iBAAS,aAAa,IAAI,MAAM,CAI/B;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const BINARY_ENV = "TREBIRED_CODE_INSIGHTS_BINARY";
|
|
5
|
+
function packageRoot() {
|
|
6
|
+
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
for (let depth = 0; depth < 5; depth += 1) {
|
|
8
|
+
if (fs.existsSync(path.join(dir, "package.json")))
|
|
9
|
+
return dir;
|
|
10
|
+
dir = path.dirname(dir);
|
|
11
|
+
}
|
|
12
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
13
|
+
}
|
|
14
|
+
function libcVariant() {
|
|
15
|
+
const report = typeof process.report?.getReport === "function" ? process.report.getReport() : null;
|
|
16
|
+
if (report && report.header && report.header.glibcVersionRuntime)
|
|
17
|
+
return "gnu";
|
|
18
|
+
return fs.existsSync("/etc/alpine-release") ? "musl" : "gnu";
|
|
19
|
+
}
|
|
20
|
+
function platformDirName() {
|
|
21
|
+
if (process.platform !== "linux")
|
|
22
|
+
return "";
|
|
23
|
+
if (process.arch === "x64")
|
|
24
|
+
return `linux-x64-${libcVariant()}`;
|
|
25
|
+
if (process.arch === "arm64")
|
|
26
|
+
return `linux-arm64-${libcVariant()}`;
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
function binaryCandidates() {
|
|
30
|
+
const root = packageRoot();
|
|
31
|
+
const fromEnv = String(process.env[BINARY_ENV] || "").trim();
|
|
32
|
+
const platform = platformDirName();
|
|
33
|
+
return [
|
|
34
|
+
fromEnv,
|
|
35
|
+
platform ? path.join(root, "native", platform, "code-insights") : "",
|
|
36
|
+
path.join(root, "native", "code-insights", "target", "release", "code-insights"),
|
|
37
|
+
].filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
function resolveBinary() {
|
|
40
|
+
const found = binaryCandidates().find((candidate) => fs.existsSync(candidate));
|
|
41
|
+
if (found)
|
|
42
|
+
return found;
|
|
43
|
+
throw new Error(`code-insights-binary-missing: no engine for ${process.platform}-${process.arch}; set ${BINARY_ENV}`);
|
|
44
|
+
}
|
|
45
|
+
export { BINARY_ENV, resolveBinary };
|
|
46
|
+
//# sourceMappingURL=binary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../src/server/binary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,+BA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CAAC;IACpE,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,gBAAgB;IACvB,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO;QACL,OAAO;QACP,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE;QACpE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,CAAC;KACjF,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,aAAa;IACpB,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/E,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,IAAI,KAAK,CAAC,+CAA+C,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,SAAS,UAAU,EAAE,CAAC,CAAC;AACxH,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type DetectedLanguage = {
|
|
2
|
+
color: string;
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
declare function detectLanguage(input: {
|
|
8
|
+
content?: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}): Promise<DetectedLanguage | null>;
|
|
11
|
+
export { detectLanguage };
|
|
12
|
+
export type { DetectedLanguage };
|
|
13
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/server/detect.ts"],"names":[],"mappings":"AAEA,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,iBAAe,cAAc,CAAC,KAAK,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,gBAAgB,GAAC,IAAI,CAAC,CAUvG;AAED,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { runEngine } from "./process.js";
|
|
2
|
+
async function detectLanguage(input) {
|
|
3
|
+
let language = null;
|
|
4
|
+
await runEngine({
|
|
5
|
+
args: ["detect", "--path", String(input.path || "")],
|
|
6
|
+
input: String(input.content || ""),
|
|
7
|
+
onEvent: (event) => {
|
|
8
|
+
if (event.type === "language")
|
|
9
|
+
language = event.language || null;
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
return language;
|
|
13
|
+
}
|
|
14
|
+
export { detectLanguage };
|
|
15
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../../src/server/detect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,KAAK,UAAU,cAAc,CAAC,KAAyC;IACrE,IAAI,QAAQ,GAA4B,IAAI,CAAC;IAC7C,MAAM,SAAS,CAAC;QACZ,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACpD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QAClC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;gBAAE,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;QACnE,CAAC;KACJ,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { BINARY_ENV, resolveBinary } from "./binary.js";
|
|
2
|
+
export { detectLanguage } from "./detect.js";
|
|
3
|
+
export type { DetectedLanguage } from "./detect.js";
|
|
4
|
+
export { buildCodeMapData } from "./map.js";
|
|
5
|
+
export type { CodeMapOptions } from "./map.js";
|
|
6
|
+
export { CodeInsightsError } from "./process.js";
|
|
7
|
+
export { scanRepository } from "./scan.js";
|
|
8
|
+
export type { ScanLimits, ScanPhaseEvent, ScanRepositoryOptions } from "./scan.js";
|
|
9
|
+
export type * from "../shared/types.d.ts";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACnF,mBAAkB,eAAe,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BINARY_ENV, resolveBinary } from "./binary.js";
|
|
2
|
+
export { detectLanguage } from "./detect.js";
|
|
3
|
+
export { buildCodeMapData } from "./map.js";
|
|
4
|
+
export { CodeInsightsError } from "./process.js";
|
|
5
|
+
export { scanRepository } from "./scan.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../src/server/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGhH,iBAAS,WAAW,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,IAAI,GAAG,uBAAuB,CAOjF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { resolveLogger } from "@package/logger-adapter";
|
|
2
|
+
import { PACKAGE_NAME } from "../shared/constants.js";
|
|
3
|
+
function insightsLog(logger) {
|
|
4
|
+
return resolveLogger({
|
|
5
|
+
defaultLogger: false,
|
|
6
|
+
fallback: "noop",
|
|
7
|
+
logger: logger || undefined,
|
|
8
|
+
source: PACKAGE_NAME,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export { insightsLog };
|
|
12
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../src/server/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA0D,MAAM,yBAAyB,CAAC;AAChH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,SAAS,WAAW,CAAC,MAAmC;IACtD,OAAO,aAAa,CAAC;QACjB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,MAAM,IAAI,SAAS;QAC3B,MAAM,EAAE,YAAY;KACvB,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CodeInsightsResult, CodeMapData, CodeMapLevel } from "../shared/types.d.ts";
|
|
2
|
+
type CodeMapOptions = {
|
|
3
|
+
maxNodes?: number;
|
|
4
|
+
};
|
|
5
|
+
declare function buildCodeMapData(result: CodeInsightsResult, level: CodeMapLevel, options?: CodeMapOptions): CodeMapData;
|
|
6
|
+
export { buildCodeMapData };
|
|
7
|
+
export type { CodeMapOptions };
|
|
8
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/server/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAe,YAAY,EAAe,MAAM,eAAe,CAAC;AAE7G,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAmEF,iBAAS,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAcpH;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const ROOT_GROUP = ".";
|
|
2
|
+
function folderAt(path, depth) {
|
|
3
|
+
const parts = path.split("/").slice(0, -1);
|
|
4
|
+
return parts.length ? parts.slice(0, depth).join("/") : ROOT_GROUP;
|
|
5
|
+
}
|
|
6
|
+
function chooseDepth(paths) {
|
|
7
|
+
for (let depth = 1; depth <= 4; depth += 1) {
|
|
8
|
+
const groups = new Set(paths.map((path) => folderAt(path, depth))).size;
|
|
9
|
+
if (groups > 24)
|
|
10
|
+
return Math.max(1, depth - 1);
|
|
11
|
+
if (groups >= 4)
|
|
12
|
+
return depth;
|
|
13
|
+
}
|
|
14
|
+
return 4;
|
|
15
|
+
}
|
|
16
|
+
function fileNodes(result) {
|
|
17
|
+
const graph = result.imports;
|
|
18
|
+
if (!graph)
|
|
19
|
+
return { edges: [], nodes: [] };
|
|
20
|
+
const lines = new Map(result.files.map((file) => [file.path, file]));
|
|
21
|
+
const nodes = graph.nodes.map((path) => ({
|
|
22
|
+
group: "",
|
|
23
|
+
id: path,
|
|
24
|
+
kind: lines.get(path)?.language || "",
|
|
25
|
+
label: path.split("/").pop() || path,
|
|
26
|
+
line: null,
|
|
27
|
+
path,
|
|
28
|
+
size: Math.max(1, lines.get(path)?.lines.code || 1),
|
|
29
|
+
}));
|
|
30
|
+
const edges = graph.edges.map((edge) => ({ source: graph.nodes[edge.from], target: graph.nodes[edge.to], weight: 1 }));
|
|
31
|
+
return { edges, nodes };
|
|
32
|
+
}
|
|
33
|
+
function functionNodes(result) {
|
|
34
|
+
const graph = result.functions;
|
|
35
|
+
if (!graph)
|
|
36
|
+
return { edges: [], nodes: [] };
|
|
37
|
+
const nodes = graph.nodes.map((node, index) => ({
|
|
38
|
+
group: "",
|
|
39
|
+
id: `f${index}`,
|
|
40
|
+
kind: node.kind,
|
|
41
|
+
label: node.owner ? `${node.owner}.${node.name}` : node.name,
|
|
42
|
+
line: node.line,
|
|
43
|
+
path: graph.files[node.file],
|
|
44
|
+
size: Math.max(1, node.end_line - node.line + 1),
|
|
45
|
+
}));
|
|
46
|
+
const edges = graph.edges.map((edge) => ({ source: `f${edge.from}`, target: `f${edge.to}`, weight: edge.count }));
|
|
47
|
+
return { edges, nodes };
|
|
48
|
+
}
|
|
49
|
+
function keepConnected(nodes, edges, maxNodes) {
|
|
50
|
+
if (nodes.length <= maxNodes)
|
|
51
|
+
return { edges, nodes, truncated: false };
|
|
52
|
+
const degree = new Map();
|
|
53
|
+
for (const edge of edges) {
|
|
54
|
+
degree.set(edge.source, (degree.get(edge.source) || 0) + edge.weight);
|
|
55
|
+
degree.set(edge.target, (degree.get(edge.target) || 0) + edge.weight);
|
|
56
|
+
}
|
|
57
|
+
const ranked = [...nodes].sort((left, right) => (degree.get(right.id) || 0) - (degree.get(left.id) || 0));
|
|
58
|
+
const kept = new Set(ranked.slice(0, maxNodes).map((node) => node.id));
|
|
59
|
+
return {
|
|
60
|
+
edges: edges.filter((edge) => kept.has(edge.source) && kept.has(edge.target)),
|
|
61
|
+
nodes: nodes.filter((node) => kept.has(node.id)),
|
|
62
|
+
truncated: true,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function buildCodeMapData(result, level, options = {}) {
|
|
66
|
+
const source = level === "function" ? functionNodes(result) : fileNodes(result);
|
|
67
|
+
const capped = keepConnected(source.nodes, source.edges, Math.max(50, options.maxNodes || 4000));
|
|
68
|
+
const depth = chooseDepth(capped.nodes.map((node) => node.path));
|
|
69
|
+
const sizes = new Map();
|
|
70
|
+
for (const node of capped.nodes) {
|
|
71
|
+
node.group = folderAt(node.path, depth);
|
|
72
|
+
sizes.set(node.group, (sizes.get(node.group) || 0) + 1);
|
|
73
|
+
}
|
|
74
|
+
const groups = [...sizes.entries()]
|
|
75
|
+
.map(([id, size]) => ({ id, label: id === ROOT_GROUP ? "/" : `${id}/`, size }))
|
|
76
|
+
.sort((left, right) => right.size - left.size);
|
|
77
|
+
const truncated = capped.truncated || Boolean(level === "function" ? result.functions?.truncated : result.imports?.truncated);
|
|
78
|
+
return { edges: capped.edges, groups, level, nodes: capped.nodes, truncated };
|
|
79
|
+
}
|
|
80
|
+
export { buildCodeMapData };
|
|
81
|
+
//# sourceMappingURL=map.js.map
|