Skip to content

Releases: PurpleKingdomGames/tyrian

0.5.0

01 Jun 22:04
Compare
Choose a tag to compare

Http Client Overhaul

This release is a fast follow up to 0.4.0, which unfortunately contained a defect in the Http client implementation.

While the defect was being addressed, the entire Http client implementation was revisited, cleaned up, and simplified.

Please read the 0.4.0 release notes for the full picture!

Full Changelog: v0.4.0...v0.5.0

0.4.0

29 May 22:28
Compare
Choose a tag to compare

Notice: Bad release, do not use. Upgrade to 0.5.0 instead.

Unfortunately, despite all the good stuff in this release, a nasty bug in the Http client somehow slipped through. A new release will be arriving very soon to replace this one. The release notes below are still valid otherwise.


The quiet hero of this release is @armanbilge, who patiently steered the Cats Effect work through to completion, helped answer all my daft questions, and put up with a lot of grumpiness while I got my head around it. Thank you sir!

Details of new features:

New Build Target Versions:

Scala.js 1.10.0

Scala 3.1.2

Scala.js Snabbdom AKA ‘No More NPM!’

Until now, Tyrian has been reliant on a well known JavaScript library called Snabbdom to handle its VirtualDom based rendering.

Then @buntec turned up with a plan to re-implement Snabbdom - once again in collaboration with @armanbilge - directly in Scala.js for their own nefarious purposes. They’ve done an amazing job, and I’m super excited to be able to utilise the fruits of their labor!

Tyrian now depends purely on normal Scala dependencies, and no NPM libs for its core functionality. True, you may (probably will) still need to bring in NPM deps for further functionality, but I think this is a very exciting step towards a future where frontend dev in Scala.js is not reliant on the NPM ecosystem.

Exciting times!

Cats Effect 3.0

Tyrian started life as a library called Scalm, which was written and abandoned many years ago.

Part of the original implementation was a perfectly functional effect type called Task. Task was specialised to the JS ecosystem and to the needs of Scalm. There was really nothing wrong with it except that in the years since it was created, effect types have come a long way, and people have certain expectations about how they should behave.

Task is gone, and Tyrian now uses Cats Effect 3.0 to handle its side effects. In theory, Tyrian does not care which effect type you favour, but at the time the work was done the only compatible (or possibly just published?) type seemed to be IO. Very happy to add support for other effect types - PRs welcome!

The upshot of all this work is that while Tyrian largely feels the same in terms of being ‘friendly-FP’, it is now much more serious about its ability to encode and manage side effects and effectful computations.

Important performance note! There is now a significant performance difference between fastOpt and fullOpt when compiling to JavaScript. Cats Effect and FS2 have many layers of abstraction, so fastOpt produced code is noticeably slower than the fullOpt equivalent. CE3 also enables tracing and fiber dumps by default in fastOpt, but removes them completely in fullOpt. You can disable this by adding the following global variable to your HTML page.

<script type="text/javascript">
    var process = { env: { 'CATS_EFFECT_TRACING_MODE': 'NONE' } };
</script>

SVG Tags

This release of Tyrian adds support for a range of SVG tags and SVG specific attributes. Previously you would have needed to describe the tags manually… but not any more thanks to @JPonte!

What's Changed

New Contributors

Full Changelog: v0.3.2...v0.4.0

0.3.2

05 Mar 15:16
Compare
Choose a tag to compare

This release is largely thanks to @gvolpe's feedback and contributions, based on converting an existing Elm app to Tyrian.

Details of new features:

New Build Target Versions:

Scala.js 1.9.0
Scala 3.1.1

Input field focus/blur

Taking inspiration from Elm’s Browser.Dom package, we’ve added commands that allow you to tell the browser to focus or blur (un-focus) input elements.

WebSocket overhaul

Release 0.3.0 added simple WebSocket support, known to be naive but intended as a reasonable placeholder. This release improves WebSockets in a number of ways, adding support for keep-alive, graceful shutdowns, and a better API.

The WebSocket example has had it's implementation updated accordingly.

Hot-reloading support

Hot-reloading is the process of noticing a file change, say after a re-compile, updating the app and automatically refreshing the browser. Many bundlers like Parcel.js and Webpack come with dev-servers that perform this function out of the box. What they do not do is continue your app from exactly where you left off, because they have no way to capture your application's running state, and restore it after reload. This release of Tyrian adds a dead simple HotReload convenience module with a command to snapshot and store your app’s state and then restore it again on start-up, provided you supply a serialisation method.

Hash/Anchor based Navigation

In a step towards frontend routing, this release adds the ability to navigate around your SPA based on the url hash (anchor).

Local storage support

A series of commands have been added that expose the browser’s local storage API.

Summary of other changes:

Bug fixes

  • Fixed #55 - BUG: value attribute is unusable (broken DSL syntax)
  • Fixed #60: Values are properties, not attributes (certain attributes must be declared as properties rather than attributes in order for them to work in the expected way)

Other Improvements

  • ‘No value’ attributes can be set with a predicate, e.g. div(hidden(true))(..) - which is handy for inlining presentation decisions.

What's Changed

New Contributors

Full Changelog: v0.3.1...v0.3.2

0.3.1

20 Feb 14:37
Compare
Choose a tag to compare

This release is a quick follow up to 0.3.0 last week, which was perfectly fine to use.

The changes are:

  • Upgrade to Scala.js 1.9.0 - You will need to upgrade your project
  • Improved Random Cmd behaviour to make it more user friendly
  • Use the latest version of Indigo, 0.12.1.

Please see the release notes for 0.3.0 as this was the major release and contained many more improvements.


What's Changed

Full Changelog: v0.3.0...v0.3.1

0.3.0

