changed electron to tauri v2

This commit is contained in:
2026-08-20 20:59:46 -07:00
parent a1d61a23ff
commit 4754801fe3
72 changed files with 11783 additions and 5228 deletions

6
.gitignore vendored
View File

@@ -10,6 +10,9 @@ manifest.json
integrity-report.json
validation-report.json
# Rust & Tauri
src-tauri/target/
# Encrypted files (build-time only)
config/encrypted-credentials.json
@@ -37,9 +40,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Electron
out/
# Temporary files
*.tmp
*.temp

View File

@@ -13,7 +13,7 @@ build:
- build-pipeline.js
- package.json
- config/**/*
- main.js
- src-tauri/**/*
- service-manager.js
- patcher.js
- credential-manager.js
@@ -43,8 +43,10 @@ build:
key:
files:
- package-lock.json
- src-tauri/Cargo.lock
paths:
- node_modules/
- src-tauri/target/
script:
- npm ci
@@ -121,15 +123,25 @@ build:
Write-Host "Validation report verified"
}
- Write-Host "Packaging Electron application..."
- npm run dist
- Write-Host "Setting up Rust toolchain..."
- |
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "rustup-init.exe"
.\rustup-init.exe -y --default-toolchain stable
Remove-Item "rustup-init.exe"
}
$env:Path = "$env:USERPROFILE\.cargo\bin;" + $env:Path
- Write-Host "Packaging Tauri application..."
- npm run build
- |
Write-Host "Publishing Release to GitLab..."
$versionTag = "v$env:CI_PIPELINE_IID"
$exeItem = Get-ChildItem dist/*.exe | Select-Object -First 1
$exeItem = Get-ChildItem src-tauri/target/release/bundle/nsis/*.exe, src-tauri/target/release/bundle/msi/*.msi | Select-Object -First 1
$exeName = $exeItem.Name
$exeEncoded = [System.Uri]::EscapeDataString($exeName)
$bundleDir = $exeItem.Directory.Name
$releaseBody = @{
name = "Vyla Home Release $versionTag"
@@ -140,7 +152,7 @@ build:
links = @(
@{
name = "$exeName"
url = "$env:CI_PROJECT_URL/-/jobs/$env:CI_JOB_ID/artifacts/raw/dist/$exeEncoded"
url = "$env:CI_PROJECT_URL/-/jobs/$env:CI_JOB_ID/artifacts/raw/src-tauri/target/release/bundle/$bundleDir/$exeEncoded"
link_type = "package"
},
@{
@@ -175,6 +187,6 @@ build:
- update-payload.zip
- manifest.json
- validation-report.json
- dist/*.exe
- dist/*.exe.blockmap
- src-tauri/target/release/bundle/nsis/*.exe
- src-tauri/target/release/bundle/msi/*.msi
expire_in: 30 days

View File

@@ -69,28 +69,6 @@ function installOneRepo(repo) {
cwd: repoDir,
stdio: 'inherit'
});
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
const hasNativeDeps = pkg.dependencies && Object.keys(pkg.dependencies).some(dep =>
['bcrypt', 'sharp', 'sqlite3'].includes(dep)
);
if (hasNativeDeps) {
const electronVersion = JSON.parse(
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8')
).devDependencies.electron.replace(/^[\^~]/, '');
if (!/^\d+\.\d+\.\d+$/.test(electronVersion)) {
throw new Error(`Cannot resolve exact Electron version from "${electronVersion}"; pin an exact version in package.json devDependencies before building.`);
}
const rebuildBin = path.join(__dirname, 'node_modules', '.bin', process.platform === 'win32' ? 'electron-rebuild.cmd' : 'electron-rebuild');
execSync(`"${rebuildBin}" -f -v ${electronVersion} -m "${repoDir}"`, {
cwd: __dirname,
stdio: 'inherit'
});
}
} catch (error) {
throw new Error(`npm install failed for ${repo}: ${error.message}`);
}

View File

@@ -14,6 +14,7 @@
"PROXY_URL": "https://txt.primebox.workers.dev",
"PROXY_STREAMS": "true",
"ENABLE_DEBUG_ROUTE": "true",
"BYPASS_AUTH": "true"
"BYPASS_AUTH": "true",
"TOKEN_SECRET": "vyla_default_secure_token_secret_local_dev_32chars"
}
}

601
main.js
View File

@@ -1,33 +1,20 @@
const { app, BrowserWindow, ipcMain, Menu } = require('electron');
const path = require('path');
const fs = require('fs');
const os = require('os');
const express = require('express');
const ServiceManager = require('./service-manager');
const Patcher = require('./patcher');
const UpdateClient = require('./update-client');
let mainWindow;
let serviceManager;
let expressApp;
let expressServer;
let playerExpressApp;
let playerExpressServer;
const gotLock = app.requestSingleInstanceLock();
if (!gotLock) {
app.quit();
} else {
app.on('second-instance', () => {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
});
}
const APPDATA_DIR = path.join(app.getPath('userData'), 'vyla-home-files');
const APPDATA_DIR = process.env.APPDATA_PATH || path.join(os.homedir(), 'AppData', 'Roaming', 'vyla-home', 'vyla-home-files');
fs.mkdirSync(APPDATA_DIR, { recursive: true });
console.log(`[DEBUG] AppData directory: ${APPDATA_DIR}`);
const envConfig = JSON.parse(fs.readFileSync(path.join(__dirname, 'config/env.json'), 'utf8'));
const replacementsConfig = JSON.parse(fs.readFileSync(path.join(__dirname, 'config/replacements.json'), 'utf8'));
@@ -36,508 +23,24 @@ const updateClient = new UpdateClient(APPDATA_DIR);
process.on('unhandledRejection', (reason) => {
const message = reason && reason.message ? reason.message : String(reason);
console.error(`[ERROR] Unhandled Rejection: ${message}`);
fs.appendFileSync(path.join(APPDATA_DIR, 'crash.log'), `[${new Date().toISOString()}] UNHANDLED REJECTION: ${message}\n`, 'utf8');
});
process.on('uncaughtException', (err) => {
console.error(`[ERROR] Uncaught Exception: ${err.message}`);
fs.appendFileSync(path.join(APPDATA_DIR, 'crash.log'), `[${new Date().toISOString()}] UNCAUGHT EXCEPTION: ${err.message}\n`, 'utf8');
});
async function createWindow() {
const asciiLogo = fs.readFileSync(path.join(__dirname, 'build', 'logo.txt'), 'utf8');
mainWindow = new BrowserWindow({
width: 1280,
height: 800,
title: 'Vyla Home',
icon: path.join(__dirname, 'build', 'icon.ico'),
titleBarStyle: 'hidden',
titleBarOverlay: {
color: '#00000000',
symbolColor: '#ffffff',
height: 40
},
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
}
});
Menu.setApplicationMenu(null);
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
mainWindow.loadURL(url);
return { action: 'deny' };
});
mainWindow.loadURL('data:text/html;charset=utf-8,' + encodeURIComponent(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vyla Home</title>
<style>
* {
box-sizing: border-box;
function sendToTauri(event, data) {
process.stdout.write(JSON.stringify({ event, data }) + '\n');
}
html,
body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #000;
color: #fff;
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}
body {
-webkit-app-region: no-drag;
}
.titlebar-drag {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 40px;
-webkit-app-region: drag;
z-index: 10;
}
button, a, input, .no-drag {
-webkit-app-region: no-drag;
}
canvas {
position: fixed;
inset: 0;
display: block;
width: 100vw;
height: 100vh;
}
.overlay {
position: fixed;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 28px;
pointer-events: none;
}
#ascii-logo {
font-family: "Cascadia Mono", "Consolas", monospace;
font-size: 11px;
line-height: 1.15;
color: rgba(255,255,255,.75);
white-space: pre;
margin: 0;
user-select: none;
text-shadow: 0 4px 12px rgba(0,0,0,.6);
transform: scale(0.4);
opacity: 0;
animation: logoIn 1.1s cubic-bezier(.16,1,.3,1) forwards;
}
#status {
font-size: 10px;
font-weight: 500;
letter-spacing: .08em;
text-transform: uppercase;
color: rgba(255,255,255,.4);
opacity: 0;
animation: statusIn .6s ease forwards .7s;
}
@keyframes logoIn {
0% {
transform: scale(0.4);
opacity: 0;
filter: blur(6px);
}
60% {
opacity: 1;
filter: blur(0);
}
100% {
transform: scale(1);
opacity: 1;
filter: blur(0);
}
}
@keyframes statusIn {
from {
opacity: 0;
transform: translateY(6px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="titlebar-drag"></div>
<canvas id="c"></canvas>
<div class="overlay">
<pre id="ascii-logo">${asciiLogo.replace(/`/g, '\\`').replace(/\$/g, '\\$')}</pre>
</div>
<script>
const CHARS = ' .:-=+*#%@';
const FONT_SIZE = 50;
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
let CW, CH;
let cols, rows;
let t = 0;
let mouseX = -9999;
let mouseY = -9999;
let lastMouseMove = 0;
let mouseStrength = 0;
const FADE_TIME = 250;
const SMOOTHING = 0.08;
function initFont() {
ctx.font = FONT_SIZE + 'px "Courier New", monospace';
CW = Math.ceil(ctx.measureText('M').width);
CH = FONT_SIZE + 2;
ctx.textBaseline = 'top';
}
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
initFont();
cols = Math.ceil(canvas.width / CW) + 1;
rows = Math.ceil(canvas.height / CH) + 1;
}
window.addEventListener('resize', resize);
window.addEventListener('mousemove', (e) => {
const rect = canvas.getBoundingClientRect();
mouseX = e.clientX - rect.left;
mouseY = e.clientY - rect.top;
lastMouseMove = performance.now();
});
function plasma(cx, cy, tt) {
const x = cx + Math.sin(cy * 3 + tt * 0.7) * 0.07;
const y = cy + Math.cos(cx * 3 + tt * 0.5) * 0.07;
let v =
Math.sin(x * 10 + tt) +
Math.sin(y * 10 + tt) +
Math.sin((x + y) * 7 + tt) +
Math.sin(Math.sqrt(x * x + y * y) * 12 - tt * 1.2) +
Math.sin(x * 6 - tt * 0.8) +
Math.sin(y * 8 + tt * 0.9);
return (v / 6 + 1) / 2;
}
function render() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
t += 0.03;
const elapsed = performance.now() - lastMouseMove;
const targetStrength = Math.max(0, 1 - elapsed / FADE_TIME);
mouseStrength += (targetStrength - mouseStrength) * SMOOTHING;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
const x = col * CW;
const y = row * CH;
const dx = x - mouseX;
const dy = y - mouseY;
const dist = Math.sqrt(dx * dx + dy * dy);
const force = (7000 / (dist * dist + 1500)) * mouseStrength;
const offsetX = dx * force;
const offsetY = dy * force;
const v = plasma(col / cols, row / rows, t);
const brightness = Math.round(v * 60);
const charIdx = Math.floor(v * (CHARS.length - 0.001));
const ch = CHARS[charIdx];
ctx.fillStyle = 'rgb(' + brightness + ',' + brightness + ',' + brightness + ')';
ctx.fillText(ch, x + offsetX, y + offsetY);
}
}
requestAnimationFrame(render);
}
resize();
render();
</script>
</body>
</html>
`));
async function start() {
console.log('[DEBUG] Initializing patcher and service manager...');
const patcher = new Patcher(APPDATA_DIR);
serviceManager = new ServiceManager(APPDATA_DIR, envConfig);
const showUpdatePrompt = (currentVersion, newVersion) => {
return new Promise((resolve) => {
ipcMain.removeAllListeners('update-choice');
ipcMain.once('update-choice', (event, choice) => {
resolve(choice);
});
mainWindow.loadURL('data:text/html;charset=utf-8,' + encodeURIComponent(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Available</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
width: 100%;
height: 100%;
background: #000;
color: #fff;
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}
body {
display: flex;
align-items: center;
justify-content: center;
padding: 32px;
}
.container {
max-width: 480px;
text-align: center;
}
.icon {
width: 38px;
height: 38px;
margin: 0 auto 22px;
color: #0a84ff;
}
h1 {
margin: 0;
font-size: 22px;
font-weight: 600;
letter-spacing: -.02em;
}
p {
margin: 14px 0 28px;
color: rgba(255,255,255,.55);
font-size: 14px;
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
}
.buttons {
display: flex;
gap: 10px;
justify-content: center;
}
button {
appearance: none;
border: 0;
border-radius: 8px;
padding: 11px 20px;
font-size: 13px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
transition: opacity .15s ease, transform .15s ease;
min-width: 120px;
}
button:hover:not(:disabled) {
opacity: .85;
}
button:active:not(:disabled) {
transform: scale(.97);
}
button:disabled {
cursor: default;
opacity: .35;
}
.primary {
background: #fff;
color: #000;
}
.secondary {
background: rgba(255,255,255,.1);
color: #fff;
}
</style>
</head>
<body>
<div class="container">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="8" x2="12" y2="12"/>
<line x1="12" y1="16" x2="12.01" y2="16"/>
</svg>
<h1>Update Available</h1>
<p>You're running version ${currentVersion}. Version ${newVersion} is available.\nInstalling will fetch the latest build.</p>
<div class="buttons">
<button id="skipBtn" class="secondary" onclick="handleChoice('skip')">
Skip For Now
</button>
<button id="installBtn" class="primary" onclick="handleChoice('install')">
Install Update
</button>
</div>
<script>
function handleChoice(choice) {
document.getElementById('skipBtn').disabled = true;
document.getElementById('installBtn').disabled = true;
window.vylaHome.sendUpdateChoice(choice);
}
</script>
</body>
</html>
`));
});
};
const handleFatalError = (errMessage) => {
mainWindow.loadURL('data:text/html;charset=utf-8,' + encodeURIComponent(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Startup Error</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
width: 100%;
height: 100%;
background: #000;
color: #fff;
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}
body {
display: flex;
align-items: center;
justify-content: center;
padding: 32px;
}
.container {
max-width: 480px;
text-align: center;
}
.icon {
width: 38px;
height: 38px;
margin: 0 auto 22px;
color: #ff453a;
}
h1 {
margin: 0;
font-size: 22px;
font-weight: 600;
letter-spacing: -.02em;
}
p {
margin: 14px 0 28px;
color: rgba(255,255,255,.55);
font-size: 14px;
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
}
button {
appearance: none;
border: 0;
border-radius: 999px;
background: #fff;
color: #000;
padding: 10px 18px;
font-size: 13px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
transition: opacity .2s ease;
}
button:hover {
opacity: .82;
}
button:active {
opacity: .65;
}
</style>
</head>
<body>
<div class="container">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="7" x2="12" y2="13"/>
<circle cx="12" cy="17" r="1"/>
</svg>
<h1>Couldn't start Vyla Home</h1>
<p>${errMessage}</p>
<button onclick="location.reload()">
Try Again
</button>
</div>
</body>
</html>
`));
};
const installBuild = async (release) => {
const tempZipPath = path.join(APPDATA_DIR, 'download-temp.zip');
let attempts = 0;
@@ -546,14 +49,17 @@ button:active {
while (attempts < 3 && !downloadSuccess) {
attempts++;
try {
console.log(`[DEBUG] Downloading update, attempt ${attempts}...`);
await updateClient.downloadUpdate(release, tempZipPath, (downloaded, total) => {
const percent = Math.round((downloaded / total) * 100);
sendToTauri('download-progress', { downloaded, total, percent });
});
if (!patcher.verifyChecksum(tempZipPath, release.sha256)) {
throw new Error('SHA-256 checksum verification failed.');
}
console.log('[DEBUG] Extracting payload and applying patches...');
patcher.purgeOldCode();
patcher.extractZipPayload(tempZipPath);
@@ -581,54 +87,67 @@ button:active {
const isFirstRun = !patcher.verifyExtraction();
const localVersion = patcher.getCurrentVersion();
const localSha = patcher.getCurrentSha();
console.log(`[DEBUG] Local version: ${localVersion}, isFirstRun: ${isFirstRun}`);
const release = await updateClient.checkForUpdates();
const hasUpdate = release.version !== localVersion || (release.sha256 && release.sha256 !== localSha);
let release = null;
try {
release = await updateClient.checkForUpdates();
} catch (e) {
console.warn('[DEBUG] Could not check for remote updates:', e.message);
}
if (isFirstRun) {
await installBuild(release);
} else if (hasUpdate) {
const choice = await showUpdatePrompt(localVersion, release.version);
if (choice === 'install') {
if (release) {
const hasUpdate = release.version !== localVersion || (release.sha256 && release.sha256 !== localSha);
if (isFirstRun || hasUpdate) {
console.log('[DEBUG] Performing update install from release...');
await installBuild(release);
}
} else if (isFirstRun) {
const localZip = path.join(__dirname, 'update-payload.zip');
console.log(`[DEBUG] Checking local zip at: ${localZip} (exists: ${fs.existsSync(localZip)})`);
if (fs.existsSync(path.join(__dirname, 'update-payload.zip'))) {
const localZip = path.join(__dirname, 'update-payload.zip');
console.log('[DEBUG] Syncing local update-payload.zip to AppData...');
patcher.purgeOldCode();
patcher.extractZipPayload(localZip);
patcher.applyPatches(replacementsConfig);
patcher.bridgeCredentials(serviceManager.credentialManager);
patcher.saveCurrentVersion("1.0.0");
}
}
if (!patcher.verifyExtraction()) {
throw new Error('No application files found. Check your internet connection and try again.');
const verified = patcher.verifyExtraction();
console.log(`[DEBUG] Payload verification status: ${verified}`);
if (!verified) {
throw new Error('No application files found. Build the payload first using "npm run build:payload" or check your internet connection.');
}
console.log('[DEBUG] Loading credentials...');
serviceManager.credentialManager.loadCredentials();
console.log('[DEBUG] Starting auth-proxy and stream-api...');
await serviceManager.startServices([
{ name: 'auth-proxy', relativeDir: 'auth-proxy' },
{ name: 'stream-api', relativeDir: 'stream-api' },
]);
const playerDir = path.join(APPDATA_DIR, 'player');
console.log(`[DEBUG] Starting Player Express server on port 3001 from: ${playerDir}`);
playerExpressApp = express();
playerExpressApp.use(express.static(playerDir, { maxAge: '1d', etag: true }));
playerExpressApp.get('*', (req, res) => {
res.sendFile(path.join(playerDir, 'index.html'));
});
playerExpressServer = playerExpressApp.listen(3001);
playerExpressServer = playerExpressApp.listen(3001, () => {
console.log('[DEBUG] Player Express server listening on 3001');
});
console.log('[DEBUG] Waiting for ports [3000, 3001, 7860]...');
await serviceManager.waitForPorts([3000, 3001, 7860]);
const healthChecks = [
{ port: 3001, name: 'player' },
{ port: 3000, name: 'auth-proxy' },
{ port: 7860, name: 'stream-api' },
];
for (const { port, name } of healthChecks) {
try {
await serviceManager.checkHealth(port, '/');
} catch (e) {
serviceManager.logToFile(name, `Health check on / did not pass, continuing anyway: ${e.message}`);
}
}
console.log('[DEBUG] All ports ready!');
const frontendDir = path.join(APPDATA_DIR, 'frontend');
console.log(`[DEBUG] Starting Frontend Express server on port 4890 from: ${frontendDir}`);
expressApp = express();
expressApp.use(express.static(frontendDir, { maxAge: '1d', etag: true }));
expressApp.get('*', (req, res) => {
@@ -637,28 +156,24 @@ button:active {
const FRONTEND_PORT = 4890;
expressServer = expressApp.listen(FRONTEND_PORT, () => {
mainWindow.loadURL(`http://localhost:${FRONTEND_PORT}`);
console.log(`[DEBUG] Frontend Express server active at http://localhost:${FRONTEND_PORT}`);
sendToTauri('ready', { url: `http://localhost:${FRONTEND_PORT}` });
});
} catch (error) {
if (serviceManager) {
await serviceManager.stopAll().catch(() => { });
}
handleFatalError(error.message);
console.error('[DEBUG] Fatal error caught:', error.message);
sendToTauri('error', { message: error.message });
}
}
if (gotLock) {
app.whenReady().then(createWindow);
}
app.on('window-all-closed', async () => {
process.on('SIGINT', async () => {
if (expressServer) expressServer.close();
if (playerExpressServer) playerExpressServer.close();
if (serviceManager) {
await serviceManager.stopAll();
}
if (process.platform !== 'darwin') {
app.quit();
}
});
if (serviceManager) await serviceManager.stopAll();
process.exit(0);
});
start();

4887
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,21 +4,20 @@
"description": "Vyla Home Desktop App Launcher",
"main": "main.js",
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"build": "node build-pipeline.js"
"dev": "tauri dev",
"build:payload": "node build-pipeline.js",
"build": "tauri build"
},
"dependencies": {
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@tauri-apps/plugin-process": "^2.0.0",
"@vyla-entertainment/sdk": "^1.2.0",
"adm-zip": "^0.6.0",
"audit": "^0.0.6",
"express": "^4.19.2"
},
"devDependencies": {
"@electron/rebuild": "^4.2.0",
"electron": "^42.7.0",
"electron-builder": "^25.1.8",
"@tauri-apps/cli": "^2.0.0",
"javascript-obfuscator": "^4.1.0"
},
"build": {

View File

@@ -39,19 +39,26 @@ class ServiceManager {
throw new Error(`Service script not found: ${scriptPath}`);
}
const tokenSecret = process.env.TOKEN_SECRET ||
process.env.STREAM_API_TOKEN_SECRET ||
this.credentialManager.getCredential('stream-api', 'TOKEN_SECRET') ||
require('crypto').randomBytes(32).toString('hex');
const env = {
...process.env,
TOKEN_SECRET: tokenSecret,
STREAM_API_TOKEN_SECRET: tokenSecret,
...(this.envConfig[name] || {}),
...(this.credentialManager.getServiceCredentials(name) || {}),
ELECTRON_RUN_AS_NODE: '1'
...(this.credentialManager.getServiceCredentials(name) || {})
};
this.logToFile(name, `--- Starting ${name} in ${serviceDir} ---`);
const child = spawn(process.execPath, [scriptPath], {
const child = spawn('node', [scriptPath], {
cwd: serviceDir,
env,
stdio: ['ignore', 'pipe', 'pipe']
stdio: ['ignore', 'pipe', 'pipe'],
shell: process.platform === 'win32'
});
this.processes[name] = {
@@ -70,11 +77,13 @@ class ServiceManager {
child.stdout.on('data', (data) => {
const text = data.toString().trim();
console.log(`[${name}] STDOUT: ${text}`);
this.logToFile(name, `STDOUT: ${text}`);
});
child.stderr.on('data', (data) => {
const text = data.toString().trim();
console.error(`[${name}] STDERR: ${text}`);
this.logToFile(name, `STDERR: ${text}`);
});

5168
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

16
src-tauri/Cargo.toml Normal file
View File

@@ -0,0 +1,16 @@
[package]
name = "vyla-home"
version = "1.0.0"
description = "Vyla Home Desktop App Launcher"
edition = "2021"
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-shell = "2"
tauri-plugin-process = "2"
tauri-plugin-opener = "2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

3
src-tauri/build.rs Normal file
View File

@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
{}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

BIN
src-tauri/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
src-tauri/icons/32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src-tauri/icons/64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>

BIN
src-tauri/icons/icon.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

131
src-tauri/src/main.rs Normal file
View File

@@ -0,0 +1,131 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::path::PathBuf;
use std::process::{Child, Command, Stdio};
use std::sync::Mutex;
use tauri::{Manager, State, WebviewUrl, WebviewWindowBuilder};
struct NodeServices(Mutex<Option<Child>>);
#[derive(serde::Deserialize)]
struct BackendMessage {
event: String,
data: serde_json::Value,
}
fn get_project_root() -> PathBuf {
let mut dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
if dir.ends_with("src-tauri") {
dir.pop();
}
dir
}
const LINK_HANDLER_SCRIPT: &str = r#"
window.open = function(url) {
if (!url) return null;
if (url.startsWith('http://localhost') || url.startsWith('/') || url.startsWith(window.location.origin)) {
window.location.href = url;
} else if (window.__TAURI__ && window.__TAURI__.opener) {
window.__TAURI__.opener.openUrl(url);
} else if (window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__.invoke('plugin:opener|open_url', { rule: { url: url } });
}
return null;
};
document.addEventListener('click', (e) => {
const a = e.target.closest('a');
if (!a || !a.href) return;
const isLocal = a.href.startsWith('http://localhost') || a.href.startsWith('tauri://') || a.href.startsWith(window.location.origin) || a.href.startsWith('/');
if (a.target === '_blank') {
e.preventDefault();
if (isLocal) {
window.location.href = a.href;
} else if (window.__TAURI__ && window.__TAURI__.opener) {
window.__TAURI__.opener.openUrl(a.href);
} else if (window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__.invoke('plugin:opener|open_url', { rule: { url: a.href } });
}
}
}, true);
"#;
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_opener::init())
.manage(NodeServices(Mutex::new(None)))
.setup(|app| {
let app_data = app.path().app_data_dir().unwrap_or_default();
let app_data_str = app_data.to_string_lossy().to_string();
let window = WebviewWindowBuilder::new(app, "main", WebviewUrl::App("index.html".into()))
.title("Vyla Home")
.inner_size(1280.0, 800.0)
.decorations(true)
.resizable(true)
.fullscreen(false)
.initialization_script(LINK_HANDLER_SCRIPT)
.build()?;
let root_dir = get_project_root();
let main_js = root_dir.join("main.js");
let mut cmd = Command::new("node");
cmd.arg(&main_js)
.current_dir(&root_dir)
.env("APPDATA_PATH", &app_data_str)
.stdout(Stdio::piped())
.stderr(Stdio::inherit());
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x08000000;
cmd.creation_flags(CREATE_NO_WINDOW);
}
if let Ok(mut child) = cmd.spawn() {
if let Some(stdout) = child.stdout.take() {
let w = window.clone();
std::thread::spawn(move || {
use std::io::{BufRead, BufReader};
let reader = BufReader::new(stdout);
for line in reader.lines().flatten() {
println!("{}", line);
if let Ok(msg) = serde_json::from_str::<BackendMessage>(&line) {
if msg.event == "ready" {
if let Some(url) = msg.data.get("url").and_then(|u| u.as_str()) {
let _ = w.eval(&format!("window.location.href = '{}';", url));
}
}
}
}
});
}
let state: State<NodeServices> = app.state();
if let Ok(mut lock) = state.0.lock() {
*lock = Some(child);
};
}
Ok(())
})
.on_window_event(|window, event| {
if let tauri::WindowEvent::Destroyed = event {
let state: State<NodeServices> = window.state();
if let Ok(mut lock) = state.0.lock() {
if let Some(mut child) = lock.take() {
let _ = child.kill();
}
};
}
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

26
src-tauri/tauri.conf.json Normal file
View File

@@ -0,0 +1,26 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/schema.json",
"productName": "Vyla Home",
"version": "1.0.0",
"identifier": "com.vyla.home",
"build": {
"frontendDist": "../ui"
},
"app": {
"withGlobalTauri": true,
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}

270
ui/index.html Normal file
View File

@@ -0,0 +1,270 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vyla Home</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #000;
color: #fff;
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
display: block;
width: 100vw;
height: 100vh;
}
.overlay {
position: fixed;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 28px;
pointer-events: none;
}
#ascii-logo {
font-family: "Cascadia Mono", "Consolas", monospace;
font-size: 11px;
line-height: 1.15;
color: rgba(255, 255, 255, .75);
white-space: pre;
margin: 0;
user-select: none;
text-shadow: 0 4px 12px rgba(0, 0, 0, .6);
transform: scale(0.4);
opacity: 0;
animation: logoIn 1.1s cubic-bezier(.16, 1, .3, 1) forwards;
}
#status {
font-size: 10px;
font-weight: 500;
letter-spacing: .08em;
text-transform: uppercase;
color: rgba(255, 255, 255, .4);
opacity: 0;
animation: statusIn .6s ease forwards .7s;
}
@keyframes logoIn {
0% {
transform: scale(0.4);
opacity: 0;
filter: blur(6px);
}
60% {
opacity: 1;
filter: blur(0);
}
100% {
transform: scale(1);
opacity: 1;
filter: blur(0);
}
}
@keyframes statusIn {
from {
opacity: 0;
transform: translateY(6px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.error-view {
position: fixed;
inset: 0;
display: none;
align-items: center;
justify-content: center;
background: #000;
padding: 32px;
z-index: 100;
}
.container {
max-width: 480px;
text-align: center;
}
.icon {
width: 38px;
height: 38px;
margin: 0 auto 22px;
color: #ff453a;
}
h1 {
margin: 0;
font-size: 22px;
font-weight: 600;
letter-spacing: -.02em;
}
p {
margin: 14px 0 28px;
color: rgba(255, 255, 255, .55);
font-size: 14px;
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
}
button {
appearance: none;
border: 0;
border-radius: 999px;
background: #fff;
color: #000;
padding: 10px 18px;
font-size: 13px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
}
</style>
</head>
<body>
<canvas id="c"></canvas>
<div class="overlay">
<pre id="ascii-logo"></pre>
<div id="status">Starting Vyla Home...</div>
</div>
<div id="error-view" class="error-view">
<div class="container">
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10" />
<line x1="12" y1="7" x2="12" y2="13" />
<circle cx="12" cy="17" r="1" />
</svg>
<h1>Couldn't start Vyla Home</h1>
<p id="error-msg"></p>
<button onclick="location.reload()">Try Again</button>
</div>
</div>
<script>
fetch('logo.txt').then(r => r.text()).then(t => {
document.getElementById('ascii-logo').textContent = t;
}).catch(() => { });
const CHARS = ' .:-=+*#%@';
const FONT_SIZE = 50;
const canvas = document.getElementById('c');
const ctx = canvas.getContext('2d');
let CW, CH, cols, rows, t = 0;
let mouseX = -9999, mouseY = -9999, lastMouseMove = 0, mouseStrength = 0;
const FADE_TIME = 250, SMOOTHING = 0.08;
function initFont() {
ctx.font = FONT_SIZE + 'px "Courier New", monospace';
CW = Math.ceil(ctx.measureText('M').width);
CH = FONT_SIZE + 2;
ctx.textBaseline = 'top';
}
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
initFont();
cols = Math.ceil(canvas.width / CW) + 1;
rows = Math.ceil(canvas.height / CH) + 1;
}
window.addEventListener('resize', resize);
window.addEventListener('mousemove', (e) => {
const rect = canvas.getBoundingClientRect();
mouseX = e.clientX - rect.left;
mouseY = e.clientY - rect.top;
lastMouseMove = performance.now();
});
function plasma(cx, cy, tt) {
const x = cx + Math.sin(cy * 3 + tt * 0.7) * 0.07;
const y = cy + Math.cos(cx * 3 + tt * 0.5) * 0.07;
let v =
Math.sin(x * 10 + tt) +
Math.sin(y * 10 + tt) +
Math.sin((x + y) * 7 + tt) +
Math.sin(Math.sqrt(x * x + y * y) * 12 - tt * 1.2) +
Math.sin(x * 6 - tt * 0.8) +
Math.sin(y * 8 + tt * 0.9);
return (v / 6 + 1) / 2;
}
function render() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
t += 0.03;
const elapsed = performance.now() - lastMouseMove;
const targetStrength = Math.max(0, 1 - elapsed / FADE_TIME);
mouseStrength += (targetStrength - mouseStrength) * SMOOTHING;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
const x = col * CW;
const y = row * CH;
const dx = x - mouseX;
const dy = y - mouseY;
const dist = Math.sqrt(dx * dx + dy * dy);
const force = (7000 / (dist * dist + 1500)) * mouseStrength;
const v = plasma(col / cols, row / rows, t);
const brightness = Math.round(v * 60);
const charIdx = Math.floor(v * (CHARS.length - 0.001));
ctx.fillStyle = 'rgb(' + brightness + ',' + brightness + ',' + brightness + ')';
ctx.fillText(CHARS[charIdx], x + dx * force, y + dy * force);
}
}
requestAnimationFrame(render);
}
resize();
render();
function checkBackend() {
fetch('http://localhost:4890')
.then(res => {
if (res.ok) {
window.location.href = 'http://localhost:4890';
} else {
setTimeout(checkBackend, 1000);
}
})
.catch(() => {
setTimeout(checkBackend, 1000);
});
}
setTimeout(checkBackend, 1000);
</script>
</body>
</html>

6
ui/logo.txt Normal file
View File

@@ -0,0 +1,6 @@
██████╗ ██╗ ██╗██╗ ██╗██╗ █████╗ ███████╗███╗ ██╗████████╗███████╗██████╗ ████████╗ █████╗ ██╗███╗ ██╗███╗ ███╗███████╗███╗ ██╗████████╗
██╔═══██╗██║ ██║╚██╗ ██╔╝██║ ██╔══██╗ ██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╔══██╗╚══██╔══╝██╔══██╗██║████╗ ██║████╗ ████║██╔════╝████╗ ██║╚══██╔══╝
██║██╗██║██║ ██║ ╚████╔╝ ██║ ███████║ █████╗ ██╔██╗ ██║ ██║ █████╗ ██████╔╝ ██║ ███████║██║██╔██╗ ██║██╔████╔██║█████╗ ██╔██╗ ██║ ██║
██║██║██║╚██╗ ██╔╝ ╚██╔╝ ██║ ██╔══██║ ██╔══╝ ██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗ ██║ ██╔══██║██║██║╚██╗██║██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║
╚█║████╔╝ ╚████╔╝ ██║ ███████╗██║ ██║ ███████╗██║ ╚████║ ██║ ███████╗██║ ██║ ██║ ██║ ██║██║██║ ╚████║██║ ╚═╝ ██║███████╗██║ ╚████║ ██║
╚╝╚═══╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝

View File

@@ -15,22 +15,29 @@ function isAllowedHost(url) {
}
class UpdateClient {
constructor(appDataPath) {
constructor(appDataPath, token = null) {
this.appDataPath = appDataPath;
this.token = token || process.env.GITLAB_TOKEN || process.env.VYLA_GITLAB_TOKEN || null;
}
fetchJson(url) {
return new Promise((resolve, reject) => {
const urlObj = new URL(url);
const headers = {
'User-Agent': 'VylaHome-Client',
'Accept': 'application/json'
};
if (this.token) {
headers['PRIVATE-TOKEN'] = this.token;
}
const requestOptions = {
hostname: urlObj.hostname,
port: 443,
path: urlObj.pathname + urlObj.search,
method: 'GET',
headers: {
'User-Agent': 'VylaHome-Client',
'Accept': 'application/json'
}
headers
};
const req = https.request(requestOptions, (res) => {
@@ -68,14 +75,20 @@ class UpdateClient {
}
const urlObj = new URL(requestUrl);
const headers = {
'User-Agent': 'VylaHome-Client',
'Accept': 'application/octet-stream'
};
if (this.token) {
headers['PRIVATE-TOKEN'] = this.token;
}
const requestOptions = {
hostname: urlObj.hostname,
port: 443,
path: urlObj.pathname + urlObj.search,
headers: {
'User-Agent': 'VylaHome-Client',
'Accept': 'application/octet-stream'
}
headers
};
const req = https.get(requestOptions, (res) => {
@@ -142,14 +155,20 @@ class UpdateClient {
}
const urlObj = new URL(requestUrl);
const headers = {
'User-Agent': 'VylaHome-Client',
'Accept': 'application/octet-stream'
};
if (this.token) {
headers['PRIVATE-TOKEN'] = this.token;
}
const requestOptions = {
hostname: urlObj.hostname,
port: 443,
path: urlObj.pathname + urlObj.search,
headers: {
'User-Agent': 'VylaHome-Client',
'Accept': 'application/octet-stream'
}
headers
};
const req = https.get(requestOptions, (res) => {
@@ -189,15 +208,15 @@ class UpdateClient {
async checkForUpdates() {
const releases = await this.fetchJson(RELEASES_API);
if (!releases || releases.length === 0) {
throw new Error('No releases found.');
return null;
}
const release = releases[0];
const payloadAsset = (release.assets.links || []).find(a => a.name === 'update-payload.zip');
const manifestAsset = (release.assets.links || []).find(a => a.name === 'manifest.json');
const payloadAsset = (release.assets && release.assets.links ? release.assets.links : []).find(a => a.name === 'update-payload.zip');
const manifestAsset = (release.assets && release.assets.links ? release.assets.links : []).find(a => a.name === 'manifest.json');
if (!payloadAsset) {
throw new Error('No update-payload.zip asset found on latest release.');
return null;
}
let sha256 = null;