Files
jellyfin_vr_web_plugin/build.py
T
cat-shark 838675baa6 Jellyfin Web VR plugin for Quest 3 (VR180 stereo playback)
Injects a 「VR 播放」 button into Jellyfin Web's video player page and plays
VR180 / VR360 stereo content on Meta Quest 3 directly in the browser, with
DirectPlay 8K HEVC, in-VR subtitles and an in-VR control panel.

Modules (src/, concatenated in filename order into dist/jfvr.js):
  00-core.js       namespace, shared state, GL helpers, layer/frame-hook registry
  10-subtitles.js  libass canvas -> head-locked quad layer, auto-cropped to ink,
                   with depth/size decoupling (angular-size lock)
  20-controls.js   in-VR control panel: progress/seek, transport, subtitle rows,
                   aiming beam, padlock, pure 2D canvas -> XR quad layer
  30-hands.js      system hand model (Three.js + generic-hand GLB) via a manually
                   driven projection layer
  90-main.js       boot, XR session lifecycle, rAF broker (rAF stops during XR),
                   input dispatch, settings panel, localStorage persistence

Key on-device findings are documented in HANDOFF.md §6 and README.md addenda:
requestAnimationFrame stops during an XR session, 3:2 pulldown at 90 Hz needs
updateTargetFrameRate(120), libass must be resized before entering VR, a quad's
local -Z is its plane normal, and hand aiming must use the gaze ray because the
emulated targetRaySpace points sideways. Quest does not expose eye tracking.

Docs: INTERFACES.md (module contract + addenda), README.md (measurements),
HANDOFF.md (handover notes). Credentials are NOT in the repo: deploy.py reads
the SSH password from the JF_PW environment variable.
2026-10-11 19:19:06 +08:00

83 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""
Concatenate src/*.js (in filename order) into dist/jfvr.js.
Each module is already a self-contained IIFE that attaches to window.__JFVR,
so the build is a straight concatenation with a banner. No minification: the
deployed file stays readable in DevTools, which matters because on-device
debugging happens over CDP.
Usage:
python3 build.py # build
python3 build.py --check # build + syntax check every module
"""
import hashlib
import os
import subprocess
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
SRC = os.path.join(HERE, "src")
DIST = os.path.join(HERE, "dist")
OUT = os.path.join(DIST, "jfvr.js")
ORDER = ["00-core.js", "10-subtitles.js", "20-controls.js", "30-hands.js", "90-main.js"]
def sources():
"""Return (path, text) for every module, in load order."""
found = sorted(f for f in os.listdir(SRC) if f.endswith(".js"))
ordered = [f for f in ORDER if f in found]
ordered += [f for f in found if f not in ORDER]
if not ordered:
sys.exit("no sources in %s" % SRC)
return [(f, open(os.path.join(SRC, f), encoding="utf-8").read()) for f in ordered]
def syntax_check():
bad = 0
for name, _ in sources():
p = os.path.join(SRC, name)
r = subprocess.run(["node", "--check", p], capture_output=True, text=True)
status = "ok" if r.returncode == 0 else "FAIL"
print(" %-18s %s" % (name, status))
if r.returncode != 0:
print(r.stderr.strip())
bad += 1
return bad
def main():
if "--check" in sys.argv:
print("syntax check:")
sys.exit(1 if syntax_check() else 0)
mods = sources()
parts = [
"/*!",
" * JFVR (Jellyfin Web VR) — built bundle. DO NOT EDIT.",
" * Edit src/*.js and run: python3 build.py",
" * Modules: " + ", ".join(n for n, _ in mods),
" */",
]
for name, text in mods:
parts.append("\n/* ===== %s ===== */\n" % name)
parts.append(text.rstrip("\n"))
parts.append("\n")
bundle = "\n".join(parts)
os.makedirs(DIST, exist_ok=True)
with open(OUT, "w", encoding="utf-8") as fh:
fh.write(bundle)
digest = hashlib.md5(bundle.encode()).hexdigest()
print("built %s" % OUT)
print(" modules : %d (%s)" % (len(mods), ", ".join(n for n, _ in mods)))
print(" bytes : %d" % len(bundle))
print(" md5 : %s" % digest)
print(" version : %s" % digest[:6])
if __name__ == "__main__":
main()