- Fixing issue #42: An exception thrown while sending HTTP headers in the ring
adapter would could mean opening output streams that aren't closed (think
Brotli write profile). We now send headers before doing anything else.
- Fixing issue #41: The SSE generator from the ring adapter detects a client
disconnecting when an IOException is thrown sending a patch. When it does,
it closes output streams created by the write profile used. Right now, closing
these will throw, the underlying OS (provided by the server) is already closed
after the first IOException. With this fix we discard the second IOException,
it is just a consequence of the first, the client just disconnected.
- The CDN link in the api now point to D* v1.0.4
- updated the dependencies of the libraries
- Added links CDN links to the newest D* + Rocket bundle
sse-query function to make SSE QUERY action (added in D* v1.0.4)
- The SDK adapter for generic ring used to improperly get rid of its output
stream before closing it in the case of an exception being thrown while sending
a SSE event. See #39.
- The new
view-transition-selector option for patch elements functions that
was introduced in Datastar v1.0.2 is now supported.
- The Datastar CDN url provided in the api now points to Datastar v1.0.2
- The code handling exceptions arising when closing a sse generator has been
redesigned. Errors are thrown as is, exceptions are wrapped in an ExceptionInfo
whose
ex-data contains an exception thrown during the closing of IO resources
and/or an exception thrown during the on-close callback.
See the closing-io-exception and closing-on-close-exception vars in your
adapter namespace to get at a specific exception. See the docstring for
starfederation.datastar.clojure.adapter.common/close-sse! for more
information about the whole sse-gen closing process. (#37) - Brotli now uses UTF-8 by default (#35)
- Fixed a typo in the Aleph malli schema namespace (#25)
- Reworked docstings and typo fixes (#28)
- Build process cleanup: removed unused code (#33), simplified bb tasks (#34)
- fixed the ci process, several jar weren't available on github after a build (#29)
- Added malli schemas for element namespaces when using patch-elements (#27)
- Added warnings about string interpolation in execute-script helpers docstrings (#31)
- The CDN urls now point to the latest 1.0.1 release of Datastar.
- Following a change in Datastar, the
get-signals function now handles DELETE
http request the same way it handles GET requests. - Updated library dependencies.
- The main README has been corrected, it now longer says that brotli only works
with http-kit
- Some docs and examples were still using Datastar's old syntax. This is now
fixed.
- Brolti compression now works for the Ring implementation of the SDK by using
the new
custom flush option for write profiles.
- New
custom-flush option in write profiles allowing to have more control over
flushing behavior. - A new implementation of the SDK for the Aleph ring adapter has been added.
- The tests have been refactored in order to be somewhat more legible and REPL friendly.
- The clj-kondo config from the sdk library is now properly added into the jar.
- Patch elements functions in the SDK now provide the namespace option introduced in
Datastar RC7.
- Urls for the Datastar CDN provided in the API now point to
Datastar RC7.
- Fixed
starfederation.datastar.clojure.adapter.http-kit2/wrap-start-responding,
the async arity was improperly managed.
- The internals of the Ring SSE generator have been reworked. The SSE gen won't error
if a user reuses it for different requests anymore. Documentation is in place to warn
against such reuse and this change makes for much simpler code.
- When creating SSE events we need to split on end of lines the text that will
constitute the data lines of the event. This can prevent SSE event injection
problems. The SSE machinery has been refactored so that this splitting happens
in a code path that all API functions go through instead of doing it in every
d* patch function. This way we can't forget that splitting.
This version's purpose is to transition the SDK to the new Datastar attribute
syntax introduced in
v1.0.0-RC6.
-
BREAKING: The SDK APIs remain the same except for 2
vars:
starfederation.datastar.clojure.api/CDN-urlstarfederation.datastar.clojure.api/CDN-map-url
These now point to Datastar v1.0.0-RC6. If you use them,
updating to this version of the SDK will change your Datastar CDN import.
Your app will break until you transition to the new :data-* syntax.
-
Examples and tests now use the new syntax along with the RC6 js bundle.
Fixed the scm info that goes in pom.xml files.
This release is mostly centered around documentation and cljdoc compatibility.
- Several dependencies have been updated
- Libraries interdependencies are now explicit in their
deps.edn - Malli schemas are now split into 3 libraries. This comes from the need to be
cljdoc compatible
- New articles have been added to the
doc directory - Several docstrings have been added / updated
- There are new babashka tasks to help running a local cljdoc instance and
ingesting the docs locally
- The build process updates libraries interdependencies versions automatically
- A warning about which Http-kit version to use has been added in the proper
README
-
The public API has seen it's main functions renamed following the new SDK ADR.
Several functions have been renamed or removed:
| Old | new |
|---|
merge-fragment! | patch-elements! |
merge-fragments! | patch-elements-seq! |
remove-fragments! | remove-element! |
merge-signals! | patch-signals! |
remove-signals | removed |
-
All the examples and snippets have been updated following the ADR changes.
- A superfluous newline character was send when marking the end of a SSE event
- The clj-kondo config file for the SDK has been moved in a
clj-kondo.exports/starfederation.datastar.clojure/sdk directory. This change
allows for other projects to use
starfederation.datastar.clojure/XXXX/config.edn for their clj-kondo config.
- There is a new http-kit API that allows a more natural ring response model when
using SSE. With the current API the status and headers for a response are
sent directly while
->sse-response is running, the on-open callback runs
just after. For instance that any middleware that would add headers after the
execution of the ->sse-response function won't work, the initial response
being already sent.
The new starfederation.datastar.clojure.adapter.http-kit2
API changes this behavior. In this new api the initial response is not sent
during ->sse-response. Instead a middleware takes care of sending it and
only then calls the on-open callback. If this middleware is the last to run
on the return any addition to the response map will be taken into account. - A new library providing Brotli write profile has been added.
- The vars holding keywords (like
on-open) in the adapter namespaces were not
properly recognized by Clj-kondo. This generated unresolved var warnings. A
specific Clj-kondo config has been added to fix these warnings.
- The HTTP version detection that determines whether to add the
Connection keep-alive HTTP header has been changed. The header is now
properly added for versions older than HTTP/1.1.
- Bumped the ring version from
1.13.0 to 1.14.1. This encourages users
to use Jetty 12 when using ring jetty adapter.
- Removed the use of the deprecated
:on-open and :on-close keywords. The
->sse-response functions of both adapters will not use them anymore. The
corresponding docstrings are updated.
- the use of
:on-open and :on-close keywords for the ->sse-response
function is deprecated and will be removed in a future release.
See ->sse-response's docstring.
- Added a "write profile" mechanism that allows user to use compression of
SSE streams and let them control the IO buffering behavior.
- Added new malli schemas to go with the "write profiles".
- Added the ability to pass an on-error callback to SSE generators, it allows
for changing or augmenting the behavior on exceptions.
starfederation.datastar.clojure.api/lock-sse!. This is a macro allowing
its body to be protected by a SSE generator's lock.- Added a Flowstorm setup to help debugging when working on the SDK.
- Fixed a typo in the cache-control HTTP header.
- Fixed some malli schemas
- There were problems with the handling of concurrent uses of the ring adapter.
This adapter uses a re-entrant lock to prevent some bad behaviors and the
previous implementation was too simplistic. The lock management has been
redone and there are now some basic tests for the hairiest part of the lock's
handling.
- The handling of errors and the management of concurrency for the adapters has
been redesigned. The ring implementation particularly needed some work.
Now when a
IOException is thrown sending an event, adapters will close
themselves. Other exceptions are rethrown. When trying to close an already
closed SSE generator, the close-sse! function just returns false.
Previously the ring adapter was potentially throwing in that case.
Also the on-close callback can be called at most once.
Both adapters behave similarly when it comes to errors. - A slight change to the
starfederation.datastar.clojure.api.sse namespace
makes it a generic SSE event formatter.
starfederation.datastar.clojure.sse/write-event! is now Datastar agnosticstarfederation.datastar.clojure.sse/headers is now a generic function
to make HTTP headers containing the SSE specific ones.
- The SSE headers added by the SDK no longer override the user provided ones.
- bumped http-kit version:
2.9.0-alpha2 -> 2.9.0-alpha4
- Several docstrings, and documentation files have been corrected/added.
- Added documentation giving the rationale for the "write profile" concept
and giving some usage examples.
- Added the load_more code snippet to the main site's code snippets
starfederation.datastar.clojure.adapter.test/->sse-response. This is a mock
for a SSE ring response that records the SSE events sent with it.- Example snippets for the main site, ie, polling and redirection. These
examples are runnable from the development examples.
- Development example of the usage of the redirect sugar.
- Fixed the main readme example (wrong arity of
:on-close callback using http-kit) - The jetty adapter now returns a harmless value when sending an event. It used
to return the write buffer which shouldn't be used directly.
- The
starfederation.datastar.clojure.api/redirect! helper function uses a js
timeout for redirection
- The ring adapter for the SDK is now a generic ring adapter. This adapter
depends solely on the ring core protocols, the dependency to the ring
jetty adapter has been removed.
[!important]
This change comes with these breaking changes:
- The
adapter-jetty directory has been renamed adapter-ring, this mean a
change in your deps.edn. Check the readme. - The
starfederation.datastar.clojure.adapter.ring-jetty has been moved to
starfederation.datastar.clojure.adapter.ring
- Added a function to the main API that test for the presence of Datastar
headers in a ring request.
- The
->sse-response functions from the adapters now have the option to
modify the HTTP response status code. It is useful when wanting to return
204 responses for instance. - rj9a will be supported as soon as there is a fix for the connection lifetime
issue in asynchronous ring.
- SSE retry duration data line is now properly elided when its value passed
as an option is equal the default retry duration value from the generated
constants.
- Fixed miss-management of web-drivers in tests, the drivers are now killed
when the JVM shuts down