agentgui 1.0.274 → 1.0.275
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/CLAUDE.md +280 -280
- package/IPFS_DOWNLOADER.md +277 -277
- package/TASK_2C_COMPLETION.md +334 -334
- package/bin/gmgui.cjs +54 -54
- package/build-portable.js +3 -42
- package/database.js +1422 -1406
- package/lib/claude-runner.js +1130 -1130
- package/lib/ipfs-downloader.js +459 -459
- package/lib/speech.js +152 -152
- package/package.json +1 -1
- package/readme.md +76 -76
- package/server.js +3787 -3794
- package/setup-npm-token.sh +68 -68
- package/static/app.js +773 -773
- package/static/event-rendering-showcase.html +708 -708
- package/static/index.html +3178 -3180
- package/static/js/agent-auth.js +298 -298
- package/static/js/audio-recorder-processor.js +18 -18
- package/static/js/client.js +2656 -2656
- package/static/js/conversations.js +583 -583
- package/static/js/dialogs.js +267 -267
- package/static/js/event-consolidator.js +101 -101
- package/static/js/event-filter.js +311 -311
- package/static/js/event-processor.js +452 -452
- package/static/js/features.js +413 -413
- package/static/js/kalman-filter.js +67 -67
- package/static/js/progress-dialog.js +130 -130
- package/static/js/script-runner.js +219 -219
- package/static/js/streaming-renderer.js +2123 -2120
- package/static/js/syntax-highlighter.js +269 -269
- package/static/js/tts-websocket-handler.js +152 -152
- package/static/js/ui-components.js +431 -431
- package/static/js/voice.js +849 -849
- package/static/js/websocket-manager.js +596 -596
- package/static/templates/INDEX.html +465 -465
- package/static/templates/README.md +190 -190
- package/static/templates/agent-capabilities.html +56 -56
- package/static/templates/agent-metadata-panel.html +44 -44
- package/static/templates/agent-status-badge.html +30 -30
- package/static/templates/code-annotation-panel.html +155 -155
- package/static/templates/code-suggestion-panel.html +184 -184
- package/static/templates/command-header.html +77 -77
- package/static/templates/command-output-scrollable.html +118 -118
- package/static/templates/elapsed-time.html +54 -54
- package/static/templates/error-alert.html +106 -106
- package/static/templates/error-history-timeline.html +160 -160
- package/static/templates/error-recovery-options.html +109 -109
- package/static/templates/error-stack-trace.html +95 -95
- package/static/templates/error-summary.html +80 -80
- package/static/templates/event-counter.html +48 -48
- package/static/templates/execution-actions.html +97 -97
- package/static/templates/execution-progress-bar.html +80 -80
- package/static/templates/execution-stepper.html +120 -120
- package/static/templates/file-breadcrumb.html +118 -118
- package/static/templates/file-diff-viewer.html +121 -121
- package/static/templates/file-metadata.html +133 -133
- package/static/templates/file-read-panel.html +66 -66
- package/static/templates/file-write-panel.html +120 -120
- package/static/templates/git-branch-remote.html +107 -107
- package/static/templates/git-diff-list.html +101 -101
- package/static/templates/git-log-visualization.html +153 -153
- package/static/templates/git-status-panel.html +115 -115
- package/static/templates/quality-metrics-display.html +170 -170
- package/static/templates/terminal-output-panel.html +87 -87
- package/static/templates/test-results-display.html +144 -144
- package/static/theme.js +72 -72
- package/test-download-progress.js +223 -223
- package/test-websocket-broadcast.js +147 -147
- package/tests/ipfs-downloader.test.js +370 -370
|
@@ -1,219 +1,219 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
const BASE = window.__BASE_URL || '';
|
|
3
|
-
let currentConversationId = null;
|
|
4
|
-
let scriptState = { running: false, script: null, hasStart: false, hasDev: false };
|
|
5
|
-
let terminal = null;
|
|
6
|
-
let fitAddon = null;
|
|
7
|
-
let hasTerminalContent = false;
|
|
8
|
-
let resizeObserver = null;
|
|
9
|
-
|
|
10
|
-
function init() {
|
|
11
|
-
setupListeners();
|
|
12
|
-
setupButtons();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function setupListeners() {
|
|
16
|
-
window.addEventListener('conversation-selected', function(e) {
|
|
17
|
-
currentConversationId = e.detail.conversationId;
|
|
18
|
-
hasTerminalContent = false;
|
|
19
|
-
if (terminal) terminal.clear();
|
|
20
|
-
hideTerminalTab();
|
|
21
|
-
checkScripts();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
window.addEventListener('ws-message', function(e) {
|
|
25
|
-
const data = e.detail;
|
|
26
|
-
if (!data || !currentConversationId) return;
|
|
27
|
-
if (data.conversationId !== currentConversationId) return;
|
|
28
|
-
|
|
29
|
-
if (data.type === 'script_started') {
|
|
30
|
-
scriptState.running = true;
|
|
31
|
-
scriptState.script = data.script;
|
|
32
|
-
hasTerminalContent = false;
|
|
33
|
-
if (terminal) terminal.clear();
|
|
34
|
-
updateButtons();
|
|
35
|
-
showTerminalTab();
|
|
36
|
-
} else if (data.type === 'script_stopped') {
|
|
37
|
-
scriptState.running = false;
|
|
38
|
-
const msg = data.error ? data.error : ('exited with code ' + (data.code || 0));
|
|
39
|
-
if (terminal) terminal.writeln('\r\n\x1b[90m[process ' + msg + ']\x1b[0m');
|
|
40
|
-
updateButtons();
|
|
41
|
-
} else if (data.type === 'script_output') {
|
|
42
|
-
hasTerminalContent = true;
|
|
43
|
-
showTerminalTab();
|
|
44
|
-
if (terminal) terminal.write(data.data);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
window.addEventListener('resize', debounce(fitTerminal, 200));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function setupButtons() {
|
|
52
|
-
var startBtn = document.getElementById('scriptStartBtn');
|
|
53
|
-
var devBtn = document.getElementById('scriptDevBtn');
|
|
54
|
-
var stopBtn = document.getElementById('scriptStopBtn');
|
|
55
|
-
|
|
56
|
-
if (startBtn) startBtn.addEventListener('click', function() { runScript('start'); });
|
|
57
|
-
if (devBtn) devBtn.addEventListener('click', function() { runScript('dev'); });
|
|
58
|
-
if (stopBtn) stopBtn.addEventListener('click', function() { stopScript(); });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function checkScripts() {
|
|
62
|
-
if (!currentConversationId) return;
|
|
63
|
-
fetch(BASE + '/api/conversations/' + currentConversationId + '/scripts')
|
|
64
|
-
.then(function(r) { return r.json(); })
|
|
65
|
-
.then(function(data) {
|
|
66
|
-
scriptState.hasStart = data.hasStart;
|
|
67
|
-
scriptState.hasDev = data.hasDev;
|
|
68
|
-
scriptState.running = data.running;
|
|
69
|
-
scriptState.script = data.runningScript;
|
|
70
|
-
updateButtons();
|
|
71
|
-
if (data.running || hasTerminalContent) showTerminalTab();
|
|
72
|
-
})
|
|
73
|
-
.catch(function() {
|
|
74
|
-
scriptState.hasStart = false;
|
|
75
|
-
scriptState.hasDev = false;
|
|
76
|
-
updateButtons();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function updateButtons() {
|
|
81
|
-
var container = document.getElementById('scriptButtons');
|
|
82
|
-
var startBtn = document.getElementById('scriptStartBtn');
|
|
83
|
-
var devBtn = document.getElementById('scriptDevBtn');
|
|
84
|
-
var stopBtn = document.getElementById('scriptStopBtn');
|
|
85
|
-
|
|
86
|
-
var showAny = scriptState.hasStart || scriptState.hasDev || scriptState.running;
|
|
87
|
-
if (container) container.style.display = showAny ? 'flex' : 'none';
|
|
88
|
-
|
|
89
|
-
if (scriptState.running) {
|
|
90
|
-
if (startBtn) startBtn.style.display = 'none';
|
|
91
|
-
if (devBtn) devBtn.style.display = 'none';
|
|
92
|
-
if (stopBtn) stopBtn.style.display = 'flex';
|
|
93
|
-
} else {
|
|
94
|
-
if (startBtn) startBtn.style.display = scriptState.hasStart ? 'flex' : 'none';
|
|
95
|
-
if (devBtn) devBtn.style.display = scriptState.hasDev ? 'flex' : 'none';
|
|
96
|
-
if (stopBtn) stopBtn.style.display = 'none';
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function runScript(script) {
|
|
101
|
-
if (!currentConversationId || scriptState.running) return;
|
|
102
|
-
fetch(BASE + '/api/conversations/' + currentConversationId + '/run-script', {
|
|
103
|
-
method: 'POST',
|
|
104
|
-
headers: { 'Content-Type': 'application/json' },
|
|
105
|
-
body: JSON.stringify({ script: script })
|
|
106
|
-
})
|
|
107
|
-
.then(function(r) { return r.json(); })
|
|
108
|
-
.then(function(data) {
|
|
109
|
-
if (data.ok) {
|
|
110
|
-
scriptState.running = true;
|
|
111
|
-
scriptState.script = script;
|
|
112
|
-
hasTerminalContent = false;
|
|
113
|
-
updateButtons();
|
|
114
|
-
showTerminalTab();
|
|
115
|
-
switchToTerminalView();
|
|
116
|
-
ensureTerminal();
|
|
117
|
-
if (terminal) {
|
|
118
|
-
terminal.clear();
|
|
119
|
-
terminal.writeln('\x1b[36m[running npm run ' + script + ']\x1b[0m\r\n');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
.catch(function(err) {
|
|
124
|
-
console.error('Failed to start script:', err);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function stopScript() {
|
|
129
|
-
if (!currentConversationId) return;
|
|
130
|
-
fetch(BASE + '/api/conversations/' + currentConversationId + '/stop-script', {
|
|
131
|
-
method: 'POST',
|
|
132
|
-
headers: { 'Content-Type': 'application/json' },
|
|
133
|
-
body: '{}'
|
|
134
|
-
}).catch(function(err) {
|
|
135
|
-
console.error('Failed to stop script:', err);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function showTerminalTab() {
|
|
140
|
-
var btn = document.getElementById('terminalTabBtn');
|
|
141
|
-
if (btn) btn.style.display = '';
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function hideTerminalTab() {
|
|
145
|
-
var btn = document.getElementById('terminalTabBtn');
|
|
146
|
-
if (btn) btn.style.display = 'none';
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function switchToTerminalView() {
|
|
150
|
-
var bar = document.getElementById('viewToggleBar');
|
|
151
|
-
if (!bar) return;
|
|
152
|
-
var termBtn = bar.querySelector('[data-view="terminal"]');
|
|
153
|
-
if (termBtn) termBtn.click();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function ensureTerminal() {
|
|
157
|
-
if (terminal) return;
|
|
158
|
-
if (typeof window.Terminal === 'undefined') {
|
|
159
|
-
setTimeout(ensureTerminal, 200);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
var container = document.getElementById('terminalOutput');
|
|
163
|
-
if (!container) return;
|
|
164
|
-
|
|
165
|
-
terminal = new window.Terminal({
|
|
166
|
-
cursorBlink: false,
|
|
167
|
-
scrollback: 10000,
|
|
168
|
-
fontSize: 13,
|
|
169
|
-
fontFamily: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",
|
|
170
|
-
theme: { background: '#1e1e1e', foreground: '#d4d4d4' },
|
|
171
|
-
convertEol: true,
|
|
172
|
-
disableStdin: true
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
if (window.FitAddon) {
|
|
176
|
-
fitAddon = new window.FitAddon.FitAddon();
|
|
177
|
-
terminal.loadAddon(fitAddon);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
terminal.open(container);
|
|
181
|
-
fitTerminal();
|
|
182
|
-
|
|
183
|
-
if (resizeObserver) resizeObserver.disconnect();
|
|
184
|
-
resizeObserver = new ResizeObserver(debounce(fitTerminal, 100));
|
|
185
|
-
resizeObserver.observe(container);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function fitTerminal() {
|
|
189
|
-
if (fitAddon) {
|
|
190
|
-
try { fitAddon.fit(); } catch {}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function debounce(fn, ms) {
|
|
195
|
-
var timer;
|
|
196
|
-
return function() {
|
|
197
|
-
clearTimeout(timer);
|
|
198
|
-
timer = setTimeout(fn, ms);
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
window.addEventListener('view-switched', function(e) {
|
|
203
|
-
if (e.detail && e.detail.view === 'terminal') {
|
|
204
|
-
ensureTerminal();
|
|
205
|
-
setTimeout(fitTerminal, 50);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
if (document.readyState === 'loading') {
|
|
210
|
-
document.addEventListener('DOMContentLoaded', init);
|
|
211
|
-
} else {
|
|
212
|
-
init();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
window.scriptRunner = {
|
|
216
|
-
getState: function() { return scriptState; },
|
|
217
|
-
getTerminal: function() { return terminal; }
|
|
218
|
-
};
|
|
219
|
-
})();
|
|
1
|
+
(function() {
|
|
2
|
+
const BASE = window.__BASE_URL || '';
|
|
3
|
+
let currentConversationId = null;
|
|
4
|
+
let scriptState = { running: false, script: null, hasStart: false, hasDev: false };
|
|
5
|
+
let terminal = null;
|
|
6
|
+
let fitAddon = null;
|
|
7
|
+
let hasTerminalContent = false;
|
|
8
|
+
let resizeObserver = null;
|
|
9
|
+
|
|
10
|
+
function init() {
|
|
11
|
+
setupListeners();
|
|
12
|
+
setupButtons();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function setupListeners() {
|
|
16
|
+
window.addEventListener('conversation-selected', function(e) {
|
|
17
|
+
currentConversationId = e.detail.conversationId;
|
|
18
|
+
hasTerminalContent = false;
|
|
19
|
+
if (terminal) terminal.clear();
|
|
20
|
+
hideTerminalTab();
|
|
21
|
+
checkScripts();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
window.addEventListener('ws-message', function(e) {
|
|
25
|
+
const data = e.detail;
|
|
26
|
+
if (!data || !currentConversationId) return;
|
|
27
|
+
if (data.conversationId !== currentConversationId) return;
|
|
28
|
+
|
|
29
|
+
if (data.type === 'script_started') {
|
|
30
|
+
scriptState.running = true;
|
|
31
|
+
scriptState.script = data.script;
|
|
32
|
+
hasTerminalContent = false;
|
|
33
|
+
if (terminal) terminal.clear();
|
|
34
|
+
updateButtons();
|
|
35
|
+
showTerminalTab();
|
|
36
|
+
} else if (data.type === 'script_stopped') {
|
|
37
|
+
scriptState.running = false;
|
|
38
|
+
const msg = data.error ? data.error : ('exited with code ' + (data.code || 0));
|
|
39
|
+
if (terminal) terminal.writeln('\r\n\x1b[90m[process ' + msg + ']\x1b[0m');
|
|
40
|
+
updateButtons();
|
|
41
|
+
} else if (data.type === 'script_output') {
|
|
42
|
+
hasTerminalContent = true;
|
|
43
|
+
showTerminalTab();
|
|
44
|
+
if (terminal) terminal.write(data.data);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
window.addEventListener('resize', debounce(fitTerminal, 200));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function setupButtons() {
|
|
52
|
+
var startBtn = document.getElementById('scriptStartBtn');
|
|
53
|
+
var devBtn = document.getElementById('scriptDevBtn');
|
|
54
|
+
var stopBtn = document.getElementById('scriptStopBtn');
|
|
55
|
+
|
|
56
|
+
if (startBtn) startBtn.addEventListener('click', function() { runScript('start'); });
|
|
57
|
+
if (devBtn) devBtn.addEventListener('click', function() { runScript('dev'); });
|
|
58
|
+
if (stopBtn) stopBtn.addEventListener('click', function() { stopScript(); });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function checkScripts() {
|
|
62
|
+
if (!currentConversationId) return;
|
|
63
|
+
fetch(BASE + '/api/conversations/' + currentConversationId + '/scripts')
|
|
64
|
+
.then(function(r) { return r.json(); })
|
|
65
|
+
.then(function(data) {
|
|
66
|
+
scriptState.hasStart = data.hasStart;
|
|
67
|
+
scriptState.hasDev = data.hasDev;
|
|
68
|
+
scriptState.running = data.running;
|
|
69
|
+
scriptState.script = data.runningScript;
|
|
70
|
+
updateButtons();
|
|
71
|
+
if (data.running || hasTerminalContent) showTerminalTab();
|
|
72
|
+
})
|
|
73
|
+
.catch(function() {
|
|
74
|
+
scriptState.hasStart = false;
|
|
75
|
+
scriptState.hasDev = false;
|
|
76
|
+
updateButtons();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function updateButtons() {
|
|
81
|
+
var container = document.getElementById('scriptButtons');
|
|
82
|
+
var startBtn = document.getElementById('scriptStartBtn');
|
|
83
|
+
var devBtn = document.getElementById('scriptDevBtn');
|
|
84
|
+
var stopBtn = document.getElementById('scriptStopBtn');
|
|
85
|
+
|
|
86
|
+
var showAny = scriptState.hasStart || scriptState.hasDev || scriptState.running;
|
|
87
|
+
if (container) container.style.display = showAny ? 'flex' : 'none';
|
|
88
|
+
|
|
89
|
+
if (scriptState.running) {
|
|
90
|
+
if (startBtn) startBtn.style.display = 'none';
|
|
91
|
+
if (devBtn) devBtn.style.display = 'none';
|
|
92
|
+
if (stopBtn) stopBtn.style.display = 'flex';
|
|
93
|
+
} else {
|
|
94
|
+
if (startBtn) startBtn.style.display = scriptState.hasStart ? 'flex' : 'none';
|
|
95
|
+
if (devBtn) devBtn.style.display = scriptState.hasDev ? 'flex' : 'none';
|
|
96
|
+
if (stopBtn) stopBtn.style.display = 'none';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function runScript(script) {
|
|
101
|
+
if (!currentConversationId || scriptState.running) return;
|
|
102
|
+
fetch(BASE + '/api/conversations/' + currentConversationId + '/run-script', {
|
|
103
|
+
method: 'POST',
|
|
104
|
+
headers: { 'Content-Type': 'application/json' },
|
|
105
|
+
body: JSON.stringify({ script: script })
|
|
106
|
+
})
|
|
107
|
+
.then(function(r) { return r.json(); })
|
|
108
|
+
.then(function(data) {
|
|
109
|
+
if (data.ok) {
|
|
110
|
+
scriptState.running = true;
|
|
111
|
+
scriptState.script = script;
|
|
112
|
+
hasTerminalContent = false;
|
|
113
|
+
updateButtons();
|
|
114
|
+
showTerminalTab();
|
|
115
|
+
switchToTerminalView();
|
|
116
|
+
ensureTerminal();
|
|
117
|
+
if (terminal) {
|
|
118
|
+
terminal.clear();
|
|
119
|
+
terminal.writeln('\x1b[36m[running npm run ' + script + ']\x1b[0m\r\n');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
.catch(function(err) {
|
|
124
|
+
console.error('Failed to start script:', err);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function stopScript() {
|
|
129
|
+
if (!currentConversationId) return;
|
|
130
|
+
fetch(BASE + '/api/conversations/' + currentConversationId + '/stop-script', {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: { 'Content-Type': 'application/json' },
|
|
133
|
+
body: '{}'
|
|
134
|
+
}).catch(function(err) {
|
|
135
|
+
console.error('Failed to stop script:', err);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function showTerminalTab() {
|
|
140
|
+
var btn = document.getElementById('terminalTabBtn');
|
|
141
|
+
if (btn) btn.style.display = '';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function hideTerminalTab() {
|
|
145
|
+
var btn = document.getElementById('terminalTabBtn');
|
|
146
|
+
if (btn) btn.style.display = 'none';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function switchToTerminalView() {
|
|
150
|
+
var bar = document.getElementById('viewToggleBar');
|
|
151
|
+
if (!bar) return;
|
|
152
|
+
var termBtn = bar.querySelector('[data-view="terminal"]');
|
|
153
|
+
if (termBtn) termBtn.click();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function ensureTerminal() {
|
|
157
|
+
if (terminal) return;
|
|
158
|
+
if (typeof window.Terminal === 'undefined') {
|
|
159
|
+
setTimeout(ensureTerminal, 200);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var container = document.getElementById('terminalOutput');
|
|
163
|
+
if (!container) return;
|
|
164
|
+
|
|
165
|
+
terminal = new window.Terminal({
|
|
166
|
+
cursorBlink: false,
|
|
167
|
+
scrollback: 10000,
|
|
168
|
+
fontSize: 13,
|
|
169
|
+
fontFamily: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",
|
|
170
|
+
theme: { background: '#1e1e1e', foreground: '#d4d4d4' },
|
|
171
|
+
convertEol: true,
|
|
172
|
+
disableStdin: true
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (window.FitAddon) {
|
|
176
|
+
fitAddon = new window.FitAddon.FitAddon();
|
|
177
|
+
terminal.loadAddon(fitAddon);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
terminal.open(container);
|
|
181
|
+
fitTerminal();
|
|
182
|
+
|
|
183
|
+
if (resizeObserver) resizeObserver.disconnect();
|
|
184
|
+
resizeObserver = new ResizeObserver(debounce(fitTerminal, 100));
|
|
185
|
+
resizeObserver.observe(container);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function fitTerminal() {
|
|
189
|
+
if (fitAddon) {
|
|
190
|
+
try { fitAddon.fit(); } catch {}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function debounce(fn, ms) {
|
|
195
|
+
var timer;
|
|
196
|
+
return function() {
|
|
197
|
+
clearTimeout(timer);
|
|
198
|
+
timer = setTimeout(fn, ms);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
window.addEventListener('view-switched', function(e) {
|
|
203
|
+
if (e.detail && e.detail.view === 'terminal') {
|
|
204
|
+
ensureTerminal();
|
|
205
|
+
setTimeout(fitTerminal, 50);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
if (document.readyState === 'loading') {
|
|
210
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
211
|
+
} else {
|
|
212
|
+
init();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
window.scriptRunner = {
|
|
216
|
+
getState: function() { return scriptState; },
|
|
217
|
+
getTerminal: function() { return terminal; }
|
|
218
|
+
};
|
|
219
|
+
})();
|