You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Python→JS transpiler (src/HTeaLeaf/JS/py2js.py) covers a useful core (assignments, if/while/for, calls, f-strings, list/dict/tuple literals, operators), but several common constructs aren't handled, and non-trivial client logic hits a wall. Concretely:
generic_visitraises NotImplementedError for any unhandled expression node (py2js.py:74).
_emit_body emits /* TODO: <NodeName> */ for unhandled statements (py2js.py:67) — i.e. silently produces broken JS.
Rich client features can't be expressed in @js today and fall back to hand-written JSCode, which erodes the "write the client in Python" value. Examples we need:
Error handling (try/except) and comprehensions for shaping data before render.
What would help (any subset)
Broaden transpiler coverage: at minimum try/except, comprehensions, lambda.
A first-class, typed escape hatch for browser APIs — e.g. JSCode/window proxies for navigator, MediaRecorder, FileReader, EventSource, fetch().body streaming — so @js functions can call them without raw string injection.
Make unhandled nodes a hard error rather than a silent /* TODO */ that ships broken JS.
Context
Raised while evaluating HTeaLeaf to replace a Vue + FastAPI frontend with pure Python. The DSL is great for static + simple-interaction views; this is the gap for the dynamic client logic (chat streaming, voice). Related: #16 (server push), and the multipart upload issue.
Summary (enhancement)
The Python→JS transpiler (
src/HTeaLeaf/JS/py2js.py) covers a useful core (assignments,if/while/for, calls, f-strings, list/dict/tuple literals, operators), but several common constructs aren't handled, and non-trivial client logic hits a wall. Concretely:generic_visitraisesNotImplementedErrorfor any unhandled expression node (py2js.py:74)._emit_bodyemits/* TODO: <NodeName> */for unhandled statements (py2js.py:67) — i.e. silently produces broken JS.No
visit_*for:try/except(Try), comprehensions (ListComp/DictComp/SetComp/GeneratorExp),Lambda,ClassDef,With,Raise,Assert,await/async defs.Why it matters
Rich client features can't be expressed in
@jstoday and fall back to hand-writtenJSCode, which erodes the "write the client in Python" value. Examples we need:navigator.mediaDevices.getUserMedia+MediaRecorder(events, async).FileReader/Blobfor attachments.EventSource/WebSockethandlers that accumulate chunks and patch the DOM (pairs with Server push (SSE / WebSocket) for streaming responses and real-time UIs #16).try/except) and comprehensions for shaping data before render.What would help (any subset)
try/except, comprehensions,lambda.JSCode/windowproxies fornavigator,MediaRecorder,FileReader,EventSource,fetch().bodystreaming — so@jsfunctions can call them without raw string injection./* TODO */that ships broken JS.Context
Raised while evaluating HTeaLeaf to replace a Vue + FastAPI frontend with pure Python. The DSL is great for static + simple-interaction views; this is the gap for the dynamic client logic (chat streaming, voice). Related: #16 (server push), and the multipart upload issue.