HS: socket feature (E36) — WebSocket wrapper + RPC proxy (+16 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

Parser: socket feature (name, url, with timeout, on message, json/raw).
Runtime: hs-socket-register!, hs-socket-normalise-url, hs-socket-bind-name!,
  hs-socket-reconnect!, hs-socket-rpc!, hs-socket-resolve-rpc! — full
  WebSocket lifecycle with reconnect, pending-map RPC, and timeout.
Compiler: compile-socket-feat stub (feature is self-registering at activation).
Test harness: dispatch-object pattern for RPC proxy — OCaml WASM kernel cannot
  return values created inside a JS Proxy get trap; plain function with
  _hsRpcDispatch method + host-get intercept avoids the limitation.
Test suite: 16 new tests (hs-upstream-socket) covering URL normalisation,
  socket registration, on-message, JSON/raw, RPC calls, timeout, reconnect,
  noTimeout modifier, reply-with-throw. 16/16 pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 11:44:13 +00:00
parent 0f63216adc
commit 623529d3be
7 changed files with 886 additions and 42 deletions

View File

@@ -2356,6 +2356,25 @@
((= head (quote live-no-op)) nil)
((= head (quote when-feat-no-op)) nil)
((= head (quote bind-feat)) nil)
((= head (quote socket))
(let
((name-path (nth ast 1))
(url (nth ast 2))
(timeout (nth ast 3))
(on-message (nth ast 4)))
(let
((handler-sx (if (and (list? on-message) (= (first on-message) (quote on-message))) (list (quote fn) (list (quote event)) (hs-to-sx (nth on-message 2))) nil)))
(let
((json? (if (and (list? on-message) (= (first on-message) (quote on-message))) (nth on-message 1) false)))
(list
(quote hs-socket-register!)
(cons
(quote list)
(map (fn (seg) seg) name-path))
(hs-to-sx url)
(hs-to-sx timeout)
handler-sx
json?)))))
((= head (quote on)) (emit-on ast))
((= head (quote when-changes))
(let