townmouse 0.0.0-stage → 0.4.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 +196 -0
- package/DESIGN.md +153 -0
- package/LICENSE +661 -0
- package/README.md +600 -2
- package/SECURITY.md +60 -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 +371 -0
- package/docs/browser-workspace.md +237 -0
- package/docs/panes.md +442 -0
- package/native/TownmouseApp.swift +108 -0
- package/npm-shrinkwrap.json +1282 -0
- package/package.json +93 -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/browser-picture.mjs +159 -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/app-version.mjs +35 -0
- package/public/features/autosave.mjs +80 -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 +76 -0
- package/public/features/osc-bridge.mjs +64 -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 +251 -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 +137 -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 +70 -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 +47 -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 +2304 -0
- package/public/input-chunks.mjs +22 -0
- package/public/input-guard.mjs +218 -0
- package/public/manifest.json +56 -0
- package/public/panes.css +1433 -0
- package/public/panes.html +211 -0
- package/public/panes.mjs +3183 -0
- package/public/service-worker.js +67 -0
- package/public/workspace.css +1621 -0
- package/public/workspace.mjs +1715 -0
- package/scripts/install-service.sh +303 -0
- package/scripts/node-runtime.sh +138 -0
- package/scripts/panes +568 -0
- package/scripts/prepare-native.sh +35 -0
- package/scripts/retire-legacy-service.sh +76 -0
- package/scripts/run-hooks +69 -0
- package/scripts/townmouse.sh +152 -0
- package/scripts/uninstall-service.sh +65 -0
- package/src/agent-guide.js +329 -0
- package/src/attachments.js +128 -0
- package/src/browser-dom.js +548 -0
- package/src/browser-workspace.js +1733 -0
- package/src/chrome-resolve.js +80 -0
- package/src/owner-page.js +43 -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 +1582 -0
- package/src/shell-resolve.js +42 -0
- package/src/static-deps.js +61 -0
- package/src/workspace-panes.js +1431 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swipe-up command history tray (phone vertical).
|
|
3
|
+
*
|
|
4
|
+
* On iPhone, swiping up from the bottom key bar opens a drawer showing the
|
|
5
|
+
* most recent commands from the local history ring. Tapping a command pastes
|
|
6
|
+
* it into the terminal input.
|
|
7
|
+
*/
|
|
8
|
+
const HISTORY_KEY = 'terminalone.commandHistory';
|
|
9
|
+
|
|
10
|
+
export function init(T1) {
|
|
11
|
+
if (T1.device !== 'iphone') return;
|
|
12
|
+
|
|
13
|
+
T1.ui.addStyle(`
|
|
14
|
+
.t1-swipe-history-tray {
|
|
15
|
+
position: fixed;
|
|
16
|
+
left: 0; right: 0; bottom: 0;
|
|
17
|
+
max-height: 45vh;
|
|
18
|
+
background: var(--ui-elevated);
|
|
19
|
+
border-top: 1px solid var(--ui-border);
|
|
20
|
+
border-radius: 12px 12px 0 0;
|
|
21
|
+
transform: translateY(110%);
|
|
22
|
+
visibility: hidden;
|
|
23
|
+
transition: transform 0.25s ease;
|
|
24
|
+
z-index: 250;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
28
|
+
}
|
|
29
|
+
.t1-swipe-history-tray.open { transform: translateY(0); visibility: visible; }
|
|
30
|
+
.t1-swipe-history-tray header {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
padding: 10px 14px;
|
|
35
|
+
border-bottom: 1px solid var(--ui-border);
|
|
36
|
+
}
|
|
37
|
+
.t1-swipe-history-tray h3 { margin: 0; font-size: 13px; color: var(--ui-fg); }
|
|
38
|
+
.t1-swipe-history-tray .close-btn {
|
|
39
|
+
background: transparent; border: none; color: var(--ui-muted); font-size: 16px;
|
|
40
|
+
}
|
|
41
|
+
.t1-swipe-history-list {
|
|
42
|
+
overflow-y: auto;
|
|
43
|
+
-webkit-overflow-scrolling: touch;
|
|
44
|
+
}
|
|
45
|
+
.t1-swipe-history-list .cmd {
|
|
46
|
+
padding: 12px 14px;
|
|
47
|
+
border-bottom: 1px solid var(--ui-border);
|
|
48
|
+
font-size: 13px;
|
|
49
|
+
color: var(--ui-fg);
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
text-overflow: ellipsis;
|
|
54
|
+
}
|
|
55
|
+
.t1-swipe-history-list .cmd:active { background: var(--ui-accent); color: var(--ui-on-accent, #14171b); }
|
|
56
|
+
.t1-swipe-history-list .empty {
|
|
57
|
+
padding: 20px 14px; color: var(--ui-muted); font-size: 12px; text-align: center;
|
|
58
|
+
}
|
|
59
|
+
.t1-swipe-history-hint {
|
|
60
|
+
position: fixed;
|
|
61
|
+
left: 50%; bottom: 4px;
|
|
62
|
+
transform: translateX(-50%);
|
|
63
|
+
width: 36px; height: 4px;
|
|
64
|
+
border-radius: 2px;
|
|
65
|
+
background: var(--ui-border);
|
|
66
|
+
z-index: 251;
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
}
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
const tray = document.createElement('div');
|
|
72
|
+
tray.className = 't1-swipe-history-tray';
|
|
73
|
+
tray.setAttribute('role', 'dialog');
|
|
74
|
+
tray.setAttribute('aria-label', 'Command history');
|
|
75
|
+
tray.innerHTML = `
|
|
76
|
+
<header><h3>Recent commands</h3><button type="button" class="close-btn" aria-label="Close history">×</button></header>
|
|
77
|
+
<div class="t1-swipe-history-list"></div>
|
|
78
|
+
`;
|
|
79
|
+
document.body.appendChild(tray);
|
|
80
|
+
|
|
81
|
+
const hint = document.createElement('div');
|
|
82
|
+
hint.className = 't1-swipe-history-hint';
|
|
83
|
+
document.body.appendChild(hint);
|
|
84
|
+
|
|
85
|
+
const list = tray.querySelector('.t1-swipe-history-list');
|
|
86
|
+
tray.querySelector('.close-btn').addEventListener('click', close);
|
|
87
|
+
|
|
88
|
+
function readHistory() {
|
|
89
|
+
try { return JSON.parse(T1.storage.get(HISTORY_KEY, '[]')); }
|
|
90
|
+
catch (_) { return []; }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function render() {
|
|
94
|
+
const hist = readHistory().slice().reverse();
|
|
95
|
+
list.innerHTML = '';
|
|
96
|
+
if (!hist.length) {
|
|
97
|
+
list.innerHTML = '<div class="empty">No commands yet. Type something and press Enter.</div>';
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const cmd of hist) {
|
|
101
|
+
const row = document.createElement('div');
|
|
102
|
+
row.className = 'cmd';
|
|
103
|
+
row.textContent = cmd;
|
|
104
|
+
row.setAttribute('role', 'button');
|
|
105
|
+
row.setAttribute('tabindex', '0');
|
|
106
|
+
row.addEventListener('click', () => { T1.sendData(cmd); close(); T1.toast('Pasted from history'); });
|
|
107
|
+
row.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); row.click(); } });
|
|
108
|
+
list.appendChild(row);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function open() { render(); tray.classList.add('open'); }
|
|
113
|
+
function close() { tray.classList.remove('open'); }
|
|
114
|
+
|
|
115
|
+
// Swipe up from the bottom key bar opens the tray.
|
|
116
|
+
const keybar = document.getElementById('keybarIphone');
|
|
117
|
+
if (keybar) {
|
|
118
|
+
let startY = 0;
|
|
119
|
+
let startX = 0;
|
|
120
|
+
keybar.addEventListener('touchstart', (e) => {
|
|
121
|
+
const t = e.touches[0];
|
|
122
|
+
startY = t.clientY;
|
|
123
|
+
startX = t.clientX;
|
|
124
|
+
}, { passive: true });
|
|
125
|
+
keybar.addEventListener('touchend', (e) => {
|
|
126
|
+
const t = e.changedTouches[0];
|
|
127
|
+
const dy = startY - t.clientY;
|
|
128
|
+
const dx = Math.abs(startX - t.clientX);
|
|
129
|
+
if (dy > 40 && dx < 60) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
open();
|
|
132
|
+
}
|
|
133
|
+
}, { passive: false });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Clicking the hint also opens it for discoverability.
|
|
137
|
+
hint.addEventListener('click', open);
|
|
138
|
+
|
|
139
|
+
// Test hook.
|
|
140
|
+
window.__terminalOneSwipeHistory = { open, close, tray, render, readHistory };
|
|
141
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swipe-left/right session switcher.
|
|
3
|
+
*
|
|
4
|
+
* Two-finger horizontal swipe or edge swipe switches to next/previous
|
|
5
|
+
* session tab. Wraps around at the ends. Works on phones and tablets.
|
|
6
|
+
*/
|
|
7
|
+
export function init(T1) {
|
|
8
|
+
if (T1.device === 'desktop') return;
|
|
9
|
+
|
|
10
|
+
let startX = 0;
|
|
11
|
+
let startY = 0;
|
|
12
|
+
let isTwoFinger = false;
|
|
13
|
+
const EDGE_PX = 28;
|
|
14
|
+
|
|
15
|
+
function getTabs() {
|
|
16
|
+
return Array.from(document.querySelectorAll('.t1session-tab')).filter((t) => !t.classList.contains('t1session-new'));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getActiveIndex(tabs) {
|
|
20
|
+
return tabs.findIndex((t) => t.classList.contains('active'));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function switchTo(tabs, idx) {
|
|
24
|
+
if (!tabs.length || idx < 0 || idx >= tabs.length) return;
|
|
25
|
+
tabs[idx].dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
26
|
+
T1.toast(`Switched to ${tabs[idx].textContent.trim()}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function next() {
|
|
30
|
+
const tabs = getTabs();
|
|
31
|
+
let i = getActiveIndex(tabs);
|
|
32
|
+
if (i < 0) i = 0;
|
|
33
|
+
switchTo(tabs, (i + 1) % tabs.length);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function prev() {
|
|
37
|
+
const tabs = getTabs();
|
|
38
|
+
let i = getActiveIndex(tabs);
|
|
39
|
+
if (i < 0) i = 0;
|
|
40
|
+
switchTo(tabs, (i - 1 + tabs.length) % tabs.length);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const target = T1.term?.element || document.querySelector('.terminal-container') || document.body;
|
|
44
|
+
|
|
45
|
+
target.addEventListener('touchstart', (e) => {
|
|
46
|
+
if (e.touches.length >= 2) {
|
|
47
|
+
isTwoFinger = true;
|
|
48
|
+
startX = (e.touches[0].clientX + e.touches[1].clientX) / 2;
|
|
49
|
+
startY = (e.touches[0].clientY + e.touches[1].clientY) / 2;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
isTwoFinger = false;
|
|
53
|
+
const t = e.touches[0];
|
|
54
|
+
startX = t.clientX;
|
|
55
|
+
startY = t.clientY;
|
|
56
|
+
}, { passive: true });
|
|
57
|
+
|
|
58
|
+
target.addEventListener('touchend', (e) => {
|
|
59
|
+
if (!startX && !startY) return;
|
|
60
|
+
const t = e.changedTouches[0];
|
|
61
|
+
const dx = t.clientX - startX;
|
|
62
|
+
const dy = Math.abs(t.clientY - startY);
|
|
63
|
+
const minDX = 70;
|
|
64
|
+
const maxDY = 80;
|
|
65
|
+
|
|
66
|
+
if (dy > maxDY) { startX = 0; startY = 0; return; }
|
|
67
|
+
|
|
68
|
+
if (isTwoFinger) {
|
|
69
|
+
if (dx > minDX) { e.preventDefault(); prev(); }
|
|
70
|
+
else if (dx < -minDX) { e.preventDefault(); next(); }
|
|
71
|
+
isTwoFinger = false;
|
|
72
|
+
} else {
|
|
73
|
+
const isEdge = startX <= EDGE_PX || startX >= window.innerWidth - EDGE_PX;
|
|
74
|
+
if (isEdge && Math.abs(dx) > minDX) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
if (dx > 0) prev(); else next();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
startX = 0;
|
|
80
|
+
startY = 0;
|
|
81
|
+
}, { passive: false });
|
|
82
|
+
|
|
83
|
+
// Expose for tests.
|
|
84
|
+
window.__terminalOneSwipeSessions = { next, prev, getTabs };
|
|
85
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag-to-reorder session tabs.
|
|
3
|
+
*
|
|
4
|
+
* Session tabs in the header can be dragged to reorder; the new order is
|
|
5
|
+
* persisted to localStorage.
|
|
6
|
+
*
|
|
7
|
+
* Retired on 2026-11-28 and no longer loaded by public/index.html. The code
|
|
8
|
+
* below is kept as it was. It did not work as described: the saved order was
|
|
9
|
+
* never read back, so the next re-render undid a drag; only a mouse could
|
|
10
|
+
* reach it; and it moved a chip's button out of the wrapper that now carries
|
|
11
|
+
* the chip's close control. The row's order is the server's (creation order)
|
|
12
|
+
* and sessions are told apart by name. Do not re-add it to FEATURE_MODULES as
|
|
13
|
+
* it stands.
|
|
14
|
+
*/
|
|
15
|
+
const LS_ORDER = 'terminalone.sessionOrder';
|
|
16
|
+
|
|
17
|
+
export function init(T1) {
|
|
18
|
+
const tabsEl = document.querySelector('.t1session-tabs');
|
|
19
|
+
if (!tabsEl) return;
|
|
20
|
+
|
|
21
|
+
T1.ui.addStyle(`
|
|
22
|
+
.t1session-tab[draggable="true"] { cursor: grab; }
|
|
23
|
+
.t1session-tab.dragging { opacity: 0.6; }
|
|
24
|
+
.t1session-tab.drop-target { border-left: 2px solid var(--ui-accent); }
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
function readOrder() {
|
|
28
|
+
try { return JSON.parse(T1.storage.get(LS_ORDER, '[]')); }
|
|
29
|
+
catch (_) { return []; }
|
|
30
|
+
}
|
|
31
|
+
function writeOrder(order) { T1.storage.set(LS_ORDER, JSON.stringify(order)); }
|
|
32
|
+
|
|
33
|
+
function getIds() {
|
|
34
|
+
return Array.from(tabsEl.querySelectorAll('.t1session-tab')).map((t) => t.dataset.sessionId).filter(Boolean);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function wire() {
|
|
38
|
+
const tabs = tabsEl.querySelectorAll('.t1session-tab');
|
|
39
|
+
for (const tab of tabs) {
|
|
40
|
+
if (tab.dataset.reorderWired) continue;
|
|
41
|
+
tab.dataset.reorderWired = '1';
|
|
42
|
+
tab.draggable = true;
|
|
43
|
+
tab.addEventListener('dragstart', (e) => {
|
|
44
|
+
tab.classList.add('dragging');
|
|
45
|
+
e.dataTransfer.setData('text/plain', tab.dataset.sessionId);
|
|
46
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
47
|
+
});
|
|
48
|
+
tab.addEventListener('dragend', () => {
|
|
49
|
+
tab.classList.remove('dragging');
|
|
50
|
+
tabsEl.querySelectorAll('.drop-target').forEach((t) => t.classList.remove('drop-target'));
|
|
51
|
+
writeOrder(getIds());
|
|
52
|
+
});
|
|
53
|
+
tab.addEventListener('dragover', (e) => {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
const dragging = tabsEl.querySelector('.dragging');
|
|
56
|
+
if (!dragging || dragging === tab) return;
|
|
57
|
+
const after = tab.compareDocumentPosition(dragging) & Node.DOCUMENT_POSITION_FOLLOWING;
|
|
58
|
+
if (after) tabsEl.insertBefore(dragging, tab.nextSibling);
|
|
59
|
+
else tabsEl.insertBefore(dragging, tab);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const mo = new MutationObserver(wire);
|
|
65
|
+
mo.observe(tabsEl, { childList: true });
|
|
66
|
+
wire();
|
|
67
|
+
|
|
68
|
+
// Expose for tests.
|
|
69
|
+
window.__terminalOneTabReorder = { wire, readOrder, writeOrder, getIds };
|
|
70
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme system preference detection — on the first visit with no manually
|
|
3
|
+
* stored theme, follow the OS `prefers-color-scheme` setting. Once the user
|
|
4
|
+
* explicitly picks a theme in Settings we stop syncing so their choice sticks.
|
|
5
|
+
*/
|
|
6
|
+
const LS_THEME = 'terminalone.theme';
|
|
7
|
+
const LS_THEME_USER_SET = 'terminalone.themeUserSet';
|
|
8
|
+
|
|
9
|
+
export function init(T1) {
|
|
10
|
+
const darkMq = window.matchMedia('(prefers-color-scheme: dark)');
|
|
11
|
+
|
|
12
|
+
function hasStoredTheme() {
|
|
13
|
+
try { return localStorage.getItem(LS_THEME) !== null; } catch (_) { return false; }
|
|
14
|
+
}
|
|
15
|
+
function userHasSetTheme() {
|
|
16
|
+
try { return localStorage.getItem(LS_THEME_USER_SET) === '1'; } catch (_) { return false; }
|
|
17
|
+
}
|
|
18
|
+
function setUserSetTheme() {
|
|
19
|
+
try { localStorage.setItem(LS_THEME_USER_SET, '1'); } catch (_) {}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// If the user has never picked a theme, seed from system preference.
|
|
23
|
+
if (!hasStoredTheme() && !userHasSetTheme()) {
|
|
24
|
+
const systemDark = darkMq.matches;
|
|
25
|
+
const initialTheme = systemDark ? 'tokyo-night' : 'solarized-light';
|
|
26
|
+
if (window.__terminalOne && typeof window.__terminalOne.setTheme === 'function') {
|
|
27
|
+
window.__terminalOne.setTheme(initialTheme);
|
|
28
|
+
} else if (T1.ui && T1.ui.settingsPanel) {
|
|
29
|
+
const sel = document.getElementById('themeSelect');
|
|
30
|
+
if (sel) { sel.value = initialTheme; sel.dispatchEvent(new Event('change')); }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Listen to OS changes and sync only while the user has not manually chosen.
|
|
35
|
+
const onSchemeChange = () => {
|
|
36
|
+
if (userHasSetTheme()) return;
|
|
37
|
+
const theme = darkMq.matches ? 'tokyo-night' : 'solarized-light';
|
|
38
|
+
if (window.__terminalOne && typeof window.__terminalOne.setTheme === 'function') {
|
|
39
|
+
window.__terminalOne.setTheme(theme);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
try { darkMq.addEventListener('change', onSchemeChange); } catch (_) {
|
|
43
|
+
try { darkMq.addListener(onSchemeChange); } catch (_) {}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Mark a manual theme pick so system changes stop overriding it.
|
|
47
|
+
const themeSelect = document.getElementById('themeSelect');
|
|
48
|
+
if (themeSelect) {
|
|
49
|
+
themeSelect.addEventListener('change', () => setUserSetTheme(), { once: true });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toast notifications and status bar — extends the built-in banner/toast with
|
|
3
|
+
* a persistent log. Clicking the status text opens a small panel showing the
|
|
4
|
+
* last 20 system messages so users can review warnings they missed.
|
|
5
|
+
*/
|
|
6
|
+
const KEY = 'terminalone.statusLog';
|
|
7
|
+
const MAX = 20;
|
|
8
|
+
|
|
9
|
+
export function init(T1) {
|
|
10
|
+
const originalToast = T1.toast;
|
|
11
|
+
let log = [];
|
|
12
|
+
|
|
13
|
+
function load() {
|
|
14
|
+
try {
|
|
15
|
+
const v = JSON.parse(T1.storage.get(KEY, '[]'));
|
|
16
|
+
log = Array.isArray(v) ? v.slice(-MAX) : [];
|
|
17
|
+
} catch (_) { log = []; }
|
|
18
|
+
}
|
|
19
|
+
function save() {
|
|
20
|
+
T1.storage.set(KEY, JSON.stringify(log.slice(-MAX)));
|
|
21
|
+
}
|
|
22
|
+
function add(type, msg) {
|
|
23
|
+
log.push({ t: Date.now(), type, msg });
|
|
24
|
+
if (log.length > MAX) log.shift();
|
|
25
|
+
save();
|
|
26
|
+
updatePanel();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Wrap the global toast so every toast is logged.
|
|
30
|
+
T1.toast = function(msg, type = 'info') {
|
|
31
|
+
add(type, msg);
|
|
32
|
+
return originalToast.call(this, msg, type);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Also log connection status changes.
|
|
36
|
+
const statusEl = document.getElementById('status');
|
|
37
|
+
if (statusEl) {
|
|
38
|
+
const obs = new MutationObserver(() => {
|
|
39
|
+
const text = statusEl.textContent;
|
|
40
|
+
if (text && (text.includes('Disconnected') || text.includes('error') || text.includes('Exited'))) {
|
|
41
|
+
add(text.includes('Disconnected') || text.includes('error') ? 'error' : 'warn', text);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
obs.observe(statusEl, { childList: true, subtree: true });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Status panel attached to the footer.
|
|
48
|
+
const footer = document.querySelector('.terminal-footer');
|
|
49
|
+
if (!footer) return;
|
|
50
|
+
|
|
51
|
+
T1.ui.addStyle(`
|
|
52
|
+
.t1status-panel {
|
|
53
|
+
position: absolute;
|
|
54
|
+
bottom: 100%;
|
|
55
|
+
right: 8px;
|
|
56
|
+
z-index: 300;
|
|
57
|
+
min-width: 240px;
|
|
58
|
+
max-width: 80vw;
|
|
59
|
+
max-height: 40vh;
|
|
60
|
+
overflow-y: auto;
|
|
61
|
+
background: var(--ui-elevated);
|
|
62
|
+
border: 1px solid var(--ui-border);
|
|
63
|
+
border-radius: 8px 8px 0 0;
|
|
64
|
+
box-shadow: 0 -8px 32px rgba(0,0,0,0.35);
|
|
65
|
+
display: none;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
padding: 8px;
|
|
68
|
+
}
|
|
69
|
+
.t1status-panel.open { display: flex; }
|
|
70
|
+
.t1status-entry {
|
|
71
|
+
font-size: 11px;
|
|
72
|
+
padding: 4px 0;
|
|
73
|
+
border-bottom: 1px solid var(--ui-border);
|
|
74
|
+
color: var(--ui-fg);
|
|
75
|
+
}
|
|
76
|
+
.t1status-entry:last-child { border-bottom: none; }
|
|
77
|
+
.t1status-entry.info { color: var(--ui-accent); }
|
|
78
|
+
.t1status-entry.warn { color: var(--ui-warning, #dcc38b); }
|
|
79
|
+
.t1status-entry.error { color: var(--ui-danger, #e2a69e); }
|
|
80
|
+
.t1status-time { color: var(--ui-muted); margin-right: 6px; }
|
|
81
|
+
.t1status-footer { color: var(--ui-muted); font-size: 11px; cursor: pointer; }
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
const panel = document.createElement('div');
|
|
85
|
+
panel.className = 't1status-panel';
|
|
86
|
+
footer.appendChild(panel);
|
|
87
|
+
|
|
88
|
+
const statusWrap = document.querySelector('.statuswrap');
|
|
89
|
+
const clickTarget = statusWrap || footer;
|
|
90
|
+
clickTarget.style.cursor = 'pointer';
|
|
91
|
+
clickTarget.title = 'Click to view status log';
|
|
92
|
+
clickTarget.addEventListener('click', () => panel.classList.toggle('open'));
|
|
93
|
+
|
|
94
|
+
function updatePanel() {
|
|
95
|
+
panel.innerHTML = '';
|
|
96
|
+
if (!log.length) {
|
|
97
|
+
const empty = document.createElement('div');
|
|
98
|
+
empty.className = 't1status-entry';
|
|
99
|
+
empty.textContent = 'No status messages yet';
|
|
100
|
+
panel.appendChild(empty);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const entry of log.slice().reverse()) {
|
|
104
|
+
const row = document.createElement('div');
|
|
105
|
+
row.className = `t1status-entry ${entry.type || 'info'}`;
|
|
106
|
+
const time = new Date(entry.t).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
107
|
+
row.innerHTML = `<span class="t1status-time">${time}</span>${entry.msg}`;
|
|
108
|
+
panel.appendChild(row);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
load();
|
|
113
|
+
updatePanel();
|
|
114
|
+
|
|
115
|
+
document.addEventListener('click', (e) => {
|
|
116
|
+
if (!panel.contains(e.target) && !clickTarget.contains(e.target)) panel.classList.remove('open');
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two-finger tap context menu (tablet).
|
|
3
|
+
*
|
|
4
|
+
* A two-finger tap on the terminal opens a context menu with Copy, Paste,
|
|
5
|
+
* Select All, Clear, and Search.
|
|
6
|
+
*/
|
|
7
|
+
export function init(T1) {
|
|
8
|
+
if (T1.device !== 'ipad') return;
|
|
9
|
+
|
|
10
|
+
T1.ui.addStyle(`
|
|
11
|
+
.t1-twofinger-menu {
|
|
12
|
+
position: fixed;
|
|
13
|
+
background: var(--ui-elevated);
|
|
14
|
+
border: 1px solid var(--ui-border);
|
|
15
|
+
border-radius: 8px;
|
|
16
|
+
padding: 4px 0;
|
|
17
|
+
z-index: 210;
|
|
18
|
+
display: none;
|
|
19
|
+
min-width: 140px;
|
|
20
|
+
box-shadow: 0 4px 14px rgba(0,0,0,0.3);
|
|
21
|
+
}
|
|
22
|
+
.t1-twofinger-menu button {
|
|
23
|
+
display: block; width: 100%;
|
|
24
|
+
padding: 8px 14px; background: transparent; border: none;
|
|
25
|
+
color: var(--ui-fg); text-align: left; font-size: 13px; cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
.t1-twofinger-menu button:active { background: var(--ui-accent); color: var(--ui-on-accent, #14171b); }
|
|
28
|
+
`);
|
|
29
|
+
|
|
30
|
+
const menu = document.createElement('div');
|
|
31
|
+
menu.className = 't1-twofinger-menu';
|
|
32
|
+
menu.setAttribute('role', 'menu');
|
|
33
|
+
menu.innerHTML = `
|
|
34
|
+
<button type="button" role="menuitem" data-action="copy">Copy</button>
|
|
35
|
+
<button type="button" role="menuitem" data-action="paste">Paste</button>
|
|
36
|
+
<button type="button" role="menuitem" data-action="select-all">Select All</button>
|
|
37
|
+
<button type="button" role="menuitem" data-action="clear">Clear</button>
|
|
38
|
+
<button type="button" role="menuitem" data-action="search">Search</button>
|
|
39
|
+
`;
|
|
40
|
+
document.body.appendChild(menu);
|
|
41
|
+
|
|
42
|
+
let firstTouch = null;
|
|
43
|
+
const target = T1.term?.element || document.querySelector('.terminal-container') || document.body;
|
|
44
|
+
|
|
45
|
+
function hide() { menu.style.display = 'none'; }
|
|
46
|
+
|
|
47
|
+
target.addEventListener('touchstart', (e) => {
|
|
48
|
+
if (e.touches.length === 2) {
|
|
49
|
+
firstTouch = { x: (e.touches[0].clientX + e.touches[1].clientX) / 2, y: (e.touches[0].clientY + e.touches[1].clientY) / 2 };
|
|
50
|
+
} else { firstTouch = null; }
|
|
51
|
+
}, { passive: true });
|
|
52
|
+
|
|
53
|
+
target.addEventListener('touchend', (e) => {
|
|
54
|
+
if (!firstTouch || e.touches.length > 0) return;
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
menu.style.left = `${firstTouch.x}px`;
|
|
57
|
+
menu.style.top = `${firstTouch.y}px`;
|
|
58
|
+
menu.style.display = 'block';
|
|
59
|
+
firstTouch = null;
|
|
60
|
+
}, { passive: false });
|
|
61
|
+
|
|
62
|
+
menu.addEventListener('click', async (e) => {
|
|
63
|
+
const action = e.target.dataset.action;
|
|
64
|
+
if (!action) return;
|
|
65
|
+
hide();
|
|
66
|
+
const term = T1.term;
|
|
67
|
+
try {
|
|
68
|
+
if (action === 'copy') {
|
|
69
|
+
const selection = term?.getSelection?.() || '';
|
|
70
|
+
if (!selection) { T1.toast('Select terminal text first', 'warn'); return; }
|
|
71
|
+
await navigator.clipboard.writeText(selection);
|
|
72
|
+
T1.toast('Selection copied');
|
|
73
|
+
}
|
|
74
|
+
if (action === 'paste') {
|
|
75
|
+
const text = await navigator.clipboard.readText();
|
|
76
|
+
if (text) T1.sendData(text);
|
|
77
|
+
}
|
|
78
|
+
if (action === 'select-all' && term) term.selectAll();
|
|
79
|
+
if (action === 'clear' && term) term.clear();
|
|
80
|
+
if (action === 'search') window.dispatchEvent(new CustomEvent('t1:action', { detail: { action: 'toggle-search' } }));
|
|
81
|
+
} catch (_) {
|
|
82
|
+
T1.toast('Clipboard is unavailable in this browser', 'warn');
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
window.__terminalOneTwoFingerMenu = { menu, hide };
|
|
87
|
+
}
|