From f405dd8ba07b16c2e9ec5699ce99cfae9cb45ae2 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 19 Jan 2024 13:48:43 +0100 Subject: [PATCH] Delete experimental marker from stable resources APIs (#4144) --- .../compose/resources/ComposeResourceTest.android.kt | 2 +- .../jetbrains/compose/resources/FontResources.android.kt | 1 - .../kotlin/org/jetbrains/compose/resources/FontResources.kt | 2 +- .../org/jetbrains/compose/resources/ImageResources.kt | 4 +--- .../org/jetbrains/compose/resources/ResourceReader.kt | 1 - .../org/jetbrains/compose/resources/StringResources.kt | 6 ------ .../compose/resources/ComposeResourceTest.desktop.kt | 2 +- .../org/jetbrains/compose/resources/ResourceReader.ios.kt | 1 - .../compose/resources/ResourceReader.jvmAndAndroid.kt | 1 - .../org/jetbrains/compose/resources/ResourceReader.macos.kt | 1 - .../org/jetbrains/compose/resources/FontResources.skiko.kt | 1 - .../src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt | 1 - 12 files changed, 4 insertions(+), 19 deletions(-) diff --git a/components/resources/library/src/androidInstrumentedTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.android.kt b/components/resources/library/src/androidInstrumentedTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.android.kt index 7c4441a9e1..83c36d588e 100644 --- a/components/resources/library/src/androidInstrumentedTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.android.kt +++ b/components/resources/library/src/androidInstrumentedTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.android.kt @@ -12,7 +12,7 @@ import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith -@OptIn(ExperimentalResourceApi::class, ExperimentalTestApi::class) +@OptIn(ExperimentalTestApi::class) class ComposeResourceTest { @Before diff --git a/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/FontResources.android.kt b/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/FontResources.android.kt index 46212bb3dc..50891efb49 100644 --- a/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/FontResources.android.kt +++ b/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/FontResources.android.kt @@ -5,7 +5,6 @@ import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.font.* -@ExperimentalResourceApi @Composable actual fun Font(resource: FontResource, weight: FontWeight, style: FontStyle): Font { val environment = LocalComposeEnvironment.current.rememberEnvironment() diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/FontResources.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/FontResources.kt index 657d6d4dae..e060f02f56 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/FontResources.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/FontResources.kt @@ -21,6 +21,7 @@ class FontResource(id: String, items: Set): Resource(id, items) * @param path The path to the font resource file. * @return A new [FontResource] object. */ +@ExperimentalResourceApi fun FontResource(path: String): FontResource = FontResource( id = "FontResource:$path", items = setOf(ResourceItem(emptySet(), path)) @@ -37,7 +38,6 @@ fun FontResource(path: String): FontResource = FontResource( * * @throws NotFoundException if the specified resource ID is not found. */ -@ExperimentalResourceApi @Composable expect fun Font( resource: FontResource, diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt index 0dfc5c034d..0545f178a5 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt @@ -29,6 +29,7 @@ class DrawableResource(id: String, items: Set) : Resource(id, item * @param path The path of the drawable resource. * @return An [DrawableResource] object. */ +@ExperimentalResourceApi fun DrawableResource(path: String): DrawableResource = DrawableResource( id = "DrawableResource:$path", items = setOf(ResourceItem(emptySet(), path)) @@ -41,7 +42,6 @@ fun DrawableResource(path: String): DrawableResource = DrawableResource( * @param resource The drawable resource to be used. * @return The [Painter] loaded from the resource. */ -@ExperimentalResourceApi @Composable fun painterResource(resource: DrawableResource): Painter { val environment = LocalComposeEnvironment.current.rememberEnvironment() @@ -62,7 +62,6 @@ private val emptyImageBitmap: ImageBitmap by lazy { ImageBitmap(1, 1) } * @param resource The drawable resource to be used. * @return The ImageBitmap loaded from the resource. */ -@ExperimentalResourceApi @Composable fun imageResource(resource: DrawableResource): ImageBitmap { val resourceReader = LocalResourceReader.current @@ -86,7 +85,6 @@ private val emptyImageVector: ImageVector by lazy { * @param resource The drawable resource to be used. * @return The ImageVector loaded from the resource. */ -@ExperimentalResourceApi @Composable fun vectorResource(resource: DrawableResource): ImageVector { val resourceReader = LocalResourceReader.current diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt index c8d7f9ac1a..044a6f5a84 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt @@ -2,7 +2,6 @@ package org.jetbrains.compose.resources import androidx.compose.runtime.staticCompositionLocalOf -@ExperimentalResourceApi class MissingResourceException(path: String) : Exception("Missing resource with path: $path") /** diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResources.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResources.kt index 527d337393..c80c9488b4 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResources.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResources.kt @@ -69,7 +69,6 @@ private suspend fun parseStringXml(path: String, resourceReader: ResourceReader) * * @throws IllegalArgumentException If the provided ID is not found in the resource file. */ -@ExperimentalResourceApi @Composable fun stringResource(resource: StringResource): String { val resourceReader = LocalResourceReader.current @@ -87,7 +86,6 @@ fun stringResource(resource: StringResource): String { * * @throws IllegalArgumentException If the provided ID is not found in the resource file. */ -@ExperimentalResourceApi suspend fun getString(resource: StringResource): String = loadString(resource, DefaultResourceReader, getResourceEnvironment()) @@ -112,7 +110,6 @@ private suspend fun loadString( * * @throws IllegalArgumentException If the provided ID is not found in the resource file. */ -@ExperimentalResourceApi @Composable fun stringResource(resource: StringResource, vararg formatArgs: Any): String { val resourceReader = LocalResourceReader.current @@ -132,7 +129,6 @@ fun stringResource(resource: StringResource, vararg formatArgs: Any): String { * * @throws IllegalArgumentException If the provided ID is not found in the resource file. */ -@ExperimentalResourceApi suspend fun getString(resource: StringResource, vararg formatArgs: Any): String = loadString( resource, formatArgs.map { it.toString() }, @@ -160,7 +156,6 @@ private suspend fun loadString( * * @throws IllegalStateException if the string array with the given ID is not found. */ -@ExperimentalResourceApi @Composable fun stringArrayResource(resource: StringResource): List { val resourceReader = LocalResourceReader.current @@ -178,7 +173,6 @@ fun stringArrayResource(resource: StringResource): List { * * @throws IllegalStateException if the string array with the given ID is not found. */ -@ExperimentalResourceApi suspend fun getStringArray(resource: StringResource): List = loadStringArray(resource, DefaultResourceReader, getResourceEnvironment()) diff --git a/components/resources/library/src/desktopTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.desktop.kt b/components/resources/library/src/desktopTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.desktop.kt index 7c4441a9e1..83c36d588e 100644 --- a/components/resources/library/src/desktopTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.desktop.kt +++ b/components/resources/library/src/desktopTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.desktop.kt @@ -12,7 +12,7 @@ import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith -@OptIn(ExperimentalResourceApi::class, ExperimentalTestApi::class) +@OptIn(ExperimentalTestApi::class) class ComposeResourceTest { @Before diff --git a/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt b/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt index 3eabef4cd1..484062e735 100644 --- a/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt +++ b/components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt @@ -6,7 +6,6 @@ import platform.Foundation.NSBundle import platform.Foundation.NSFileManager import platform.posix.memcpy -@OptIn(ExperimentalResourceApi::class) actual suspend fun readResourceBytes(path: String): ByteArray { val fileManager = NSFileManager.defaultManager() // todo: support fallback path at bundle root? diff --git a/components/resources/library/src/jvmAndAndroidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.jvmAndAndroid.kt b/components/resources/library/src/jvmAndAndroidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.jvmAndAndroid.kt index 3360bcaf47..c19aee37e6 100644 --- a/components/resources/library/src/jvmAndAndroidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.jvmAndAndroid.kt +++ b/components/resources/library/src/jvmAndAndroidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.jvmAndAndroid.kt @@ -2,7 +2,6 @@ package org.jetbrains.compose.resources private object JvmResourceReader -@OptIn(ExperimentalResourceApi::class) actual suspend fun readResourceBytes(path: String): ByteArray { val classLoader = Thread.currentThread().contextClassLoader ?: JvmResourceReader.javaClass.classLoader val resource = classLoader.getResourceAsStream(path) ?: throw MissingResourceException(path) diff --git a/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.macos.kt b/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.macos.kt index 23f2255aaa..7c295e851e 100644 --- a/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.macos.kt +++ b/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.macos.kt @@ -5,7 +5,6 @@ import kotlinx.cinterop.usePinned import platform.Foundation.NSFileManager import platform.posix.memcpy -@OptIn(ExperimentalResourceApi::class) actual suspend fun readResourceBytes(path: String): ByteArray { val currentDirectoryPath = NSFileManager.defaultManager().currentDirectoryPath val contentsAtPath = NSFileManager.defaultManager().run { diff --git a/components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/FontResources.skiko.kt b/components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/FontResources.skiko.kt index 0bd899be07..07643c2436 100644 --- a/components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/FontResources.skiko.kt +++ b/components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/FontResources.skiko.kt @@ -29,7 +29,6 @@ private val emptyFontBase64 = @OptIn(ExperimentalEncodingApi::class) private val defaultEmptyFont by lazy { Font("org.jetbrains.compose.emptyFont", Base64.decode(emptyFontBase64)) } -@ExperimentalResourceApi @Composable actual fun Font(resource: FontResource, weight: FontWeight, style: FontStyle): Font { val resourceReader = LocalResourceReader.current diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt index f4fa6199a6..ed6c2d8b92 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt @@ -159,7 +159,6 @@ abstract class ComposePlugin : Plugin { } object CommonComponentsDependencies { - @ExperimentalComposeLibrary val resources = composeDependency("org.jetbrains.compose.components:components-resources") }