synabun 1.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.
- package/CHANGELOG.md +665 -0
- package/LICENSE +191 -0
- package/README.md +853 -0
- package/hooks/claude-code/post-plan.mjs +391 -0
- package/hooks/claude-code/post-remember.mjs +239 -0
- package/hooks/claude-code/pre-compact.mjs +241 -0
- package/hooks/claude-code/pre-websearch.mjs +90 -0
- package/hooks/claude-code/prompt-submit.mjs +861 -0
- package/hooks/claude-code/session-start.mjs +494 -0
- package/hooks/claude-code/shared.mjs +368 -0
- package/hooks/claude-code/stop.mjs +646 -0
- package/hooks/claude-code/test-user-learning.mjs +531 -0
- package/mcp-server/package.json +38 -0
- package/mcp-server/run.mjs +10 -0
- package/mcp-server/src/config.ts +70 -0
- package/mcp-server/src/http.ts +93 -0
- package/mcp-server/src/index.ts +203 -0
- package/mcp-server/src/preload-http.ts +25 -0
- package/mcp-server/src/preload.ts +29 -0
- package/mcp-server/src/scripts/migrate-qdrant-to-sqlite.ts +506 -0
- package/mcp-server/src/services/categories.ts +429 -0
- package/mcp-server/src/services/discord.ts +702 -0
- package/mcp-server/src/services/file-checksums.ts +33 -0
- package/mcp-server/src/services/local-embeddings.ts +77 -0
- package/mcp-server/src/services/neural-interface.ts +344 -0
- package/mcp-server/src/services/sqlite.ts +823 -0
- package/mcp-server/src/tools/browser-advanced.ts +123 -0
- package/mcp-server/src/tools/browser-interact.ts +255 -0
- package/mcp-server/src/tools/browser-navigate.ts +77 -0
- package/mcp-server/src/tools/browser-observe.ts +1330 -0
- package/mcp-server/src/tools/browser.ts +107 -0
- package/mcp-server/src/tools/card-tools.ts +193 -0
- package/mcp-server/src/tools/card.ts +22 -0
- package/mcp-server/src/tools/category.ts +379 -0
- package/mcp-server/src/tools/discord-channel.ts +274 -0
- package/mcp-server/src/tools/discord-guild.ts +188 -0
- package/mcp-server/src/tools/discord-member.ts +158 -0
- package/mcp-server/src/tools/discord-message.ts +231 -0
- package/mcp-server/src/tools/discord-onboarding.ts +228 -0
- package/mcp-server/src/tools/discord-role.ts +209 -0
- package/mcp-server/src/tools/discord-thread.ts +110 -0
- package/mcp-server/src/tools/discord-webhook.ts +176 -0
- package/mcp-server/src/tools/discord.ts +40 -0
- package/mcp-server/src/tools/forget.ts +38 -0
- package/mcp-server/src/tools/git-tools.ts +141 -0
- package/mcp-server/src/tools/git.ts +13 -0
- package/mcp-server/src/tools/image-tools.ts +98 -0
- package/mcp-server/src/tools/image.ts +17 -0
- package/mcp-server/src/tools/leonardo-browser-tools.ts +281 -0
- package/mcp-server/src/tools/leonardo.ts +28 -0
- package/mcp-server/src/tools/loop.ts +348 -0
- package/mcp-server/src/tools/memories.ts +118 -0
- package/mcp-server/src/tools/recall.ts +323 -0
- package/mcp-server/src/tools/reflect.ts +145 -0
- package/mcp-server/src/tools/remember.ts +115 -0
- package/mcp-server/src/tools/response.ts +26 -0
- package/mcp-server/src/tools/restore.ts +34 -0
- package/mcp-server/src/tools/sync.ts +114 -0
- package/mcp-server/src/tools/tictactoe-tools.ts +98 -0
- package/mcp-server/src/tools/tictactoe.ts +13 -0
- package/mcp-server/src/tools/utils.ts +25 -0
- package/mcp-server/src/tools/whiteboard-tools.ts +260 -0
- package/mcp-server/src/tools/whiteboard.ts +22 -0
- package/mcp-server/src/tui.ts +940 -0
- package/mcp-server/src/types.ts +85 -0
- package/mcp-server/tsconfig.json +19 -0
- package/neural-interface/package.json +27 -0
- package/neural-interface/public/apple-touch-icon.png +0 -0
- package/neural-interface/public/category-logos/claude.svg +1 -0
- package/neural-interface/public/category-logos/gemini-color.svg +1 -0
- package/neural-interface/public/category-logos/openai.svg +1 -0
- package/neural-interface/public/category-logos/synabun.png +0 -0
- package/neural-interface/public/claude-chat.css +878 -0
- package/neural-interface/public/claude-chat.html +92 -0
- package/neural-interface/public/claude-chat.js +1168 -0
- package/neural-interface/public/favicon-16x16.png +0 -0
- package/neural-interface/public/favicon-32x32.png +0 -0
- package/neural-interface/public/gallery.svg +6 -0
- package/neural-interface/public/icon-192.png +0 -0
- package/neural-interface/public/icon-512.png +0 -0
- package/neural-interface/public/index-legacy.html +14677 -0
- package/neural-interface/public/index.html +212 -0
- package/neural-interface/public/index2d-legacy.html +8193 -0
- package/neural-interface/public/index2d.html +127 -0
- package/neural-interface/public/invite.html +351 -0
- package/neural-interface/public/leonardoai.svg +1 -0
- package/neural-interface/public/logo-synabun.png +0 -0
- package/neural-interface/public/logoHD.png +0 -0
- package/neural-interface/public/manifest.json +14 -0
- package/neural-interface/public/offline.html +299 -0
- package/neural-interface/public/onboarding.html +2335 -0
- package/neural-interface/public/openclaw-logo-text.png +0 -0
- package/neural-interface/public/pin-svgrepo-com.svg +25 -0
- package/neural-interface/public/sessionicon.svg +8 -0
- package/neural-interface/public/shared/ansi-parser.js +305 -0
- package/neural-interface/public/shared/api.js +1043 -0
- package/neural-interface/public/shared/colors.js +153 -0
- package/neural-interface/public/shared/constants.js +141 -0
- package/neural-interface/public/shared/html-shell.js +777 -0
- package/neural-interface/public/shared/html-term-renderer.js +1022 -0
- package/neural-interface/public/shared/i18n.js +147 -0
- package/neural-interface/public/shared/registry.js +82 -0
- package/neural-interface/public/shared/state.js +86 -0
- package/neural-interface/public/shared/storage.js +150 -0
- package/neural-interface/public/shared/styles.css +21212 -0
- package/neural-interface/public/shared/ui-automation-studio.js +3573 -0
- package/neural-interface/public/shared/ui-bookmarks.js +231 -0
- package/neural-interface/public/shared/ui-claude-panel.js +6333 -0
- package/neural-interface/public/shared/ui-command-runner.js +534 -0
- package/neural-interface/public/shared/ui-cost-widget.js +602 -0
- package/neural-interface/public/shared/ui-detail.js +1454 -0
- package/neural-interface/public/shared/ui-explorer.js +1356 -0
- package/neural-interface/public/shared/ui-file-explorer.js +2750 -0
- package/neural-interface/public/shared/ui-games.js +411 -0
- package/neural-interface/public/shared/ui-help.js +107 -0
- package/neural-interface/public/shared/ui-image-gallery.js +461 -0
- package/neural-interface/public/shared/ui-invite.js +519 -0
- package/neural-interface/public/shared/ui-keybinds.js +452 -0
- package/neural-interface/public/shared/ui-layouts.js +297 -0
- package/neural-interface/public/shared/ui-link.js +731 -0
- package/neural-interface/public/shared/ui-loading.js +255 -0
- package/neural-interface/public/shared/ui-menubar.js +499 -0
- package/neural-interface/public/shared/ui-multiselect.js +93 -0
- package/neural-interface/public/shared/ui-navbar.js +222 -0
- package/neural-interface/public/shared/ui-notifications.js +287 -0
- package/neural-interface/public/shared/ui-panels.js +309 -0
- package/neural-interface/public/shared/ui-resume.js +653 -0
- package/neural-interface/public/shared/ui-search.js +145 -0
- package/neural-interface/public/shared/ui-sessions.js +531 -0
- package/neural-interface/public/shared/ui-settings.js +5987 -0
- package/neural-interface/public/shared/ui-sidebar.js +1905 -0
- package/neural-interface/public/shared/ui-skills.js +2805 -0
- package/neural-interface/public/shared/ui-stats.js +38 -0
- package/neural-interface/public/shared/ui-sync.js +201 -0
- package/neural-interface/public/shared/ui-terminal.js +6385 -0
- package/neural-interface/public/shared/ui-tooltip.js +123 -0
- package/neural-interface/public/shared/ui-trash.js +439 -0
- package/neural-interface/public/shared/ui-tutorial-draw.js +875 -0
- package/neural-interface/public/shared/ui-tutorial-steps.js +2276 -0
- package/neural-interface/public/shared/ui-tutorial.js +1117 -0
- package/neural-interface/public/shared/ui-update.js +244 -0
- package/neural-interface/public/shared/ui-whiteboard.js +3262 -0
- package/neural-interface/public/shared/ui-workspaces.js +722 -0
- package/neural-interface/public/shared/utils.js +360 -0
- package/neural-interface/public/shared/vterm-buffer.js +1102 -0
- package/neural-interface/public/sw.js +52 -0
- package/neural-interface/public/synabun.png +0 -0
- package/neural-interface/public/toolbar-album.svg +8 -0
- package/neural-interface/public/toolbar-question.svg +6 -0
- package/neural-interface/public/toolbar-sessions.svg +6 -0
- package/neural-interface/public/variant/2d/background.js +113 -0
- package/neural-interface/public/variant/2d/context-menu.js +133 -0
- package/neural-interface/public/variant/2d/gfx.js +45 -0
- package/neural-interface/public/variant/2d/graph.js +1635 -0
- package/neural-interface/public/variant/2d/hulls.js +207 -0
- package/neural-interface/public/variant/2d/lasso.js +135 -0
- package/neural-interface/public/variant/2d/layout.js +594 -0
- package/neural-interface/public/variant/2d/main.js +521 -0
- package/neural-interface/public/variant/2d/minimap.js +312 -0
- package/neural-interface/public/variant/2d/settings-gfx.js +98 -0
- package/neural-interface/public/variant/3d/background.js +884 -0
- package/neural-interface/public/variant/3d/camera.js +661 -0
- package/neural-interface/public/variant/3d/gfx.js +116 -0
- package/neural-interface/public/variant/3d/graph.js +2399 -0
- package/neural-interface/public/variant/3d/main.js +500 -0
- package/neural-interface/public/variant/3d/settings-gfx.js +228 -0
- package/neural-interface/scripts/rebuild-pty.js +100 -0
- package/neural-interface/server.js +15000 -0
- package/neural-interface/templates/CLAUDE-template.md +211 -0
- package/package.json +53 -0
- package/postinstall.js +135 -0
- package/setup.js +260 -0
- package/skills/leonardo/SKILL.md +159 -0
- package/skills/leonardo/icon.svg +1 -0
- package/skills/leonardo/modules/browser-guide.md +378 -0
- package/skills/leonardo/modules/image-prompter.md +277 -0
- package/skills/leonardo/modules/model-advisor.md +100 -0
- package/skills/leonardo/modules/prompt-library.md +110 -0
- package/skills/leonardo/modules/style-guide.md +186 -0
- package/skills/leonardo/modules/video-prompter.md +311 -0
- package/skills/synabun/SKILL.md +185 -0
- package/skills/synabun/icon.png +0 -0
- package/skills/synabun/modules/audit.md +374 -0
- package/skills/synabun/modules/changelog.md +194 -0
- package/skills/synabun/modules/idea.md +144 -0
- package/skills/synabun/modules/memorize.md +188 -0
- package/skills/synabun/synabunicon.png +0 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun Neural Interface — Panel System
|
|
3
|
+
// Drag, resize, pin toggle, layout save/restore, viewport clamping
|
|
4
|
+
// ═══════════════════════════════════════════
|
|
5
|
+
|
|
6
|
+
import { KEYS } from './constants.js';
|
|
7
|
+
import { storage } from './storage.js';
|
|
8
|
+
import { state, emit } from './state.js';
|
|
9
|
+
|
|
10
|
+
const MIN_W = 140;
|
|
11
|
+
const MIN_H = 100;
|
|
12
|
+
|
|
13
|
+
/** Read the dynamically-measured navbar height from the CSS variable */
|
|
14
|
+
function getNavbarHeight() {
|
|
15
|
+
return parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--navbar-height')) || 48;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ── Viewport clamping ──
|
|
19
|
+
|
|
20
|
+
export function clampPanelsToViewport() {
|
|
21
|
+
document.querySelectorAll('.resizable').forEach(el => {
|
|
22
|
+
const minVisible = 60;
|
|
23
|
+
const minHeight = 100;
|
|
24
|
+
const minWidth = 140;
|
|
25
|
+
|
|
26
|
+
let rect = el.getBoundingClientRect();
|
|
27
|
+
|
|
28
|
+
if (el.style.left) {
|
|
29
|
+
const currentLeft = parseInt(el.style.left);
|
|
30
|
+
const maxLeft = Math.max(0, window.innerWidth - rect.width - 10);
|
|
31
|
+
if (currentLeft > maxLeft) {
|
|
32
|
+
el.style.left = maxLeft + 'px';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (el.style.top) {
|
|
37
|
+
const navH = getNavbarHeight();
|
|
38
|
+
const currentTop = parseInt(el.style.top);
|
|
39
|
+
const maxTop = Math.max(navH, window.innerHeight - rect.height - 10);
|
|
40
|
+
if (currentTop < navH) {
|
|
41
|
+
el.style.top = navH + 'px';
|
|
42
|
+
} else if (currentTop > maxTop) {
|
|
43
|
+
el.style.top = maxTop + 'px';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
rect = el.getBoundingClientRect();
|
|
48
|
+
|
|
49
|
+
if (rect.right > window.innerWidth && el.style.width) {
|
|
50
|
+
const maxWidth = window.innerWidth - rect.left - 10;
|
|
51
|
+
if (maxWidth > minWidth) {
|
|
52
|
+
el.style.width = maxWidth + 'px';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
rect = el.getBoundingClientRect();
|
|
57
|
+
if (rect.bottom > window.innerHeight) {
|
|
58
|
+
const maxHeight = window.innerHeight - rect.top - 10;
|
|
59
|
+
if (maxHeight > minHeight) {
|
|
60
|
+
el.style.maxHeight = maxHeight + 'px';
|
|
61
|
+
if (el.style.height && el.style.height !== 'auto') {
|
|
62
|
+
const currentHeight = parseInt(el.style.height);
|
|
63
|
+
if (currentHeight > maxHeight) {
|
|
64
|
+
el.style.height = maxHeight + 'px';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── Save/Restore panel layout ──
|
|
73
|
+
|
|
74
|
+
export function savePanelLayout(el) {
|
|
75
|
+
const id = el.id;
|
|
76
|
+
const data = {
|
|
77
|
+
left: el.style.left || null,
|
|
78
|
+
top: el.style.top || null,
|
|
79
|
+
right: el.style.right || null,
|
|
80
|
+
width: el.style.width || null,
|
|
81
|
+
height: el.style.height || null,
|
|
82
|
+
maxHeight: el.style.maxHeight || null,
|
|
83
|
+
};
|
|
84
|
+
storage.setItem(KEYS.PANEL_PREFIX + id, JSON.stringify(data));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function restorePanelLayout(el, sizeOnly) {
|
|
88
|
+
const saved = storage.getItem(KEYS.PANEL_PREFIX + el.id);
|
|
89
|
+
if (!saved) return;
|
|
90
|
+
try {
|
|
91
|
+
const data = JSON.parse(saved);
|
|
92
|
+
if (!sizeOnly) {
|
|
93
|
+
if (data.left && data.left !== 'auto') el.style.left = data.left;
|
|
94
|
+
if (data.top) { const nh = getNavbarHeight(); el.style.top = Math.max(nh, parseInt(data.top)) + 'px'; }
|
|
95
|
+
if (data.right) el.style.right = data.right;
|
|
96
|
+
}
|
|
97
|
+
if (data.width) el.style.width = data.width;
|
|
98
|
+
if (data.height) el.style.height = data.height;
|
|
99
|
+
} catch {}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ── UI Scale helper ──
|
|
103
|
+
|
|
104
|
+
function getElScale(el) {
|
|
105
|
+
return parseFloat(getComputedStyle(el).getPropertyValue('--ui-scale')) || parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--ui-scale')) || 1;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function ensureLeftTop(el) {
|
|
109
|
+
const cs = getComputedStyle(el);
|
|
110
|
+
el.style.left = cs.left;
|
|
111
|
+
el.style.top = cs.top;
|
|
112
|
+
el.style.right = 'auto';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ── Initialize panel system ──
|
|
116
|
+
|
|
117
|
+
export function initPanelSystem() {
|
|
118
|
+
let resizing = null;
|
|
119
|
+
let dragging = null;
|
|
120
|
+
let rafPending = false;
|
|
121
|
+
let latestMouseX = 0;
|
|
122
|
+
let latestMouseY = 0;
|
|
123
|
+
|
|
124
|
+
// --- Resize (all 8 directions, event delegation for dynamic panels) ---
|
|
125
|
+
document.addEventListener('mousedown', (e) => {
|
|
126
|
+
const handle = e.target.closest('.resize-handle');
|
|
127
|
+
if (!handle) return;
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
const dir = handle.dataset.resize;
|
|
130
|
+
const el = handle.closest('.resizable');
|
|
131
|
+
if (!el) return;
|
|
132
|
+
|
|
133
|
+
handle.classList.add('active');
|
|
134
|
+
el.classList.add('dragging');
|
|
135
|
+
|
|
136
|
+
const s = getElScale(el);
|
|
137
|
+
ensureLeftTop(el);
|
|
138
|
+
const cs = getComputedStyle(el);
|
|
139
|
+
|
|
140
|
+
const elMinW = Math.max(MIN_W, parseInt(cs.minWidth) || 0);
|
|
141
|
+
const elMinH = Math.max(MIN_H, parseInt(cs.minHeight) || 0);
|
|
142
|
+
|
|
143
|
+
resizing = {
|
|
144
|
+
el, dir, scale: s,
|
|
145
|
+
startX: e.clientX, startY: e.clientY,
|
|
146
|
+
startW: parseFloat(cs.width), startH: parseFloat(cs.height),
|
|
147
|
+
startL: parseFloat(cs.left), startT: parseFloat(cs.top),
|
|
148
|
+
minW: elMinW, minH: elMinH,
|
|
149
|
+
};
|
|
150
|
+
document.body.style.cursor = getComputedStyle(handle).cursor;
|
|
151
|
+
document.body.style.userSelect = 'none';
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// --- Drag (event delegation for dynamic panels) ---
|
|
155
|
+
document.addEventListener('mousedown', (e) => {
|
|
156
|
+
const handle = e.target.closest('.drag-handle');
|
|
157
|
+
if (!handle) return;
|
|
158
|
+
if (e.target.closest('.resize-handle')) return;
|
|
159
|
+
const tag = e.target.closest('button, input, select, textarea, a, [contenteditable], [draggable="true"]');
|
|
160
|
+
if (tag) return;
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
const el = document.getElementById(handle.dataset.drag);
|
|
163
|
+
if (!el) return;
|
|
164
|
+
if (el.classList.contains('locked')) return;
|
|
165
|
+
|
|
166
|
+
el.classList.add('dragging');
|
|
167
|
+
ensureLeftTop(el);
|
|
168
|
+
const s = getElScale(el);
|
|
169
|
+
const cs = getComputedStyle(el);
|
|
170
|
+
const rect = el.getBoundingClientRect();
|
|
171
|
+
|
|
172
|
+
dragging = {
|
|
173
|
+
el, startX: e.clientX, startY: e.clientY,
|
|
174
|
+
startLeft: parseFloat(cs.left), startTop: parseFloat(cs.top),
|
|
175
|
+
startVisualLeft: rect.left, startVisualTop: rect.top,
|
|
176
|
+
startW: rect.width, startH: rect.height,
|
|
177
|
+
};
|
|
178
|
+
document.body.style.cursor = 'move';
|
|
179
|
+
document.body.style.userSelect = 'none';
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// RAF tick
|
|
183
|
+
function applyInteraction() {
|
|
184
|
+
rafPending = false;
|
|
185
|
+
const mx = latestMouseX;
|
|
186
|
+
const my = latestMouseY;
|
|
187
|
+
|
|
188
|
+
if (resizing) {
|
|
189
|
+
const { el, dir, scale: rScale, startX, startY, startW, startH, startL, startT, minW: rMinW, minH: rMinH } = resizing;
|
|
190
|
+
const dx = (mx - startX) / rScale;
|
|
191
|
+
const dy = (my - startY) / rScale;
|
|
192
|
+
|
|
193
|
+
let newW = startW, newH = startH, newL = startL, newT = startT;
|
|
194
|
+
|
|
195
|
+
if (dir === 'r' || dir === 'br' || dir === 'tr') newW = Math.max(rMinW, startW + dx);
|
|
196
|
+
if (dir === 'l' || dir === 'bl' || dir === 'tl') { newW = Math.max(rMinW, startW - dx); newL = startL + startW - newW; }
|
|
197
|
+
if (dir === 'b' || dir === 'br' || dir === 'bl') newH = Math.max(rMinH, startH + dy);
|
|
198
|
+
if (dir === 't' || dir === 'tr' || dir === 'tl') { newH = Math.max(rMinH, startH - dy); newT = startT + startH - newH; }
|
|
199
|
+
|
|
200
|
+
newL = Math.max(0, newL);
|
|
201
|
+
const navH2 = getNavbarHeight();
|
|
202
|
+
newT = Math.max(navH2, newT);
|
|
203
|
+
const maxWidth = window.innerWidth / rScale - newL - 10;
|
|
204
|
+
const maxHeight = window.innerHeight / rScale - newT - 10;
|
|
205
|
+
newW = Math.min(newW, maxWidth);
|
|
206
|
+
newH = Math.min(newH, maxHeight);
|
|
207
|
+
|
|
208
|
+
el.style.width = newW + 'px';
|
|
209
|
+
el.style.height = newH + 'px';
|
|
210
|
+
el.style.left = newL + 'px';
|
|
211
|
+
el.style.top = newT + 'px';
|
|
212
|
+
el.style.maxHeight = maxHeight + 'px';
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (dragging) {
|
|
216
|
+
const { el, startX, startY, startLeft, startTop, startVisualLeft, startVisualTop, startW, startH } = dragging;
|
|
217
|
+
const dx = mx - startX;
|
|
218
|
+
const dy = my - startY;
|
|
219
|
+
|
|
220
|
+
const clampedDx = Math.max(-startVisualLeft, Math.min(window.innerWidth - startW - 10 - startVisualLeft, dx));
|
|
221
|
+
const clampedDy = Math.max(-startVisualTop, Math.min(window.innerHeight - startH - 10 - startVisualTop, dy));
|
|
222
|
+
|
|
223
|
+
let finalLeft = startLeft + clampedDx;
|
|
224
|
+
let finalTop = startTop + clampedDy;
|
|
225
|
+
|
|
226
|
+
if (state.gridSnap) {
|
|
227
|
+
const gs = state.gridSize || 20;
|
|
228
|
+
finalLeft = Math.round(finalLeft / gs) * gs;
|
|
229
|
+
finalTop = Math.round(finalTop / gs) * gs;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Keep panels below the title bar
|
|
233
|
+
const navH = getNavbarHeight();
|
|
234
|
+
finalTop = Math.max(navH, finalTop);
|
|
235
|
+
el.style.left = finalLeft + 'px';
|
|
236
|
+
el.style.top = finalTop + 'px';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
document.addEventListener('mousemove', (e) => {
|
|
241
|
+
if (!resizing && !dragging) return;
|
|
242
|
+
latestMouseX = e.clientX;
|
|
243
|
+
latestMouseY = e.clientY;
|
|
244
|
+
if (!rafPending) {
|
|
245
|
+
rafPending = true;
|
|
246
|
+
requestAnimationFrame(applyInteraction);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
document.addEventListener('mouseup', () => {
|
|
251
|
+
rafPending = false;
|
|
252
|
+
if (resizing) {
|
|
253
|
+
document.querySelectorAll('.resize-handle.active').forEach(h => h.classList.remove('active'));
|
|
254
|
+
resizing.el.classList.remove('dragging');
|
|
255
|
+
savePanelLayout(resizing.el);
|
|
256
|
+
if (resizing.el.classList.contains('detail-card')) emit('detail:layout-changed');
|
|
257
|
+
resizing = null;
|
|
258
|
+
}
|
|
259
|
+
if (dragging) {
|
|
260
|
+
dragging.el.classList.remove('dragging');
|
|
261
|
+
savePanelLayout(dragging.el);
|
|
262
|
+
if (dragging.el.classList.contains('detail-card')) emit('detail:layout-changed');
|
|
263
|
+
dragging = null;
|
|
264
|
+
}
|
|
265
|
+
document.body.style.cursor = '';
|
|
266
|
+
document.body.style.userSelect = '';
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Restore saved layouts
|
|
270
|
+
const sidebar = document.getElementById('category-sidebar');
|
|
271
|
+
if (sidebar) restorePanelLayout(sidebar, false);
|
|
272
|
+
|
|
273
|
+
clampPanelsToViewport();
|
|
274
|
+
|
|
275
|
+
// Window resize handler — emit event so variant can resize graph
|
|
276
|
+
window.addEventListener('resize', () => {
|
|
277
|
+
emit('window:resize', { width: window.innerWidth, height: window.innerHeight });
|
|
278
|
+
clampPanelsToViewport();
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// ── Pin toggle (event delegation for dynamic panels) ──
|
|
283
|
+
|
|
284
|
+
export function initPinToggle() {
|
|
285
|
+
// Restore pinned state for static panels at boot
|
|
286
|
+
document.querySelectorAll('.pin-btn').forEach(btn => {
|
|
287
|
+
const panelId = btn.dataset.pin;
|
|
288
|
+
const panel = document.getElementById(panelId);
|
|
289
|
+
if (!panel) return;
|
|
290
|
+
const key = 'neural-pinned-' + panelId;
|
|
291
|
+
if (storage.getItem(key) === 'true') {
|
|
292
|
+
panel.classList.add('locked');
|
|
293
|
+
btn.classList.add('pinned');
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Document-level delegation — works for both static and dynamically spawned panels
|
|
298
|
+
document.addEventListener('click', (e) => {
|
|
299
|
+
const btn = e.target.closest('.pin-btn');
|
|
300
|
+
if (!btn) return;
|
|
301
|
+
const panelId = btn.dataset.pin;
|
|
302
|
+
const panel = document.getElementById(panelId);
|
|
303
|
+
if (!panel) return;
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
const pinned = panel.classList.toggle('locked');
|
|
306
|
+
btn.classList.toggle('pinned', pinned);
|
|
307
|
+
storage.setItem('neural-pinned-' + panelId, pinned);
|
|
308
|
+
});
|
|
309
|
+
}
|