From 2d225f3450b07bb36d481974daa394af3b794cc0 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 18 Apr 2024 14:32:51 +0200 Subject: [PATCH] Delete the experimental mark from the stable resources library API (#4623) And remove internal testing methods --- .../demo/shared/src/jsMain/kotlin/main.js.kt | 3 +-- .../shared/src/wasmJsMain/kotlin/main.wasm.kt | 3 +-- .../compose/resources/FontResources.android.kt | 1 - .../compose/resources/ResourceReader.android.kt | 2 -- .../jetbrains/compose/resources/FontResources.kt | 14 -------------- .../compose/resources/ImageResources.kt | 16 ---------------- .../compose/resources/PluralStringResources.kt | 7 ------- .../org/jetbrains/compose/resources/Resource.kt | 1 - .../compose/resources/ResourceEnvironment.kt | 2 +- .../compose/resources/ResourceReader.kt | 1 - .../compose/resources/StringArrayResources.kt | 4 ---- .../compose/resources/StringResources.kt | 7 ------- .../vector/xmldom/MalformedXMLException.kt | 3 --- .../compose/resources/ComposeResourceTest.kt | 12 ++++++------ .../jetbrains/compose/resources/ResourceTest.kt | 5 ++--- .../org/jetbrains/compose/resources/TestUtils.kt | 8 +++++--- .../compose/resources/ResourceReader.desktop.kt | 2 -- .../compose/resources/ResourceReader.ios.kt | 1 - .../compose/resources/ImageResources.js.kt | 1 - .../compose/resources/ResourceReader.js.kt | 1 - .../compose/resources/ResourceReader.macos.kt | 1 - .../resources/vector/xmldom/DomXmlParser.kt | 2 -- .../compose/resources/FontResources.skiko.kt | 1 - .../compose/resources/ImageResources.wasmJs.kt | 1 - .../compose/resources/ResourceReader.wasmJs.kt | 1 - .../jetbrains/compose/resources/Resource.web.kt | 4 ---- .../compose/resources/GeneratedResClassSpec.kt | 6 ++---- .../my/lib/res/String0.androidMain.kt | 4 ---- .../my/lib/res/Drawable0.commonMain.kt | 10 ---------- .../my/lib/res/Font0.commonMain.kt | 4 ---- .../my/lib/res/Plurals0.commonMain.kt | 4 ---- .../my/lib/res/String0.commonMain.kt | 16 ---------------- .../commonResClass/my/lib/res/Res.kt | 5 +++-- .../my/lib/res/String0.desktopMain.kt | 4 ---- .../generated/resources/String0.androidMain.kt | 4 ---- .../generated/resources/Drawable0.commonMain.kt | 10 ---------- .../generated/resources/Font0.commonMain.kt | 4 ---- .../generated/resources/Plurals0.commonMain.kt | 4 ---- .../generated/resources/String0.commonMain.kt | 16 ---------------- .../resources_test/generated/resources/Res.kt | 3 ++- .../generated/resources/String0.desktopMain.kt | 4 ---- .../misc/emptyResources/expected/Res.kt | 3 ++- .../jvmonlyresources/generated/resources/Res.kt | 3 ++- .../generated/resources/Drawable0.main.kt | 4 ---- 44 files changed, 27 insertions(+), 185 deletions(-) diff --git a/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt b/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt index 6a065b6f071..ecbb400a2af 100644 --- a/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt +++ b/components/resources/demo/shared/src/jsMain/kotlin/main.js.kt @@ -5,13 +5,12 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.window.CanvasBasedWindow -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.configureWebResources import org.jetbrains.compose.resources.demo.shared.UseResources import org.jetbrains.skiko.wasm.onWasmReady -@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class) +@OptIn(ExperimentalComposeUiApi::class) fun main() { configureWebResources { // Not necessary - It's the same as the default. We add it here just to present this feature. diff --git a/components/resources/demo/shared/src/wasmJsMain/kotlin/main.wasm.kt b/components/resources/demo/shared/src/wasmJsMain/kotlin/main.wasm.kt index bcd51ccb26d..13e78a309a5 100644 --- a/components/resources/demo/shared/src/wasmJsMain/kotlin/main.wasm.kt +++ b/components/resources/demo/shared/src/wasmJsMain/kotlin/main.wasm.kt @@ -1,10 +1,9 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.window.CanvasBasedWindow -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.configureWebResources import org.jetbrains.compose.resources.demo.shared.UseResources -@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class) +@OptIn(ExperimentalComposeUiApi::class) fun main() { configureWebResources { // Not necessary - It's the same as the default. We add it here just to present this feature. 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 854b66580be..c85d34c1e82 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/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt b/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt index f4630dcc327..5ec66d7f024 100644 --- a/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt +++ b/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt @@ -19,7 +19,6 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou return result } - @OptIn(ExperimentalResourceApi::class) override fun getUri(path: String): String { val classLoader = getClassLoader() val resource = classLoader.getResource(path) ?: run { @@ -31,7 +30,6 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou return resource.toURI().toString() } - @OptIn(ExperimentalResourceApi::class) private fun getResourceAsStream(path: String): InputStream { val classLoader = getClassLoader() val resource = classLoader.getResourceAsStream(path) ?: run { 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 0054858dcf6..1493218d586 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 @@ -12,23 +12,10 @@ import androidx.compose.ui.text.font.* * * @see Resource */ -@ExperimentalResourceApi @Immutable class FontResource @InternalResourceApi constructor(id: String, items: Set): Resource(id, items) -/** - * Creates an [FontResource] object with the specified path. - * - * @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, -1, -1)) -) - /** * Creates a font using the specified font resource, weight, and style. * @@ -41,7 +28,6 @@ fun FontResource(path: String): FontResource = FontResource( * @throws NotFoundException if the specified resource ID is not found. */ @Composable -@ExperimentalResourceApi expect fun Font( resource: FontResource, weight: FontWeight = FontWeight.Normal, 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 29400950414..cdb9d85224e 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 @@ -21,23 +21,10 @@ import org.jetbrains.compose.resources.vector.xmldom.Element * @param id The unique identifier of the drawable resource. * @param items The set of resource items associated with the image resource. */ -@ExperimentalResourceApi @Immutable class DrawableResource @InternalResourceApi constructor(id: String, items: Set) : Resource(id, items) -/** - * Creates an [DrawableResource] object with the specified path. - * - * @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, -1, -1)) -) - /** * Retrieves a [Painter] using the specified drawable resource. * Automatically select a type of the Painter depending on the file extension. @@ -45,7 +32,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() @@ -67,7 +53,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 @@ -91,7 +76,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/PluralStringResources.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/PluralStringResources.kt index 477e1ba3ba8..abe769000ff 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/PluralStringResources.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/PluralStringResources.kt @@ -11,7 +11,6 @@ import org.jetbrains.compose.resources.plural.PluralRuleList * @param key The key used to retrieve the string resource. * @param items The set of resource items associated with the string resource. */ -@ExperimentalResourceApi @Immutable class PluralStringResource @InternalResourceApi constructor(id: String, val key: String, items: Set) : Resource(id, items) @@ -25,7 +24,6 @@ class PluralStringResource * * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file. */ -@ExperimentalResourceApi @Composable fun pluralStringResource(resource: PluralStringResource, quantity: Int): String { val resourceReader = LocalResourceReader.current @@ -44,11 +42,9 @@ fun pluralStringResource(resource: PluralStringResource, quantity: Int): String * * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file. */ -@ExperimentalResourceApi suspend fun getPluralString(resource: PluralStringResource, quantity: Int): String = loadPluralString(resource, quantity, DefaultResourceReader, getResourceEnvironment()) -@OptIn(InternalResourceApi::class, ExperimentalResourceApi::class) private suspend fun loadPluralString( resource: PluralStringResource, quantity: Int, @@ -78,7 +74,6 @@ private suspend fun loadPluralString( * * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file. */ -@ExperimentalResourceApi @Composable fun pluralStringResource(resource: PluralStringResource, quantity: Int, vararg formatArgs: Any): String { val resourceReader = LocalResourceReader.current @@ -99,7 +94,6 @@ fun pluralStringResource(resource: PluralStringResource, quantity: Int, vararg f * * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file. */ -@ExperimentalResourceApi suspend fun getPluralString(resource: PluralStringResource, quantity: Int, vararg formatArgs: Any): String = loadPluralString( resource, quantity, @@ -108,7 +102,6 @@ suspend fun getPluralString(resource: PluralStringResource, quantity: Int, varar getResourceEnvironment(), ) -@OptIn(ExperimentalResourceApi::class) private suspend fun loadPluralString( resource: PluralStringResource, quantity: Int, diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/Resource.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/Resource.kt index e752cb84227..6c4d4edd75b 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/Resource.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/Resource.kt @@ -14,7 +14,6 @@ annotation class InternalResourceApi * @property id The ID of the resource. * @property items The set of resource items associated with the resource. */ -@ExperimentalResourceApi @Immutable sealed class Resource @InternalResourceApi constructor( diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.kt index 00f322fb090..51b37b83130 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.kt @@ -48,7 +48,7 @@ internal expect fun getSystemEnvironment(): ResourceEnvironment */ internal var getResourceEnvironment = ::getSystemEnvironment -@OptIn(InternalResourceApi::class, ExperimentalResourceApi::class) +@OptIn(InternalResourceApi::class) internal fun Resource.getResourceItemByEnvironment(environment: ResourceEnvironment): ResourceItem { //Priority of environments: https://developer.android.com/guide/topics/resources/providing-resources#table2 items.toList() 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 d34f3b782e8..7c2979e5869 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/StringArrayResources.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringArrayResources.kt index 2ddfe5a8979..6eb35147e87 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringArrayResources.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringArrayResources.kt @@ -16,7 +16,6 @@ import org.jetbrains.compose.resources.vector.xmldom.NodeList * @param key The key used to retrieve the string array resource. * @param items The set of resource items associated with the string array resource. */ -@ExperimentalResourceApi @Immutable class StringArrayResource @InternalResourceApi constructor(id: String, val key: String, items: Set) : Resource(id, items) @@ -29,7 +28,6 @@ class StringArrayResource * * @throws IllegalStateException if the string array with the given ID is not found. */ -@ExperimentalResourceApi @Composable fun stringArrayResource(resource: StringArrayResource): List { val resourceReader = LocalResourceReader.current @@ -47,11 +45,9 @@ fun stringArrayResource(resource: StringArrayResource): List { * * @throws IllegalStateException if the string array with the given ID is not found. */ -@ExperimentalResourceApi suspend fun getStringArray(resource: StringArrayResource): List = loadStringArray(resource, DefaultResourceReader, getResourceEnvironment()) -@OptIn(ExperimentalResourceApi::class, InternalResourceApi::class) private suspend fun loadStringArray( resource: StringArrayResource, resourceReader: ResourceReader, 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 dab3241d2f7..9fcbc4c9b9a 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 @@ -9,7 +9,6 @@ import androidx.compose.runtime.* * @param key The key used to retrieve the string resource. * @param items The set of resource items associated with the string resource. */ -@ExperimentalResourceApi @Immutable class StringResource @InternalResourceApi constructor(id: String, val key: String, items: Set) : Resource(id, items) @@ -22,7 +21,6 @@ class StringResource * * @throws IllegalArgumentException If the provided ID is not found in the resource file. */ -@ExperimentalResourceApi @Composable fun stringResource(resource: StringResource): String { val resourceReader = LocalResourceReader.current @@ -40,11 +38,9 @@ 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()) -@OptIn(ExperimentalResourceApi::class, InternalResourceApi::class) private suspend fun loadString( resource: StringResource, resourceReader: ResourceReader, @@ -64,7 +60,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 @@ -84,7 +79,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() }, @@ -92,7 +86,6 @@ suspend fun getString(resource: StringResource, vararg formatArgs: Any): String getResourceEnvironment() ) -@OptIn(ExperimentalResourceApi::class) private suspend fun loadString( resource: StringResource, args: List, diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/MalformedXMLException.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/MalformedXMLException.kt index 48bb17f371f..50c9c221ce1 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/MalformedXMLException.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/MalformedXMLException.kt @@ -1,9 +1,6 @@ package org.jetbrains.compose.resources.vector.xmldom -import org.jetbrains.compose.resources.ExperimentalResourceApi - /** * Error throw when parsed XML is malformed */ -@ExperimentalResourceApi class MalformedXMLException(message: String?) : Exception(message) diff --git a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt index fba9c1daad6..d12ececcda8 100644 --- a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt +++ b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.test.runTest import org.jetbrains.skiko.URIManager import kotlin.test.* -@OptIn(ExperimentalTestApi::class, ExperimentalResourceApi::class, InternalResourceApi::class) +@OptIn(ExperimentalTestApi::class, InternalResourceApi::class) class ComposeResourceTest { init { @@ -20,7 +20,7 @@ class ComposeResourceTest { @Test fun testCountRecompositions() = runComposeUiTest { - var res by mutableStateOf(DrawableResource("1.png")) + var res by mutableStateOf(TestDrawableResource("1.png")) val recompositionsCounter = RecompositionsCounter() setContent { CompositionLocalProvider(LocalComposeEnvironment provides TestComposeEnvironment) { @@ -31,7 +31,7 @@ class ComposeResourceTest { } } waitForIdle() - res = DrawableResource("2.png") + res = TestDrawableResource("2.png") waitForIdle() assertEquals(2, recompositionsCounter.count) } @@ -39,7 +39,7 @@ class ComposeResourceTest { @Test fun testImageResourceCache() = runComposeUiTest { val testResourceReader = TestResourceReader() - var res by mutableStateOf(DrawableResource("1.png")) + var res by mutableStateOf(TestDrawableResource("1.png")) setContent { CompositionLocalProvider( LocalResourceReader provides testResourceReader, @@ -49,9 +49,9 @@ class ComposeResourceTest { } } waitForIdle() - res = DrawableResource("2.png") + res = TestDrawableResource("2.png") waitForIdle() - res = DrawableResource("1.png") + res = TestDrawableResource("1.png") waitForIdle() assertEquals( diff --git a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ResourceTest.kt b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ResourceTest.kt index 61bccc16c0f..e530054bcea 100644 --- a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ResourceTest.kt +++ b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ResourceTest.kt @@ -10,16 +10,15 @@ import org.jetbrains.compose.resources.ThemeQualifier.DARK import org.jetbrains.compose.resources.ThemeQualifier.LIGHT import kotlin.test.* -@OptIn(ExperimentalResourceApi::class, InternalResourceApi::class) class ResourceTest { @Test fun testResourceEquals() { - assertEquals(DrawableResource("a"), DrawableResource("a")) + assertEquals(TestDrawableResource("a"), TestDrawableResource("a")) } @Test fun testResourceNotEquals() { - assertNotEquals(DrawableResource("a"), DrawableResource("b")) + assertNotEquals(TestDrawableResource("a"), TestDrawableResource("b")) } @Test diff --git a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/TestUtils.kt b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/TestUtils.kt index d36ac897818..e260331f78b 100644 --- a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/TestUtils.kt +++ b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/TestUtils.kt @@ -17,27 +17,29 @@ private val cvrMap: Map = mapOf( "str_arr" to ResourceItem(setOf(), "strings.cvr", 211, 47), ) -@OptIn(ExperimentalResourceApi::class) internal fun TestStringResource(key: String) = StringResource( "STRING:$key", key, setOf(cvrMap[key] ?: error("String ID=`$key` is not found!")) ) -@OptIn(ExperimentalResourceApi::class) internal fun TestStringArrayResource(key: String) = StringArrayResource( "STRING:$key", key, setOf(cvrMap[key] ?: error("String ID=`$key` is not found!")) ) -@OptIn(ExperimentalResourceApi::class) internal fun TestPluralStringResource(key: String) = PluralStringResource( "PLURALS:$key", key, setOf(cvrMap[key] ?: error("String ID=`$key` is not found!")) ) +internal fun TestDrawableResource(path: String) = DrawableResource( + path, + setOf(ResourceItem(emptySet(), path, -1, -1)) +) + internal fun parsePluralSamples(samples: String): List { return samples.split(',').flatMap { val range = it.trim() diff --git a/components/resources/library/src/desktopMain/kotlin/org/jetbrains/compose/resources/ResourceReader.desktop.kt b/components/resources/library/src/desktopMain/kotlin/org/jetbrains/compose/resources/ResourceReader.desktop.kt index ab9ffe4a3a9..25d4ef44c14 100644 --- a/components/resources/library/src/desktopMain/kotlin/org/jetbrains/compose/resources/ResourceReader.desktop.kt +++ b/components/resources/library/src/desktopMain/kotlin/org/jetbrains/compose/resources/ResourceReader.desktop.kt @@ -18,14 +18,12 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou return result } - @OptIn(ExperimentalResourceApi::class) override fun getUri(path: String): String { val classLoader = getClassLoader() val resource = classLoader.getResource(path) ?: throw MissingResourceException(path) return resource.toURI().toString() } - @OptIn(ExperimentalResourceApi::class) private fun getResourceAsStream(path: String): InputStream { val classLoader = getClassLoader() return classLoader.getResourceAsStream(path) ?: throw MissingResourceException(path) 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 9d4ee1c9a62..0da7725bc36 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 @@ -5,7 +5,6 @@ import kotlinx.cinterop.usePinned import platform.Foundation.* import platform.posix.memcpy -@OptIn(ExperimentalResourceApi::class) internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { override suspend fun read(path: String): ByteArray { val data = readData(getPathInBundle(path)) diff --git a/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ImageResources.js.kt b/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ImageResources.js.kt index 8061e6529b2..725ffd532dd 100644 --- a/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ImageResources.js.kt +++ b/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ImageResources.js.kt @@ -3,7 +3,6 @@ package org.jetbrains.compose.resources import org.jetbrains.compose.resources.vector.xmldom.* import org.w3c.dom.parsing.DOMParser -@OptIn(ExperimentalResourceApi::class) internal actual fun ByteArray.toXmlElement(): Element { val xmlString = decodeToString() val xmlDom = DOMParser().parseFromString(xmlString, "application/xml") diff --git a/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.js.kt b/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.js.kt index f249c676cec..0dbaeac1fa5 100644 --- a/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.js.kt +++ b/components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.js.kt @@ -7,7 +7,6 @@ import org.khronos.webgl.Int8Array import org.w3c.files.Blob import kotlin.js.Promise -@OptIn(ExperimentalResourceApi::class) internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { override suspend fun read(path: String): ByteArray { return readAsBlob(path).asByteArray() 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 10a5969b08b..4b042d11081 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.* import platform.posix.memcpy -@OptIn(ExperimentalResourceApi::class) internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { override suspend fun read(path: String): ByteArray { val data = readData(getPathOnDisk(path)) diff --git a/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt b/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt index 3d2a94a47bc..ab6b51d30e2 100644 --- a/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt +++ b/components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt @@ -4,7 +4,6 @@ */ package org.jetbrains.compose.resources.vector.xmldom -import org.jetbrains.compose.resources.ExperimentalResourceApi import platform.Foundation.NSError import platform.Foundation.NSString import platform.Foundation.NSUTF8StringEncoding @@ -58,7 +57,6 @@ private class ElementImpl( override fun lookupPrefix(namespaceURI: String): String = prefixMap[namespaceURI] ?: "" } -@OptIn(ExperimentalResourceApi::class) @Suppress("CONFLICTING_OVERLOADS", "PARAMETER_NAME_CHANGED_ON_OVERRIDE") private class DomXmlParser : NSObject(), NSXMLParserDelegateProtocol { 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 b15d7c0dfc9..5390361c63b 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/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ImageResources.wasmJs.kt b/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ImageResources.wasmJs.kt index 8cd2208f30d..4de24550e75 100644 --- a/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ImageResources.wasmJs.kt +++ b/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ImageResources.wasmJs.kt @@ -5,7 +5,6 @@ import org.jetbrains.compose.resources.vector.xmldom.ElementImpl import org.jetbrains.compose.resources.vector.xmldom.MalformedXMLException import org.w3c.dom.parsing.DOMParser -@OptIn(ExperimentalResourceApi::class) internal actual fun ByteArray.toXmlElement(): Element { val xmlString = decodeToString() val xmlDom = DOMParser().parseFromString(xmlString, "application/xml".toJsString()) diff --git a/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.wasmJs.kt b/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.wasmJs.kt index c3dbae6c411..3a78cdfcafd 100644 --- a/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.wasmJs.kt +++ b/components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.wasmJs.kt @@ -22,7 +22,6 @@ private external fun jsExportInt8ArrayToWasm(src: Int8Array, size: Int, dstAddr: @JsFun("(blob) => blob.arrayBuffer()") private external fun jsExportBlobAsArrayBuffer(blob: Blob): Promise -@OptIn(ExperimentalResourceApi::class) internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { override suspend fun read(path: String): ByteArray { return readAsBlob(path).asByteArray() diff --git a/components/resources/library/src/webMain/kotlin/org/jetbrains/compose/resources/Resource.web.kt b/components/resources/library/src/webMain/kotlin/org/jetbrains/compose/resources/Resource.web.kt index f1ebbc55318..aa441119874 100644 --- a/components/resources/library/src/webMain/kotlin/org/jetbrains/compose/resources/Resource.web.kt +++ b/components/resources/library/src/webMain/kotlin/org/jetbrains/compose/resources/Resource.web.kt @@ -6,7 +6,6 @@ package org.jetbrains.compose.resources * @see configureWebResources - for overriding the default configuration. */ @Suppress("unused") -@ExperimentalResourceApi object WebResourcesConfiguration { internal var getResourcePath: (path: String) -> String = { "./$it" } @@ -16,7 +15,6 @@ object WebResourcesConfiguration { * * @param map the mapping function that takes a path String and returns a modified path String */ - @ExperimentalResourceApi fun resourcePathMapping(map: (path: String) -> String) { getResourcePath = map } @@ -41,12 +39,10 @@ object WebResourcesConfiguration { * ``` */ @Suppress("unused") -@ExperimentalResourceApi fun configureWebResources(configure: WebResourcesConfiguration.() -> Unit) { WebResourcesConfiguration.configure() } -@OptIn(ExperimentalResourceApi::class) internal fun getResourceUrl(windowOrigin: String, windowPathname: String, resourcePath: String): String { val path = WebResourcesConfiguration.getResourcePath(resourcePath) return when { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt index bbe8a02be47..1ecdd84f350 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt @@ -127,7 +127,6 @@ internal fun getResFileSpec( ) file.addType(TypeSpec.objectBuilder("Res").also { resObject -> resObject.addModifiers(resModifier) - resObject.addAnnotation(experimentalAnnotation) //readFileBytes val readResourceBytes = MemberName("org.jetbrains.compose.resources", "readResourceBytes") @@ -143,6 +142,7 @@ internal fun getResFileSpec( @return The content of the file as a byte array. """.trimIndent() ) + .addAnnotation(experimentalAnnotation) .addParameter("path", String::class) .addModifiers(KModifier.SUSPEND) .returns(ByteArray::class) @@ -164,6 +164,7 @@ internal fun getResFileSpec( @return The URI string of the file. """.trimIndent() ) + .addAnnotation(experimentalAnnotation) .addParameter("path", String::class) .returns(String::class) .addStatement("""return %M("$moduleDir" + path)""", getResourceUri) @@ -237,7 +238,6 @@ private fun getChunkFileSpec( val objectSpec = TypeSpec.objectBuilder(chunkClassName).also { typeObject -> typeObject.addModifiers(KModifier.PRIVATE) - typeObject.addAnnotation(experimentalAnnotation) val properties = idToResources.keys.map { resName -> PropertySpec.builder(resName, type.getClassName()) .delegate("\nlazy·{ init_$resName() }") @@ -250,14 +250,12 @@ private fun getChunkFileSpec( idToResources.forEach { (resName, items) -> val accessor = PropertySpec.builder(resName, type.getClassName(), resModifier) .receiver(ClassName(packageName, "Res", type.accessorName)) - .addAnnotation(experimentalAnnotation) .getter(FunSpec.getterBuilder().addStatement("return $chunkClassName.$resName").build()) .build() chunkFile.addProperty(accessor) val initializer = FunSpec.builder("init_$resName") .addModifiers(KModifier.PRIVATE) - .addAnnotation(experimentalAnnotation) .returns(type.getClassName()) .addStatement( CodeBlock.builder() diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt index c657bcaa880..4c07207da06 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt @@ -3,20 +3,16 @@ package my.lib.res import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.StringResource -@ExperimentalResourceApi private object AndroidMainString0 { public val android_str: StringResource by lazy { init_android_str() } } -@ExperimentalResourceApi public val Res.string.android_str: StringResource get() = AndroidMainString0.android_str -@ExperimentalResourceApi private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource( "string:android_str", "android_str", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt index 290092ea95d..408e508f377 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt @@ -4,9 +4,7 @@ package my.lib.res import kotlin.OptIn import org.jetbrains.compose.resources.DrawableResource -import org.jetbrains.compose.resources.ExperimentalResourceApi -@ExperimentalResourceApi private object CommonMainDrawable0 { public val _3_strange_name: DrawableResource by lazy { init__3_strange_name() } @@ -21,11 +19,9 @@ private object CommonMainDrawable0 { lazy { init_vector_2() } } -@ExperimentalResourceApi public val Res.drawable._3_strange_name: DrawableResource get() = CommonMainDrawable0._3_strange_name -@ExperimentalResourceApi private fun init__3_strange_name(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:_3_strange_name", @@ -34,11 +30,9 @@ private fun init__3_strange_name(): DrawableResource = ) ) -@ExperimentalResourceApi public val Res.drawable.camelCaseName: DrawableResource get() = CommonMainDrawable0.camelCaseName -@ExperimentalResourceApi private fun init_camelCaseName(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:camelCaseName", @@ -47,11 +41,9 @@ private fun init_camelCaseName(): DrawableResource = ) ) -@ExperimentalResourceApi public val Res.drawable.vector: DrawableResource get() = CommonMainDrawable0.vector -@ExperimentalResourceApi private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector", setOf( @@ -72,11 +64,9 @@ private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.Dr ) ) -@ExperimentalResourceApi public val Res.drawable.vector_2: DrawableResource get() = CommonMainDrawable0.vector_2 -@ExperimentalResourceApi private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector_2", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt index a7f4e063735..1d69a111bbf 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt @@ -3,20 +3,16 @@ package my.lib.res import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.FontResource -@ExperimentalResourceApi private object CommonMainFont0 { public val emptyFont: FontResource by lazy { init_emptyFont() } } -@ExperimentalResourceApi public val Res.font.emptyFont: FontResource get() = CommonMainFont0.emptyFont -@ExperimentalResourceApi private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource( "font:emptyFont", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt index a41fe0fadc9..95ecbbca591 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt @@ -3,20 +3,16 @@ package my.lib.res import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.PluralStringResource -@ExperimentalResourceApi private object CommonMainPlurals0 { public val numberOfSongsAvailable: PluralStringResource by lazy { init_numberOfSongsAvailable() } } -@ExperimentalResourceApi public val Res.plurals.numberOfSongsAvailable: PluralStringResource get() = CommonMainPlurals0.numberOfSongsAvailable -@ExperimentalResourceApi private fun init_numberOfSongsAvailable(): PluralStringResource = org.jetbrains.compose.resources.PluralStringResource( "plurals:numberOfSongsAvailable", "numberOfSongsAvailable", diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt index c7848ef50df..d3a70bb1f25 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt @@ -3,10 +3,8 @@ package my.lib.res import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.StringResource -@ExperimentalResourceApi private object CommonMainString0 { public val PascalCase: StringResource by lazy { init_PascalCase() } @@ -30,11 +28,9 @@ private object CommonMainString0 { lazy { init_str_template() } } -@ExperimentalResourceApi public val Res.string.PascalCase: StringResource get() = CommonMainString0.PascalCase -@ExperimentalResourceApi private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource( "string:PascalCase", "PascalCase", setOf( @@ -43,11 +39,9 @@ private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources. ) ) -@ExperimentalResourceApi public val Res.string._1_kebab_case: StringResource get() = CommonMainString0._1_kebab_case -@ExperimentalResourceApi private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource( "string:_1_kebab_case", "_1_kebab_case", setOf( @@ -56,11 +50,9 @@ private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resourc ) ) -@ExperimentalResourceApi public val Res.string.app_name: StringResource get() = CommonMainString0.app_name -@ExperimentalResourceApi private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource( "string:app_name", "app_name", setOf( @@ -69,11 +61,9 @@ private fun init_app_name(): StringResource = org.jetbrains.compose.resources.St ) ) -@ExperimentalResourceApi public val Res.string.camelCase: StringResource get() = CommonMainString0.camelCase -@ExperimentalResourceApi private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource( "string:camelCase", "camelCase", setOf( @@ -82,11 +72,9 @@ private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.S ) ) -@ExperimentalResourceApi public val Res.string.hello: StringResource get() = CommonMainString0.hello -@ExperimentalResourceApi private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource( "string:hello", "hello", setOf( @@ -95,11 +83,9 @@ private fun init_hello(): StringResource = org.jetbrains.compose.resources.Strin ) ) -@ExperimentalResourceApi public val Res.string.multi_line: StringResource get() = CommonMainString0.multi_line -@ExperimentalResourceApi private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource( "string:multi_line", "multi_line", setOf( @@ -108,11 +94,9 @@ private fun init_multi_line(): StringResource = org.jetbrains.compose.resources. ) ) -@ExperimentalResourceApi public val Res.string.str_template: StringResource get() = CommonMainString0.str_template -@ExperimentalResourceApi private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource( "string:str_template", "str_template", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt index 4e2092bc2dd..e5a14096343 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt @@ -12,7 +12,6 @@ import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.getResourceUri import org.jetbrains.compose.resources.readResourceBytes -@ExperimentalResourceApi public object Res { /** * Reads the content of the resource file at the specified path and returns it as a byte array. @@ -22,6 +21,7 @@ public object Res { * @param path The path of the file to read in the compose resource's directory. * @return The content of the file as a byte array. */ + @ExperimentalResourceApi public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) /** @@ -32,6 +32,7 @@ public object Res { * @param path The path of the file in the compose resource's directory. * @return The URI string of the file. */ + @ExperimentalResourceApi public fun getUri(path: String): String = getResourceUri("" + path) public object drawable @@ -43,4 +44,4 @@ public object Res { public object plurals public object font -} +} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt index 50c85b8d351..4fcecd75b6c 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt @@ -3,20 +3,16 @@ package my.lib.res import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.StringResource -@ExperimentalResourceApi private object DesktopMainString0 { public val desktop_str: StringResource by lazy { init_desktop_str() } } -@ExperimentalResourceApi public val Res.string.desktop_str: StringResource get() = DesktopMainString0.desktop_str -@ExperimentalResourceApi private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource( "string:desktop_str", "desktop_str", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt index a76ea38a4e2..98e03554540 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt @@ -3,20 +3,16 @@ package app.group.resources_test.generated.resources import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.StringResource -@ExperimentalResourceApi private object AndroidMainString0 { public val android_str: StringResource by lazy { init_android_str() } } -@ExperimentalResourceApi internal val Res.string.android_str: StringResource get() = AndroidMainString0.android_str -@ExperimentalResourceApi private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource( "string:android_str", "android_str", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt index 3a17148357f..5e7a25ac0ed 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt @@ -4,9 +4,7 @@ package app.group.resources_test.generated.resources import kotlin.OptIn import org.jetbrains.compose.resources.DrawableResource -import org.jetbrains.compose.resources.ExperimentalResourceApi -@ExperimentalResourceApi private object CommonMainDrawable0 { public val _3_strange_name: DrawableResource by lazy { init__3_strange_name() } @@ -21,11 +19,9 @@ private object CommonMainDrawable0 { lazy { init_vector_2() } } -@ExperimentalResourceApi internal val Res.drawable._3_strange_name: DrawableResource get() = CommonMainDrawable0._3_strange_name -@ExperimentalResourceApi private fun init__3_strange_name(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:_3_strange_name", @@ -34,11 +30,9 @@ private fun init__3_strange_name(): DrawableResource = ) ) -@ExperimentalResourceApi internal val Res.drawable.camelCaseName: DrawableResource get() = CommonMainDrawable0.camelCaseName -@ExperimentalResourceApi private fun init_camelCaseName(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:camelCaseName", @@ -47,11 +41,9 @@ private fun init_camelCaseName(): DrawableResource = ) ) -@ExperimentalResourceApi internal val Res.drawable.vector: DrawableResource get() = CommonMainDrawable0.vector -@ExperimentalResourceApi private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector", setOf( @@ -72,11 +64,9 @@ private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.Dr ) ) -@ExperimentalResourceApi internal val Res.drawable.vector_2: DrawableResource get() = CommonMainDrawable0.vector_2 -@ExperimentalResourceApi private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector_2", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt index e756e8c84c8..89ff6eb7b8b 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt @@ -3,20 +3,16 @@ package app.group.resources_test.generated.resources import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.FontResource -@ExperimentalResourceApi private object CommonMainFont0 { public val emptyFont: FontResource by lazy { init_emptyFont() } } -@ExperimentalResourceApi internal val Res.font.emptyFont: FontResource get() = CommonMainFont0.emptyFont -@ExperimentalResourceApi private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource( "font:emptyFont", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt index f4fa373e40b..9674a83744d 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt @@ -3,20 +3,16 @@ package app.group.resources_test.generated.resources import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.PluralStringResource -@ExperimentalResourceApi private object CommonMainPlurals0 { public val numberOfSongsAvailable: PluralStringResource by lazy { init_numberOfSongsAvailable() } } -@ExperimentalResourceApi internal val Res.plurals.numberOfSongsAvailable: PluralStringResource get() = CommonMainPlurals0.numberOfSongsAvailable -@ExperimentalResourceApi private fun init_numberOfSongsAvailable(): PluralStringResource = org.jetbrains.compose.resources.PluralStringResource( "plurals:numberOfSongsAvailable", "numberOfSongsAvailable", diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt index ddfe1791a4b..c57944b0039 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt @@ -3,10 +3,8 @@ package app.group.resources_test.generated.resources import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.StringResource -@ExperimentalResourceApi private object CommonMainString0 { public val PascalCase: StringResource by lazy { init_PascalCase() } @@ -30,11 +28,9 @@ private object CommonMainString0 { lazy { init_str_template() } } -@ExperimentalResourceApi internal val Res.string.PascalCase: StringResource get() = CommonMainString0.PascalCase -@ExperimentalResourceApi private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource( "string:PascalCase", "PascalCase", setOf( @@ -43,11 +39,9 @@ private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources. ) ) -@ExperimentalResourceApi internal val Res.string._1_kebab_case: StringResource get() = CommonMainString0._1_kebab_case -@ExperimentalResourceApi private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource( "string:_1_kebab_case", "_1_kebab_case", setOf( @@ -56,11 +50,9 @@ private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resourc ) ) -@ExperimentalResourceApi internal val Res.string.app_name: StringResource get() = CommonMainString0.app_name -@ExperimentalResourceApi private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource( "string:app_name", "app_name", setOf( @@ -69,11 +61,9 @@ private fun init_app_name(): StringResource = org.jetbrains.compose.resources.St ) ) -@ExperimentalResourceApi internal val Res.string.camelCase: StringResource get() = CommonMainString0.camelCase -@ExperimentalResourceApi private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource( "string:camelCase", "camelCase", setOf( @@ -82,11 +72,9 @@ private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.S ) ) -@ExperimentalResourceApi internal val Res.string.hello: StringResource get() = CommonMainString0.hello -@ExperimentalResourceApi private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource( "string:hello", "hello", setOf( @@ -95,11 +83,9 @@ private fun init_hello(): StringResource = org.jetbrains.compose.resources.Strin ) ) -@ExperimentalResourceApi internal val Res.string.multi_line: StringResource get() = CommonMainString0.multi_line -@ExperimentalResourceApi private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource( "string:multi_line", "multi_line", setOf( @@ -108,11 +94,9 @@ private fun init_multi_line(): StringResource = org.jetbrains.compose.resources. ) ) -@ExperimentalResourceApi internal val Res.string.str_template: StringResource get() = CommonMainString0.str_template -@ExperimentalResourceApi private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource( "string:str_template", "str_template", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt index e3beeb0da9a..9b19cafa4cd 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt @@ -12,7 +12,6 @@ import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.getResourceUri import org.jetbrains.compose.resources.readResourceBytes -@ExperimentalResourceApi internal object Res { /** * Reads the content of the resource file at the specified path and returns it as a byte array. @@ -22,6 +21,7 @@ internal object Res { * @param path The path of the file to read in the compose resource's directory. * @return The content of the file as a byte array. */ + @ExperimentalResourceApi public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) /** @@ -32,6 +32,7 @@ internal object Res { * @param path The path of the file in the compose resource's directory. * @return The URI string of the file. */ + @ExperimentalResourceApi public fun getUri(path: String): String = getResourceUri("" + path) public object drawable diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt index aa67ed8e2da..badfa7b5b20 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt @@ -3,20 +3,16 @@ package app.group.resources_test.generated.resources import kotlin.OptIn -import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.StringResource -@ExperimentalResourceApi private object DesktopMainString0 { public val desktop_str: StringResource by lazy { init_desktop_str() } } -@ExperimentalResourceApi internal val Res.string.desktop_str: StringResource get() = DesktopMainString0.desktop_str -@ExperimentalResourceApi private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource( "string:desktop_str", "desktop_str", setOf( diff --git a/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt index 5b4a1753175..b6fbefa22ea 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt @@ -12,7 +12,6 @@ import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.getResourceUri import org.jetbrains.compose.resources.readResourceBytes -@ExperimentalResourceApi internal object Res { /** * Reads the content of the resource file at the specified path and returns it as a byte array. @@ -22,6 +21,7 @@ internal object Res { * @param path The path of the file to read in the compose resource's directory. * @return The content of the file as a byte array. */ + @ExperimentalResourceApi public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) /** @@ -32,6 +32,7 @@ internal object Res { * @param path The path of the file in the compose resource's directory. * @return The URI string of the file. */ + @ExperimentalResourceApi public fun getUri(path: String): String = getResourceUri("" + path) public object drawable diff --git a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt index 4790d781265..7004b885d85 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt @@ -12,7 +12,6 @@ import org.jetbrains.compose.resources.ExperimentalResourceApi import org.jetbrains.compose.resources.getResourceUri import org.jetbrains.compose.resources.readResourceBytes -@ExperimentalResourceApi internal object Res { /** * Reads the content of the resource file at the specified path and returns it as a byte array. @@ -22,6 +21,7 @@ internal object Res { * @param path The path of the file to read in the compose resource's directory. * @return The content of the file as a byte array. */ + @ExperimentalResourceApi public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) /** @@ -32,6 +32,7 @@ internal object Res { * @param path The path of the file in the compose resource's directory. * @return The URI string of the file. */ + @ExperimentalResourceApi public fun getUri(path: String): String = getResourceUri("" + path) public object drawable diff --git a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt index 0c5db2a8be9..98f4998f2b1 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt @@ -4,19 +4,15 @@ package me.app.jvmonlyresources.generated.resources import kotlin.OptIn import org.jetbrains.compose.resources.DrawableResource -import org.jetbrains.compose.resources.ExperimentalResourceApi -@ExperimentalResourceApi private object MainDrawable0 { public val vector: DrawableResource by lazy { init_vector() } } -@ExperimentalResourceApi internal val Res.drawable.vector: DrawableResource get() = MainDrawable0.vector -@ExperimentalResourceApi private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector", setOf(