Remove client

This commit is contained in:
2026-01-09 18:43:33 +01:00
parent 96b1cf501c
commit 0b5488be00
19 changed files with 3 additions and 4750 deletions
-111
View File
@@ -1,111 +0,0 @@
const path = require("node:path");
const { app, BrowserWindow } = require("electron");
const { autoUpdater } = require("electron-updater");
const initialWindowWidthPx = 960;
const initialWindowHeightPx = 640;
let canvasSizeInterval;
function clearCanvasSizeInterval() {
if (canvasSizeInterval) {
clearInterval(canvasSizeInterval);
canvasSizeInterval = undefined;
}
}
async function autoResizeWindow(win, lastSize) {
if (win.isDestroyed()) {
return lastSize;
}
const newSize = await win.webContents.executeJavaScript(`(() => {
const canvas = document.getElementById('broadcast-canvas');
if (!canvas) {
return null;
}
const rect = canvas.getBoundingClientRect();
return {
width: Math.round(rect.width),
height: Math.round(rect.height),
};
})();`);
if (!newSize?.width || !newSize?.height) {
return lastSize;
}
if (lastSize.width === newSize.width && lastSize.height === newSize.height) {
return lastSize;
}
console.info(
`Window size did not match canvas old: ${lastSize.width}x${lastSize.height} new: ${newSize.width}x${newSize.height}. Resizing.`,
);
win.setContentSize(newSize.width, newSize.height, false);
win.setResizable(false);
return newSize;
}
function onPostNavigationLoad(win, url, broadcastRect) {
url = url || win.webContents.getURL();
let pathname;
try {
pathname = new URL(url).pathname;
} catch (e) {
console.error(`Failed to parse URL: ${url}`, e);
return;
}
const isBroadcast = /\/view\/[^/]+\/broadcast\/?$/.test(pathname);
console.info(`Navigation to ${url} detected. Is broadcast: ${isBroadcast}`);
if (isBroadcast) {
clearCanvasSizeInterval();
console.info("Setting up auto-resize for broadcast window.");
canvasSizeInterval = setInterval(() => {
autoResizeWindow(win, broadcastRect).then((newSize) => {
broadcastRect = newSize;
});
}, 750);
autoResizeWindow(win, broadcastRect).then((newSize) => {
broadcastRect = newSize;
});
} else {
clearCanvasSizeInterval();
win.setSize(initialWindowWidthPx, initialWindowHeightPx, false);
}
}
function createWindow(version) {
const win = new BrowserWindow({
width: initialWindowWidthPx,
height: initialWindowHeightPx,
transparent: true,
frame: true,
alwaysOnTop: false,
icon: path.join(__dirname, "../resources/assets/icon/appicon.ico"),
webPreferences: { backgroundThrottling: false },
});
win.setMenu(null);
win.setTitle(`Imgfloat Client v${version}`);
return win;
}
app.whenReady().then(() => {
if (process.env.CI) {
process.on("uncaughtException", (err) => {
console.error("Uncaught exception:", err);
app.exit(1);
});
setTimeout(() => app.quit(), 3000);
}
autoUpdater.checkForUpdatesAndNotify();
let broadcastRect = { width: 0, height: 0 };
const version = app.getVersion();
const win = createWindow(version);
win.loadURL(process.env["IMGFLOAT_CHANNELS_URL"] || "https://imgfloat.kruhlmann.dev/channels");
win.webContents.on("did-finish-load", () => onPostNavigationLoad(win, undefined, broadcastRect));
win.webContents.on("did-navigate", (_, url) => onPostNavigationLoad(win, url, broadcastRect));
win.webContents.on("did-navigate-in-page", (_, url) => onPostNavigationLoad(win, url, broadcastRect));
win.on("page-title-updated", (e) => e.preventDefault());
win.on("closed", clearCanvasSizeInterval);
});
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,49 +0,0 @@
#!/usr/bin/env sh
set -eu
ELECTRON="$1"
APP_ENTRY="src/main/node/app.js"
SIZE="1280x800"
RUNTIME="${XDG_RUNTIME_DIR:-/tmp}"
# Find free WAYLAND_DISPLAY
for d in 1 2 3 4 5; do
if [ ! -S "$RUNTIME/wayland-$d" ]; then
WAYLAND_NUM="$d"
break
fi
done
[ -n "${WAYLAND_NUM:-}" ] || {
echo "No free WAYLAND_DISPLAY found" >&2
exit 1
}
export WAYLAND_DISPLAY="wayland-$WAYLAND_NUM"
export XDG_RUNTIME_DIR="$RUNTIME"
cleanup() {
kill "$ELECTRON_PID" "$WESTON_PID" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
weston \
--backend=wayland-backend.so \
--width="${SIZE%x*}" \
--height="${SIZE#*x}" \
--xwayland \
--socket="$WAYLAND_DISPLAY" &
WESTON_PID=$!
sleep 1
WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
DISPLAY="" \
"${ELECTRON}" "$APP_ENTRY" &
ELECTRON_PID=$!
while :; do
kill -0 "$ELECTRON_PID" 2>/dev/null || break
kill -0 "$WESTON_PID" 2>/dev/null || break
sleep 0.5
done
-58
View File
@@ -1,58 +0,0 @@
#!/usr/bin/env sh
set -eu
ELECTRON="$1"
APP_ENTRY="src/main/node/app.js"
SCREEN="1280x800"
for d in 99 98 97 96 95; do
if ! xdpyinfo -display ":$d" >/dev/null 2>&1; then
DISP="$d"
break
fi
done
[ -n "${DISP:-}" ] || {
echo "No free DISPLAY found" >&2
exit 1
}
echo "Using DISPLAY=:$DISP"
cleanup() {
kill "$ELECTRON_PID" "$OPENBOX_PID" "$XEPHYR_PID" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
Xephyr ":$DISP" -screen "$SCREEN" -resizeable -ac &
XEPHYR_PID=$!
sleep 1
DISPLAY=":$DISP" openbox &
OPENBOX_PID=$!
sleep 0.5
DISPLAY=":$DISP" "${ELECTRON}" "$APP_ENTRY" &
ELECTRON_PID=$!
DISPLAY=":$DISP" xsetroot -solid "#009999"
while :; do
if ! kill -0 "$ELECTRON_PID" 2>/dev/null; then
echo "Electron exited — killing Xephyr"
kill "$XEPHYR_PID" 2>/dev/null || true
break
fi
if ! kill -0 "$XEPHYR_PID" 2>/dev/null; then
echo "Xephyr exited — killing Electron"
kill "$ELECTRON_PID" 2>/dev/null || true
break
fi
sleep 0.5
done
wait "$ELECTRON_PID" 2>/dev/null || true
wait "$XEPHYR_PID" 2>/dev/null || true