Add a font cache on non-android targets.
Android targets already have own font caching.
Fixes https://youtrack.jetbrains.com/issue/CMP-1477
## Release Notes
### Features - Resources
- To avoid constant reading raw font bytes on each Font usage on
non-android targets, there was added the font cache. Android has own
font cache inside the platform implementation.
The PR adds a generation special properties with maps a string ID to the
resource for each type of resources:
```kotlin
val Res.allDrawableResources: Map<String, DrawableResource>
val Res.allStringResources: Map<String, StringResource>
val Res.allStringArrayResources: Map<String, StringArrayResource>
val Res.allPluralStringResources: Map<String, PluralStringResource>
val Res.allFontResources: Map<String, FontResource>
```
<!-- Optional -->
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4880
Fixes https://youtrack.jetbrains.com/issue/CMP-1607
## Testing
I checked it in the sample project but this should be tested by QA (KMP
and JVM only projects)
## Release Notes
### Features - Resources
- Now the gradle plugin generates resources map to find a resource by a
string ID
Add file associations support to Compose Desktop
<!-- Optional -->
Fixes#773
## Testing
Tested on the [sample
project](https://github.com/zhelenskiy/file-associations-demo).
Behaviours per OSs:
- MacOS Sonoma: associations work for distributables.
- Windows 11: associations work after the installation of the MSI.
- Kubuntu: associations do not work, but everything else works fine.
However, IDEA also does not have associations there, so I assume this is
fine.
I didn't write any unit tests because I don’t know which of them you are
expecting me to write. So, I'm looking forward to your feedback and
suggestions.
<!-- Optional -->
This should be tested by QA
## Release Notes
<!--
Optional, if omitted - won't be included in the changelog
Sections:
- Highlights
- Known issues
- Breaking changes
- Features
- Fixes
Subsections:
- Multiple Platforms
- iOS
- Desktop
- Web
- Resources
- Gradle Plugin
-->
### Highlight - Desktop
- Introduction of the new DSL function in `nativeDistributions` block:
```kotlin
fun fileAssociation(mimeType: String, extension: String, description:
String): Unit
```
With the new API it is possible to customize compose resources
directories. For example:
```kotlin
abstract class GenerateAndroidRes : DefaultTask() {
@get:Inject
abstract val layout: ProjectLayout
@get:OutputDirectory
val outputDir = layout.buildDirectory.dir("generatedAndroidResources")
@TaskAction
fun run() {...}
}
compose.resources {
customDirectory(
sourceSetName = "androidMain",
directoryProvider = tasks.register<GenerateAndroidRes>("generateAndroidRes").map { it.outputDir.get() }
)
customDirectory(
sourceSetName = "desktopMain",
directoryProvider = provider { layout.projectDirectory.dir("desktopResources") }
)
}
```
<!-- Optional -->
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4718
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4564
## Release Notes
### Features - Resources
- Add a customization for resources directories. Now it is possible to
use e.g downloaded resources.
`rememberRipple` was deprecated:
https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Task4ValidateExamples/4656662?hideTestsFromDependencies=false&hideProblemsFromDependencies=false&expandBuildDeploymentsSection=false&expandBuildProblemsSection=true
```
e: file:///home/teamcity/agent/work/b302b5c06ec67883/examples/jetsnack/common/src/commonMain/kotlin/com/example/jetsnack/ui/components/Button.kt:94:52 '@Deprecated(...) @Composable() fun rememberRipple(bounded: Boolean = ..., radius: Dp = ..., color: Color = ...): Indication' is deprecated. rememberRipple has been deprecated - it returns an old Indication implementation that is not compatible with the new Indication APIs that provide notable performance improvements. Instead, use the new ripple APIs provided by design system libraries, such as material and material3. If you are implementing your own design system library, use createRippleNode to create your own custom ripple implementation that queries your own theme values. For a migration guide and background information, please visit developer.android.com.
```
We had two build services:
1) to check unsupported compose compiler plugins were applied
2) to check a native cache kind configuration
Both of them are outdated and we may get rid of them.
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4815
## Release Notes
### Fixes - Gradle Plugin
- Delete outdated build services
In some cases the skip and read methods may handle less bytes then
expected. The PR fixes it by proper API on the JVM and manual check on
the Android.
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4938
## Testing
I manually checked it on the project from the issue.
## Release Notes
### Fixes - Resources
- Read exactly requested count of bytes from InputStream on jvm
platforms.
Fixes#4886
## Testing
- Built the gradle plugin to mavenLocal
- used it in the reproducer of #4886, - the issue is gonve
This should be tested by QA
## Release Notes
### Fixes - Gradle Plugin
- Make sure tryGetSkikoRuntimeIfNeeded is executed only during the task
execution
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4548
## Testing
Add compose resources with name such as "package", "is" or "item_$xxx"
and check that app compiles and works fine. Accessors should be properly
escaped
## Release Notes
### Fixes - Resources
- Fix resource accessors escaping. Now it is possible to use resources
with names: "package", "is", "item_$xxx" etc
By mistake the generation resources directory was linked to "podInstall"
task instead "podspec".
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4720
## Testing
- create a new Compose App project with an iOS integration via Cocoapods
- add some multiplatform resources
- clean all caches and build dirs
- call "pod install"
- check that first run of the iOS app works fine
## Release Notes
### Fixes - Resources
- Create an empty resource dir with "podspec" task instead "podInstall"
The change speeds resources web rendering up by the reading a cached
value instantly by request (it was being dispatched to the end of the UI
queue in `LaunchedEffect`)
## Release Notes
### Features - Resources
- Speed resources web rendering up by the reading a cached value
instantly
Fixes#4863
Before this update, when a new `resource` value was passed to
`org.jetbrains.compose.resources.Font` composable, it kept the original
value.
Test sample code. `Res.font` here is autogenerated from
`commonMain/composeResources/font/` folder content.
```kt
var flag by remember {
mutableStateOf(false)
}
Column {
Text(
"hey",
fontFamily = FontFamily(Font(if (flag) Res.font.HelveticaNeueMedium else Res.font.COMICSANS, FontWeight.Normal))
)
Switch(checked = flag, onCheckedChange = { flag = it })
}
```
## Release Notes
### Fixes - Resources
- Fix a cached font if the resource acessor was changed
Changes:
- update all examples to Kotlin 2.0
- migrate to using kotlin("plugin.compose") for Compose compiler
configuration
- remove deprecated Compose Web gradle API usages
- added a workaround for
https://github.com/JetBrains/compose-multiplatform/issues/4848 in
Jetsnack example
Testing:
- `./gradlew build` in every example
- run some examples in simulators (or desktop, browser)