Christian Tanul 923b022d9b
Extract SSE from core into standalone extension (#3666)
Move SSE out of htmx core into a standalone extension (hx-sse.js).

The new extension uses Fetch + ReadableStream instead of EventSource,
so it works with POST, custom headers, and cookies. Two modes:
- One-off streams: any hx-get/hx-post returning text/event-stream
- Persistent connections: hx-sse:connect with auto-reconnect

SSE events now follow the extension pattern:
- htmx:before:sse:connection / htmx:after:sse:connection
- htmx:before:sse:message / htmx:after:sse:message
- htmx:sse:error / htmx:sse:close

New features:
- hx-sse:close="eventname" to close connection on a named event
- htmx:sse:close event with reason (message, removed, ended, etc.)
- htmx:before:response core event for extension response interception
- Server retry: field updates reconnect delay per SSE spec
- Non-2xx reconnect responses fire htmx:sse:error

SSE parser improvements (spec compliance):
- Handle CRLF, CR, and LF line endings
- Strip leading BOM (U+FEFF)
- Dispatch empty data fields
- Ignore id fields containing NULL
- Process field-only lines (no colon) per spec

Docs:
- Document htmx:before:response in events, reference, building guide
- Add htmx 2.x → 4.x SSE migration guide
- Document hx-sse:close and htmx:sse:close
- Add hx-sse:connect, hx-sse:close to JetBrains web-types
- Fix stale Accept header reference in migration guide

Remove htmx.config.sse from core config tables (extension-only now).
Remove stale SSE event references from core docs.
2026-02-21 14:43:06 -07:00
..