omo-web 0.1.9 → 0.1.10
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/README.md +1 -1
- package/bin/tui.js +43 -21
- package/dist/app.js +43 -38
- package/dist/server.js +1230 -600
- package/package.json +1 -1
- package/public/dag-graph.css +62 -6
- package/public/index.html +11 -15
- package/public/login.css +93 -0
- package/public/login.html +27 -0
- package/public/styles.css +20 -9
- package/public/tool-ledger.css +56 -35
- package/public/workbench.css +116 -78
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ omo-web
|
|
|
15
15
|
|
|
16
16
|
Open the printed URL (normally `http://127.0.0.1:4317`). The local browser connects to OmO on the host. `omo-web --help` lists startup commands.
|
|
17
17
|
|
|
18
|
-
In an interactive terminal, `omo-web` opens a keyboard-driven launcher. Use ↑/↓ and Enter to choose working directories or open **Access settings**. There you can change or disable the password, toggle HTTPS, generate a self-signed certificate (requires OpenSSL 1.1.1+ on `PATH`), bind to an IPv4 interface, or set the HTTPS origin of a reverse proxy. Changes apply on the next start. Non-loopback listeners require HTTPS; passwordless remote access needs confirmation. The browser
|
|
18
|
+
In an interactive terminal, `omo-web` opens a keyboard-driven launcher. Use ↑/↓ and Enter to choose working directories or open **Access settings**. There you can change or disable the password, toggle HTTPS, generate a self-signed certificate (requires OpenSSL 1.1.1+ on `PATH`), bind to an IPv4 interface, or set the HTTPS origin of a reverse proxy. Changes apply on the next start. Non-loopback listeners require HTTPS; passwordless remote access needs confirmation. The browser sign-in page asks only for the password. Use at least 20 characters for remote access; shorter passwords are accepted with a warning.
|
|
19
19
|
|
|
20
20
|
For a local proxy or tunnel that handles HTTPS, keep the default upstream `http://127.0.0.1:4317`, preserve the original `Host`, and set the exact public origin (for example `https://web.example.com`) in **Proxy origin** or `OMO_WEB_PROXY_ORIGIN`.
|
|
21
21
|
|
package/bin/tui.js
CHANGED
|
@@ -168,6 +168,11 @@ export async function startTui({ entry, version }) {
|
|
|
168
168
|
let paint;
|
|
169
169
|
const finished = new Promise(resolve => { settle = resolve; });
|
|
170
170
|
|
|
171
|
+
const browserUrl = () => {
|
|
172
|
+
if (!url) return;
|
|
173
|
+
return parseProxyOrigin(proxyOrigin())?.origin ??
|
|
174
|
+
(env.OMO_WEB_ORIGIN === new URL(url).origin ? env.OMO_WEB_ORIGIN : url);
|
|
175
|
+
};
|
|
171
176
|
const directoriesLabel = cliTr("工作目录", "Working directories");
|
|
172
177
|
const quitAction = [cliTr("退出", "Quit"), () => quit(0)];
|
|
173
178
|
const stopAction = [cliTr("停止服务", "Stop web"), stopWeb];
|
|
@@ -238,21 +243,23 @@ export async function startTui({ entry, version }) {
|
|
|
238
243
|
const [state, tone] = status[phase];
|
|
239
244
|
const label = state();
|
|
240
245
|
const build = fold(`v${version}`, 20)[0];
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
`|${title}${ink(tone, label)}${" ".repeat(gap)}${build} |`,
|
|
248
|
-
ink("36", `+${"-".repeat(width)}+`),
|
|
249
|
-
] : fold(`OmO Web / ${label}`, width).map(line => ink(tone, line));
|
|
246
|
+
const brand = "OmO Web";
|
|
247
|
+
const gap = width - textWidth(`${brand} ${label}${build}`);
|
|
248
|
+
const header = gap >= 3 ? [
|
|
249
|
+
`${ink("36;1", brand)} ${ink(tone, label)}${" ".repeat(gap)}${ink("2", build)}`,
|
|
250
|
+
ink("2", "─".repeat(Math.floor(width / cells("─")))),
|
|
251
|
+
] : fold(`${brand} / ${label}`, width).map(line => ink(tone, line));
|
|
250
252
|
const short = text => fold(text, width)[0];
|
|
253
|
+
const addressRows = (title, href) => [ink("1", short(title)), ...fold(href, Math.max(2, width - 2)).map(row => ` ${row}`)];
|
|
251
254
|
const editorTitle = draft && ink("1", short(draft.title));
|
|
252
255
|
const menu = activeMenu(dimensions);
|
|
253
256
|
const focus = Math.min(selected, menu.length - 1);
|
|
254
|
-
const
|
|
255
|
-
|
|
257
|
+
const proxyAction = phase === "settings" && proxyOrigin();
|
|
258
|
+
const proxyOverflows = proxyAction && textWidth(` ${menu[5][0]}`) > width;
|
|
259
|
+
const actions = menu.map(([action], index) => {
|
|
260
|
+
const title = proxyOverflows && index === 5 ? cliTr("代理入口:开", "Proxy origin: On") : action;
|
|
261
|
+
return index === focus ? ink("36;1", short(`> ${title}`)) : short(` ${title}`);
|
|
262
|
+
});
|
|
256
263
|
const message = notice ? fold(notice, width).slice(0, 2).map(line => ink("33;1", line)) : [];
|
|
257
264
|
const warning = unprotected() && (optedIn() || server) && phase !== "confirming"
|
|
258
265
|
? fold(REMOTE_WARNING, width).map(line => ink("33;1", line)) : [];
|
|
@@ -261,6 +268,7 @@ export async function startTui({ entry, version }) {
|
|
|
261
268
|
? riskLines(width).map(line => ink("33;1", line)) : [];
|
|
262
269
|
let editor;
|
|
263
270
|
let lines;
|
|
271
|
+
let readyAddresses = [];
|
|
264
272
|
if (draft) {
|
|
265
273
|
editor = editorLine(draft.masked ? { ...draft, text: "*".repeat(draft.text.length) } : draft, Math.max(2, width - 2));
|
|
266
274
|
lines = [...header, "", editorTitle, `> ${editor}`, "",
|
|
@@ -274,15 +282,18 @@ export async function startTui({ entry, version }) {
|
|
|
274
282
|
} else if (phase === "settings" || phase === "networks") {
|
|
275
283
|
const hint = phase === "networks" ? cliTr("选择监听网卡,不会修改防火墙规则。", "Select a listen interface; firewall rules are unchanged.")
|
|
276
284
|
: cliTr("Enter 修改 · 保存后下次启动生效 · Esc 返回", "Enter to edit · Applies on the next start · Esc back");
|
|
277
|
-
const origin = phase === "settings" && hasHttps() ?
|
|
278
|
-
|
|
279
|
-
lines = [...header, "", ...actions, "", ...message, ...origin, ...fold(hint, width)];
|
|
285
|
+
const origin = phase === "settings" && hasHttps() ? addressRows(cliTr("HTTPS 地址", "HTTPS URL"), env.OMO_WEB_ORIGIN) : [];
|
|
286
|
+
const proxy = proxyOverflows ? addressRows(cliTr("代理入口地址", "Proxy URL"), proxyAction) : [];
|
|
287
|
+
lines = [...header, "", ...actions, "", ...message, ...proxy, ...origin, ...fold(hint, width)];
|
|
280
288
|
} else {
|
|
281
289
|
const paths = activePaths();
|
|
282
|
-
const urlRows = url ? fold(url, Math.max(2, width - 2)) : [];
|
|
283
290
|
const pathCount = height >= 23 ? 4 : 2;
|
|
284
|
-
const
|
|
285
|
-
|
|
291
|
+
const browser = browserUrl();
|
|
292
|
+
const browserRows = browser ? addressRows(cliTr("浏览器地址", "Browser URL"), browser) : [];
|
|
293
|
+
const upstreamRows = browser && new URL(browser).href !== url
|
|
294
|
+
? addressRows(cliTr("本地上游", "Local upstream"), url) : [];
|
|
295
|
+
readyAddresses = [browserRows, upstreamRows];
|
|
296
|
+
const details = browser ? [...browserRows, ...upstreamRows, ""] : [];
|
|
286
297
|
const directories = paths.length ? paths.slice(0, pathCount).map(path => ` ${pathLabel(path, width - 2)}`)
|
|
287
298
|
: [short(cliTr(" (未配置)", " (none configured)"))];
|
|
288
299
|
if (paths.length > pathCount) directories.push(short(cliTr(` 另有 ${paths.length - pathCount} 个`, ` +${paths.length - pathCount} more`)));
|
|
@@ -305,7 +316,16 @@ export async function startTui({ entry, version }) {
|
|
|
305
316
|
lines = [...risk, ...actions];
|
|
306
317
|
} else {
|
|
307
318
|
const compactStatus = ink(tone, short(`OmO Web / ${label}`));
|
|
308
|
-
|
|
319
|
+
const addressSpace = height - warning.length - 2;
|
|
320
|
+
if (phase === "ready" && readyAddresses[0].length - 1 <= addressSpace) {
|
|
321
|
+
const [browserRows, upstreamRows] = readyAddresses;
|
|
322
|
+
const addresses = browserRows.length + upstreamRows.length <= addressSpace ? readyAddresses.flat()
|
|
323
|
+
: browserRows.length <= addressSpace ? browserRows : browserRows.slice(1);
|
|
324
|
+
const controls = [compactStatus, ...warning, ...addresses];
|
|
325
|
+
const available = height - controls.length;
|
|
326
|
+
controls.push(...(available >= actions.length ? actions : [actions[focus]]));
|
|
327
|
+
lines = controls;
|
|
328
|
+
} else if (phase === "settings" || phase === "networks") {
|
|
309
329
|
const slots = Math.max(1, height - 1 - message.length);
|
|
310
330
|
const first = Math.max(0, Math.min(focus - Math.floor(slots / 2), actions.length - slots));
|
|
311
331
|
lines = height > 1 ? [compactStatus, ...actions.slice(first, first + slots), ...message] : [actions[focus]];
|
|
@@ -597,11 +617,13 @@ export async function startTui({ entry, version }) {
|
|
|
597
617
|
|
|
598
618
|
function openBrowser() {
|
|
599
619
|
const current = server;
|
|
620
|
+
const href = browserUrl();
|
|
621
|
+
if (!href) return;
|
|
600
622
|
const commands = {
|
|
601
|
-
darwin: ["open",
|
|
602
|
-
win32: ["rundll32.exe", "url.dll,FileProtocolHandler",
|
|
623
|
+
darwin: ["open", href],
|
|
624
|
+
win32: ["rundll32.exe", "url.dll,FileProtocolHandler", href],
|
|
603
625
|
};
|
|
604
|
-
const [command, ...args] = commands[process.platform] ?? ["xdg-open",
|
|
626
|
+
const [command, ...args] = commands[process.platform] ?? ["xdg-open", href];
|
|
605
627
|
const browser = spawn(command, args, { stdio: "ignore", windowsHide: true, detached: !windows });
|
|
606
628
|
const failed = () => {
|
|
607
629
|
if (server !== current || phase !== "ready" || exitCode !== undefined) return;
|