glassbrain 0.2.0-alpha.6 → 0.2.0-alpha.8
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/README.md +6 -7
- package/dist/chunks/{chunk-LMYD4QHC.js → chunk-3CNHFYHG.js} +1329 -1610
- package/dist/chunks/chunk-7PWRJEZT.js +35 -0
- package/dist/chunks/chunk-CHOCJIOD.js +1340 -0
- package/dist/chunks/chunk-DHYIMBHU.js +960 -0
- package/dist/chunks/{chunk-3SAL4526.js → chunk-NDUF3CBQ.js} +349 -989
- package/dist/cli/glassbrain.js +441 -230
- package/dist/cli/viewer.js +228 -194
- package/dist/core.d.ts +2 -0
- package/dist/core.js +54 -26
- package/dist/diff.d.ts +9 -1
- package/dist/edit.d.ts +10 -0
- package/dist/index.js +63 -35
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +103 -73
- package/dist/kinds.d.ts +23 -0
- package/dist/layers.d.ts +3 -1
- package/dist/lint-report.d.ts +70 -0
- package/dist/profile.d.ts +15 -3
- package/dist/react/DetailPanel.d.ts +31 -1
- package/dist/react/DetailPanel.js +8 -4
- package/dist/react/EdgeMark.d.ts +22 -0
- package/dist/react/EditPanel.d.ts +6 -6
- package/dist/react/GraphCanvas.d.ts +18 -5
- package/dist/react/GraphCanvas.js +4 -4
- package/dist/react/Inspector.d.ts +72 -0
- package/dist/react/ObjectRef.d.ts +12 -0
- package/dist/react/Toolbar.d.ts +10 -3
- package/dist/react/ZoomBoundary.d.ts +4 -0
- package/dist/react/camera.d.ts +7 -0
- package/dist/react/i18n.d.ts +2 -2
- package/dist/react/icons.d.ts +7 -1
- package/dist/react/input.d.ts +5 -3
- package/dist/react/useSubgraph.d.ts +15 -0
- package/dist/shell.d.ts +1 -0
- package/dist/strings.d.ts +24 -3
- package/dist/style.d.ts +2 -0
- package/dist/subgraph.d.ts +13 -0
- package/dist/tree.d.ts +1 -0
- package/dist/view.d.ts +3 -1
- package/package.json +1 -1
- package/schema/profile.schema.json +2 -2
- package/dist/chunks/chunk-3P34XHQ2.js +0 -244
- package/dist/chunks/chunk-5DEN6HXJ.js +0 -99
- package/dist/chunks/chunk-M3MAM2VD.js +0 -67
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/kinds.ts
|
|
2
|
+
function kindDistribution(items) {
|
|
3
|
+
const counts = /* @__PURE__ */ new Map();
|
|
4
|
+
for (const item of items) if (item.kind) counts.set(item.kind, (counts.get(item.kind) ?? 0) + 1);
|
|
5
|
+
const sizes = [...counts].map(([kind, count]) => ({ kind, count })).sort((a, b) => b.count - a.count || a.kind.localeCompare(b.kind));
|
|
6
|
+
const typed = sizes.reduce((sum, row) => sum + row.count, 0);
|
|
7
|
+
const effective = sizes.reduce((sum, row) => sum + Math.sqrt(row.count / typed), 0) ** 2;
|
|
8
|
+
const fragmentation = typed > 1 ? effective / Math.log(typed) : 0;
|
|
9
|
+
return {
|
|
10
|
+
total: items.length,
|
|
11
|
+
typed,
|
|
12
|
+
missing: items.length - typed,
|
|
13
|
+
count: sizes.length,
|
|
14
|
+
sizes,
|
|
15
|
+
effective,
|
|
16
|
+
fragmentation,
|
|
17
|
+
reason: typed >= 10 && fragmentation > 2 ? "too fragmented" : null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function kindHeading(space, d) {
|
|
21
|
+
return `${space} kinds: ${d.count}${d.reason ? ` (${d.reason})` : ""}`;
|
|
22
|
+
}
|
|
23
|
+
function kindSummary(space, d, labels = {}) {
|
|
24
|
+
return [
|
|
25
|
+
kindHeading(space, d),
|
|
26
|
+
...d.sizes.map((row) => `${Object.hasOwn(labels, row.kind) ? labels[row.kind] : row.kind} ${row.count}/${d.total}`),
|
|
27
|
+
...d.missing ? [`(no kind) ${d.missing}/${d.total}`] : []
|
|
28
|
+
].join(" | ");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
kindDistribution,
|
|
33
|
+
kindHeading,
|
|
34
|
+
kindSummary
|
|
35
|
+
};
|