14 Feb 00:22
Compare
Choose a tag to compare

Details of the major changes:

New Build Target Versions:

Scala.js 1.8.0

Scala 3.1.1

Tyrian 💜’s Indigo

This release brings native Indigo support to Tyrian. If you’ve ever wanted to build a Single Page App (SPA) with an HTML rendered UI that communicates directly with an Indigo game, now you can.

Your Indigo games can live in the exact same code base as your SPA, and be launched via completely ordinary Scala calls. Communication between Tyrian and Indigo is handled by a pub/sub system. Indigo runs a provided SubSystem and Tyrian holds a bridge instance that between them allows you to send ordinary Scala values / data types seamlessly between the two systems.

Please see the examples.

Server-side Rendering (SSR)

This release introduces simple SSR to Tyrian. What this means is that you can use Tyrian’s html syntax to render HTML in your JVM Scala web service, as if it were a templating engine. You can even reuse the views from your SPA’s if you like. SSR supports both full page and page fragment rendering.

WebSocket support

At long last, simple WebSocket support has been added! This implementation will almost certainly not be good enough for all but simple use-cases, but it establishes the pattern and gives us a starting point for future work. If you have a real use case, please let us know and we’ll be happy to help improve support in this area.

TyrianApp

Previous versions of Tyrian were launched straight from a main method, and this was ok for simple use cases. If you want to produce anything cleverer, then you need to be able to tell the app which element to attach itself to, and to pass it over start up flags.

Tyrian is now much more like it’s sibling Indigo, for better or worse. To create a Tyrian app you now extend TyrianApp[Msg, Model] and the compiler will tell you what needs to be implemented. You get the ability to pass in flags during init and you launch the app in JavaScript by calling launch, e.g.: TyrianApp.launch("myapp", {"message": "Hello, Tyrian!"});

One benefit of bringing Indigo and Tyrian together here is that if we figure out how to improve one, we can apply it to the other.

Basic CSS Property generation

Tyrian has long generated all it’s HTML tags and attributes, and it now also generates basic CSS properties.

Breaking Change: Removed Cats Dependency

Cats-core was playing a superficial role in Tyrian, adding syntax options for one or two types, helping massage the code in a couple of places, but doing no serious heavy lifting. As such it has been dropped.

This doesn’t mean that Cats couldn’t / wouldn’t be brought back if there was a good reason to do so, but Tyrian - like Indigo - is a sort of minimally opinionated FP-first solution. FP is strongly encouraged, but we keep it light and open. There is nothing to stop you using Cats or any other library with Tyrian if you like.

Breaking Change: Removed Snabbdom hook support

This probably won’t affect anyone, but Snabbdom supports the notion of Hooks - essentially freestyle html rendering - that are incompatible with our future plans, and so support for Hooks has been dropped.

Breaking Change: Attribute syntax

Any tag that supports plain text, will now accept plain text, e.g. <p>Hello</p> used to be written as p(text("Hello")), which was boring, and can now be written as p("Hello").

This looks great but presents a problem for things like title, is title("my title") a title tag or an attribute? Scala’s compiler can’t tell.

To disambiguate and also because it looks nicer and is consistent with other Scala libraries, attributes are now constructed using :=. So title := "my title" is an attribute, and title("my title") is an HTML tag.

Summary of other changes:

Breaking changes

  • Removed Cats.
  • Removed Snabbdom hook support
  • Attributes are now constructed using :=
  • Removed "simple" Tyrian constructor - you must now extend TyrianApp

Other Improvements

  • Added Sub.Batch to mirror Cmd.Batch
  • Sub+Cmd now support Indigo-style combine operator
  • Added Http.Decoder.asString
  • Allow strings as tag contents
  • Added Sub.emit - emit a message once
  • WebSocket support

Also includes other small improvements, performance enhancements, and docs not listed here.


What's Changed

New Contributors

Full Changelog: v0.2.1...v0.3.0

0.2.1

12 Nov 09:34
Compare
Choose a tag to compare

Development status: Alpha - expect further breaking changes.

This release is essentially just a version bump to bring Tyrian up to date with the latest Scala and Scala.js releases. There have been other minor improvements but nothing noticeable from a user perspective.

However! Since Scala 3.1.0 and Scala.js 1.7.1 are only forwards compatible, this release should arguably have been 0.3.0. Please remember to update your projects Scala and Scala.js versions.

0.2.0

05 Jul 22:14
Compare
Choose a tag to compare

Development status: Alpha - expect further breaking changes.

0.1.0 was a simple re-release of Scalm.

This release is the result of actually using Tyrian in anger to build a few (admittedly small/demo/toy) websites.

This release expands the APIs with regard to HTML tags and attributes, and also the usefulness of commands.

Tags & Attributes

Generated a complete list of tags and attributes for view building.

New Cmd Types

  • Emit - no side effect, emit a message.
  • SideEffect - Fire and forget side effect execution
  • Run - Essentially a way to create a RunTask without explicitly making the Task.
  • Combine - Combine two Cmds together (product)
  • Batch - Represents a list of commands to run.

New Built-in Cmds

  • Logger - Simple side effecting cmd that logs to the console.
  • Random - Generate a random value
  • ImageLoader - Given a path, load an image.
  • FileLoader - handles the result of a file input selection (text and images)

Other changes

  • Changed the Http Cmd syntax
  • Swapped Seq for List everywhere

0.1.0

06 Jun 17:36
Compare
Choose a tag to compare

Development status: Alpha - expect further breaking changes.

This is the first release of Tyrian, which is itself largely a re-release of Scalm by @julienrf, fully converted to Scala 3.

In this release, all dependancies have been brought up to date, more examples have been added, and some of the APIs have been massaged or expanded.