Browse Source

Delete experimental marker from stable resources APIs (#4144)

pull/4145/head
Konstantin 10 months ago committed by GitHub
parent
commit
f405dd8ba0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      components/resources/library/src/androidInstrumentedTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.android.kt
  2. 1
      components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/FontResources.android.kt
  3. 2
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/FontResources.kt
  4. 4
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt
  5. 1
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt
  6. 6
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResources.kt
  7. 2
      components/resources/library/src/desktopTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.desktop.kt
  8. 1
      components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt
  9. 1
      components/resources/library/src/jvmAndAndroidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.jvmAndAndroid.kt
  10. 1
      components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.macos.kt
  11. 1
      components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/FontResources.skiko.kt
  12. 1
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

2
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

1
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()

2
components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/FontResources.kt

@ -21,6 +21,7 @@ class FontResource(id: String, items: Set<ResourceItem>): 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,

4
components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt

@ -29,6 +29,7 @@ class DrawableResource(id: String, items: Set<ResourceItem>) : 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

1
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")
/**

6
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<String> {
val resourceReader = LocalResourceReader.current
@ -178,7 +173,6 @@ fun stringArrayResource(resource: StringResource): List<String> {
*
* @throws IllegalStateException if the string array with the given ID is not found.
*/
@ExperimentalResourceApi
suspend fun getStringArray(resource: StringResource): List<String> =
loadStringArray(resource, DefaultResourceReader, getResourceEnvironment())

2
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

1
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?

1
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)

1
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 {

1
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

1
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

@ -159,7 +159,6 @@ abstract class ComposePlugin : Plugin<Project> {
}
object CommonComponentsDependencies {
@ExperimentalComposeLibrary
val resources = composeDependency("org.jetbrains.compose.components:components-resources")
}

Loading…
Cancel
Save