Releases: JakeWharton/mosaic
0.18.0
New:
- JVM artifacts can now be used as modules in the Java module system.
- On Java 22 and newer, Mosaic now uses the foreign function & memory API to call into its native library instead of JNI.
Changed:
- Unsolicited focus, theme, and resize events are now ignored unless the terminal has reported that it supports each of those modes.
This should have no real impact on anything, except that now theTerminal.capabilitiesvalue can now be trusted to indicate whetherTerminal.statewill ever change in the case of focus and theme.
For terminal size, a platform-specific fallback exists which will attempt to still correctly report the size, but asynchronously. - Terminal theme is now always queried for an initial value regardless of whether the terminal supports sending theme changes.
- Java 11 is now the minimum-supported JVM version.
- In-development snapshots of Mosaic are now published to the Central Portal Snapshots repository at https://central.sonatype.com/repository/maven-snapshots/.
Fixed:
- Windows now reports the terminal size correctly. Previously it reported the buffer size instead of the window size.
- Windows Terminal and ConEmu are now correctly detected as supporting color.
0.17.0
New:
TerminalandLocalTerminalare now renamed toTerminalStateandLocalTerminalState, respectively, along with some new capabilities:- Add
focusedboolean which defaults to true. If the terminal supports sending focus changes, this will be updated in real time. - Add
themeproperty which defaults to 'unknown'. If the terminal supports querying theme state, this will be 'light' or 'dark' and be updated in real time. Note: this is not the OS theme, but instead reflects the theme of the terminal color scheme. - Size property now features the size in pixels in addition to cells. These values will be 0 if unsupported by the terminal.
- Add
- Bind
TerminalState.focusedto aLifecycleand expose into the composition asLocalLifecycleOwner. This allows using Compose lifecycle helpers such asLifecycleResumeEffectand others. - Fancy underline styles (single, double, dashed, dotted, curved) and colors can now be specified for text and annotated string spans.
LocalStaticLoggercomposition local provides access toStaticLoggerwhich allows logging plain strings at arbitrary points for inclusion in the next frame. This can be used from effects, callback, state classes, etc. Support for loggingAnnotatedStrings will come in a future release.runMosaicMainfunction replaces the existingrunMosaicBlockingfor use specifically infun main()or main-like scenarios.
Changed:
- Switched to our own terminal integration and parsing library. Report any issues with keyboard input, incorrect size reporting, or garbled output. This unlocks many of the features listed above, as well as many more planned in the future.
- Only disable the cursor and emit synchronized rendering markers if the terminal reports support for those features.
Staticfunction is now calledStaticEffectto better indicate that it only renders its content once.runMosaicandrunMosaicBlockingnow accept aNonInteractivePolicyargument which dictates the behavior when Mosaic cannot connect directly to the TTY.
Fixed:
- Prevent final character from being erased when a row writes into the last column of the terminal.
- Do not emit ANSI style reset escape sequence when colors are disabled (such as in testing).
- Do not draw blank spaces at the end of every line.
Removed:
renderMosaicwas removed without replacement. As the capabilities of the library grow, supporting a string as a render target was increasingly difficult.
0.16.0
New:
- Add
setContentAndSnapshotto 'mosaic-testing' which returns the initial composition snapshot. This avoids a potential problem with callingsetContentand thenawaitSnapshotsince the latter will trigger a subsequent recomposition (if needed), preventing observation of the initial state.
Changed:
Staticcomposable no longer takes a list. Instead, it behaves like a normal composable which only renders its function once.- Drop use of Jansi library for supporting ANSI color output on Windows.
0.15.0
New:
- Create
mosaic-animationlibrary, that provides various possibilities for animating Mosaic. An analog of androidx.compose.animation-core. - Add
IntrinsicSizeand relatedModifier.width/height/requiredWidth/requiredHeight. - New
mosaic-testinglibrary for deterministically rendering Mosaic composables under test. - Add
Mosaic.layoutIdwhich allows identifying the element within its parent during layout. - Add
Modifier.composedthat allows creating custom reusable modifiers with access to Compose functionality inside.
Changed:
- Rendering now occurs as fast as possible, although still only when necessary. Previously the maximum FPS was capped to 20, which could cause minor visual delays when processing events.
Fixed:
- Fix the handling of custom
Modifiers that have multiple parents fromLayoutModifier,DrawModifier,KeyModifier,ParentDataModifier.
0.14.0
New:
- Support synchronized terminal update for rendering. This should eliminate tearing when rendering updates for terminals that support this feature.
- The terminal cursor is now automatically hidden during rendering and restored afterward.
- Added
Modifier.onKeyEventorModifier.onPreKeyEventto listen to keyboard events. - Send real frame times into Compose which can be used for things like animations.
Changed:
- The entrypoints (
runMosaicandrunMosaicBlocking) have been changed to directly accept a composable lambda. Asynchronous work should now be performed inside Compose's effect system (e.g.,LaunchedEffect), and rendering will complete when all effects have completed. Check out our samples for more information about how to do this. - Π‘hange
DrawScope#drawRectAPI with the ability to draw with text characters and specifyDrawStyle(FillorStroke). - Drop support for JS target. If you were using this, please file an issue so we can discuss support.
0.13.0
New:
- Support Kotlin 2.0.0!
Changed:
- Remove our Gradle plugin in favor of JetBrains' (see below for more).
Note: Version 0.12.0 was also released today, but it still supports Kotlin 1.9.24.
Check out its release entry for more on what's new.
Gradle plugin removed
This version of Mosaic removes the custom Gradle plugin in favor of the official JetBrains Compose compiler plugin which ships as part of Kotlin itself.
Each module in which you had previously applied the com.jakewharton.mosaic plugin should be changed to apply org.jetbrains.kotlin.plugin.compose instead.
The Mosaic runtime will no longer be added as a result of the plugin change, and so any module which references Mosaic APIs should apply the com.jakewharton.mosaic:mosaic-runtime dependency.
For posterity, the Kotlin version compatibility table and compiler version customization for our old Mosaic Gradle plugin will be archived here:
Mosaic 0.12.0 Gradle plugin Kotlin compatibility table
Since Kotlin compiler plugins are an unstable API, certain versions of Mosaic only work with
certain versions of Kotlin.
| Kotlin | Mosaic |
|---|---|
| 1.9.24 | 0.12.0 |
| 1.9.22 | 0.11.0 |
| 1.9.20 | 0.10.0 |
| 1.9.10 | 0.9.1 |
| 1.9.0 | 0.8.0 - 0.9.0 |
| 1.8.22 | 0.7.1 |
| 1.8.21 | 0.7.0 |
| 1.8.20 | 0.6.0 |
| 1.8.10 | 0.5.0 |
| 1.8.0 | 0.3.0 - 0.4.0 |
| 1.7.10 | 0.2.0 |
| 1.5.10 | 0.1.0 |
Mosaic 0.12.0 Gradle plugin Compose compiler customization instructions
Each version of Mosaic ships with a specific JetBrains Compose compiler version which works with
a single version of Kotlin (see version table above). Newer versions of the Compose
compiler or alternate Compose compilers can be specified using the Gradle extension.
To use a new version of the JetBrains Compose compiler version:
mosaic {
kotlinCompilerPlugin.set("1.4.8")
}To use an alternate Compose compiler dependency:
mosaic {
kotlinCompilerPlugin.set("com.example:custom-compose-compiler:1.0.0")
}0.12.0
New:
- Add
linuxArm64target. - Add
rrtopsample. - Support true color palette.
Changed:
- Disable klib signature clash checks for JS compilations. These occasionally occur as a result of Compose compiler behavior, and are safe to disable (the first-party JetBrains Compose Gradle plugin also disables them).
- Remove
Terminal$Sizeand useIntSizeinstead inTerminal#sizefor optimization purposes. - Remove
Color.Bright*constants. UseColorfunction to create the desired color. - Replace nullable
ColorandTextStylewithColor.UnspecifiedandTextStyle.Unspecifiedrespectively. Also makeTextStylean inline class.
Fixed:
- Use CRLF line endings to fix rendering when a terminal is in raw mode.
0.11.0
New:
- Support Kotlin 1.9.22 via JetBrains Compose compiler 1.5.10.
Fillercomposable is like aSpacerbut fills its area with a character instead of a space.Boxwithout content provides the ability to render using drawing modifiers without needing an empty chidlren lambda.Modifier.aspectRatioattempts to constrain a composable to an aspect ratio in either the vertical or horizontal direction.Modifier.offsetoffsets the composable in its parent by the given coordinates.Modifier.fillMaxWidth,Modifier.fillMaxHeight,Modifier.fillMaxSize,Modifier.wrapContentWidth,Modifier.wrapContentHeight,Modifier.wrapContentSize, andModifier.defaultMinSizehelp size composable measurement in relation to their parent.Modifier.weightallows sizing a composable proportionally to others within the same parent.RowandColumneach feature an arrangement parameter which controls the placement of children on the main axis of the container.
Changed:
Modifierparameter is now universally calledmodifierin the API.- Disable decoy generation for JS target to make compatible with JetBrains Compose 1.6. This is an ABI-breaking change, so all Compose-based libraries targeting JS will also need to have been recompiled.
Fix:
- Ensure ANSI control sequences are written properly to Windows terminals.
- Robot sample now correctly moves on Windows.
This version works with Kotlin 1.9.22 by default.
0.10.0
New:
-
Support Kotlin 1.9.20 via JetBrains Compose compiler 1.5.3.
-
@MosaicComposableannotation restricts composable function usage to those meant for Mosaic
(e.g., ourText) or general-purpose (e.g., Compose'sremember). In most cases the Compose
compiler can infer this automatically, but it's available for explicit use if needed. -
LocalTerminalcomposition local provides the size of the terminal if it can be detected.
If the size changes, your function will automatically be recomposed with the new values.val size = LocalTerminal.current.size Text("Terminal(w=${size.width}, h=${size.height})")
-
Row,Column, andBoxnow support horizontal and vertical alignment of their children.Column { Text("This is very long") Text( "On the right", modifier = Modifier.align(End), ) }
-
Add
AnnotatedStringwithSpanStylefor string customization. Instead of writing a series of
Textfunctions in aRow, emit a singleTextwith formatting changes within the string.Text(buildAnnotatedString { append("Plain! ") withStyle(SpanStyle(color = BrightGreen)) { append("Green! ") } withStyle(SpanStyle(color = BrightBlue)) { append("Blue!") } })
-
Spacernode for occupying space within layouts. -
Constraints and intrinsics are now available in the layout system.
This version works with Kotlin 1.9.20 by default.
0.9.1
New:
- Support Kotlin 1.9.10 via JetBrains Compose compiler 1.5.2.
This version works with Kotlin 1.9.10 by default.
