This release includes a wide range of miscellaneous fixes, including a growing number of external contributions, which is really appreciated!
The SVG APIs have seen a significant expansion since the last release. For example, gradient support has been added:
Svg(attrs = {
width(200)
height(200)
}) {
val gradientId = SvgId("myGradient")
Defs {
RadialGradient(gradientId, attrs = {
cx(0.25)
cy(0.25)
r(0.25)
}) {
Stop(10.percent, Colors.Gold)
Stop(90.percent, Colors.DarkOrange)
}
}
Circle {
cx(100)
cy(100)
r(50)
fill(gradientId)
}
}But that's just one of many features. For a more detailed list of release notes, read on!
Frontend
- SVG APIs have been significantly extended
- You can now use concepts like
defs,symbol, gradients,transform, and a few others. - ⛔ SVG APIs have moved to a subpackage. If you were an early adopter of these APIs, you will need to change any imports by adding ".svg" to the end of them. More information in the notes section below.
- You can now use concepts like
- More SVG icons have landed, such as arrows, an attachment icon, close and hamburger icons, and a few more.
- SVG icons can potentially allow you to avoid using font-awesome or Google material design icons, which can help keep your final site a little slimmer.
- Thanks @binayshaw7777 for their continued work in this area.
- Have an icon that you think should be part of the standard set? Let us know!
- Routing logic no longer 404s when the route links directly to a file
- New
FontVariantmodifiers. - New
WordBreakmodifier.
Silk
- A new variant for links ("Always Underlined") has been added
- Thanks @Geanik!
- ⚠️
registerBaseStylehas been deprecated and renamed toregisterStyleBase.
Backend
- You can now register a dispose listener for when the server is shutting down, giving you a chance to release resources.
- This can be particularly useful in dev mode, since in that case you might get the server restarting many times in a short period of time due to live reloading behavior.
- Example in the notes section below.
- Thanks to @zypus for raising, discussing, and then implementing this feature.
- Fixed an issue where paths with trailing slashes would incorrectly 404 only when running the server in production mode.
Markdown
- You can now link to other markdown files directly, and then will be properly converted to html links at compile time.
- For example,
Read more at our [privacy policy](../privacy-policy.md) - Thanks @MartinTheDragon for proposing, discussing, and then implementing this feature.
- For example,
Gradle
- The Gradle plugin now reports output from the "Download browser" step at export time.
- Occasionally users report getting mysteriously stuck on export, and it's always an issue with downloading browsers. This change might fix the underlying problem, and additionally, it's very useful to see the progress.
- Thanks @DennisTsar for the idea and implementation here. I had given up thinking I was powerless to do anything else here.
Notes
Kobweb backend: Disposing resources
If you are initializing an unmanaged external resource in your server that you'd like to release when the server goes down, you can use a new onDispose event for this. A basic example looks like this:
@InitApi
fun setUpDatabase(ctx: InitApiContext) {
val db = Database() // As a side effect, starts up and creates a lock file
ctx.data.add(db)
ctx.events.onDispose { db.shutdown() }
}The event is passed a DisposeEvent parameter you can use if you'd like to check the source of the dispose request (e.g. ctx.events.onDispose { evt -> ... }). The reason will either be due to a live reloading dev event, the server shutting down, or the JVM getting shut down (which can be caused if the server's process is interrupted externally).
It's worth noting that Kobweb firing a dispose event is best effort. There is no guarantee it will be called in every situation -- for example, if the machine that your backend is running on loses power, or if the process is killed aggressively by the OS. Still, adding a dispose handler when appropriate can still often be useful, especially in development when live reloading events are very common.
SVG classes have moved
If you are a user who jumped into using SVGs early, note that all SVG methods have moved under a subpackage. If you get a compile error, please change your import from com.varabyte.kobweb.compose.dom to com.varabyte.kobweb.compose.dom.svg (that is, just add a .svg to the end of the imports)
We tried to support deprecating the old path instead of turning this into a compile error. However, this was not possible due to the large number of extension methods we have in this API.
We genuinely apologize for the inconvenience!
registerBaseStyle to registerStyleBase
While cleaning up code, we noticed that a very old method name was inconsistent with newer APIs, so we deprecated the old. This is possibly used in a lot of user's projects since it's part of the default app template.
Migrating should be trivial (it's just a rename), but we mention this here since it's likely so common.
New Contributors
We are always grateful for people who decide to brave our codebase and submit fixes. Thank you all!
- @MartinTheDragon made their first contribution in #333
- @Geanik made their first contribution in #342
- @zypus made their first contribution in #353
Full Changelog: v0.14.1...v0.14.2
