project-graph-mcp 2.2.6 → 2.3.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 (150) hide show
  1. package/ARCHITECTURE.md +81 -0
  2. package/CHANGELOG.md +57 -0
  3. package/README.md +9 -4
  4. package/package.json +6 -13
  5. package/src/compact/expand.js +1 -1
  6. package/src/core/graph-builder.js +2 -2
  7. package/src/core/parser.js +2 -2
  8. package/src/network/server.js +1 -2
  9. package/vendor/symbiote-node/CHANGELOG.md +31 -0
  10. package/vendor/symbiote-node/LICENSE +21 -0
  11. package/vendor/symbiote-node/README.md +206 -0
  12. package/vendor/symbiote-node/canvas/AutoLayout.js +725 -0
  13. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.css.js +73 -0
  14. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.js +93 -0
  15. package/vendor/symbiote-node/canvas/Breadcrumb/Breadcrumb.tpl.js +9 -0
  16. package/vendor/symbiote-node/canvas/CanvasConnectionRenderer.js +962 -0
  17. package/vendor/symbiote-node/canvas/ConnectionRenderer.js +1468 -0
  18. package/vendor/symbiote-node/canvas/FlowSimulator.js +323 -0
  19. package/vendor/symbiote-node/canvas/ForceLayout.js +189 -0
  20. package/vendor/symbiote-node/canvas/ForceWorker.js +1325 -0
  21. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.css.js +97 -0
  22. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.js +176 -0
  23. package/vendor/symbiote-node/canvas/GraphTabs/GraphTabs.tpl.js +12 -0
  24. package/vendor/symbiote-node/canvas/LODManager.js +88 -0
  25. package/vendor/symbiote-node/canvas/Minimap/Minimap.css.js +71 -0
  26. package/vendor/symbiote-node/canvas/Minimap/Minimap.js +207 -0
  27. package/vendor/symbiote-node/canvas/Minimap/Minimap.tpl.js +9 -0
  28. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.css.js +261 -0
  29. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.js +1840 -0
  30. package/vendor/symbiote-node/canvas/NodeCanvas/NodeCanvas.tpl.js +22 -0
  31. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.css.js +97 -0
  32. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.js +132 -0
  33. package/vendor/symbiote-node/canvas/NodeSearch/NodeSearch.tpl.js +21 -0
  34. package/vendor/symbiote-node/canvas/NodeViewManager.js +584 -0
  35. package/vendor/symbiote-node/canvas/PinExpansion.js +131 -0
  36. package/vendor/symbiote-node/canvas/PseudoConnection.js +80 -0
  37. package/vendor/symbiote-node/canvas/SubgraphManager.js +201 -0
  38. package/vendor/symbiote-node/canvas/SubgraphRouter.js +443 -0
  39. package/vendor/symbiote-node/canvas/ViewportActions.js +446 -0
  40. package/vendor/symbiote-node/core/Connection.js +45 -0
  41. package/vendor/symbiote-node/core/Editor.js +451 -0
  42. package/vendor/symbiote-node/core/Frame.js +31 -0
  43. package/vendor/symbiote-node/core/GraphMermaid.js +348 -0
  44. package/vendor/symbiote-node/core/GraphText.js +210 -0
  45. package/vendor/symbiote-node/core/Node.js +143 -0
  46. package/vendor/symbiote-node/core/Portal.js +104 -0
  47. package/vendor/symbiote-node/core/Socket.js +185 -0
  48. package/vendor/symbiote-node/core/SubgraphNode.js +125 -0
  49. package/vendor/symbiote-node/index.js +103 -0
  50. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.css.js +361 -0
  51. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.js +332 -0
  52. package/vendor/symbiote-node/inspector/InspectorPanel/InspectorPanel.tpl.js +96 -0
  53. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.css.js +104 -0
  54. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.js +133 -0
  55. package/vendor/symbiote-node/inspector/TemplatePreview/TemplatePreview.tpl.js +33 -0
  56. package/vendor/symbiote-node/interactions/ConnectFlow.js +307 -0
  57. package/vendor/symbiote-node/interactions/Drag.js +102 -0
  58. package/vendor/symbiote-node/interactions/Selector.js +132 -0
  59. package/vendor/symbiote-node/interactions/SnapGrid.js +65 -0
  60. package/vendor/symbiote-node/interactions/Zoom.js +140 -0
  61. package/vendor/symbiote-node/layout/ActionZone/ActionZone.css.js +88 -0
  62. package/vendor/symbiote-node/layout/ActionZone/ActionZone.js +254 -0
  63. package/vendor/symbiote-node/layout/ActionZone/ActionZone.tpl.js +11 -0
  64. package/vendor/symbiote-node/layout/Layout/Layout.css.js +88 -0
  65. package/vendor/symbiote-node/layout/Layout/Layout.js +622 -0
  66. package/vendor/symbiote-node/layout/Layout/Layout.tpl.js +25 -0
  67. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.css.js +293 -0
  68. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.js +467 -0
  69. package/vendor/symbiote-node/layout/LayoutNode/LayoutNode.tpl.js +33 -0
  70. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.css.js +46 -0
  71. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.js +102 -0
  72. package/vendor/symbiote-node/layout/LayoutPreview/LayoutPreview.tpl.js +6 -0
  73. package/vendor/symbiote-node/layout/LayoutRouter/LayoutRouter.js +156 -0
  74. package/vendor/symbiote-node/layout/LayoutRouter/routerSync.js +250 -0
  75. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.css.js +379 -0
  76. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.js +263 -0
  77. package/vendor/symbiote-node/layout/LayoutSidebar/LayoutSidebar.tpl.js +20 -0
  78. package/vendor/symbiote-node/layout/LayoutSidebar/SidebarSection.js +183 -0
  79. package/vendor/symbiote-node/layout/LayoutTree.js +246 -0
  80. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.css.js +43 -0
  81. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.js +89 -0
  82. package/vendor/symbiote-node/layout/PanelMenu/PanelMenu.tpl.js +14 -0
  83. package/vendor/symbiote-node/layout/index.js +16 -0
  84. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.css.js +61 -0
  85. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.js +79 -0
  86. package/vendor/symbiote-node/menu/ContextMenu/ContextMenu.tpl.js +19 -0
  87. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.css.js +41 -0
  88. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.js +24 -0
  89. package/vendor/symbiote-node/node/CtrlItem/CtrlItem.tpl.js +16 -0
  90. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.css.js +65 -0
  91. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.js +29 -0
  92. package/vendor/symbiote-node/node/GraphFrame/GraphFrame.tpl.js +13 -0
  93. package/vendor/symbiote-node/node/GraphNode/GraphNode.css.js +683 -0
  94. package/vendor/symbiote-node/node/GraphNode/GraphNode.js +92 -0
  95. package/vendor/symbiote-node/node/GraphNode/GraphNode.tpl.js +17 -0
  96. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.js +25 -0
  97. package/vendor/symbiote-node/node/NodeSocket/NodeSocket.tpl.js +7 -0
  98. package/vendor/symbiote-node/node/PortItem/PortItem.css.js +90 -0
  99. package/vendor/symbiote-node/node/PortItem/PortItem.js +87 -0
  100. package/vendor/symbiote-node/node/PortItem/PortItem.tpl.js +10 -0
  101. package/vendor/symbiote-node/package.json +59 -0
  102. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.css.js +143 -0
  103. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.js +131 -0
  104. package/vendor/symbiote-node/palette/PaletteBrowser/PaletteBrowser.tpl.js +16 -0
  105. package/vendor/symbiote-node/plugins/History.js +384 -0
  106. package/vendor/symbiote-node/plugins/Readonly.js +59 -0
  107. package/vendor/symbiote-node/shapes/CircleShape.js +80 -0
  108. package/vendor/symbiote-node/shapes/CommentShape.js +35 -0
  109. package/vendor/symbiote-node/shapes/DiamondShape.js +115 -0
  110. package/vendor/symbiote-node/shapes/NodeShape.js +80 -0
  111. package/vendor/symbiote-node/shapes/PillShape.js +91 -0
  112. package/vendor/symbiote-node/shapes/RectShape.js +72 -0
  113. package/vendor/symbiote-node/shapes/SVGShape.js +494 -0
  114. package/vendor/symbiote-node/shapes/index.js +53 -0
  115. package/vendor/symbiote-node/themes/Palette.js +32 -0
  116. package/vendor/symbiote-node/themes/Skin.js +113 -0
  117. package/vendor/symbiote-node/themes/Theme.js +84 -0
  118. package/vendor/symbiote-node/themes/carbon.js +137 -0
  119. package/vendor/symbiote-node/themes/dark.js +137 -0
  120. package/vendor/symbiote-node/themes/ebook.js +138 -0
  121. package/vendor/symbiote-node/themes/grey.js +137 -0
  122. package/vendor/symbiote-node/themes/light.js +137 -0
  123. package/vendor/symbiote-node/themes/neon.js +138 -0
  124. package/vendor/symbiote-node/themes/pcb.js +273 -0
  125. package/vendor/symbiote-node/themes/synthwave.js +137 -0
  126. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.css.js +86 -0
  127. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.js +128 -0
  128. package/vendor/symbiote-node/toolbar/QuickToolbar/QuickToolbar.tpl.js +29 -0
  129. package/web/app.js +6 -5
  130. package/web/components/canvas-graph.js +1666 -0
  131. package/web/components/event-feed/CodeWidget.js +32 -0
  132. package/web/components/event-feed/EventWidget.js +97 -0
  133. package/web/components/event-feed/ListWidget.js +57 -0
  134. package/web/components/event-feed/MiniGraphWidget.js +69 -0
  135. package/web/dashboard.js +1 -1
  136. package/web/index.html +4 -0
  137. package/web/panels/ActionBoard/ActionBoard.js +1 -1
  138. package/web/panels/SettingsPanel/SettingsPanel.tpl.js +1 -1
  139. package/web/panels/code-viewer.js +50 -15
  140. package/web/panels/dep-graph.js +2712 -7
  141. package/web/panels/file-tree.js +5 -2
  142. package/web/panels/live-monitor.js +75 -3
  143. package/web/style.css +33 -0
  144. package/docs/img/explorer-compact.jpg +0 -0
  145. package/docs/img/explorer-expanded.jpg +0 -0
  146. package/src/.contextignore +0 -22
  147. package/src/.project-graph-cache.json +0 -1
  148. package/src/compact/.project-graph-cache.json +0 -1
  149. package/web/.project-graph-cache.json +0 -1
  150. package/web/panels/SettingsPanel/.project-graph-cache.json +0 -1
