Releases: cashapp/redwood
0.18.0
New:
- Schema
@Widget
s can now setinternalComposable = true
to have their@Composable
functions generated as internal. This will require that you define a public version in the main sources of the module which generates the functions. This can be used to hide old widgets that should no longer be used, create more complex widget protocols away from callers, and to conditionally split implementation between two bindings, for example. - UI changes which come from Treehouse are now converted to their final value on a background thread. Previously JSON deserialization happened on the background thread to an intermediate model, but mapping that model to the final value still occurred on the main thread.
Changed:
- Schema dependencies can now be a graph (i.e., dependencies can have their own dependencies), but the entire transitive set needs to be redeclared on the root schema (for the protocol to work properly).
- Compose UI widget type has been changed from
@Composable () -> Unit
to@Composable (Modifier) -> Unit
to support unscoped modifiers. - JVM and Android artifacts now target Java 11 bytecode, as the upstream Compose dependencies now all target Java 11.
- The host protocol type has been renamed from
ProtocolFactory
toHostProtocol
. An instance ofHostProtocol
is now required when constructing aTreehouseAppFactory
. - Enforce that event properties declared in your schema always return
Unit
. - The root node's children are now identified using the tag 99,999 instead of 1. This attempts to prevent accidentally using the value for non-root nodes. The old value is still supported by the actual root node for compatibility with older guest code.
- In-development snapshots are now published to the Central Portal Snapshots repository at https://central.sonatype.com/repository/maven-snapshots/.
Fixed:
- Don't double insets on insets-aware
UIViews
. Previously we offered the same insets via two mechanisms, which could result in double insets. - Don't conflate
CrossAxisAlignment.Stretch
withContraint.Fill
. We had a bug whereCrossAxisAlignment.Stretch
would cause children to fill their parent container. - Honor the inbound max width for
Row
andColumn
layouts usingConstraint.Wrap
on iOS. This is necessary for child components that can wrap, like text. - Using "stretch" cross-axis alignment on a lazy list now works correctly in Compose UI.
Upgraded:
- Kotlin 2.2.0
- Zipline 1.21.0
0.17.0
Breaking:
- Treehouse hosts running Redwood 0.11.0 or older are not longer actively supported. They will continue to work, but they will experience indefinite memory leaks of native widgets.
- Old, deprecated overloads of
ZiplineTreehouseUi.start
have been removed. The new overloads have been available since Redwood 0.8.0 for over a year.
New:
UIConfiguration.viewInsets
tracks the safe area of the specificRedwoodView
being targeted. This is currently implemented for views on Android and UIViews on iOS.ConsumeInsets {}
composable consumes insets. Most applications should call this in their root composable function.- Add
TestRedwoodComposition.setContentAndSnapshot
function which is a fused version ofsetContent
andawaitSnapshot
, except that it guarantees the returned snapshot is the result of the initial composition of the content without any additional frames sent.
Fixed:
- Fix inconsistency in margin application between
ComposeUiBox
andViewBox
. - Add support for the Height modifier in
ComposeUiBox
. - Add support for the Width modifier in
ComposeUiBox
. - Call
DisposableEffect
when a screen is unbound. We were only calling these when the effect was removed from the composition. - Support
movableContentOf
in Treehouse (and generally in the Redwood protocol). Note: this requires the host be running version 0.17.0 or newer. - Fix case where
Column
andRow
would not update their intrinsic size on iOS if they are not a child of anotherColumn
orRow
.
0.16.0
New:
- Redwood publishes what's happening in bound content through the new
Content.State
type. - Accept a
ZiplineHttpClient
inTreehouseAppFactory
on Android.
Changed:
- Drop support for non-incremental layouts in
Row
andColumn
. - Support for
@Default
annotation has now been removed, as detailed in the 0.15.0 release.
Fixed:
- Fix a layout bug where children of fixed-with
Row
containers were assigned the wrong width. - Fix inconsistencies between iOS and Android for
Column
andRow
layouts. - Fix a layout bug where
Row
andColumn
layouts reported the wrong dimensions if their subviews could wrap. - Correctly update the layout when a Box's child's modifiers are removed.
- Fix a layout bug where children of
Box
containers were not measured properly. - Fix a bug where
LazyColumn
didn't honor child widget resizes.
Breaking:
- Replace
CodeListener
with a newDynamicContentWidgetFactory
API. Now loading and crashed views work like all other child widgets.
0.15.0
New:
- Default expressions can now be used directly in the schema rather than using the
@Default
annotation. The annotation has been deprecated, and will be removed in the next release. EventListener.Factory.close()
is called byTreehouseApp.close()
to release any resources held by the factory.- Lambda parameter names defined in the schema are now propagated to the generated composable and widget interface.
ResizableWidget
is an interface thatUIView
widgets must use if their intrinsic sizes may change dynamically. It notifies any enclosing parent views to trigger a new layout.
Changed:
- Removed Wasm JS target. We are not ready to support it yet.
Fixed:
- Breaking the last remaining retain cycle in
UIViewLazyList
. - Don't leak the
DisplayLink
when aTreehouseApp
is stopped on iOS. - Correctly handle dynamic size changes for child widgets of
Box
,Column
, andRow
. - Don't clip elements of
Column
andRow
layouts whose unbounded size exceeds the container size. - Correctly implement margins for
Box
on iOS. - Correctly handle dynamic updates to modifiers on
Column
andRow
.
0.14.0
New:
- Source-based schema parser is now the default. The
useFir
Gradle property has been removed. TreehouseAppFactory
accepts aLeakDetector
which can be used to notify you of reference leaks for native UI nodes, Zipline instances, Redwood's own internal wrappers, and more.- Introduce a
LoadingStrategy
interface to manageLazyList
preloading. - Optimize encoding modifiers in Kotlin/JS.
Changed:
- In Treehouse, events from the UI are now serialized on a background thread. This means that there is both a delay and a thread change between when a UI binding sends an event and when that object is converted to JSON. All arguments to events must not be mutable and support property reads on any thread. Best practice is for all event arguments to be completely immutable.
ProtocolFactory
interface is now sealed as arbitrary subtypes were never supported. Only schema-generated subtypes should be used.UIViewLazyList
doesn't crash with aNullPointerException
if cells are added, removed, and re-added without being reused.- Change
UiConfiguration.viewportSize
to be nullable. A nullviewportSize
indicates the viewport's size has not been resolved yet.
Fixed:
- Breaking
content: UIView
retain cycle inUIViewLazyList
'sLazyListContainerCell
. - Update
ProtocolNode
widget IDs when recycling widgets. This was causing pooled nodes to be leaked.
Breaking:
- The
TreehouseApp.spec
property is removed. Most callers should be able to useTreehouseApp.name
instead. This is necessary to avoid a retain cycle.
Upgraded:
- Kotlin 2.0.20
- Zipline 1.17.0
0.13.0
New:
- Wasm JS added as a target for common Redwood modules. There is no Treehouse support today.
- Add
onScroll
property toRow
andColumn
. This property is invoked whenoverflow = Overflow.Scroll
and the container is scrolled. - Add
Px
class to represent a raw pixel value in the host's coordinate system. - New source-based schema parser can be enabled with
redwood { useFir = true }
in your schema module. Please report and failures to the issue tracker. This parser will become the default in 0.14.0.
Changed:
- The
TreehouseApp
type is now an abstract class. This should make it easier to write unit tests for code that integrates Treehouse. - The
TreehouseApp.Spec.bindServices()
function is now suspending. - The
TreehouseAppFactory
function now accepts a ZiplineLoaderEventListener
parameter.
Fixed:
- Using a
data object
for a widget of modifier no longer causes schema parsing to crash. - Ensuring
LazyList
'sitemsBefore
anditemsAfter
properties are always within[0, itemCount]
, to preventIndexOutOfBoundsException
crashes. - Don't crash in
LazyList
when a scroll and content change occur in the same update. - Updating a flex container's margin now works correctly for Yoga-based layouts.
Breaking:
- The
TreehouseApp.Factory.dispatchers
property is removed, and callers should migrate toTreehouseApp.dispatchers
. With this update eachTreehouseApp
has its own private thread so a shareddispatchers
property no longer fits our implementation.
-TreehouseApp.Spec.bindServices()
now accepts aTreehouseApp
parameter.
Upgraded:
- Zipline 1.16.0
0.12.0
New:
- Upgrade to Kotlin 2.0!
- Added a basic DOM-based
LazyList
implementation. TreehouseApp.close()
stops the app and prevents it from being started again later.- Added
UiConfiguration.layoutDirection
to support reading the host's layout direction. - New
redwood-bom
artifact can be used to ensure all Redwood artifacts use the same version. See Gradle's documentation on how to use the BOM in your build.
Changed:
- The
app.cash.redwood
Gradle plugin has been removed. This plugin did two things: apply the Compose compiler and add a dependency on theredwood-compose
artifact. The Compose compiler can now be added by applying theorg.jetbrains.kotlin.plugin.compose
Gradle plugin. Dependencies on Redwood artifacts can be added manually. - Removed deprecated
typealias
es for generated-WidgetFactories
type which was renamed to-WidgetSystem
in 0.10.0. - Removed deprecated
Modifier.flex
extension function which is now supported natively byRow
andColumn
since 0.8.0. - Removed deprecated
TreehouseWidgetView
andTreehouseUIKitView
type aliases forTreehouseLayout
andTreehouseUIView
which were renamed in 0.7.0. - Removed deprecated
TreehouseAppFactory
functions with the oldFileSystem
andPath
order which were changed in 0.11.0. - Rename the two types named
ProtocolBridge
toProtocolHost
andProtocolGuest
.
Fixed:
- Fix memory leaks caused by reference cycles on iOS. We got into trouble mixing garbage-collected Kotlin objects with reference-counted Swift objects.
Breaking:
TreehouseApp.zipline
is now aStateFlow<Zipline?>
instead of aZipline?
.CodeListener.onCodeDetached()
replacesonUncaughtException()
. The new function is called
whenever code stops driving a view for any reason. The new function accepts aThrowable?
that is
non-null if it's detached due to exception.Content.awaitContent()
now accepts an optionalInt
parameter for the number of updates to
observe before the function returns.- MacOS targets have been (temporarily) removed from all modules.
Upgraded:
- Kotlin 2.0.0
- Zipline 1.13.0
- kotlinx.serialization 1.7.0
Gradle plugin removed
This version of Redwood 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 app.cash.redwood
plugin should be changed to apply org.jetbrains.kotlin.plugin.compose
instead.
The Redwood dependencies will no longer be added as a result of the plugin change, and so any module which references Redwoods APIs should add those dependencies explicitly.
For posterity, the Kotlin version compatibility table and compiler version customization for our old Redwood Gradle plugin will be archived here:
Redwood 0.12.0 Gradle plugin Kotlin compatibility table
Since Kotlin compiler plugins are an unstable API, certain versions of Redwood only work with
certain versions of Kotlin.
Kotlin | Redwood |
---|---|
1.9.24 | 0.11.0 |
1.9.23 | 0.10.0 |
1.9.22 | 0.8.0 - 0.9.0 |
1.9.10 | 0.7.0 |
1.9.0 | 0.6.0 |
1.8.22 | 0.5.0 |
1.8.20 | 0.3.0 - 0.4.0 |
1.7.20 | 0.1.0 - 0.2.1 |
Redwood 0.12.0 Gradle plugin Compose compiler customization instructions
Each version of Redwood 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:
redwood {
kotlinCompilerPlugin.set("1.4.8")
}
To use an alternate Compose compiler dependency:
redwood {
kotlinCompilerPlugin.set("com.example:custom-compose-compiler:1.0.0")
}
0.11.0
New:
- Added
toDebugString
method forWidgetValue
andList<WidgetValue>
which returns a formatted string of a widget's children and properties, useful for test debugging.
Changed:
- Removed generated
typealias
es for package names which changed in 0.10.0. - In
UIViewLazyList
'sUITableView
, adding special-case handling for programmatic scroll-to-top calls. - APIs accepting a
FileSystem
andPath
now have theFileSystem
coming before thePath
in the parameter list. Compatibility functions are retained for this version, but will be removed in the next version.
Fixed:
- Work around a problem with our memory-leak fix where our old LazyList code would crash when its placeholders were unexpectedly removed.
- Avoid calling into the internal Zipline instance from the UI thread on startup. This would manifest as weird native crashes due to multiple threads mutating shared memory.
- In
UIViewLazyList
, fixUInt
toUIColor
conversion math used forpullRefreshContentColor
. - In
YogaUIView
'ssetScrollEnabled
method, only callsetNeedsLayout
if thescrollEnabled
value is actually changing. - In
YogaUIView
'slayoutNodes
method, return early for nestedYogaUIView
s to prevent redundant frame calculations.
Upgraded:
- Zipline 1.10.1.
This version works with Kotlin 1.9.24 by default.
0.10.0
New:
- Compose UI implementation for
Box
. - Layout modifier support for HTML DOM layouts.
- Unscoped modifiers provide a global hook for side-effecting behavior on native views. For example, create a background color modifier which changes the platform-native UI node through a factory function.
Widget.Children
interface now exposeswidgets: List<Widget<W>>
property. Most subtypes were already exposing this individually.
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).
onModifierChanged
callback inWidget.Children
now receives the index and theWidget
instance affected by the change.- The package of 'redwood-protocol-host' changed to
app.cash.redwood.protocol.host
. This should not affect end-users as its types are mostly for internal use. - The entire
redwood-yoga
artifact's public API has been annotated with an opt-in annotation indicating that it's only for Redwood internal use and is not stable. - Revert: Don't block touch events to non-subviews below a
Row
,Column
, orBox
in the iOSUIView
implementation. This matches the behavior of the Android View and Compose UI implementations. - The generated "widget factories" type (e.g.,
MySchemaWidgetFactories
) is now called a "widget system" (e.g.,MySchemaWidgetSystem
). Sometimes it was also referred to as a "provider" in parameter names. A@Deprecated typealias
is generated for now, but will be removed in the future. - The package names of some generated code has changed. Deprecated
typealias
es are generated in the old locations for public types and functions, but those will be removed in the next release.- Testing code is now under
your.package.testing
. - Protocol guest code is now under
your.package.protocol.guest
. - Protocol host code is now under
your.package.protocol.host
.
- Testing code is now under
- The 'app.cash.redwood.generator.compose.protocol' and 'app.cash.redwood.generator.widget.protocol' Gradle plugins are now deprecated and will be removed in the next release. Use 'app.cash.redwood.generator.protocol.guest' and 'app.cash.redwood.generator.protocol.host', respectively.
- The 'redwood-tooling-codegen' CLI flags for protocol codegen have changed from
--compose-protocol
and--widget-protocol
to--protocol-guest
and--protocol-host
, respectively. - Entrypoints to the protocol on the host-side and guest-side now require supplying the version of Redwood in use on the other side in order to ensure compatibility and work around any bugs in older versions. This uses a new
RedwoodVersion
type, and will be automatically wired if using our Treehouse artifacts.
Fixed:
- Fix failure to release JS resources when calling
CoroutineScope
is being cancelled - JVM targets now correctly link against Java 8 APIs. Previously they produced Java 8 bytecode, but linked against the compile JDK's APIs (21). This allowed linking against newer APIs that might not exist on older runtimes, which is no longer possible. Android targets which also produce Java 8 bytecode were not affected.
- Fix the
View
implementation ofBox
to wrap its width and height by default. This matches the behavior of theUIView
implementation and all other layout widgets. - Fix the
UIView
implementation ofBox
not updating when some of its parameters are changed. - Fix
Modifier.size
not being applied to children inside aBox
. - Fix
Margin
not being applied to theUIView
implementation ofBox
. - The
View
implementation ofBox
now applies start/end margins correctly in RTL, and does not crash if set before the native view was attached. - Fix the backgroundColor for
UIViewLazyList
to be transparent. This matches the behavior of the otherLazyList
platform implementations. - Fix
TreehouseUIView
to size itself according to the size of its subview. - In
UIViewLazyList
, addingbeginUpdates
/endUpdates
calls toinsertRows
/deleteRows
, and wrapping changes inUIView.performWithoutAnimation
blocks. - Fix memory leak in 'protocol-guest' and 'protocol-host' where child nodes beneath a removed node were incorrectly retained in an internal map indefinitely. The guest protocol code has been updated to work around this memory leak when deployed to old hosts by sending individual remove operations for each node in the subtree.
- Ensure that Zipline services are not closed prematurely when disposing a Treehouse UI.
- In
UIViewLazyList
, don't remove subviews from hierarchy duringprepareForReuse
call
0.9.0
Changed:
- Added
Modifier
parameter toRedwoodContent
which is applied to the rootBox
into which content is rendered (https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-api-guidelines.md#elements-accept-and-respect-a-modifier-parameter). - The parameter order of
LazyRow
andLazyColumn
have changed to reflect Compose best practices (https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-api-guidelines.md#elements-accept-and-respect-a-modifier-parameter). - The parameter order of
TreehouseContent
has changed to reflect Compose best practices (https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-api-guidelines.md#elements-accept-and-respect-a-modifier-parameter). - The render function of
ComposeWidgetChildren
has been renamed toRender
to reflect Compose best practices (https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-api-guidelines.md#naming-unit-composable-functions-as-entities). - 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.
Fixed:
- Don't block touch events to non-subviews below a
Row
,Column
, orBox
in the iOSUIView
implementation. This matches the behavior of the Android View and Compose UI implementations.
This version works with Kotlin 1.9.22 by default.