Add SSE, response headers, view transitions, and 5 new sx attributes
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Implement missing SxEngine features: - SSE (sx-sse, sx-sse-swap) with EventSource management and auto-cleanup - Response headers: SX-Trigger, SX-Retarget, SX-Reswap, SX-Redirect, SX-Refresh, SX-Location, SX-Replace-Url, SX-Trigger-After-Swap/Settle - View Transitions API: transition:true swap modifier + global config - every:<time> trigger for polling (setInterval) - sx-replace-url (replaceState instead of pushState) - sx-disabled-elt (disable elements during request) - sx-prompt (window.prompt, value sent as SX-Prompt header) - sx-params (filter form parameters: *, none, not x,y, x,y) Adds docs (ATTR_DETAILS, BEHAVIOR_ATTRS, headers, events), demo components in reference.sx, API endpoints (prompt-echo, sse-time), and 27 new unit tests for engine logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -165,6 +165,19 @@ ATTRIBUTES = [
|
||||
"sx-media",
|
||||
"sx-disable",
|
||||
"sx-on", # URL slug for sx-on:*
|
||||
"sx-boost",
|
||||
"sx-preload",
|
||||
"sx-preserve",
|
||||
"sx-indicator",
|
||||
"sx-validate",
|
||||
"sx-ignore",
|
||||
"sx-optimistic",
|
||||
"sx-replace-url",
|
||||
"sx-disabled-elt",
|
||||
"sx-prompt",
|
||||
"sx-params",
|
||||
"sx-sse",
|
||||
"sx-sse-swap",
|
||||
"sx-retry",
|
||||
"data-sx",
|
||||
"data-sx-env",
|
||||
@@ -441,3 +454,24 @@ class TestReferenceAPIs:
|
||||
def test_flaky(self):
|
||||
r = _get("/reference/api/flaky")
|
||||
assert r.status_code in (200, 503)
|
||||
|
||||
def test_prompt_echo(self):
|
||||
r = httpx.get(
|
||||
f"{SX_BASE}/reference/api/prompt-echo",
|
||||
headers={**HEADERS, "SX-Prompt": "Alice"},
|
||||
timeout=TIMEOUT,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert "Alice" in r.text
|
||||
|
||||
def test_sse_time(self):
|
||||
"""SSE endpoint returns event-stream content type."""
|
||||
with httpx.stream("GET", f"{SX_BASE}/reference/api/sse-time",
|
||||
headers=HEADERS, timeout=TIMEOUT) as r:
|
||||
assert r.status_code == 200
|
||||
ct = r.headers.get("content-type", "")
|
||||
assert "text/event-stream" in ct
|
||||
# Read just the first chunk to verify format
|
||||
for chunk in r.iter_text():
|
||||
assert "event:" in chunk or "data:" in chunk
|
||||
break # only need the first chunk
|
||||
|
||||
Reference in New Issue
Block a user