All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased
0.2.3 - 2026-03-14
Fixed
- Corrected Datastar attribute from
data-on-loadtodata-initin documentation examples (reflects the correct Datastar API). - Fixed misleading code comment in
patch_fragment/3docs that said "Replace inner HTML" when the example was actually appending content.
Improved
- Enhanced Phoenix controller example in both library docs and README to show a more realistic workflow with form editing and updates.
- Added explicit Datastar RC.8+ compatibility notice in docs to clarify which versions of the Datastar client are supported.
- Added link to live demo in README to help users see the package in action.
0.2.2 - 2026-03-14
Fixed
- Corrected stale function-arity references in the README:
execute_script/2,remove_fragment/2,patch_signals/2, andredirect_to/2have been updated to their correct current arities (/3) in the SSE Protocol, Merge Modes, and Security sections. - Added
cli/0tomix.exswithpreferred_envs: ["test.ci": :test]so themix test.cialias runs in the correct:testenvironment without requiringMIX_ENV=testto be set manually.
0.2.1 - 2026-03-14
Fixed
- Fix ExDoc deprecation warning by replacing
:groups_for_functionswith:groups_for_docsin documentation configuration. - Add LICENSE file to documentation extras so it's properly included and referenced without warnings.
0.2.0 - 2026-03-14
Added
Datastar.check_connection/1— Sends a blank SSE comment to the client to verify the connection is still alive. Returns{:ok, conn}on success or{:error, conn}when the client has disconnected. Useful for long-running SSE streams.Datastar.remove_signals/3— Removes one or more client-side signals by sending adatastar-patch-signalsevent withnilvalues. Accepts a single dot-notated path string or a list of paths; shared prefixes are merged correctly into a single JSON payload.patch_fragment/3—:namespaceoption — sets the XML namespace for new elements ("html"default,"svg", or"mathml").patch_fragment/3—:use_view_transitionoption — whentrue, wraps the DOM patch in the browser's View Transitions API.patch_signals/3—:only_if_missingoption — only patches signals that do not already exist in the client signal store.execute_script/3—:auto_removeoption — whentrue, addsdata-effect="el.remove()"to the injected<script>tag so Datastar removes it from the DOM after execution.- All SSE-emitting functions now accept
:event_idand:retry_durationkeyword options, emitting the standard SSEid:andretry:fields respectively.
Changed
- Valid merge modes for
patch_fragment/3are now"outer","inner","replace","prepend","append","before","after", and"remove". The previously advertised"morph"mode has been removed to align with the Datastar RC.8+ protocol, which uses"outer"as the default morph behaviour.
Fixed
check_connection/1now rescuesArgumentError(raised byPlug.Conn.chunk/2on non-chunked connections) and returns{:error, conn}instead of crashing.
0.1.0 - 2026-03-14
Added
Datastar.init_sse/1— Initialises a chunkedtext/event-streamresponse with the required SSE headers (cache-control,connection,x-accel-buffering).Datastar.patch_fragment/3— Sends adatastar-patch-elementsSSE event to patch HTML into the DOM. Supports all Datastar merge modes (morph,inner,outer,prepend,append,before,after,remove) and an optional CSS selector. Multi-line HTML is split into onedata: elementsline per source line as required by the SSE protocol.Datastar.patch_signals/2— Sends adatastar-patch-signalsSSE event to merge a map of values into the Datastar client signal store. Values are JSON-encoded viaJason.Datastar.execute_script/2— Executes a JavaScript snippet on the client by appending a<script>tag to the document<body>via adatastar-patch-elementsevent.Datastar.redirect_to/2— Redirects the browser to a URL using asetTimeout-wrappedwindow.location.hrefassignment. The URL is JSON-encoded to prevent injection.Datastar.remove_fragment/2— Removes DOM elements matching a CSS selector by sending adatastar-patch-elementsevent withmode: remove.Datastar.close_sse/1— No-op pipeline terminator that documents intent (the SSE response body is complete).Datastar.parse_signals/1— Decodes Datastar signals from controller params for both GET requests (signals as a JSON string in?datastar=) and POST/PUT/PATCH/DELETE requests (signals as the decoded JSON body). Returns%{}on parse failure so callers always receive a map.