webapp: introduce Laravel app under webapp/ for scene overlays

Replaces the per-scene HTML directories (landing/, loading/, game/,
desktop/, goodbye/, music-box/, music/) with a single Laravel app
serving every overlay over HTTP. Supervisord runs `php artisan serve`
on 127.0.0.1:1118 and the OBS scene JSON now references HTTP routes
instead of file:// URLs.

Highlights:
 - public/css/hud.css consolidates the duplicated HUD chrome,
   scanlines/vignette/flicker, terminal styling, and pulse keyframes
   that were copy-pasted across all seven scenes.
 - Blade partials own hud-strip, crt-overlays, obs-ws-scripts,
   camera-frame, screen-frame; the seven scenes extend a shared
   overlay layout.
 - Artisan commands (`rig:setup`, `rig:telemetry`, `rig:loading`,
   `rig:playlist`, `rig:cmd`) replace the shell scripts that wrote
   per-rig JSON snapshots. TwitchHelix + HardwareSnapshot services
   handle the work the bash + Python helpers used to.
 - ObsWsClient + MusicCommandController kill the 250 ms cmd.js poll
   in the music daemon: POST /cmd/{skip|prev|pause|resume} opens a
   short-lived Pawl WS, authenticates, and broadcasts mpd:cmd.
 - AudioController streams files from the configured music dirs so
   CEF can load tracks under the HTTP origin (Chromium blocks
   HTTP-origin pages from loading file:// media).
 - DataController serves /data/playlist.js (with ETag mtime cache)
   and /cover.jpg (no-store) so the existing overlays' window.__PLAYLIST
   and cover.jpg cache-bust pattern keeps working.

scripts/obs-webapp.supervisord.conf is the supervisord unit; install
to /etc/supervisor.d/obs-webapp.conf.
scripts/rewrite-scene-urls.py is a one-shot tool that rewrites
basic/scenes/Default_Stream_HUD.json from file:// to HTTP URLs.
basic/scenes/Default_Stream_HUD.json.pre-webapp is the rollback
artifact (made with OBS closed; full pre-migration state).

The seven old scene directories, vendor/, and the bash scripts are
still on disk pending visual verification; the next commit will
prune them.
This commit is contained in:
Jakub Zych
2026-05-21 12:47:10 +02:00
parent c8f9c11c93
commit 059f069ef4
85 changed files with 19180 additions and 49 deletions

View File

@@ -0,0 +1,87 @@
<?php
namespace App\Support;
class RigData
{
private array $cache = [];
public function loading(): array
{
return $this->read('loading.json', [
'game' => null, 'gameId' => null, 'subtitle' => null,
'countdownMin' => 5, 'camera' => true, 'microphone' => true,
'compiledAt' => null,
]);
}
public function telemetry(): array
{
return $this->read('telemetry.json', [
'rig' => config('rig.rig_name') ?? 'unknown',
'host' => [], 'cpu' => [], 'gpu' => [], 'mem' => [], 'obs' => [],
]);
}
public function playlist(): array
{
return $this->read('playlist.json', [
'syncedAt' => null, 'sourceDirs' => [], 'trackCount' => 0, 'tracks' => [],
]);
}
public function playlistCount(): int
{
$p = $this->playlist();
return (int) ($p['trackCount'] ?? count($p['tracks'] ?? []));
}
public function cmd(): array
{
return $this->read('cmd.json', ['id' => 0, 'type' => 'none', 'ts' => 0]);
}
public function writeCmd(string $type): array
{
$cmd = ['id' => (int) (microtime(true) * 1000), 'type' => $type, 'ts' => time()];
$this->write('cmd.json', $cmd);
$this->cache['cmd.json'] = $cmd;
return $cmd;
}
public function playlistPath(): string
{
return rtrim(config('rig.storage_data'), '/') . '/playlist.json';
}
public function coverPath(): string
{
return (string) config('rig.cover_jpg');
}
private function read(string $file, array $fallback): array
{
if (isset($this->cache[$file])) return $this->cache[$file];
$path = rtrim(config('rig.storage_data'), '/') . '/' . $file;
if (!is_file($path)) return $this->cache[$file] = $fallback;
$raw = @file_get_contents($path);
if ($raw === false) return $this->cache[$file] = $fallback;
$parsed = json_decode($raw, true);
if (!is_array($parsed)) return $this->cache[$file] = $fallback;
return $this->cache[$file] = $parsed + $fallback;
}
private function write(string $file, array $data): void
{
$dir = rtrim(config('rig.storage_data'), '/');
if (!is_dir($dir)) @mkdir($dir, 0775, true);
file_put_contents(
$dir . '/' . $file,
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
);
}
}