#!/usr/bin/env python3
"""Extract the served JS from webui.py and run `node --check` on it.
Catches:
- Regex literals with unbalanced escapes (the Part 43 bug)
- Unclosed strings / braces / parentheses
- Any JS that a browser would reject wholesale
"""
import re
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
WEBUI = ROOT / "src" / "sunnyware" / "webui.py"
def main():
src = WEBUI.read_text(encoding="utf-8")
# Grab the last block (the app JS)
matches = list(re.finditer(r"", src, re.DOTALL))
if not matches:
print("[FAIL] no