@@ -0,0 +1,96 @@
1
+ /**
2
+ * InspectorPanel template
3
+ * @module symbiote-node/inspector/InspectorPanel.tpl
4
+ */
5
+ import { html } from '@symbiotejs/symbiote';
6
+
7
+ export const template = html`
8
+ <div class="insp-resize-handle"></div>
9
+
10
+ <div class="insp-body">
11
+ <div class="insp-empty">
12
+ <span class="material-symbols-outlined">touch_app</span>
13
+ <span>Select a node</span>
14
+ </div>
15
+
16
+ <div class="insp-content" hidden>
17
+ <div class="insp-field">
18
+ <label>Label</label>
19
+ <div class="insp-value">{{nodeLabel}}</div>
20
+ </div>
21
+ <div class="insp-field">
22
+ <label>Type</label>
23
+ <div class="insp-value insp-tag">{{nodeType}}</div>
24
+ </div>
25
+ <div class="insp-field">
26
+ <label>Category</label>
27
+ <div class="insp-value insp-tag">{{nodeCategory}}</div>
28
+ </div>
29
+ <div class="insp-field">
30
+ <label>ID</label>
31
+ <div class="insp-value insp-mono">{{nodeId}}</div>
32
+ </div>
33
+
34
+ <div class="insp-section">
35
+ <div class="insp-section-title">
36
+ <span class="material-symbols-outlined">input</span> Inputs
37
+ </div>
38
+ <div ${{ itemize: 'inputsList', 'item-tag': 'insp-port-item' }}></div>
39
+ </div>
40
+
41
+ <div class="insp-section">
42
+ <div class="insp-section-title">
43
+ <span class="material-symbols-outlined">output</span> Outputs
44
+ </div>
45
+ <div ${{ itemize: 'outputsList', 'item-tag': 'insp-port-item' }}></div>
46
+ </div>
47
+
48
+ <div class="insp-section">
49
+ <div class="insp-section-title">
50
+ <span class="material-symbols-outlined">tune</span> Controls
51
+ </div>
52
+ <div ${{ itemize: 'controlsList', 'item-tag': 'insp-ctrl-item' }}></div>
53
+ </div>
54
+
55
+ <div class="insp-template-preview" ${{ '@hidden': '!isTemplateBuilder' }}>
56
+ <template-preview></template-preview>
57
+ </div>
58
+
59
+ <div class="insp-fire" ${{ '@hidden': '!isFireable' }}>
60
+ <button class="insp-fire-btn" ${{ onclick: 'onFire' }}>
61
+ <span class="material-symbols-outlined">play_arrow</span>
62
+ Fire
63
+ </button>
64
+ </div>
65
+
66
+ <div class="insp-subgraph" hidden>
67
+ <div class="insp-section-title">
68
+ <span class="material-symbols-outlined">account_tree</span> Subgraph
69
+ </div>
70
+ <div class="insp-field">
71
+ <label>Inner Nodes</label>
72
+ <div class="insp-value">{{innerNodeCount}}</div>
73
+ </div>
74
+ <button class="insp-enter-btn" ${{ onclick: 'onEnterSubgraph' }}>
75
+ <span class="material-symbols-outlined">login</span>
76
+ Enter Subgraph
77
+ </button>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ `;
82
+
83
+ export const inspPortItemTemplate = html`
84
+ <div class="insp-port">
85
+ <span class="insp-port-dot"></span>
86
+ <span class="insp-port-label">{{label}}</span>
87
+ <span class="insp-port-type">{{socketType}}</span>
88
+ </div>
89
+ `;
90
+
91
+ export const inspCtrlItemTemplate = html`
92
+ <div class="insp-ctrl">
93
+ <label class="insp-ctrl-label">{{label}}</label>
94
+ <div class="insp-ctrl-input"></div>
95
+ </div>
96
+ `;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * TemplatePreview styles
3
+ * @module symbiote-node/inspector/TemplatePreview.css
4
+ */
5
+ import { css } from '@symbiotejs/symbiote';
6
+
7
+ export const styles = css`
8
+ template-preview {
9
+ display: block;
10
+ padding-top: 8px;
11
+
12
+ & .tpl-preview-section {
13
+ margin-bottom: 10px;
14
+ }
15
+
16
+ & .tpl-chips-label,
17
+ & .tpl-preview-label {
18
+ display: flex;
19
+ align-items: center;
20
+ gap: 4px;
21
+ font-size: 10px;
22
+ font-weight: 600;
23
+ text-transform: uppercase;
24
+ color: var(--sn-text-dim, #888);
25
+ margin-bottom: 4px;
26
+ letter-spacing: 0.5px;
27
+ }
28
+
29
+ & .tpl-chips-label .material-symbols-outlined,
30
+ & .tpl-preview-label .material-symbols-outlined {
31
+ font-size: 14px;
32
+ opacity: 0.6;
33
+ }
34
+
35
+ & .tpl-chips {
36
+ display: flex;
37
+ flex-wrap: wrap;
38
+ gap: 4px;
39
+ }
40
+
41
+ & .tpl-chips-empty {
42
+ font-size: 11px;
43
+ color: var(--sn-text-dim, #666);
44
+ font-style: italic;
45
+ padding: 4px 0;
46
+
47
+ &[hidden] {
48
+ display: none;
49
+ }
50
+ }
51
+
52
+ & .tpl-test-data {
53
+ width: 100%;
54
+ padding: 6px 8px;
55
+ font-size: 11px;
56
+ font-family: 'SF Mono', 'Fira Code', monospace;
57
+ color: var(--sn-text, #d4d4d4);
58
+ background: color-mix(in srgb, currentColor 6%, transparent);
59
+ border: 1px solid rgba(255,255,255,0.06);
60
+ border-radius: 4px;
61
+ outline: none;
62
+ resize: vertical;
63
+ min-height: 50px;
64
+ box-sizing: border-box;
65
+ line-height: 1.4;
66
+ transition: border-color 0.15s;
67
+
68
+ &:focus {
69
+ border-color: var(--sn-node-selected, #4a9eff);
70
+ }
71
+ }
72
+
73
+ & .tpl-preview-result {
74
+ font-size: 12px;
75
+ font-family: 'SF Mono', 'Fira Code', monospace;
76
+ color: var(--sn-text, #d4d4d4);
77
+ background: color-mix(in srgb, currentColor 4%, transparent);
78
+ border: 1px solid rgba(255,255,255,0.04);
79
+ border-radius: 4px;
80
+ padding: 8px;
81
+ white-space: pre-wrap;
82
+ word-break: break-word;
83
+ min-height: 30px;
84
+ line-height: 1.4;
85
+ }
86
+ }
87
+
88
+ .tpl-chip {
89
+ display: inline-block;
90
+ padding: 2px 8px;
91
+ font-size: 11px;
92
+ font-family: 'SF Mono', 'Fira Code', monospace;
93
+ border-radius: 10px;
94
+ background: color-mix(in srgb, #4caf50 20%, transparent);
95
+ color: #81c784;
96
+ border: 1px solid rgba(76, 175, 80, 0.3);
97
+
98
+ &[data-missing] {
99
+ background: color-mix(in srgb, #f44336 20%, transparent);
100
+ color: #ef9a9a;
101
+ border-color: rgba(244, 67, 54, 0.3);
102
+ }
103
+ }
104
+ `;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * TemplatePreview — live preview for template-builder node
3
+ *
4
+ * Shows placeholder chips (resolved/missing), test data input,
5
+ * and interpolated preview text. Updates reactively.
6
+ *
7
+ * @module symbiote-node/inspector/TemplatePreview
8
+ */
9
+
10
+ import Symbiote from '@symbiotejs/symbiote';
11
+ import { template } from './TemplatePreview.tpl.js';
12
+ import { styles } from './TemplatePreview.css.js';
13
+ import { extractPlaceholders } from '../../engine/packs/transform/template-builder.handler.js';
14
+
15
+ const DEFAULT_TEST_DATA = JSON.stringify({
16
+ status: 'created',
17
+ region: 'RU',
18
+ jobUid: '00c3b879-example',
19
+ details: 'Test delivery',
20
+ timestamp: new Date().toISOString(),
21
+ }, null, 2);
22
+
23
+ export class TemplatePreview extends Symbiote {
24
+ init$ = {
25
+ template: '',
26
+ testData: DEFAULT_TEST_DATA,
27
+ placeholderChips: [],
28
+ previewText: '',
29
+ noPlaceholders: true,
30
+ };
31
+
32
+ renderCallback() {
33
+ // Bind textarea to testData
34
+ /** @type {HTMLTextAreaElement|null} */
35
+ const textarea = this.querySelector('.tpl-test-data');
36
+ if (textarea) {
37
+ textarea.value = this.$.testData;
38
+ textarea.addEventListener('input', () => {
39
+ this.$.testData = textarea.value;
40
+ });
41
+ }
42
+
43
+ // React to template changes
44
+ this.sub('template', () => this._updatePreview());
45
+ this.sub('testData', () => this._updatePreview());
46
+ }
47
+
48
+ /**
49
+ * Extract placeholders, interpolate template, update chips + preview.
50
+ */
51
+ _updatePreview() {
52
+ const tpl = this.$.template;
53
+ const placeholders = extractPlaceholders(tpl);
54
+
55
+ this.$.noPlaceholders = placeholders.length === 0;
56
+
57
+ // Parse test data
58
+ let data = {};
59
+ try {
60
+ data = JSON.parse(this.$.testData);
61
+ } catch {
62
+ this.$.previewText = '⚠️ Invalid JSON in test data';
63
+ this.$.placeholderChips = placeholders.map((name) => ({ name }));
64
+ this._applyChipColors([]);
65
+ return;
66
+ }
67
+
68
+ // Build chips with resolved status
69
+ const resolved = [];
70
+ const chips = placeholders.map((name) => {
71
+ const val = this._resolvePath(data, name);
72
+ const isResolved = val !== undefined;
73
+ if (isResolved) resolved.push(name);
74
+ return { name };
75
+ });
76
+
77
+ this.$.placeholderChips = chips;
78
+
79
+ // Apply chip colors after itemize renders
80
+ requestAnimationFrame(() => this._applyChipColors(resolved));
81
+
82
+ // Interpolate
83
+ if (!tpl) {
84
+ this.$.previewText = '';
85
+ return;
86
+ }
87
+
88
+ const text = tpl.replace(/\{\{?([^{}]+)\}?\}/g, (match, key) => {
89
+ const trimmed = key.trim();
90
+ const value = this._resolvePath(data, trimmed);
91
+ if (value === undefined) return match;
92
+ if (typeof value === 'object') return JSON.stringify(value);
93
+ return String(value);
94
+ });
95
+
96
+ this.$.previewText = text;
97
+ }
98
+
99
+ /**
100
+ * Apply data-missing attribute to chip elements based on resolved status.
101
+ *
102
+ * @param {string[]} resolved - Names of resolved placeholders
103
+ */
104
+ _applyChipColors(resolved) {
105
+ const chipEls = this.querySelectorAll('.tpl-chip');
106
+ chipEls.forEach((el) => {
107
+ const name = el.textContent?.trim();
108
+ if (name && !resolved.includes(name)) {
109
+ el.setAttribute('data-missing', '');
110
+ } else {
111
+ el.removeAttribute('data-missing');
112
+ }
113
+ });
114
+ }
115
+
116
+ /**
117
+ * Resolve a dot-notation path in an object.
118
+ *
119
+ * @param {Object} obj - Data object
120
+ * @param {string} path - Dot-separated path
121
+ * @returns {*} Resolved value or undefined
122
+ */
123
+ _resolvePath(obj, path) {
124
+ return path.split('.').reduce((o, k) => {
125
+ if (o === null || o === undefined) return undefined;
126
+ return o[k];
127
+ }, obj);
128
+ }
129
+ }
130
+
131
+ TemplatePreview.template = template;
132
+ TemplatePreview.rootStyles = styles;
133
+ TemplatePreview.reg('template-preview');
@@ -0,0 +1,33 @@
1
+ /**
2
+ * TemplatePreview template
3
+ * @module symbiote-node/inspector/TemplatePreview.tpl
4
+ */
5
+ import { html } from '@symbiotejs/symbiote';
6
+
7
+ export const template = html`
8
+ <div class="tpl-preview-section">
9
+ <div class="tpl-chips-label">
10
+ <span class="material-symbols-outlined">sell</span> Placeholders
11
+ </div>
12
+ <div class="tpl-chips" itemize="placeholderChips">
13
+ <template>
14
+ <span class="tpl-chip">{{name}}</span>
15
+ </template>
16
+ </div>
17
+ <div class="tpl-chips-empty" ${{ '@hidden': '!noPlaceholders' }}>
18
+ Type {field} in template to add placeholders
19
+ </div>
20
+ </div>
21
+ <div class="tpl-preview-section">
22
+ <div class="tpl-preview-label">
23
+ <span class="material-symbols-outlined">data_object</span> Test Data (JSON)
24
+ </div>
25
+ <textarea class="tpl-test-data" rows="3" spellcheck="false"></textarea>
26
+ </div>
27
+ <div class="tpl-preview-section">
28
+ <div class="tpl-preview-label">
29
+ <span class="material-symbols-outlined">visibility</span> Preview
30
+ </div>
31
+ <div class="tpl-preview-result" ${{ textContent: 'previewText' }}></div>
32
+ </div>
33
+ `;
@@ -0,0 +1,307 @@
1
+ /**
2
+ * ConnectFlow — interactive socket-to-socket connection creation
3
+ *
4
+ * Simplified version of Rete.js ClassicFlow.
5
+ * Handles: pointerdown on socket → drag pseudo-line → pointerup on target socket → create connection.
6
+ *
7
+ * @module symbiote-node/interactions/ConnectFlow
8
+ */
9
+
10
+ import { Connection } from '../core/Connection.js';
11
+
12
+ /**
13
+ * @typedef {object} SocketData
14
+ * @property {string} nodeId - Node ID
15
+ * @property {string} key - Port key
16
+ * @property {'input'|'output'} side - Port side
17
+ * @property {HTMLElement} element - Socket DOM element
18
+ */
19
+
20
+ export class ConnectFlow {
21
+
22
+ /** @type {SocketData|null} */
23
+ #picked = null;
24
+
25
+ /** @type {import('../core/Editor.js').NodeEditor} */
26
+ #editor;
27
+
28
+ /** @type {function} */
29
+ #getNodePosition;
30
+
31
+ /** @type {function} */
32
+ #getNodeSize;
33
+
34
+ /** @type {function} */
35
+ #getTransform;
36
+
37
+ /** @type {function|null} */
38
+ #onPseudoStart = null;
39
+
40
+ /** @type {function|null} */
41
+ #onPseudoMove = null;
42
+
43
+ /** @type {function|null} */
44
+ #onPseudoEnd = null;
45
+
46
+ /** @type {function|null} */
47
+ #onDropEmpty = null;
48
+
49
+ /** @type {function|null} - called during drag with world XY + picked socket */
50
+ #onCompatibleMove = null;
51
+
52
+ /** @type {function|null} - find nearest SVG dot as drop target */
53
+ #findNearestDot = null;
54
+
55
+ /** @type {number} - last time compatible move was emitted (ms) */
56
+ #lastMoveTime = 0;
57
+
58
+ /** @type {{ x: number, y: number }|null} - cached start position from pick */
59
+ #pickedStartPos = null;
60
+
61
+ /** @type {Set<SocketData>} */
62
+ #sockets = new Set();
63
+
64
+ /**
65
+ * @param {import('../core/Editor.js').NodeEditor} editor
66
+ * @param {object} callbacks
67
+ * @param {function} callbacks.getNodePosition
68
+ * @param {function} callbacks.getNodeSize
69
+ * @param {function} callbacks.getTransform - Returns { x, y, k, rect }
70
+ * @param {function} callbacks.onPseudoStart
71
+ * @param {function} callbacks.onPseudoMove
72
+ * @param {function} callbacks.onPseudoEnd
73
+ * @param {function} [callbacks.onDropEmpty] - Called when connection dropped in empty space
74
+ */
75
+ constructor(editor, callbacks) {
76
+ this.#editor = editor;
77
+ this.#getNodePosition = callbacks.getNodePosition;
78
+ this.#getNodeSize = callbacks.getNodeSize;
79
+ this.#getTransform = callbacks.getTransform;
80
+ this.#onPseudoStart = callbacks.onPseudoStart;
81
+ this.#onPseudoMove = callbacks.onPseudoMove;
82
+ this.#onPseudoEnd = callbacks.onPseudoEnd;
83
+ this.#onDropEmpty = callbacks.onDropEmpty || null;
84
+ this.#onCompatibleMove = callbacks.onCompatibleMove || null;
85
+ this.#findNearestDot = callbacks.findNearestDot || null;
86
+
87
+ window.addEventListener('pointermove', this.#onMove);
88
+ window.addEventListener('pointerup', this.#onUp);
89
+ }
90
+
91
+ /**
92
+ * Register a socket element for connection interaction
93
+ * @param {HTMLElement} socketEl
94
+ * @param {SocketData} data
95
+ */
96
+ registerSocket(socketEl, data) {
97
+ this.#sockets.add(data);
98
+ socketEl.addEventListener('pointerdown', (e) => {
99
+ e.stopPropagation();
100
+ e.preventDefault();
101
+ this.#pick(data);
102
+ });
103
+ }
104
+
105
+ /**
106
+ * Whether a connection drag is in progress
107
+ * @returns {boolean}
108
+ */
109
+ isPicking() {
110
+ return this.#picked !== null;
111
+ }
112
+
113
+ /**
114
+ * Get the currently picked socket data (during drag)
115
+ * @returns {SocketData|null}
116
+ */
117
+ getPickedSocket() {
118
+ return this.#picked;
119
+ }
120
+
121
+ /**
122
+ * Externally initiate a connection drag from socket data
123
+ * @param {SocketData} data
124
+ */
125
+ pickSocket(data) {
126
+ // Ensure this socket is in the registry for snap targeting
127
+ if (!this.#sockets.has(data)) {
128
+ this.#sockets.add(data);
129
+ }
130
+ this.#pick(data);
131
+ }
132
+
133
+ #pick(data) {
134
+ this.#picked = data;
135
+ const pos = this.#getSocketWorldPosition(data);
136
+ if (this.#onPseudoStart) this.#onPseudoStart(pos.x, pos.y, data);
137
+ }
138
+
139
+ #onMove = (e) => {
140
+ if (!this.#picked) return;
141
+ e.preventDefault();
142
+
143
+ const startPos = this.#getSocketWorldPosition(this.#picked);
144
+ const t = this.#getTransform();
145
+ // Use clientX/Y minus container rect for accurate positioning
146
+ const endX = (e.clientX - t.rect.left - t.x) / t.k;
147
+ const endY = (e.clientY - t.rect.top - t.y) / t.k;
148
+
149
+ if (this.#onPseudoMove) this.#onPseudoMove(startPos.x, startPos.y, endX, endY);
150
+
151
+ // Throttle to ~60fps
152
+ const now = performance.now();
153
+ if (this.#onCompatibleMove && now - this.#lastMoveTime > 16) {
154
+ this.#lastMoveTime = now;
155
+ this.#onCompatibleMove(endX, endY, this.#picked);
156
+ }
157
+ };
158
+
159
+ #onUp = (e) => {
160
+ if (!this.#picked) return;
161
+
162
+ // Find nearest compatible socket within snap distance
163
+ const t = this.#getTransform();
164
+ const pointerX = (e.clientX - t.rect.left - t.x) / t.k;
165
+ const pointerY = (e.clientY - t.rect.top - t.y) / t.k;
166
+ const target = this.#findNearestSocket(pointerX, pointerY);
167
+
168
+ if (target && this.#canConnect(this.#picked, target)) {
169
+ this.#makeConnection(this.#picked, target);
170
+ } else if (this.#findNearestDot) {
171
+ // Fallback: check SVG dots as drop target
172
+ const dotTarget = this.#findNearestDot(pointerX, pointerY);
173
+ if (dotTarget) {
174
+ const dotSocket = { nodeId: dotTarget.nodeId, key: dotTarget.key, side: dotTarget.side };
175
+ if (this.#canConnect(this.#picked, dotSocket)) {
176
+ this.#makeConnection(this.#picked, dotSocket);
177
+ } else if (this.#onDropEmpty) {
178
+ this.#onDropEmpty(pointerX, pointerY, this.#picked);
179
+ }
180
+ } else if (this.#onDropEmpty) {
181
+ this.#onDropEmpty(pointerX, pointerY, this.#picked);
182
+ }
183
+ } else if (this.#onDropEmpty) {
184
+ // No target found — emit drop-in-empty event
185
+ this.#onDropEmpty(pointerX, pointerY, this.#picked);
186
+ }
187
+
188
+ this.#picked = null;
189
+ if (this.#onPseudoEnd) this.#onPseudoEnd();
190
+ };
191
+ /**
192
+ * Get socket position in graph coordinate space
193
+ * Uses getBoundingClientRect with zoom compensation
194
+ * @param {SocketData} data
195
+ * @returns {{ x: number, y: number }}
196
+ */
197
+ #getSocketWorldPosition(data) {
198
+ // Direct world coordinates (from overlay dot drag)
199
+ if (data.worldX !== undefined && data.worldY !== undefined) {
200
+ return { x: data.worldX, y: data.worldY };
201
+ }
202
+
203
+ const pos = this.#getNodePosition(data.nodeId);
204
+ if (!pos) return { x: 0, y: 0 };
205
+
206
+ if (data.element) {
207
+ const graphNode = data.element.closest('graph-node');
208
+ if (graphNode) {
209
+ const t = this.#getTransform();
210
+ const nodeRect = graphNode.getBoundingClientRect();
211
+ const socketRect = data.element.getBoundingClientRect();
212
+ // Divide by zoom to get unscaled offset within the node
213
+ const offsetX = (socketRect.left - nodeRect.left + socketRect.width / 2) / t.k;
214
+ const offsetY = (socketRect.top - nodeRect.top + socketRect.height / 2) / t.k;
215
+ return { x: pos.x + offsetX, y: pos.y + offsetY };
216
+ }
217
+ }
218
+
219
+ // Fallback: edge center
220
+ const size = this.#getNodeSize(data.nodeId);
221
+ if (!size) return { x: 0, y: 0 };
222
+ return {
223
+ x: data.side === 'output' ? pos.x + size.width : pos.x,
224
+ y: pos.y + size.height / 2,
225
+ };
226
+ }
227
+
228
+ /**
229
+ * Find nearest registered socket within snap distance
230
+ * Uses registered socket collection instead of DOM hit-testing
231
+ * @param {number} worldX - Pointer X in graph coordinates
232
+ * @param {number} worldY - Pointer Y in graph coordinates
233
+ * @returns {SocketData|null}
234
+ */
235
+ #findNearestSocket(worldX, worldY) {
236
+ const SNAP_DISTANCE = 30; // pixels in graph space
237
+ let nearest = null;
238
+ let nearestDist = SNAP_DISTANCE;
239
+
240
+ for (const socket of this.#sockets) {
241
+ // Skip same socket as picked
242
+ if (socket === this.#picked) continue;
243
+
244
+ const pos = this.#getSocketWorldPosition(socket);
245
+ const dx = worldX - pos.x;
246
+ const dy = worldY - pos.y;
247
+ const dist = Math.sqrt(dx * dx + dy * dy);
248
+
249
+ if (dist < nearestDist) {
250
+ nearestDist = dist;
251
+ nearest = socket;
252
+ }
253
+ }
254
+
255
+ return nearest;
256
+ }
257
+
258
+ /**
259
+ * Check if two sockets can be connected
260
+ * @param {SocketData} from
261
+ * @param {SocketData} to
262
+ * @returns {boolean}
263
+ */
264
+ #canConnect(from, to) {
265
+ if (from.side === to.side) return false;
266
+ if (from.nodeId === to.nodeId) return false;
267
+
268
+ const fromNode = this.#editor.getNode(from.nodeId);
269
+ const toNode = this.#editor.getNode(to.nodeId);
270
+ if (!fromNode || !toNode) return false;
271
+
272
+ const isFromOutput = from.side === 'output';
273
+ const output = isFromOutput
274
+ ? fromNode.outputs[from.key]
275
+ : toNode.outputs[to.key];
276
+ const input = isFromOutput
277
+ ? toNode.inputs[to.key]
278
+ : fromNode.inputs[from.key];
279
+
280
+ if (!output || !input) return false;
281
+
282
+ return output.socket.isCompatibleWith(input.socket);
283
+ }
284
+
285
+ /**
286
+ * Create the connection
287
+ * @param {SocketData} from
288
+ * @param {SocketData} to
289
+ */
290
+ #makeConnection(from, to) {
291
+ let sourceData = from.side === 'output' ? from : to;
292
+ let targetData = from.side === 'input' ? from : to;
293
+
294
+ const sourceNode = this.#editor.getNode(sourceData.nodeId);
295
+ const targetNode = this.#editor.getNode(targetData.nodeId);
296
+ if (!sourceNode || !targetNode) return;
297
+
298
+ const conn = new Connection(sourceNode, sourceData.key, targetNode, targetData.key);
299
+ this.#editor.addConnection(conn);
300
+ }
301
+
302
+ /** Cleanup */
303
+ destroy() {
304
+ window.removeEventListener('pointermove', this.#onMove);
305
+ window.removeEventListener('pointerup', this.#onUp);
306
+ }
307
+ }