glassbrain 0.2.0-alpha.7 → 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.
Files changed (44) hide show
  1. package/README.md +6 -7
  2. package/dist/chunks/{chunk-GZSWZSSE.js → chunk-3CNHFYHG.js} +1317 -1650
  3. package/dist/chunks/chunk-7PWRJEZT.js +35 -0
  4. package/dist/chunks/chunk-CHOCJIOD.js +1340 -0
  5. package/dist/chunks/chunk-DHYIMBHU.js +960 -0
  6. package/dist/chunks/{chunk-FNTYI7VP.js → chunk-NDUF3CBQ.js} +340 -996
  7. package/dist/cli/glassbrain.js +338 -142
  8. package/dist/cli/viewer.js +218 -213
  9. package/dist/core.d.ts +1 -0
  10. package/dist/core.js +50 -30
  11. package/dist/diff.d.ts +9 -1
  12. package/dist/edit.d.ts +10 -0
  13. package/dist/index.js +57 -37
  14. package/dist/internal.d.ts +1 -0
  15. package/dist/internal.js +98 -76
  16. package/dist/layers.d.ts +3 -1
  17. package/dist/lint-report.d.ts +70 -0
  18. package/dist/profile.d.ts +10 -2
  19. package/dist/react/DetailPanel.d.ts +31 -1
  20. package/dist/react/DetailPanel.js +8 -4
  21. package/dist/react/EdgeMark.d.ts +22 -0
  22. package/dist/react/EditPanel.d.ts +6 -6
  23. package/dist/react/GraphCanvas.d.ts +17 -6
  24. package/dist/react/GraphCanvas.js +4 -4
  25. package/dist/react/Inspector.d.ts +72 -0
  26. package/dist/react/ObjectRef.d.ts +12 -0
  27. package/dist/react/Toolbar.d.ts +10 -3
  28. package/dist/react/ZoomBoundary.d.ts +4 -0
  29. package/dist/react/camera.d.ts +7 -0
  30. package/dist/react/i18n.d.ts +2 -2
  31. package/dist/react/icons.d.ts +7 -3
  32. package/dist/react/input.d.ts +5 -3
  33. package/dist/react/useSubgraph.d.ts +15 -0
  34. package/dist/shell.d.ts +1 -0
  35. package/dist/strings.d.ts +23 -2
  36. package/dist/style.d.ts +2 -0
  37. package/dist/subgraph.d.ts +13 -0
  38. package/dist/tree.d.ts +1 -0
  39. package/dist/view.d.ts +3 -1
  40. package/package.json +1 -1
  41. package/dist/chunks/chunk-3KUNYSJE.js +0 -246
  42. package/dist/chunks/chunk-LK77SYCN.js +0 -100
  43. package/dist/chunks/chunk-Q35ZKWKF.js +0 -99
  44. package/dist/react/GlassPlanes.d.ts +0 -11
@@ -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
+ };