townmouse 0.0.0-stage → 0.2.1
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 +126 -0
- package/DESIGN.md +169 -0
- package/LICENSE +661 -0
- package/README.md +368 -2
- package/SECURITY.md +57 -0
- package/TOWNMOUSE.md +91 -0
- package/assets/brand/mascot/README.md +23 -0
- package/assets/brand/mascot/townmouse-aristocrat.png +0 -0
- package/assets/brand/mascot/townmouse-icon.svg +1 -0
- package/assets/brand/mascot/townmouse-monocled.png +0 -0
- package/bin/townmouse +68 -0
- package/docs/PACKAGING.md +275 -0
- package/docs/browser-workspace.md +184 -0
- package/docs/panes.md +252 -0
- package/native/TownmouseApp.swift +108 -0
- package/package.json +89 -4
- package/public/apple-touch-icon.png +0 -0
- package/public/brand/floydslabs-credit.png +0 -0
- package/public/brand/floydslabs-credit.webp +0 -0
- package/public/brand/townmouse-aristocrat.webp +0 -0
- package/public/brand/townmouse-monocled.webp +0 -0
- package/public/clipboard-text.mjs +5 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +1 -0
- package/public/features/autosave.mjs +76 -0
- package/public/features/clipboard.mjs +69 -0
- package/public/features/command-palette.mjs +181 -0
- package/public/features/desktop-palette.mjs +19 -0
- package/public/features/export.mjs +37 -0
- package/public/features/file-drop.mjs +77 -0
- package/public/features/floating-palette.mjs +113 -0
- package/public/features/fontsize.mjs +72 -0
- package/public/features/haptic-keys.mjs +42 -0
- package/public/features/history-undo.mjs +102 -0
- package/public/features/keepalive.mjs +36 -0
- package/public/features/keybar-config.mjs +70 -0
- package/public/features/keyboard-shortcuts.mjs +74 -0
- package/public/features/links.mjs +139 -0
- package/public/features/multi-window-sync.mjs +74 -0
- package/public/features/osc-bridge.mjs +59 -0
- package/public/features/phone-landscape-focus.mjs +157 -0
- package/public/features/recent-commands.mjs +100 -0
- package/public/features/search.mjs +134 -0
- package/public/features/session-lock.mjs +96 -0
- package/public/features/session-manager.mjs +149 -0
- package/public/features/settings-sync.mjs +77 -0
- package/public/features/shortcut-help.mjs +85 -0
- package/public/features/smart-completions.mjs +101 -0
- package/public/features/smart-suggest.mjs +124 -0
- package/public/features/snippets.mjs +85 -0
- package/public/features/split-view.mjs +102 -0
- package/public/features/status-metrics.mjs +114 -0
- package/public/features/stylus-support.mjs +124 -0
- package/public/features/swipe-history.mjs +141 -0
- package/public/features/swipe-sessions.mjs +85 -0
- package/public/features/tab-reorder.mjs +62 -0
- package/public/features/theme-system.mjs +51 -0
- package/public/features/toast-status.mjs +118 -0
- package/public/features/two-finger-menu.mjs +87 -0
- package/public/features/voice-input.mjs +244 -0
- package/public/features/wake-fullscreen.mjs +67 -0
- package/public/features/window-title.mjs +40 -0
- package/public/features/zoom.mjs +80 -0
- package/public/icon-128.png +0 -0
- package/public/icon-180.png +0 -0
- package/public/icon-192.png +0 -0
- package/public/icon-48.png +0 -0
- package/public/icon-512-maskable.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +1 -0
- package/public/index.html +1765 -0
- package/public/input-chunks.mjs +22 -0
- package/public/input-guard.mjs +210 -0
- package/public/manifest.json +56 -0
- package/public/panes.css +1257 -0
- package/public/panes.html +208 -0
- package/public/panes.mjs +2625 -0
- package/public/service-worker.js +67 -0
- package/public/workspace.css +1447 -0
- package/public/workspace.mjs +1475 -0
- package/scripts/install-service.sh +269 -0
- package/scripts/node-runtime.sh +138 -0
- package/scripts/panes +439 -0
- package/scripts/prepare-native.sh +35 -0
- package/scripts/run-hooks +69 -0
- package/scripts/t1.sh +113 -0
- package/scripts/uninstall-service.sh +49 -0
- package/src/agent-guide.js +260 -0
- package/src/attachments.js +128 -0
- package/src/browser-dom.js +545 -0
- package/src/browser-workspace.js +1246 -0
- package/src/chrome-resolve.js +80 -0
- package/src/pty-permissions.js +99 -0
- package/src/regex-worker.js +13 -0
- package/src/replay-text.js +189 -0
- package/src/request-boundary.js +58 -0
- package/src/safe-regex.js +87 -0
- package/src/server.js +1122 -0
- package/src/shell-resolve.js +42 -0
- package/src/static-deps.js +61 -0
- package/src/workspace-panes.js +1099 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command palette — Ctrl+Shift+P style overlay for TerminalOne actions.
|
|
3
|
+
* Lists themes, styles, and feature actions; filters as you type.
|
|
4
|
+
*/
|
|
5
|
+
export function init(T1) {
|
|
6
|
+
const shell = T1.ui.appShell() || document.body;
|
|
7
|
+
|
|
8
|
+
T1.ui.addStyle(`
|
|
9
|
+
.t1palette {
|
|
10
|
+
position: fixed;
|
|
11
|
+
inset: 0;
|
|
12
|
+
z-index: 500;
|
|
13
|
+
display: none;
|
|
14
|
+
align-items: flex-start;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
padding-top: 18vh;
|
|
17
|
+
background: rgba(0,0,0,0.55);
|
|
18
|
+
backdrop-filter: blur(3px);
|
|
19
|
+
}
|
|
20
|
+
.t1palette.open { display: flex; }
|
|
21
|
+
.t1palette-box {
|
|
22
|
+
width: 90%;
|
|
23
|
+
max-width: 480px;
|
|
24
|
+
background: var(--ui-elevated);
|
|
25
|
+
border: 1px solid var(--ui-border);
|
|
26
|
+
border-radius: 10px;
|
|
27
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.5);
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
}
|
|
30
|
+
.t1palette-input {
|
|
31
|
+
width: 100%;
|
|
32
|
+
background: transparent;
|
|
33
|
+
border: none;
|
|
34
|
+
border-bottom: 1px solid var(--ui-border);
|
|
35
|
+
color: var(--ui-fg);
|
|
36
|
+
font-family: inherit;
|
|
37
|
+
font-size: 15px;
|
|
38
|
+
padding: 14px 16px;
|
|
39
|
+
outline: none;
|
|
40
|
+
}
|
|
41
|
+
.t1palette-input:focus { border-bottom-color: var(--ui-accent); }
|
|
42
|
+
.t1palette-list {
|
|
43
|
+
max-height: 50vh;
|
|
44
|
+
overflow-y: auto;
|
|
45
|
+
padding: 6px;
|
|
46
|
+
}
|
|
47
|
+
.t1palette-item {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
width: 100%;
|
|
52
|
+
text-align: left;
|
|
53
|
+
background: transparent;
|
|
54
|
+
border: none;
|
|
55
|
+
border-radius: 6px;
|
|
56
|
+
color: var(--ui-fg);
|
|
57
|
+
font-family: inherit;
|
|
58
|
+
font-size: 13px;
|
|
59
|
+
padding: 8px 10px;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
.t1palette-item:hover, .t1palette-item.active {
|
|
63
|
+
background: var(--ui-bg);
|
|
64
|
+
}
|
|
65
|
+
.t1palette-item .shortcut {
|
|
66
|
+
color: var(--ui-muted);
|
|
67
|
+
font-size: 11px;
|
|
68
|
+
}
|
|
69
|
+
.t1palette-empty { padding: 14px; color: var(--ui-muted); font-size: 13px; text-align: center; }
|
|
70
|
+
`);
|
|
71
|
+
|
|
72
|
+
const palette = document.createElement('div');
|
|
73
|
+
palette.className = 't1palette';
|
|
74
|
+
palette.setAttribute('role', 'dialog');
|
|
75
|
+
palette.setAttribute('aria-label', 'Command palette');
|
|
76
|
+
const box = document.createElement('div');
|
|
77
|
+
box.className = 't1palette-box';
|
|
78
|
+
const input = document.createElement('input');
|
|
79
|
+
input.type = 'text';
|
|
80
|
+
input.className = 't1palette-input';
|
|
81
|
+
input.placeholder = 'Type a command…';
|
|
82
|
+
const list = document.createElement('div');
|
|
83
|
+
list.className = 't1palette-list';
|
|
84
|
+
box.appendChild(input);
|
|
85
|
+
box.appendChild(list);
|
|
86
|
+
palette.appendChild(box);
|
|
87
|
+
shell.appendChild(palette);
|
|
88
|
+
|
|
89
|
+
function themeActions() {
|
|
90
|
+
const out = [];
|
|
91
|
+
if (window.__terminalOne && window.__terminalOne.themes) {
|
|
92
|
+
for (const id of window.__terminalOne.themes()) {
|
|
93
|
+
const opt = document.querySelector(`#themeSelect option[value="${id}"]`);
|
|
94
|
+
const label = opt ? opt.textContent : id;
|
|
95
|
+
out.push({
|
|
96
|
+
title: `Theme: ${label}`,
|
|
97
|
+
shortcut: '',
|
|
98
|
+
run() {
|
|
99
|
+
if (window.__terminalOne && window.__terminalOne.setTheme) {
|
|
100
|
+
window.__terminalOne.setTheme(id);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function allActions() {
|
|
110
|
+
return [
|
|
111
|
+
{ title: 'Clear screen', shortcut: 'Ctrl+K', run() { window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'clear' } })); } },
|
|
112
|
+
{ title: 'Toggle search', shortcut: 'Ctrl+Shift+F', run() { window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'toggle-search' } })); } },
|
|
113
|
+
{ title: 'Toggle snippets', shortcut: 'Ctrl+B', run() { window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'toggle-snippets' } })); } },
|
|
114
|
+
{ title: 'Increase font size', shortcut: 'Ctrl++', run() { window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'font-increase' } })); } },
|
|
115
|
+
{ title: 'Decrease font size', shortcut: 'Ctrl+-', run() { window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'font-decrease' } })); } },
|
|
116
|
+
{ title: 'Open settings', shortcut: '', run() { document.getElementById('settingsBtn')?.click(); } },
|
|
117
|
+
{ title: 'Reconnect session', shortcut: '', run() { document.getElementById('reconnectBtn')?.click(); } },
|
|
118
|
+
{ title: 'Close connection', shortcut: '', run() { document.getElementById('closeBtn')?.click(); } },
|
|
119
|
+
{ title: 'Open help', shortcut: 'F1', run() { window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'help' } })); } },
|
|
120
|
+
...themeActions()
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let filtered = [];
|
|
125
|
+
let selected = 0;
|
|
126
|
+
|
|
127
|
+
function render() {
|
|
128
|
+
const q = input.value.trim().toLowerCase();
|
|
129
|
+
filtered = allActions().filter((a) => a.title.toLowerCase().includes(q));
|
|
130
|
+
list.innerHTML = '';
|
|
131
|
+
if (!filtered.length) {
|
|
132
|
+
const empty = document.createElement('div');
|
|
133
|
+
empty.className = 't1palette-empty';
|
|
134
|
+
empty.textContent = 'No matching commands';
|
|
135
|
+
list.appendChild(empty);
|
|
136
|
+
selected = 0;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
selected = Math.max(0, Math.min(selected, filtered.length - 1));
|
|
140
|
+
filtered.forEach((a, i) => {
|
|
141
|
+
const b = document.createElement('button');
|
|
142
|
+
b.type = 'button';
|
|
143
|
+
b.className = 't1palette-item' + (i === selected ? ' active' : '');
|
|
144
|
+
b.innerHTML = `<span>${a.title}</span>${a.shortcut ? `<span class="shortcut">${a.shortcut}</span>` : ''}`;
|
|
145
|
+
b.addEventListener('click', () => { a.run(); close(); });
|
|
146
|
+
list.appendChild(b);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function open() {
|
|
151
|
+
input.value = '';
|
|
152
|
+
palette.classList.add('open');
|
|
153
|
+
render();
|
|
154
|
+
setTimeout(() => input.focus(), 0);
|
|
155
|
+
}
|
|
156
|
+
function close() { palette.classList.remove('open'); }
|
|
157
|
+
|
|
158
|
+
input.addEventListener('input', () => { selected = 0; render(); });
|
|
159
|
+
input.addEventListener('keydown', (e) => {
|
|
160
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); selected = Math.min(selected + 1, filtered.length - 1); render(); }
|
|
161
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); selected = Math.max(selected - 1, 0); render(); }
|
|
162
|
+
else if (e.key === 'Enter') { e.preventDefault(); filtered[selected]?.run(); close(); }
|
|
163
|
+
else if (e.key === 'Escape') { e.preventDefault(); close(); }
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
palette.addEventListener('click', (e) => { if (e.target === palette) close(); });
|
|
167
|
+
|
|
168
|
+
// Listen for the global command-palette action.
|
|
169
|
+
window.addEventListener('t1:action', (e) => {
|
|
170
|
+
if ((e.detail || {}).action === 'command-palette') open();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Direct keyboard shortcut (global).
|
|
174
|
+
document.addEventListener('keydown', (e) => {
|
|
175
|
+
const mod = e.ctrlKey || e.metaKey;
|
|
176
|
+
if (mod && e.shiftKey && (e.key === 'p' || e.key === 'P')) {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
open();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desktop command palette shortcut Ctrl/Cmd+K.
|
|
3
|
+
*
|
|
4
|
+
* Registers a global keydown listener that opens the existing command palette
|
|
5
|
+
* even when focus is outside the terminal.
|
|
6
|
+
*/
|
|
7
|
+
export function init(T1) {
|
|
8
|
+
if (T1.device !== 'desktop') return;
|
|
9
|
+
|
|
10
|
+
document.addEventListener('keydown', (e) => {
|
|
11
|
+
const k = e.key.toLowerCase();
|
|
12
|
+
if ((e.ctrlKey || e.metaKey) && k === 'k' && !e.shiftKey && !e.altKey) {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'command-palette' } }));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
window.__terminalOneDesktopPalette = { installed: true };
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export terminal scrollback — downloads the current buffer as a .txt file.
|
|
3
|
+
*
|
|
4
|
+
* ShellFish parity: save terminal output to a file.
|
|
5
|
+
*/
|
|
6
|
+
export function init(T1) {
|
|
7
|
+
const tb = T1.ui.toolbar();
|
|
8
|
+
if (!tb) return;
|
|
9
|
+
|
|
10
|
+
const btn = T1.ui.makeButton('Export', 'Export terminal output as .txt', () => {
|
|
11
|
+
const term = T1.term;
|
|
12
|
+
if (!term || !term.buffer) {
|
|
13
|
+
T1.toast('No terminal output to export', 'warn');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const buf = term.buffer.active;
|
|
18
|
+
const lines = [];
|
|
19
|
+
for (let i = 0; i < buf.length; i += 1) {
|
|
20
|
+
const line = buf.getLine(i);
|
|
21
|
+
lines.push(line ? line.translateToString(true) : '');
|
|
22
|
+
}
|
|
23
|
+
const text = lines.join('\n') + '\n';
|
|
24
|
+
const blob = new Blob([text], { type: 'text/plain' });
|
|
25
|
+
const a = document.createElement('a');
|
|
26
|
+
a.href = URL.createObjectURL(blob);
|
|
27
|
+
const now = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
28
|
+
a.download = `terminal-output-${now}.txt`;
|
|
29
|
+
a.click();
|
|
30
|
+
URL.revokeObjectURL(a.href);
|
|
31
|
+
T1.toast('Terminal output exported');
|
|
32
|
+
} catch (err) {
|
|
33
|
+
T1.toast('Export failed', 'error');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
tb.appendChild(btn);
|
|
37
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desktop file drop into terminal.
|
|
3
|
+
*
|
|
4
|
+
* Dragging a file over the terminal shows a drop target; dropping pastes the
|
|
5
|
+
* file path (or base64 data URL for images) into the terminal input.
|
|
6
|
+
*/
|
|
7
|
+
export function init(T1) {
|
|
8
|
+
if (T1.device !== 'desktop') return;
|
|
9
|
+
|
|
10
|
+
T1.ui.addStyle(`
|
|
11
|
+
.t1-file-drop-target {
|
|
12
|
+
position: fixed; inset: 0;
|
|
13
|
+
background: rgba(122,162,247,0.15);
|
|
14
|
+
border: 3px dashed var(--ui-accent);
|
|
15
|
+
z-index: 500;
|
|
16
|
+
display: none;
|
|
17
|
+
align-items: center; justify-content: center;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
.t1-file-drop-target.active { display: flex; }
|
|
21
|
+
.t1-file-drop-target span { color: var(--ui-accent); font-size: 18px; font-weight: 600; }
|
|
22
|
+
`);
|
|
23
|
+
|
|
24
|
+
const overlay = document.createElement('div');
|
|
25
|
+
overlay.className = 't1-file-drop-target';
|
|
26
|
+
overlay.setAttribute('role', 'region');
|
|
27
|
+
overlay.setAttribute('aria-label', 'Drop file to paste path');
|
|
28
|
+
overlay.innerHTML = '<span>Drop file to paste path</span>';
|
|
29
|
+
document.body.appendChild(overlay);
|
|
30
|
+
|
|
31
|
+
const target = T1.term?.element || document.querySelector('.terminal-container') || document.body;
|
|
32
|
+
|
|
33
|
+
function show(e) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
overlay.classList.add('active');
|
|
36
|
+
}
|
|
37
|
+
function hide() { overlay.classList.remove('active'); }
|
|
38
|
+
|
|
39
|
+
window.addEventListener('dragenter', show);
|
|
40
|
+
window.addEventListener('dragover', show);
|
|
41
|
+
window.addEventListener('dragleave', (e) => { if (e.relatedTarget === null) hide(); });
|
|
42
|
+
window.addEventListener('drop', async (e) => {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
hide();
|
|
45
|
+
const files = e.dataTransfer?.files;
|
|
46
|
+
if (!files || !files.length) return;
|
|
47
|
+
|
|
48
|
+
for (const file of files) {
|
|
49
|
+
const isImage = file.type.startsWith('image/');
|
|
50
|
+
if (isImage) {
|
|
51
|
+
try {
|
|
52
|
+
const reader = new FileReader();
|
|
53
|
+
const dataUrl = await new Promise((resolve, reject) => {
|
|
54
|
+
reader.onload = () => resolve(reader.result);
|
|
55
|
+
reader.onerror = reject;
|
|
56
|
+
reader.readAsDataURL(file);
|
|
57
|
+
});
|
|
58
|
+
T1.sendData(dataUrl);
|
|
59
|
+
T1.toast(`Pasted image ${file.name}`);
|
|
60
|
+
} catch (_) {
|
|
61
|
+
// Browsers do not expose real filesystem paths to web pages for
|
|
62
|
+
// security; fall back to the filename only.
|
|
63
|
+
T1.sendData(file.name);
|
|
64
|
+
T1.toast(`Pasted ${file.name}`, 'warn');
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
// Browsers do not expose real filesystem paths to web pages; only the
|
|
68
|
+
// filename is available. Sending a fabricated path would mislead the
|
|
69
|
+
// shell, so we send the bare filename instead.
|
|
70
|
+
T1.sendData(file.name);
|
|
71
|
+
T1.toast(`Pasted ${file.name}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
window.__terminalOneFileDrop = { overlay, show, hide };
|
|
77
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating command palette (tablet touch optimized).
|
|
3
|
+
*
|
|
4
|
+
* A large touch-target, bottom-sheet palette reachable from a floating
|
|
5
|
+
* action button. Dispatches existing t1:action events so it reuses the
|
|
6
|
+
* command-palette catalog.
|
|
7
|
+
*/
|
|
8
|
+
export function init(T1) {
|
|
9
|
+
if (T1.device !== 'ipad') return;
|
|
10
|
+
|
|
11
|
+
T1.ui.addStyle(`
|
|
12
|
+
.t1-fab {
|
|
13
|
+
position: relative;
|
|
14
|
+
margin: 8px 16px; align-self: flex-end; flex-shrink: 0;
|
|
15
|
+
width: 64px; height: 44px;
|
|
16
|
+
border-radius: 8px;
|
|
17
|
+
background: var(--ui-accent);
|
|
18
|
+
color: var(--ui-on-accent, #14171b);
|
|
19
|
+
border: none;
|
|
20
|
+
font-size: 13px;
|
|
21
|
+
box-shadow: none;
|
|
22
|
+
z-index: 220;
|
|
23
|
+
display: flex; align-items: center; justify-content: center;
|
|
24
|
+
}
|
|
25
|
+
.t1-tablet-sheet {
|
|
26
|
+
position: fixed;
|
|
27
|
+
left: 0; right: 0; bottom: 0;
|
|
28
|
+
max-height: 60vh;
|
|
29
|
+
background: var(--ui-elevated);
|
|
30
|
+
border-radius: 16px 16px 0 0;
|
|
31
|
+
border-top: 1px solid var(--ui-border);
|
|
32
|
+
transform: translateY(110%);
|
|
33
|
+
visibility: hidden;
|
|
34
|
+
transition: transform 0.25s ease;
|
|
35
|
+
z-index: 230;
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
39
|
+
}
|
|
40
|
+
.t1-tablet-sheet.open { transform: translateY(0); visibility: visible; }
|
|
41
|
+
.t1-tablet-sheet header {
|
|
42
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
43
|
+
padding: 14px 18px; border-bottom: 1px solid var(--ui-border);
|
|
44
|
+
}
|
|
45
|
+
.t1-tablet-sheet h3 { margin: 0; font-size: 15px; color: var(--ui-fg); }
|
|
46
|
+
.t1-tablet-sheet .sheet-close { background: transparent; border: none; color: var(--ui-muted); font-size: 18px; }
|
|
47
|
+
.t1-tablet-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; padding: 16px; overflow-y: auto; }
|
|
48
|
+
.t1-tablet-actions button {
|
|
49
|
+
min-height: 56px; padding: 10px;
|
|
50
|
+
background: var(--ui-bg); color: var(--ui-fg);
|
|
51
|
+
border: 1px solid var(--ui-border); border-radius: 10px;
|
|
52
|
+
font-size: 14px; cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
.t1-tablet-actions button:active { background: var(--ui-accent); color: var(--ui-on-accent, #14171b); }
|
|
55
|
+
`);
|
|
56
|
+
|
|
57
|
+
const fab = document.createElement('button');
|
|
58
|
+
fab.type = 'button';
|
|
59
|
+
fab.className = 't1-fab';
|
|
60
|
+
fab.textContent = 'Cmd';
|
|
61
|
+
fab.setAttribute('aria-label', 'Open command palette');
|
|
62
|
+
document.querySelector('.app-shell').insertBefore(fab, document.querySelector('.terminal-container'));
|
|
63
|
+
|
|
64
|
+
const sheet = document.createElement('div');
|
|
65
|
+
sheet.className = 't1-tablet-sheet';
|
|
66
|
+
sheet.setAttribute('role', 'dialog');
|
|
67
|
+
sheet.setAttribute('aria-label', 'Tablet command palette');
|
|
68
|
+
sheet.innerHTML = `
|
|
69
|
+
<header><h3>Command Palette</h3><button type="button" class="sheet-close" aria-label="Close palette">×</button></header>
|
|
70
|
+
<div class="t1-tablet-actions"></div>
|
|
71
|
+
`;
|
|
72
|
+
document.body.appendChild(sheet);
|
|
73
|
+
|
|
74
|
+
const actionsEl = sheet.querySelector('.t1-tablet-actions');
|
|
75
|
+
const ACTIONS = [
|
|
76
|
+
{ label: 'Search', action: 'toggle-search' },
|
|
77
|
+
{ label: 'Command Palette', action: 'command-palette' },
|
|
78
|
+
{ label: 'Clear', action: 'clear' },
|
|
79
|
+
{ label: 'Select All', action: 'select-all' },
|
|
80
|
+
{ label: 'Copy', action: 'copy' },
|
|
81
|
+
{ label: 'Paste', action: 'paste' },
|
|
82
|
+
{ label: 'Theme', action: 'theme-settings' },
|
|
83
|
+
{ label: 'Font +', action: 'font-increase' },
|
|
84
|
+
{ label: 'Font -', action: 'font-decrease' }
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
function open() {
|
|
88
|
+
actionsEl.innerHTML = '';
|
|
89
|
+
for (const { label, action } of ACTIONS) {
|
|
90
|
+
const b = document.createElement('button');
|
|
91
|
+
b.type = 'button';
|
|
92
|
+
b.textContent = label;
|
|
93
|
+
b.addEventListener('click', () => {
|
|
94
|
+
if (action === 'theme-settings') {
|
|
95
|
+
document.querySelector('#settingsBtn')?.click();
|
|
96
|
+
close();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
window.dispatchEvent(new CustomEvent('t1:action', { detail: { action } }));
|
|
100
|
+
close();
|
|
101
|
+
});
|
|
102
|
+
actionsEl.appendChild(b);
|
|
103
|
+
}
|
|
104
|
+
sheet.classList.add('open');
|
|
105
|
+
}
|
|
106
|
+
function close() { sheet.classList.remove('open'); }
|
|
107
|
+
|
|
108
|
+
fab.addEventListener('click', open);
|
|
109
|
+
sheet.querySelector('.sheet-close').addEventListener('click', close);
|
|
110
|
+
|
|
111
|
+
// Expose for tests.
|
|
112
|
+
window.__terminalOneFloatingPalette = { open, close, fab, sheet, actionsEl };
|
|
113
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font size feature — A-/A+ buttons that resize the terminal font, show the
|
|
3
|
+
* current size, persist the choice, and re-apply it after every reconnect
|
|
4
|
+
* (the terminal instance is disposed and recreated on resume).
|
|
5
|
+
*/
|
|
6
|
+
const KEY = 'terminalone.fontSize';
|
|
7
|
+
const MIN = 8, MAX = 28, STEP = 1;
|
|
8
|
+
|
|
9
|
+
function responsiveDefault() {
|
|
10
|
+
const width = window.innerWidth;
|
|
11
|
+
if (width <= 430) return 11;
|
|
12
|
+
if (width <= 820) return 12;
|
|
13
|
+
return 14;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function init(T1) {
|
|
17
|
+
const tb = T1.ui.toolbar();
|
|
18
|
+
if (!tb) return;
|
|
19
|
+
|
|
20
|
+
T1.ui.addStyle(`
|
|
21
|
+
.t1font-group {
|
|
22
|
+
flex: 1 1 100%;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: 8px;
|
|
26
|
+
}
|
|
27
|
+
.t1font-group .t1button { flex: 1; }
|
|
28
|
+
.t1font-label {
|
|
29
|
+
flex: 0 0 auto;
|
|
30
|
+
min-width: 32px;
|
|
31
|
+
text-align: center;
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
color: var(--ui-muted);
|
|
34
|
+
user-select: none;
|
|
35
|
+
-webkit-user-select: none;
|
|
36
|
+
}
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
const clamp = (n) => Math.max(MIN, Math.min(MAX, n));
|
|
40
|
+
const stored = T1.storage.get(KEY, null);
|
|
41
|
+
let size = stored !== null && stored !== undefined && stored !== ''
|
|
42
|
+
? clamp(parseInt(stored, 10) || responsiveDefault())
|
|
43
|
+
: responsiveDefault();
|
|
44
|
+
|
|
45
|
+
const label = document.createElement('span');
|
|
46
|
+
label.className = 't1font-label';
|
|
47
|
+
const render = () => { label.textContent = `${size}px`; };
|
|
48
|
+
const apply = () => {
|
|
49
|
+
const term = T1.term;
|
|
50
|
+
if (term) { term.options.fontSize = size; T1.fit(); }
|
|
51
|
+
render();
|
|
52
|
+
};
|
|
53
|
+
const bump = (delta) => {
|
|
54
|
+
const next = clamp(size + delta);
|
|
55
|
+
if (next === size) return;
|
|
56
|
+
size = next;
|
|
57
|
+
T1.storage.set(KEY, String(size));
|
|
58
|
+
apply();
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const minus = T1.ui.makeButton('A-', 'Decrease font size', () => bump(-STEP));
|
|
62
|
+
const plus = T1.ui.makeButton('A+', 'Increase font size', () => bump(STEP));
|
|
63
|
+
|
|
64
|
+
const group = document.createElement('div');
|
|
65
|
+
group.className = 't1font-group';
|
|
66
|
+
group.append(minus, label, plus);
|
|
67
|
+
tb.appendChild(group);
|
|
68
|
+
|
|
69
|
+
render();
|
|
70
|
+
// The terminal is recreated on every (re)connect — re-apply the stored size.
|
|
71
|
+
T1.onTermReady((term) => { term.options.fontSize = size; T1.fit(); });
|
|
72
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Haptic feedback for on-screen keys (phone/tablet).
|
|
3
|
+
*
|
|
4
|
+
* Uses navigator.vibrate when available, falling back to the iOS haptic API
|
|
5
|
+
* if present. Only fires on genuine touch events, not mouse clicks.
|
|
6
|
+
*/
|
|
7
|
+
export function init(T1) {
|
|
8
|
+
if (T1.device === 'desktop') return;
|
|
9
|
+
|
|
10
|
+
const hasVibrate = typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function';
|
|
11
|
+
const haptic = typeof window !== 'undefined' && window.navigator && typeof window.navigator.vibrate === 'function'
|
|
12
|
+
? window.navigator.vibrate.bind(window.navigator)
|
|
13
|
+
: null;
|
|
14
|
+
|
|
15
|
+
function fire(ev) {
|
|
16
|
+
// Only on real touch paths (not mouse/keyboard).
|
|
17
|
+
if (ev?.sourceCapabilities?.firesTouchEvents === false) return;
|
|
18
|
+
if (hasVibrate) {
|
|
19
|
+
try { navigator.vibrate(10); } catch (_) {}
|
|
20
|
+
} else if (typeof window !== 'undefined' && window.webkit?.messageHandlers?.haptic) {
|
|
21
|
+
try { window.webkit.messageHandlers.haptic.postMessage('light'); } catch (_) {}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function wire(key) {
|
|
26
|
+
key.addEventListener('touchstart', fire, { passive: true });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function scan() {
|
|
30
|
+
document.querySelectorAll('#keybarIphone .kb-key, #keybarIpad .kb-key').forEach(wire);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Initial scan plus observer for dynamic rebuilds.
|
|
34
|
+
scan();
|
|
35
|
+
const mo = new MutationObserver(scan);
|
|
36
|
+
for (const id of ['keybarIphone', 'keybarIpad']) {
|
|
37
|
+
const el = document.getElementById(id);
|
|
38
|
+
if (el) mo.observe(el, { childList: true, subtree: true });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
window.__terminalOneHaptic = { fire, wired: scan };
|
|
42
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undo/Redo system — local command history.
|
|
3
|
+
*
|
|
4
|
+
* Every time the user submits a line (Enter) we snapshot the command text
|
|
5
|
+
* accumulated in the current line into a local history ring. The user can
|
|
6
|
+
* then Ctrl+Z to recall the previous command into the prompt and Ctrl+Y to
|
|
7
|
+
* cycle forward, independent of the shell's own history. This gives an
|
|
8
|
+
* undo/redo feel for "what I just typed" across disconnects and fresh shells.
|
|
9
|
+
*/
|
|
10
|
+
const KEY = 'terminalone.commandHistory';
|
|
11
|
+
const MAX = 50;
|
|
12
|
+
|
|
13
|
+
export function init(T1) {
|
|
14
|
+
let history = [];
|
|
15
|
+
let index = -1; // -1 means current blank line
|
|
16
|
+
let pending = '';
|
|
17
|
+
|
|
18
|
+
function load() {
|
|
19
|
+
try {
|
|
20
|
+
const v = JSON.parse(T1.storage.get(KEY, '[]'));
|
|
21
|
+
history = Array.isArray(v) ? v.slice(-MAX) : [];
|
|
22
|
+
} catch (_) { history = []; }
|
|
23
|
+
}
|
|
24
|
+
function save() {
|
|
25
|
+
T1.storage.set(KEY, JSON.stringify(history.slice(-MAX)));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function recall(dir) {
|
|
29
|
+
if (!history.length) return;
|
|
30
|
+
if (index === -1) pending = ''; // remember empty current line
|
|
31
|
+
index += dir;
|
|
32
|
+
if (index < -1) index = history.length - 1;
|
|
33
|
+
if (index >= history.length) index = -1;
|
|
34
|
+
|
|
35
|
+
const cmd = index === -1 ? pending : history[index];
|
|
36
|
+
if (!cmd) return;
|
|
37
|
+
|
|
38
|
+
// Send Ctrl+U to clear the current line, then the recalled command.
|
|
39
|
+
T1.sendData('\x15');
|
|
40
|
+
setTimeout(() => T1.sendData(cmd), 10);
|
|
41
|
+
T1.toast(index === -1 ? 'Restored blank line' : `History ${index + 1}/${history.length}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function remember(cmd) {
|
|
45
|
+
if (!cmd || cmd.trim().length === 0) return;
|
|
46
|
+
if (history[history.length - 1] === cmd) return;
|
|
47
|
+
history.push(cmd);
|
|
48
|
+
if (history.length > MAX) history.shift();
|
|
49
|
+
save();
|
|
50
|
+
index = -1;
|
|
51
|
+
pending = '';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
load();
|
|
55
|
+
|
|
56
|
+
// Heuristic line capture: when Enter is sent, read the terminal's current
|
|
57
|
+
// buffer line from xterm's active row. xterm exposes buffer.active.
|
|
58
|
+
window.addEventListener('t1:action', (e) => {
|
|
59
|
+
const { action } = e.detail || {};
|
|
60
|
+
if (action === 'history-back') { recall(-1); return; }
|
|
61
|
+
if (action === 'history-forward') { recall(1); return; }
|
|
62
|
+
if (action === 'clear') { index = -1; pending = ''; }
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Hook Enter presses to snapshot the typed line.
|
|
66
|
+
T1.onTermReady((term) => {
|
|
67
|
+
let captureTimer = 0;
|
|
68
|
+
const dataDisposable = term.onData((data) => {
|
|
69
|
+
if (data === '\r') {
|
|
70
|
+
// xterm does not expose a synchronous "current line"; wait a tick
|
|
71
|
+
// so the shell echo has landed, then read the active row.
|
|
72
|
+
if (captureTimer) clearTimeout(captureTimer);
|
|
73
|
+
captureTimer = setTimeout(() => {
|
|
74
|
+
captureTimer = 0;
|
|
75
|
+
try {
|
|
76
|
+
const row = term.buffer.active.getLine(term.buffer.active.cursorY);
|
|
77
|
+
const text = row ? row.translateToString(true) : '';
|
|
78
|
+
// Strip the prompt portion is impossible generically; store raw.
|
|
79
|
+
remember(text.trim());
|
|
80
|
+
} catch (_) {}
|
|
81
|
+
}, 50);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return () => {
|
|
85
|
+
if (captureTimer) clearTimeout(captureTimer);
|
|
86
|
+
dataDisposable.dispose();
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Global shortcuts: Ctrl+Z undo (back), Ctrl+Y redo (forward), Ctrl+Shift+Z also forward.
|
|
91
|
+
document.addEventListener('keydown', (e) => {
|
|
92
|
+
const mod = e.ctrlKey || e.metaKey;
|
|
93
|
+
if (!mod) return;
|
|
94
|
+
if (e.key === 'z' || e.key === 'Z') {
|
|
95
|
+
if (e.shiftKey) { e.preventDefault(); recall(1); }
|
|
96
|
+
else { e.preventDefault(); recall(-1); }
|
|
97
|
+
} else if (e.key === 'y' || e.key === 'Y') {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
recall(1);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background heartbeat / mobile keepalive.
|
|
3
|
+
*
|
|
4
|
+
* When the page becomes hidden (mobile app switch, desktop tab background),
|
|
5
|
+
* send a periodic WebSocket ping/heartbeat so the server keeps the session
|
|
6
|
+
* alive longer.
|
|
7
|
+
*/
|
|
8
|
+
export function init(T1) {
|
|
9
|
+
let hiddenTimer = null;
|
|
10
|
+
const INTERVAL_MS = 15_000;
|
|
11
|
+
|
|
12
|
+
function isHidden() {
|
|
13
|
+
return typeof document !== 'undefined' && document.hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function beat() {
|
|
17
|
+
const sock = T1.ws;
|
|
18
|
+
if (!sock || sock.readyState !== WebSocket.OPEN) return;
|
|
19
|
+
try { sock.send(JSON.stringify({ type: 'ping', ts: Date.now() })); } catch (_) {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function onVisibility() {
|
|
23
|
+
if (isHidden()) {
|
|
24
|
+
if (hiddenTimer) return;
|
|
25
|
+
beat();
|
|
26
|
+
hiddenTimer = setInterval(beat, INTERVAL_MS);
|
|
27
|
+
} else {
|
|
28
|
+
if (hiddenTimer) { clearInterval(hiddenTimer); hiddenTimer = null; }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
33
|
+
if (isHidden()) onVisibility();
|
|
34
|
+
|
|
35
|
+
window.__terminalOneKeepalive = { beat, isHidden, intervalMs: INTERVAL_MS };
|
|
36
|
+
}
|