join to existing call in creator app

This commit is contained in:
kulikov0 committed 2026-05-15 16:22:07 +02:00
1 parent 7528f653e9
commit 221c4f595f
9 files changed
+251 -16

No files matched your search

+14
View File
@@ -38,6 +38,20 @@
</div>
<div class="headless-info" id="headlessInfo">
<div class="headless-title" id="headlessTitle">Headless</div>
<div class="headless-start" id="headlessStart">
<div class="headless-start-card">
<div class="headless-start-card-title">Create a new call</div>
<div class="headless-start-card-desc">Start a fresh room and get a shareable link.</div>
<button class="headless-start-btn primary" id="btnHeadlessCreate">Create new</button>
</div>
<div class="headless-start-card">
<div class="headless-start-card-title">Join an existing call</div>
<div class="headless-start-card-desc" id="headlessStartTargetLabel">Paste a room id or link.</div>
<input type="text" id="headlessStartTarget" class="headless-start-input" placeholder="">
<div class="headless-start-error" id="headlessStartError"></div>
<button class="headless-start-btn" id="btnHeadlessJoin">Join existing</button>
</div>
</div>
<div class="headless-status" id="headlessStatus">Starting...</div>
<div class="headless-call-info" id="headlessCallInfo">
<div class="headless-row"><span class="headless-label">Join link:</span> <a id="headlessJoinLink" href="#" class="headless-link"></a><img class="headless-copy" src="resources/icons8-copy-50.png" data-copy="headlessJoinLink" title="Copy"></div>
+3 -3
View File
@@ -10,7 +10,7 @@ import {
YANDEX_COOKIE_DOMAINS,
DION_COOKIE_DOMAINS,
} from '../constants';
import { TunnelMode, Platform, BotSettings } from '../types';
import { TunnelMode, Platform, BotSettings, HeadlessStartArgs } from '../types';
export function registerIpcHandlers(tabManager: TabManager): void {
ipcMain.handle(IPC.GET_HOOK_CODE, async (_e, tabId: string, url: string) => {
@@ -33,8 +33,8 @@ export function registerIpcHandlers(tabManager: TabManager): void {
tabManager.startRelay(tabId, tab);
});
ipcMain.handle(IPC.START_HEADLESS, async (_e, tabId: string, platform: string) => {
await tabManager.startHeadless(tabId, platform as Platform);
ipcMain.handle(IPC.START_HEADLESS, async (_e, tabId: string, platform: string, args: HeadlessStartArgs) => {
await tabManager.startHeadless(tabId, platform as Platform, args);
});
ipcMain.handle(IPC.CLOSE_TAB, (_e, tabId: string) => {
+41 -5
View File
@@ -4,7 +4,17 @@ import { BrowserWindow, session } from 'electron';
import * as net from 'net';
import * as path from 'path';
import * as fs from 'fs/promises';
import { TabState, PortPair, TabListEntry, Platform, TunnelMode, RelayMode, CallStatus } from '../types';
import {
TabState,
PortPair,
TabListEntry,
Platform,
TunnelMode,
RelayMode,
CallStatus,
HeadlessStartArgs,
HeadlessMode,
} from '../types';
import {
INITIAL_PORT_BASE,
IPC,
@@ -273,14 +283,35 @@ export class TabManager {
}
}
async startHeadless(tabId: string, platform: Platform): Promise<void> {
private joinFlagFor(platform: Platform): string | null {
switch (platform) {
case Platform.VK:
return '--vk-link';
case Platform.Telemost:
return '--tm-link';
case Platform.WBStream:
case Platform.Dion:
return '--room';
default:
return null;
}
}
async startHeadless(tabId: string, platform: Platform, args: HeadlessStartArgs): Promise<void> {
const tab = await this.getOrCreateTab(tabId);
tab.platform = platform;
const joinTarget = args.mode === HeadlessMode.Join ? (args.target || '').trim() : '';
if (args.mode === HeadlessMode.Join && !joinTarget) {
this.sendLog(tabId, 'Join requested but no target link/room provided.');
return;
}
if (platform === Platform.WBStream) {
tab.tunnelMode = TunnelMode.HeadlessWBStream;
this.killRelay(tabId, tab);
const proc = spawn(this.headlessWBStreamPath, ['--resources', 'default'], {
const wbArgs = ['--resources', 'default'];
if (joinTarget) wbArgs.push('--room', joinTarget);
const proc = spawn(this.headlessWBStreamPath, wbArgs, {
stdio: ['ignore', 'pipe', 'pipe'],
});
tab.relay = proc;
@@ -314,7 +345,12 @@ export class TabManager {
this.killRelay(tabId, tab);
const cookiesPath = path.join(app.getPath('userData'), `cookies-${platform}.json`);
await fs.writeFile(cookiesPath, JSON.stringify(cookies));
const proc = spawn(config.binaryPath, ['--resources', 'default', '--cookies', cookiesPath], {
const spawnArgs = ['--resources', 'default', '--cookies', cookiesPath];
if (joinTarget) {
const flag = this.joinFlagFor(platform);
if (flag) spawnArgs.push(flag, joinTarget);
}
const proc = spawn(config.binaryPath, spawnArgs, {
stdio: ['ignore', 'pipe', 'pipe'],
});
tab.relay = proc;
@@ -330,7 +366,7 @@ export class TabManager {
this.sendLog(tabId, `${config.platformName} session rejected (401), clearing and re-prompting login.`);
await this.clearAuthCookies(config.cookieDomains, config.authCookie);
if (this.tabs.get(tabId) === tab) {
this.startHeadless(tabId, platform);
this.startHeadless(tabId, platform, args);
}
}
});
+2 -2
View File
@@ -35,8 +35,8 @@ import { IPC } from '../constants';
getCookies(domain: string) {
return ipcRenderer.invoke(IPC.GET_COOKIES, domain);
},
startHeadless(tabId: string, platform: string) {
return ipcRenderer.invoke(IPC.START_HEADLESS, tabId, platform);
startHeadless(tabId: string, platform: string, args: any) {
return ipcRenderer.invoke(IPC.START_HEADLESS, tabId, platform, args);
},
sendBotCallLink(tabId: string, link: string) {
return ipcRenderer.invoke(IPC.SEND_BOT_CALL_LINK, tabId, link);
+29 -1
View File
@@ -57,7 +57,35 @@ export function renderContent(tm: RendererTabManager): void {
else if (activeTab.platform === Platform.WBStream) title = 'WBStream';
else if (activeTab.platform === Platform.Dion) title = 'DION';
document.getElementById('headlessTitle')!.textContent = title;
document.getElementById('headlessStatus')!.textContent = activeTab.headlessStatus || 'Starting...';
const startEl = document.getElementById('headlessStart')!;
const statusEl = document.getElementById('headlessStatus')!;
if (!activeTab.headlessStarted) {
startEl.classList.add('visible');
statusEl.style.display = 'none';
const targetInput = document.getElementById('headlessStartTarget') as HTMLInputElement;
const targetLabel = document.getElementById('headlessStartTargetLabel')!;
const errorEl = document.getElementById('headlessStartError')!;
targetInput.value = activeTab.headlessStartTarget || '';
targetInput.classList.remove('invalid');
errorEl.textContent = '';
if (activeTab.platform === Platform.WBStream) {
targetLabel.textContent = 'Paste a room id or stream.wb.ru/room/<id> link.';
targetInput.placeholder = 'https://stream.wb.ru/room/<id>';
} else if (activeTab.platform === Platform.Dion) {
targetLabel.textContent = 'Paste a room id or dion.vc event link.';
targetInput.placeholder = 'abc-def-ghi';
} else if (activeTab.platform === Platform.Telemost) {
targetLabel.textContent = 'Paste a Telemost conference link.';
targetInput.placeholder = 'https://telemost.yandex.ru/j/...';
} else {
targetLabel.textContent = 'Paste a VK call link.';
targetInput.placeholder = 'https://vk.com/call/join/...';
}
} else {
startEl.classList.remove('visible');
statusEl.style.display = '';
statusEl.textContent = activeTab.headlessStatus || 'Starting...';
}
const callInfo = activeTab.callInfo;
const callInfoVK = document.getElementById('headlessCallInfo')!;
const callInfoTM = document.getElementById('headlessCallInfoTM')!;
+35 -1
View File
@@ -16,7 +16,7 @@ import {
detachLoginWebview,
} from './dom';
import { VK_IM_URL, TELEMOST_URL } from '../constants';
import { Platform, Bridge, BotTabData, LogPanel, TunnelMode } from '../types';
import { Platform, Bridge, BotTabData, LogPanel, TunnelMode, HeadlessMode } from '../types';
declare const window: Window & { bridge: Bridge };
@@ -128,6 +128,40 @@ function bindHeadlessEvents(): void {
if (sourceEl) copyToClipboard(sourceEl.textContent || '');
}
});
document.getElementById('btnHeadlessCreate')!.addEventListener('click', () => {
clearHeadlessJoinError();
tm.startHeadlessCall({ mode: HeadlessMode.Create });
});
document.getElementById('btnHeadlessJoin')!.addEventListener('click', () => {
const targetInput = document.getElementById('headlessStartTarget') as HTMLInputElement;
const target = targetInput.value.trim();
if (!target) {
showHeadlessJoinError('Enter a room or link to join.');
targetInput.focus();
return;
}
clearHeadlessJoinError();
tm.startHeadlessCall({ mode: HeadlessMode.Join, target });
});
document.getElementById('headlessStartTarget')!.addEventListener('input', (event) => {
const tab = tm.getActiveTab();
if (tab) tab.headlessStartTarget = (event.target as HTMLInputElement).value;
clearHeadlessJoinError();
});
}
function showHeadlessJoinError(msg: string): void {
const errEl = document.getElementById('headlessStartError')!;
const input = document.getElementById('headlessStartTarget') as HTMLInputElement;
errEl.textContent = msg;
input.classList.add('invalid');
}
function clearHeadlessJoinError(): void {
const errEl = document.getElementById('headlessStartError')!;
const input = document.getElementById('headlessStartTarget') as HTMLInputElement;
errEl.textContent = '';
input.classList.remove('invalid');
}
function openSettings(): void {
+26 -3
View File
@@ -1,4 +1,13 @@
import { RendererTab, BotTabData, BotSettings, TunnelMode, Platform, Bridge } from '../types';
import {
RendererTab,
BotTabData,
BotSettings,
TunnelMode,
Platform,
Bridge,
HeadlessMode,
HeadlessStartArgs,
} from '../types';
import { HeadlessLogMarker } from '../constants';
declare const window: Window & { bridge: Bridge };
@@ -58,13 +67,27 @@ export class RendererTabManager {
if (!tab.isBot) tab.name = 'VK';
}
tab.headless = true;
tab.headlessStarted = false;
tab.platform = platform;
tab.callInfo = undefined;
tab.headlessStatus = 'Starting...';
tab.headlessStatus = undefined;
tab.tunnelConnected = false;
tab.relayLogs = '';
tab.hookLogs = '';
window.bridge.startHeadless(this.activeTabId, platform);
if (tab.isBot) {
this.startHeadlessCall({ mode: HeadlessMode.Create });
}
this.onRender();
}
startHeadlessCall(args: HeadlessStartArgs): void {
if (!this.activeTabId) return;
const tab = this.tabs[this.activeTabId];
if (!tab || !tab.headless || !tab.platform) return;
tab.headlessStarted = true;
tab.headlessStatus = 'Starting...';
tab.callInfo = undefined;
window.bridge.startHeadless(this.activeTabId, tab.platform, args);
this.onRender();
}
+13 -1
View File
@@ -82,6 +82,16 @@ export interface CallInfo {
protocol?: string;
}
export enum HeadlessMode {
Create = 'create',
Join = 'join',
}
export interface HeadlessStartArgs {
mode: HeadlessMode;
target?: string;
}
export interface Webview extends Electron.WebviewTag {
getURL(): string;
setAudioMuted(muted: boolean): void;
@@ -100,6 +110,8 @@ export interface RendererTab {
peerId?: number;
platform?: Platform;
headless?: boolean;
headlessStarted?: boolean;
headlessStartTarget?: string;
headlessStatus?: string;
callInfo?: CallInfo;
tunnelConnected?: boolean;
@@ -130,7 +142,7 @@ export interface Bridge {
getCallCreatorCode(scriptFile: string): Promise<string>;
onBotError(cb: (msg: string) => void): void;
getCookies(domain: string): Promise<Electron.Cookie[]>;
startHeadless(tabId: string, platform: string): Promise<void>;
startHeadless(tabId: string, platform: string, args: HeadlessStartArgs): Promise<void>;
sendBotCallLink(tabId: string, link: string): Promise<void>;
onCloseBotTab(cb: (data: { tabId: string }) => void): void;
onLoginRequired(cb: (tabId: string, url: string) => void): void;
+88
View File
@@ -314,6 +314,94 @@ body {
filter: invert(0.88);
}
.headless-start {
display: none;
margin-top: 8px;
gap: 16px;
max-width: 520px;
flex-direction: column;
}
.headless-start.visible {
display: flex;
}
.headless-start-card {
border: 1px solid #333;
border-radius: 8px;
background: #1e1e1e;
padding: 16px;
display: flex;
flex-direction: column;
gap: 10px;
}
.headless-start-card-title {
font-size: 14px;
font-weight: 600;
color: #e0e0e0;
}
.headless-start-card-desc {
font-size: 12px;
color: #888;
}
.headless-start-input {
width: 100%;
padding: 8px 10px;
border: 1px solid #444;
border-radius: 6px;
background: #141414;
color: #e0e0e0;
font-family: monospace;
font-size: 13px;
outline: none;
box-sizing: border-box;
}
.headless-start-input:focus {
border-color: #4fc3f7;
}
.headless-start-input.invalid {
border-color: #ef5350;
}
.headless-start-error {
min-height: 14px;
color: #ef5350;
font-size: 12px;
}
.headless-start-btn {
align-self: flex-start;
padding: 6px 14px;
border: 1px solid #555;
border-radius: 6px;
background: #2a2a2a;
color: #e0e0e0;
font-size: 13px;
cursor: pointer;
font-family: inherit;
}
.headless-start-btn:hover {
background: #353535;
border-color: #777;
}
.headless-start-btn.primary {
background: #0077ff;
border-color: #0077ff;
color: white;
}
.headless-start-btn.primary:hover {
background: #0066dd;
border-color: #0066dd;
}
.headless-tunnel {
margin-top: 16px;
display: none;