@signalsafe/tree-spec-editor 0.1.1 → 0.2.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.
Files changed (56) hide show
  1. package/README.md +659 -4
  2. package/dist/index.d.ts +48 -7
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +39 -5
  5. package/dist/lib/PanelHeaderCollapseCarets.d.ts +10 -0
  6. package/dist/lib/PanelHeaderCollapseCarets.d.ts.map +1 -0
  7. package/dist/lib/PanelHeaderCollapseCarets.js +13 -0
  8. package/dist/lib/buildDefaultToolbarSpec.d.ts +157 -0
  9. package/dist/lib/buildDefaultToolbarSpec.d.ts.map +1 -0
  10. package/dist/lib/buildDefaultToolbarSpec.js +202 -0
  11. package/dist/lib/panelHelpers.d.ts +9 -0
  12. package/dist/lib/panelHelpers.d.ts.map +1 -0
  13. package/dist/lib/panelHelpers.js +22 -0
  14. package/dist/modals/AuditLogModal.d.ts +21 -0
  15. package/dist/modals/AuditLogModal.d.ts.map +1 -0
  16. package/dist/modals/AuditLogModal.js +23 -0
  17. package/dist/modals/DraftHistoryModal.d.ts +34 -0
  18. package/dist/modals/DraftHistoryModal.d.ts.map +1 -0
  19. package/dist/modals/DraftHistoryModal.js +27 -0
  20. package/dist/modals/PublishReviewModal.d.ts +37 -0
  21. package/dist/modals/PublishReviewModal.d.ts.map +1 -0
  22. package/dist/modals/PublishReviewModal.js +25 -0
  23. package/dist/panels/AdvancedJsonPanel.d.ts +27 -0
  24. package/dist/panels/AdvancedJsonPanel.d.ts.map +1 -0
  25. package/dist/panels/AdvancedJsonPanel.js +11 -0
  26. package/dist/panels/GraphEditorInfoPanel.d.ts +20 -0
  27. package/dist/panels/GraphEditorInfoPanel.d.ts.map +1 -0
  28. package/dist/panels/GraphEditorInfoPanel.js +25 -0
  29. package/dist/panels/InspectorPanel.d.ts +79 -0
  30. package/dist/panels/InspectorPanel.d.ts.map +1 -0
  31. package/dist/panels/InspectorPanel.js +63 -0
  32. package/dist/panels/IssuesPanel.d.ts +33 -0
  33. package/dist/panels/IssuesPanel.d.ts.map +1 -0
  34. package/dist/panels/IssuesPanel.js +46 -0
  35. package/dist/panels/NodesPanel.d.ts +28 -0
  36. package/dist/panels/NodesPanel.d.ts.map +1 -0
  37. package/dist/panels/NodesPanel.js +56 -0
  38. package/dist/panels/SelectedEdgePanel.d.ts +18 -0
  39. package/dist/panels/SelectedEdgePanel.d.ts.map +1 -0
  40. package/dist/panels/SelectedEdgePanel.js +9 -0
  41. package/dist/panels/ToolbarPanel.d.ts +90 -0
  42. package/dist/panels/ToolbarPanel.d.ts.map +1 -0
  43. package/dist/panels/ToolbarPanel.js +59 -0
  44. package/package.json +7 -3
  45. package/dist/TreeSpecGraphEditor.d.ts +0 -16
  46. package/dist/TreeSpecGraphEditor.d.ts.map +0 -1
  47. package/dist/TreeSpecGraphEditor.js +0 -272
  48. package/dist/editorHelpers.d.ts +0 -16
  49. package/dist/editorHelpers.d.ts.map +0 -1
  50. package/dist/editorHelpers.js +0 -67
  51. package/dist/model.d.ts +0 -23
  52. package/dist/model.d.ts.map +0 -1
  53. package/dist/model.js +0 -1
  54. package/dist/treeLayout.d.ts +0 -11
  55. package/dist/treeLayout.d.ts.map +0 -1
  56. package/dist/treeLayout.js +0 -63
@@ -1,63 +0,0 @@
1
- import { END_NODE_ID } from './model';
2
- /** Next default position for a newly added node (simple grid down the canvas). */
3
- export function getNextSpawnPosition(tree) {
4
- const count = Object.keys(tree.nodes).length;
5
- return { x: 80, y: 80 + count * 44 };
6
- }
7
- /**
8
- * Assign node positions in a layered layout from the start node (BFS), then fit-style grid.
9
- */
10
- export function autoLayoutTree(tree) {
11
- const level = {};
12
- const byLevel = {};
13
- const q = [];
14
- const start = tree.start_node;
15
- level[start] = 0;
16
- q.push(start);
17
- const outgoing = (id) => {
18
- const out = [];
19
- for (const t of tree.transitions) {
20
- if (t.fromNodeId !== id)
21
- continue;
22
- if (!t.toNodeId || t.toNodeId === END_NODE_ID)
23
- continue;
24
- out.push(t.toNodeId);
25
- }
26
- return out;
27
- };
28
- while (q.length) {
29
- const cur = q.shift();
30
- const curLevel = level[cur];
31
- for (const nxt of outgoing(cur)) {
32
- if (level[nxt] !== undefined)
33
- continue;
34
- level[nxt] = curLevel + 1;
35
- q.push(nxt);
36
- }
37
- }
38
- const allNodeIds = Object.keys(tree.nodes);
39
- const maxLevel = Math.max(0, ...Object.values(level));
40
- for (const id of allNodeIds) {
41
- level[id] ?? (level[id] = maxLevel + 1);
42
- }
43
- for (const id of allNodeIds) {
44
- const l = level[id];
45
- if (!byLevel[l])
46
- byLevel[l] = [];
47
- byLevel[l].push(id);
48
- }
49
- const spacingX = 420;
50
- const spacingY = 180;
51
- const marginX = 60;
52
- const marginY = 40;
53
- const nextNodes = { ...tree.nodes };
54
- for (const [lvlStr, ids] of Object.entries(byLevel)) {
55
- const lvl = Number(lvlStr);
56
- ids.sort((left, right) => left.localeCompare(right));
57
- ids.forEach((id, idx) => {
58
- const n = nextNodes[id];
59
- n.position = { x: marginX + lvl * spacingX, y: marginY + idx * spacingY };
60
- });
61
- }
62
- return { ...tree, nodes: nextNodes };
63
- }