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,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
// macOS ships zsh as the login shell, so it stays the preferred fallback, but Linux
|
|
7
|
+
// hosts and service managers (systemd, launchd plists, CI) often start TerminalOne
|
|
8
|
+
// without $SHELL and without /bin/zsh. Spawning a missing shell makes every session
|
|
9
|
+
// exit immediately (execvp ENOENT), so fall back to a shell that actually exists.
|
|
10
|
+
const FALLBACK_SHELLS = ['/bin/zsh', '/bin/bash', '/bin/sh'];
|
|
11
|
+
|
|
12
|
+
function isExecutable(file) {
|
|
13
|
+
try {
|
|
14
|
+
fs.accessSync(file, fs.constants.X_OK);
|
|
15
|
+
return fs.statSync(file).isFile();
|
|
16
|
+
} catch (_) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function accountShell() {
|
|
22
|
+
try {
|
|
23
|
+
return os.userInfo().shell || '';
|
|
24
|
+
} catch (_) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the login shell to spawn: $SHELL, then the account's shell, then the
|
|
31
|
+
* first existing fallback. Absolute paths are checked for executability.
|
|
32
|
+
*/
|
|
33
|
+
function resolveShell({ env = process.env, account = accountShell, executable = isExecutable } = {}) {
|
|
34
|
+
const candidates = [env.SHELL, account(), ...FALLBACK_SHELLS];
|
|
35
|
+
for (const candidate of candidates) {
|
|
36
|
+
if (candidate && candidate.startsWith('/') && executable(candidate)) return candidate;
|
|
37
|
+
}
|
|
38
|
+
// Nothing verifiable: keep the historical default so the error message names it.
|
|
39
|
+
return env.SHELL || '/bin/zsh';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { resolveShell, FALLBACK_SHELLS };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
// The frontend imports the terminal engine straight from the installed package:
|
|
7
|
+
//
|
|
8
|
+
// <link rel="stylesheet" href="/node_modules/@xterm/xterm/css/xterm.css">
|
|
9
|
+
// import { Terminal } from '/node_modules/@xterm/xterm/lib/xterm.mjs';
|
|
10
|
+
//
|
|
11
|
+
// `path.join(__dirname, '..', 'node_modules')` only holds those files in a
|
|
12
|
+
// checkout or a global install. A normal `npm install townmouse` (and `npx`)
|
|
13
|
+
// hoists dependencies to the project root, so that directory does not exist and
|
|
14
|
+
// every xterm asset 404s — the server answers /health while the terminal page is
|
|
15
|
+
// unusable. Resolve each package through Node's own lookup paths instead, which
|
|
16
|
+
// is correct for hoisted, nested, global, and monorepo layouts alike.
|
|
17
|
+
|
|
18
|
+
function splitPackagePath(requestPath) {
|
|
19
|
+
const clean = String(requestPath || '').replace(/\\/g, '/').replace(/^\/+/, '');
|
|
20
|
+
const segments = clean.split('/').filter((segment) => segment && segment !== '.' && segment !== '..');
|
|
21
|
+
if (!segments.length) return null;
|
|
22
|
+
const scoped = segments[0].startsWith('@');
|
|
23
|
+
const name = scoped ? segments.slice(0, 2).join('/') : segments[0];
|
|
24
|
+
if (!scoped && !/^[a-z0-9._-]+$/i.test(name)) return null;
|
|
25
|
+
const rest = segments.slice(scoped ? 2 : 1).join('/');
|
|
26
|
+
if (!rest) return null;
|
|
27
|
+
return { name, rest };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function resolveDependencyFile(requestPath, searchPaths) {
|
|
31
|
+
const parsed = splitPackagePath(requestPath);
|
|
32
|
+
if (!parsed) return null;
|
|
33
|
+
const { name, rest } = parsed;
|
|
34
|
+
const bases = searchPaths || require.resolve.paths(name) || [];
|
|
35
|
+
for (const base of bases) {
|
|
36
|
+
if (!base) continue;
|
|
37
|
+
const dir = path.resolve(base, name);
|
|
38
|
+
const file = path.resolve(dir, rest);
|
|
39
|
+
// Refuse anything that escapes the package directory.
|
|
40
|
+
if (file !== dir && !file.startsWith(dir + path.sep)) continue;
|
|
41
|
+
try {
|
|
42
|
+
if (fs.statSync(file).isFile()) return file;
|
|
43
|
+
} catch (_) { /* not in this root */ }
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function installStaticDependencies(app) {
|
|
49
|
+
app.use('/node_modules', (req, res, next) => {
|
|
50
|
+
let requestPath;
|
|
51
|
+
try { requestPath = decodeURIComponent(req.path); } catch (_) { return next(); }
|
|
52
|
+
const file = resolveDependencyFile(requestPath);
|
|
53
|
+
if (!file) return next();
|
|
54
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
55
|
+
res.sendFile(file, (error) => {
|
|
56
|
+
if (error && !res.headersSent) next();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { installStaticDependencies, resolveDependencyFile, splitPackagePath };
|