termbridge 0.3.2 → 0.3.3

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 CHANGED
@@ -16,6 +16,7 @@ npx termbridge
16
16
  ```
17
17
 
18
18
  Scan the QR code and open the URL on your phone. The CLI stays running while the tunnel is active.
19
+ Use the action tray in the UI for quick navigation, including line + page scroll jumps.
19
20
 
20
21
  ## Documentation
21
22
 
package/dist/bin.js CHANGED
@@ -1928,6 +1928,12 @@ var createTmuxBackend = (deps = {}) => {
1928
1928
  const runtime = { ...defaultDeps, ...deps };
1929
1929
  const sessions = /* @__PURE__ */ new Map();
1930
1930
  const runTmux = async (args) => runtime.execFile("tmux", args);
1931
+ const setSessionOption = async (name, option, value) => {
1932
+ try {
1933
+ await runTmux(["set-option", "-t", name, option, value]);
1934
+ } catch {
1935
+ }
1936
+ };
1931
1937
  const createSession = async (name) => {
1932
1938
  const existing = sessions.get(name);
1933
1939
  if (existing) {
@@ -1942,10 +1948,12 @@ var createTmuxBackend = (deps = {}) => {
1942
1948
  throw error;
1943
1949
  }
1944
1950
  }
1945
- try {
1946
- await runTmux(["set-option", "-t", name, "status", "off"]);
1947
- } catch {
1948
- }
1951
+ await setSessionOption(name, "status", "off");
1952
+ await setSessionOption(name, "status-left", "");
1953
+ await setSessionOption(name, "status-right", "");
1954
+ await setSessionOption(name, "status-style", "bg=default,fg=default");
1955
+ await setSessionOption(name, "message-style", "bg=default,fg=default");
1956
+ await setSessionOption(name, "message-command-style", "bg=default,fg=default");
1949
1957
  const session = { name, createdAt: /* @__PURE__ */ new Date() };
1950
1958
  sessions.set(name, {
1951
1959
  session,
@@ -2018,6 +2026,29 @@ var createTmuxBackend = (deps = {}) => {
2018
2026
  const controlSequence = controlKeyMap[key];
2019
2027
  ensurePty(entry).write(controlSequence);
2020
2028
  };
2029
+ const scroll = async (sessionName, mode, amount) => {
2030
+ if (!Number.isFinite(amount) || amount === 0) {
2031
+ return;
2032
+ }
2033
+ if (!sessions.has(sessionName)) {
2034
+ return;
2035
+ }
2036
+ const direction = amount < 0 ? "up" : "down";
2037
+ const command = mode === "pages" ? `page-${direction}` : `scroll-${direction}`;
2038
+ const steps = Math.min(50, Math.abs(Math.trunc(amount)));
2039
+ try {
2040
+ await runTmux(["copy-mode", "-e", "-t", sessionName]);
2041
+ } catch {
2042
+ return;
2043
+ }
2044
+ for (let index = 0; index < steps; index += 1) {
2045
+ try {
2046
+ await runTmux(["send-keys", "-t", sessionName, "-X", command]);
2047
+ } catch {
2048
+ break;
2049
+ }
2050
+ }
2051
+ };
2021
2052
  const resize = async (sessionName, cols, rows) => {
2022
2053
  const entry = sessions.get(sessionName);
2023
2054
  if (!entry) {
@@ -2060,6 +2091,7 @@ var createTmuxBackend = (deps = {}) => {
2060
2091
  write,
2061
2092
  resize,
2062
2093
  sendControl,
2094
+ scroll,
2063
2095
  onOutput,
2064
2096
  closeSession
2065
2097
  };
@@ -2460,6 +2492,9 @@ var parseClientMessage = (payload) => {
2460
2492
  if (parsed.type === "control" && allowedControlKeys.has(parsed.key)) {
2461
2493
  return { ok: true, message: parsed };
2462
2494
  }
2495
+ if (parsed.type === "scroll" && (parsed.mode === "lines" || parsed.mode === "pages") && typeof parsed.amount === "number" && Number.isFinite(parsed.amount)) {
2496
+ return { ok: true, message: parsed };
2497
+ }
2463
2498
  return { ok: false, error: "invalid" };
2464
2499
  } catch {
2465
2500
  return { ok: false, error: "invalid" };
@@ -2676,6 +2711,10 @@ var createAppServer = (deps) => {
2676
2711
  void deps.terminalBackend.resize(info.sessionName, message.cols, message.rows);
2677
2712
  return;
2678
2713
  }
2714
+ if (message.type === "scroll") {
2715
+ void deps.terminalBackend.scroll(info.sessionName, message.mode, message.amount);
2716
+ return;
2717
+ }
2679
2718
  void deps.terminalBackend.sendControl(info.sessionName, message.key);
2680
2719
  });
2681
2720
  socket.on("close", () => {