feat(stockholm): add Go backend integration for Stockholm frontend

Implements pkg/service/stockholm with bridge (appSend/runQueue), HTTP
proxy, static serving, config URL rewriting, native state persistence,
and device discovery. Mounts under a configurable base path (/stockholm
by default) with correct http.StripPrefix routing and apiBase-prefixed
bridge API routes matching the patched JS window.__stockholmBase calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tobias Gesellchen
2026-05-17 15:05:39 +02:00
co-authored by Claude Sonnet 4.6
parent c64e601df6
commit 6fb999435a
21 changed files with 4271 additions and 27 deletions
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
"""Patch Stockholm bridge JS files to use window.__stockholmBase for API paths.
Usage: patch-stockholm-bridge.py <file> [<file> ...]
Applied once by `make prepare-stockholm`. Idempotent — already-patched files
are left unchanged.
"""
import sys
REPLACEMENTS = [
(
'xhr.open("POST", "/api/native/appSend"',
'xhr.open("POST", (window.__stockholmBase||"") + "/api/native/appSend"',
),
(
'xhr.open("GET", "/api/native/runQueue',
'xhr.open("GET", (window.__stockholmBase||"") + "/api/native/runQueue',
),
(
'var proxyPath = "/api/http-proxy";',
'var proxyPath = (window.__stockholmBase||"") + "/api/http-proxy";',
),
(
'return new URL(url, window.location.origin + "/").href;',
'return new URL(url, window.location.origin + (window.__stockholmBase || "") + "/").href;',
),
]
for path in sys.argv[1:]:
try:
original = open(path).read()
patched = original
for old, new in REPLACEMENTS:
patched = patched.replace(old, new)
if patched != original:
open(path, "w").write(patched)
except FileNotFoundError:
print(f"warning: {path} not found, skipping", file=sys.stderr)