Browse Source

Delete the experimental mark from the stable resources library API (#4623)

And remove internal testing methods
pull/4650/head v1.6.10-dev1590
Konstantin 7 months ago committed by GitHub
parent
commit
2d225f3450
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      components/resources/demo/shared/src/jsMain/kotlin/main.js.kt
  2. 3
      components/resources/demo/shared/src/wasmJsMain/kotlin/main.wasm.kt
  3. 1
      components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/FontResources.android.kt
  4. 2
      components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt
  5. 14
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/FontResources.kt
  6. 16
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ImageResources.kt
  7. 7
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/PluralStringResources.kt
  8. 1
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/Resource.kt
  9. 2
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.kt
  10. 1
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceReader.kt
  11. 4
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringArrayResources.kt
  12. 7
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/StringResources.kt
  13. 3
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/MalformedXMLException.kt
  14. 12
      components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ComposeResourceTest.kt
  15. 5
      components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/ResourceTest.kt
  16. 8
      components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/TestUtils.kt
  17. 2
      components/resources/library/src/desktopMain/kotlin/org/jetbrains/compose/resources/ResourceReader.desktop.kt
  18. 1
      components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.ios.kt
  19. 1
      components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ImageResources.js.kt
  20. 1
      components/resources/library/src/jsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.js.kt
  21. 1
      components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceReader.macos.kt
  22. 2
      components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt
  23. 1
      components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/FontResources.skiko.kt
  24. 1
      components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ImageResources.wasmJs.kt
  25. 1
      components/resources/library/src/wasmJsMain/kotlin/org/jetbrains/compose/resources/ResourceReader.wasmJs.kt
  26. 4
      components/resources/library/src/webMain/kotlin/org/jetbrains/compose/resources/Resource.web.kt
  27. 6
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt
  28. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt
  29. 10
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt
  30. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt
  31. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt
  32. 16
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt
  33. 5
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt
  34. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt
  35. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt
  36. 10
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt
  37. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt
  38. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt
  39. 16
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt
  40. 3
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt
  41. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt
  42. 3
      gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt
  43. 3
      gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt
  44. 4
      gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt

3
components/resources/demo/shared/src/jsMain/kotlin/main.js.kt

@ -5,13 +5,12 @@
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.CanvasBasedWindow import androidx.compose.ui.window.CanvasBasedWindow
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.configureWebResources import org.jetbrains.compose.resources.configureWebResources
import org.jetbrains.compose.resources.demo.shared.UseResources import org.jetbrains.compose.resources.demo.shared.UseResources
import org.jetbrains.skiko.wasm.onWasmReady import org.jetbrains.skiko.wasm.onWasmReady
@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class) @OptIn(ExperimentalComposeUiApi::class)
fun main() { fun main() {
configureWebResources { configureWebResources {
// Not necessary - It's the same as the default. We add it here just to present this feature. // Not necessary - It's the same as the default. We add it here just to present this feature.

3
components/resources/demo/shared/src/wasmJsMain/kotlin/main.wasm.kt

@ -1,10 +1,9 @@
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.CanvasBasedWindow import androidx.compose.ui.window.CanvasBasedWindow
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.configureWebResources import org.jetbrains.compose.resources.configureWebResources
import org.jetbrains.compose.resources.demo.shared.UseResources import org.jetbrains.compose.resources.demo.shared.UseResources
@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class) @OptIn(ExperimentalComposeUiApi::class)
fun main() { fun main() {
configureWebResources { configureWebResources {
// Not necessary - It's the same as the default. We add it here just to present this feature. // Not necessary - It's the same as the default. We add it here just to present this feature.

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.platform.LocalContext
import androidx.compose.ui.text.font.* import androidx.compose.ui.text.font.*
@ExperimentalResourceApi
@Composable @Composable
actual fun Font(resource: FontResource, weight: FontWeight, style: FontStyle): Font { actual fun Font(resource: FontResource, weight: FontWeight, style: FontStyle): Font {
val environment = LocalComposeEnvironment.current.rememberEnvironment() val environment = LocalComposeEnvironment.current.rememberEnvironment()

2
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 return result
} }
@OptIn(ExperimentalResourceApi::class)
override fun getUri(path: String): String { override fun getUri(path: String): String {
val classLoader = getClassLoader() val classLoader = getClassLoader()
val resource = classLoader.getResource(path) ?: run { val resource = classLoader.getResource(path) ?: run {
@ -31,7 +30,6 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou
return resource.toURI().toString() return resource.toURI().toString()
} }
@OptIn(ExperimentalResourceApi::class)
private fun getResourceAsStream(path: String): InputStream { private fun getResourceAsStream(path: String): InputStream {
val classLoader = getClassLoader() val classLoader = getClassLoader()
val resource = classLoader.getResourceAsStream(path) ?: run { val resource = classLoader.getResourceAsStream(path) ?: run {

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

@ -12,23 +12,10 @@ import androidx.compose.ui.text.font.*
* *
* @see Resource * @see Resource
*/ */
@ExperimentalResourceApi
@Immutable @Immutable
class FontResource class FontResource
@InternalResourceApi constructor(id: String, items: Set<ResourceItem>): Resource(id, items) @InternalResourceApi constructor(id: String, items: Set<ResourceItem>): 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. * 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. * @throws NotFoundException if the specified resource ID is not found.
*/ */
@Composable @Composable
@ExperimentalResourceApi
expect fun Font( expect fun Font(
resource: FontResource, resource: FontResource,
weight: FontWeight = FontWeight.Normal, weight: FontWeight = FontWeight.Normal,

16
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 id The unique identifier of the drawable resource.
* @param items The set of resource items associated with the image resource. * @param items The set of resource items associated with the image resource.
*/ */
@ExperimentalResourceApi
@Immutable @Immutable
class DrawableResource class DrawableResource
@InternalResourceApi constructor(id: String, items: Set<ResourceItem>) : Resource(id, items) @InternalResourceApi constructor(id: String, items: Set<ResourceItem>) : 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. * Retrieves a [Painter] using the specified drawable resource.
* Automatically select a type of the Painter depending on the file extension. * 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. * @param resource The drawable resource to be used.
* @return The [Painter] loaded from the resource. * @return The [Painter] loaded from the resource.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun painterResource(resource: DrawableResource): Painter { fun painterResource(resource: DrawableResource): Painter {
val environment = LocalComposeEnvironment.current.rememberEnvironment() 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. * @param resource The drawable resource to be used.
* @return The ImageBitmap loaded from the resource. * @return The ImageBitmap loaded from the resource.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun imageResource(resource: DrawableResource): ImageBitmap { fun imageResource(resource: DrawableResource): ImageBitmap {
val resourceReader = LocalResourceReader.current val resourceReader = LocalResourceReader.current
@ -91,7 +76,6 @@ private val emptyImageVector: ImageVector by lazy {
* @param resource The drawable resource to be used. * @param resource The drawable resource to be used.
* @return The ImageVector loaded from the resource. * @return The ImageVector loaded from the resource.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun vectorResource(resource: DrawableResource): ImageVector { fun vectorResource(resource: DrawableResource): ImageVector {
val resourceReader = LocalResourceReader.current val resourceReader = LocalResourceReader.current

7
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 key The key used to retrieve the string resource.
* @param items The set of resource items associated with the string resource. * @param items The set of resource items associated with the string resource.
*/ */
@ExperimentalResourceApi
@Immutable @Immutable
class PluralStringResource class PluralStringResource
@InternalResourceApi constructor(id: String, val key: String, items: Set<ResourceItem>) : Resource(id, items) @InternalResourceApi constructor(id: String, val key: String, items: Set<ResourceItem>) : 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. * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun pluralStringResource(resource: PluralStringResource, quantity: Int): String { fun pluralStringResource(resource: PluralStringResource, quantity: Int): String {
val resourceReader = LocalResourceReader.current 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. * @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 = suspend fun getPluralString(resource: PluralStringResource, quantity: Int): String =
loadPluralString(resource, quantity, DefaultResourceReader, getResourceEnvironment()) loadPluralString(resource, quantity, DefaultResourceReader, getResourceEnvironment())
@OptIn(InternalResourceApi::class, ExperimentalResourceApi::class)
private suspend fun loadPluralString( private suspend fun loadPluralString(
resource: PluralStringResource, resource: PluralStringResource,
quantity: Int, 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. * @throws IllegalArgumentException If the provided ID or the pluralization is not found in the resource file.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun pluralStringResource(resource: PluralStringResource, quantity: Int, vararg formatArgs: Any): String { fun pluralStringResource(resource: PluralStringResource, quantity: Int, vararg formatArgs: Any): String {
val resourceReader = LocalResourceReader.current 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. * @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 = suspend fun getPluralString(resource: PluralStringResource, quantity: Int, vararg formatArgs: Any): String =
loadPluralString( loadPluralString(
resource, quantity, resource, quantity,
@ -108,7 +102,6 @@ suspend fun getPluralString(resource: PluralStringResource, quantity: Int, varar
getResourceEnvironment(), getResourceEnvironment(),
) )
@OptIn(ExperimentalResourceApi::class)
private suspend fun loadPluralString( private suspend fun loadPluralString(
resource: PluralStringResource, resource: PluralStringResource,
quantity: Int, quantity: Int,

1
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 id The ID of the resource.
* @property items The set of resource items associated with the resource. * @property items The set of resource items associated with the resource.
*/ */
@ExperimentalResourceApi
@Immutable @Immutable
sealed class Resource sealed class Resource
@InternalResourceApi constructor( @InternalResourceApi constructor(

2
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 internal var getResourceEnvironment = ::getSystemEnvironment
@OptIn(InternalResourceApi::class, ExperimentalResourceApi::class) @OptIn(InternalResourceApi::class)
internal fun Resource.getResourceItemByEnvironment(environment: ResourceEnvironment): ResourceItem { internal fun Resource.getResourceItemByEnvironment(environment: ResourceEnvironment): ResourceItem {
//Priority of environments: https://developer.android.com/guide/topics/resources/providing-resources#table2 //Priority of environments: https://developer.android.com/guide/topics/resources/providing-resources#table2
items.toList() items.toList()

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 import androidx.compose.runtime.staticCompositionLocalOf
@ExperimentalResourceApi
class MissingResourceException(path: String) : Exception("Missing resource with path: $path") class MissingResourceException(path: String) : Exception("Missing resource with path: $path")
/** /**

4
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 key The key used to retrieve the string array resource.
* @param items The set of resource items associated with the string array resource. * @param items The set of resource items associated with the string array resource.
*/ */
@ExperimentalResourceApi
@Immutable @Immutable
class StringArrayResource class StringArrayResource
@InternalResourceApi constructor(id: String, val key: String, items: Set<ResourceItem>) : Resource(id, items) @InternalResourceApi constructor(id: String, val key: String, items: Set<ResourceItem>) : Resource(id, items)
@ -29,7 +28,6 @@ class StringArrayResource
* *
* @throws IllegalStateException if the string array with the given ID is not found. * @throws IllegalStateException if the string array with the given ID is not found.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun stringArrayResource(resource: StringArrayResource): List<String> { fun stringArrayResource(resource: StringArrayResource): List<String> {
val resourceReader = LocalResourceReader.current val resourceReader = LocalResourceReader.current
@ -47,11 +45,9 @@ fun stringArrayResource(resource: StringArrayResource): List<String> {
* *
* @throws IllegalStateException if the string array with the given ID is not found. * @throws IllegalStateException if the string array with the given ID is not found.
*/ */
@ExperimentalResourceApi
suspend fun getStringArray(resource: StringArrayResource): List<String> = suspend fun getStringArray(resource: StringArrayResource): List<String> =
loadStringArray(resource, DefaultResourceReader, getResourceEnvironment()) loadStringArray(resource, DefaultResourceReader, getResourceEnvironment())
@OptIn(ExperimentalResourceApi::class, InternalResourceApi::class)
private suspend fun loadStringArray( private suspend fun loadStringArray(
resource: StringArrayResource, resource: StringArrayResource,
resourceReader: ResourceReader, resourceReader: ResourceReader,

7
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 key The key used to retrieve the string resource.
* @param items The set of resource items associated with the string resource. * @param items The set of resource items associated with the string resource.
*/ */
@ExperimentalResourceApi
@Immutable @Immutable
class StringResource class StringResource
@InternalResourceApi constructor(id: String, val key: String, items: Set<ResourceItem>) : Resource(id, items) @InternalResourceApi constructor(id: String, val key: String, items: Set<ResourceItem>) : Resource(id, items)
@ -22,7 +21,6 @@ class StringResource
* *
* @throws IllegalArgumentException If the provided ID is not found in the resource file. * @throws IllegalArgumentException If the provided ID is not found in the resource file.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun stringResource(resource: StringResource): String { fun stringResource(resource: StringResource): String {
val resourceReader = LocalResourceReader.current 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. * @throws IllegalArgumentException If the provided ID is not found in the resource file.
*/ */
@ExperimentalResourceApi
suspend fun getString(resource: StringResource): String = suspend fun getString(resource: StringResource): String =
loadString(resource, DefaultResourceReader, getResourceEnvironment()) loadString(resource, DefaultResourceReader, getResourceEnvironment())
@OptIn(ExperimentalResourceApi::class, InternalResourceApi::class)
private suspend fun loadString( private suspend fun loadString(
resource: StringResource, resource: StringResource,
resourceReader: ResourceReader, resourceReader: ResourceReader,
@ -64,7 +60,6 @@ private suspend fun loadString(
* *
* @throws IllegalArgumentException If the provided ID is not found in the resource file. * @throws IllegalArgumentException If the provided ID is not found in the resource file.
*/ */
@ExperimentalResourceApi
@Composable @Composable
fun stringResource(resource: StringResource, vararg formatArgs: Any): String { fun stringResource(resource: StringResource, vararg formatArgs: Any): String {
val resourceReader = LocalResourceReader.current 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. * @throws IllegalArgumentException If the provided ID is not found in the resource file.
*/ */
@ExperimentalResourceApi
suspend fun getString(resource: StringResource, vararg formatArgs: Any): String = loadString( suspend fun getString(resource: StringResource, vararg formatArgs: Any): String = loadString(
resource, resource,
formatArgs.map { it.toString() }, formatArgs.map { it.toString() },
@ -92,7 +86,6 @@ suspend fun getString(resource: StringResource, vararg formatArgs: Any): String
getResourceEnvironment() getResourceEnvironment()
) )
@OptIn(ExperimentalResourceApi::class)
private suspend fun loadString( private suspend fun loadString(
resource: StringResource, resource: StringResource,
args: List<String>, args: List<String>,

3
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 package org.jetbrains.compose.resources.vector.xmldom
import org.jetbrains.compose.resources.ExperimentalResourceApi
/** /**
* Error throw when parsed XML is malformed * Error throw when parsed XML is malformed
*/ */
@ExperimentalResourceApi
class MalformedXMLException(message: String?) : Exception(message) class MalformedXMLException(message: String?) : Exception(message)

12
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 org.jetbrains.skiko.URIManager
import kotlin.test.* import kotlin.test.*
@OptIn(ExperimentalTestApi::class, ExperimentalResourceApi::class, InternalResourceApi::class) @OptIn(ExperimentalTestApi::class, InternalResourceApi::class)
class ComposeResourceTest { class ComposeResourceTest {
init { init {
@ -20,7 +20,7 @@ class ComposeResourceTest {
@Test @Test
fun testCountRecompositions() = runComposeUiTest { fun testCountRecompositions() = runComposeUiTest {
var res by mutableStateOf(DrawableResource("1.png")) var res by mutableStateOf(TestDrawableResource("1.png"))
val recompositionsCounter = RecompositionsCounter() val recompositionsCounter = RecompositionsCounter()
setContent { setContent {
CompositionLocalProvider(LocalComposeEnvironment provides TestComposeEnvironment) { CompositionLocalProvider(LocalComposeEnvironment provides TestComposeEnvironment) {
@ -31,7 +31,7 @@ class ComposeResourceTest {
} }
} }
waitForIdle() waitForIdle()
res = DrawableResource("2.png") res = TestDrawableResource("2.png")
waitForIdle() waitForIdle()
assertEquals(2, recompositionsCounter.count) assertEquals(2, recompositionsCounter.count)
} }
@ -39,7 +39,7 @@ class ComposeResourceTest {
@Test @Test
fun testImageResourceCache() = runComposeUiTest { fun testImageResourceCache() = runComposeUiTest {
val testResourceReader = TestResourceReader() val testResourceReader = TestResourceReader()
var res by mutableStateOf(DrawableResource("1.png")) var res by mutableStateOf(TestDrawableResource("1.png"))
setContent { setContent {
CompositionLocalProvider( CompositionLocalProvider(
LocalResourceReader provides testResourceReader, LocalResourceReader provides testResourceReader,
@ -49,9 +49,9 @@ class ComposeResourceTest {
} }
} }
waitForIdle() waitForIdle()
res = DrawableResource("2.png") res = TestDrawableResource("2.png")
waitForIdle() waitForIdle()
res = DrawableResource("1.png") res = TestDrawableResource("1.png")
waitForIdle() waitForIdle()
assertEquals( assertEquals(

5
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 org.jetbrains.compose.resources.ThemeQualifier.LIGHT
import kotlin.test.* import kotlin.test.*
@OptIn(ExperimentalResourceApi::class, InternalResourceApi::class)
class ResourceTest { class ResourceTest {
@Test @Test
fun testResourceEquals() { fun testResourceEquals() {
assertEquals(DrawableResource("a"), DrawableResource("a")) assertEquals(TestDrawableResource("a"), TestDrawableResource("a"))
} }
@Test @Test
fun testResourceNotEquals() { fun testResourceNotEquals() {
assertNotEquals(DrawableResource("a"), DrawableResource("b")) assertNotEquals(TestDrawableResource("a"), TestDrawableResource("b"))
} }
@Test @Test

8
components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/TestUtils.kt

@ -17,27 +17,29 @@ private val cvrMap: Map<String, ResourceItem> = mapOf(
"str_arr" to ResourceItem(setOf(), "strings.cvr", 211, 47), "str_arr" to ResourceItem(setOf(), "strings.cvr", 211, 47),
) )
@OptIn(ExperimentalResourceApi::class)
internal fun TestStringResource(key: String) = StringResource( internal fun TestStringResource(key: String) = StringResource(
"STRING:$key", "STRING:$key",
key, key,
setOf(cvrMap[key] ?: error("String ID=`$key` is not found!")) setOf(cvrMap[key] ?: error("String ID=`$key` is not found!"))
) )
@OptIn(ExperimentalResourceApi::class)
internal fun TestStringArrayResource(key: String) = StringArrayResource( internal fun TestStringArrayResource(key: String) = StringArrayResource(
"STRING:$key", "STRING:$key",
key, key,
setOf(cvrMap[key] ?: error("String ID=`$key` is not found!")) setOf(cvrMap[key] ?: error("String ID=`$key` is not found!"))
) )
@OptIn(ExperimentalResourceApi::class)
internal fun TestPluralStringResource(key: String) = PluralStringResource( internal fun TestPluralStringResource(key: String) = PluralStringResource(
"PLURALS:$key", "PLURALS:$key",
key, key,
setOf(cvrMap[key] ?: error("String ID=`$key` is not found!")) 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<Int> { internal fun parsePluralSamples(samples: String): List<Int> {
return samples.split(',').flatMap { return samples.split(',').flatMap {
val range = it.trim() val range = it.trim()

2
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 return result
} }
@OptIn(ExperimentalResourceApi::class)
override fun getUri(path: String): String { override fun getUri(path: String): String {
val classLoader = getClassLoader() val classLoader = getClassLoader()
val resource = classLoader.getResource(path) ?: throw MissingResourceException(path) val resource = classLoader.getResource(path) ?: throw MissingResourceException(path)
return resource.toURI().toString() return resource.toURI().toString()
} }
@OptIn(ExperimentalResourceApi::class)
private fun getResourceAsStream(path: String): InputStream { private fun getResourceAsStream(path: String): InputStream {
val classLoader = getClassLoader() val classLoader = getClassLoader()
return classLoader.getResourceAsStream(path) ?: throw MissingResourceException(path) return classLoader.getResourceAsStream(path) ?: throw MissingResourceException(path)

1
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.Foundation.*
import platform.posix.memcpy import platform.posix.memcpy
@OptIn(ExperimentalResourceApi::class)
internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader {
override suspend fun read(path: String): ByteArray { override suspend fun read(path: String): ByteArray {
val data = readData(getPathInBundle(path)) val data = readData(getPathInBundle(path))

1
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.jetbrains.compose.resources.vector.xmldom.*
import org.w3c.dom.parsing.DOMParser import org.w3c.dom.parsing.DOMParser
@OptIn(ExperimentalResourceApi::class)
internal actual fun ByteArray.toXmlElement(): Element { internal actual fun ByteArray.toXmlElement(): Element {
val xmlString = decodeToString() val xmlString = decodeToString()
val xmlDom = DOMParser().parseFromString(xmlString, "application/xml") val xmlDom = DOMParser().parseFromString(xmlString, "application/xml")

1
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 org.w3c.files.Blob
import kotlin.js.Promise import kotlin.js.Promise
@OptIn(ExperimentalResourceApi::class)
internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader {
override suspend fun read(path: String): ByteArray { override suspend fun read(path: String): ByteArray {
return readAsBlob(path).asByteArray() return readAsBlob(path).asByteArray()

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.* import platform.Foundation.*
import platform.posix.memcpy import platform.posix.memcpy
@OptIn(ExperimentalResourceApi::class)
internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader {
override suspend fun read(path: String): ByteArray { override suspend fun read(path: String): ByteArray {
val data = readData(getPathOnDisk(path)) val data = readData(getPathOnDisk(path))

2
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 package org.jetbrains.compose.resources.vector.xmldom
import org.jetbrains.compose.resources.ExperimentalResourceApi
import platform.Foundation.NSError import platform.Foundation.NSError
import platform.Foundation.NSString import platform.Foundation.NSString
import platform.Foundation.NSUTF8StringEncoding import platform.Foundation.NSUTF8StringEncoding
@ -58,7 +57,6 @@ private class ElementImpl(
override fun lookupPrefix(namespaceURI: String): String = prefixMap[namespaceURI] ?: "" override fun lookupPrefix(namespaceURI: String): String = prefixMap[namespaceURI] ?: ""
} }
@OptIn(ExperimentalResourceApi::class)
@Suppress("CONFLICTING_OVERLOADS", "PARAMETER_NAME_CHANGED_ON_OVERRIDE") @Suppress("CONFLICTING_OVERLOADS", "PARAMETER_NAME_CHANGED_ON_OVERRIDE")
private class DomXmlParser : NSObject(), NSXMLParserDelegateProtocol { private class DomXmlParser : NSObject(), NSXMLParserDelegateProtocol {

1
components/resources/library/src/skikoMain/kotlin/org/jetbrains/compose/resources/FontResources.skiko.kt

@ -29,7 +29,6 @@ private val emptyFontBase64 =
@OptIn(ExperimentalEncodingApi::class) @OptIn(ExperimentalEncodingApi::class)
private val defaultEmptyFont by lazy { Font("org.jetbrains.compose.emptyFont", Base64.decode(emptyFontBase64)) } private val defaultEmptyFont by lazy { Font("org.jetbrains.compose.emptyFont", Base64.decode(emptyFontBase64)) }
@ExperimentalResourceApi
@Composable @Composable
actual fun Font(resource: FontResource, weight: FontWeight, style: FontStyle): Font { actual fun Font(resource: FontResource, weight: FontWeight, style: FontStyle): Font {
val resourceReader = LocalResourceReader.current val resourceReader = LocalResourceReader.current

1
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.jetbrains.compose.resources.vector.xmldom.MalformedXMLException
import org.w3c.dom.parsing.DOMParser import org.w3c.dom.parsing.DOMParser
@OptIn(ExperimentalResourceApi::class)
internal actual fun ByteArray.toXmlElement(): Element { internal actual fun ByteArray.toXmlElement(): Element {
val xmlString = decodeToString() val xmlString = decodeToString()
val xmlDom = DOMParser().parseFromString(xmlString, "application/xml".toJsString()) val xmlDom = DOMParser().parseFromString(xmlString, "application/xml".toJsString())

1
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()") @JsFun("(blob) => blob.arrayBuffer()")
private external fun jsExportBlobAsArrayBuffer(blob: Blob): Promise<ArrayBuffer> private external fun jsExportBlobAsArrayBuffer(blob: Blob): Promise<ArrayBuffer>
@OptIn(ExperimentalResourceApi::class)
internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader { internal actual fun getPlatformResourceReader(): ResourceReader = object : ResourceReader {
override suspend fun read(path: String): ByteArray { override suspend fun read(path: String): ByteArray {
return readAsBlob(path).asByteArray() return readAsBlob(path).asByteArray()

4
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. * @see configureWebResources - for overriding the default configuration.
*/ */
@Suppress("unused") @Suppress("unused")
@ExperimentalResourceApi
object WebResourcesConfiguration { object WebResourcesConfiguration {
internal var getResourcePath: (path: String) -> String = { "./$it" } 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 * @param map the mapping function that takes a path String and returns a modified path String
*/ */
@ExperimentalResourceApi
fun resourcePathMapping(map: (path: String) -> String) { fun resourcePathMapping(map: (path: String) -> String) {
getResourcePath = map getResourcePath = map
} }
@ -41,12 +39,10 @@ object WebResourcesConfiguration {
* ``` * ```
*/ */
@Suppress("unused") @Suppress("unused")
@ExperimentalResourceApi
fun configureWebResources(configure: WebResourcesConfiguration.() -> Unit) { fun configureWebResources(configure: WebResourcesConfiguration.() -> Unit) {
WebResourcesConfiguration.configure() WebResourcesConfiguration.configure()
} }
@OptIn(ExperimentalResourceApi::class)
internal fun getResourceUrl(windowOrigin: String, windowPathname: String, resourcePath: String): String { internal fun getResourceUrl(windowOrigin: String, windowPathname: String, resourcePath: String): String {
val path = WebResourcesConfiguration.getResourcePath(resourcePath) val path = WebResourcesConfiguration.getResourcePath(resourcePath)
return when { return when {

6
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 -> file.addType(TypeSpec.objectBuilder("Res").also { resObject ->
resObject.addModifiers(resModifier) resObject.addModifiers(resModifier)
resObject.addAnnotation(experimentalAnnotation)
//readFileBytes //readFileBytes
val readResourceBytes = MemberName("org.jetbrains.compose.resources", "readResourceBytes") 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. @return The content of the file as a byte array.
""".trimIndent() """.trimIndent()
) )
.addAnnotation(experimentalAnnotation)
.addParameter("path", String::class) .addParameter("path", String::class)
.addModifiers(KModifier.SUSPEND) .addModifiers(KModifier.SUSPEND)
.returns(ByteArray::class) .returns(ByteArray::class)
@ -164,6 +164,7 @@ internal fun getResFileSpec(
@return The URI string of the file. @return The URI string of the file.
""".trimIndent() """.trimIndent()
) )
.addAnnotation(experimentalAnnotation)
.addParameter("path", String::class) .addParameter("path", String::class)
.returns(String::class) .returns(String::class)
.addStatement("""return %M("$moduleDir" + path)""", getResourceUri) .addStatement("""return %M("$moduleDir" + path)""", getResourceUri)
@ -237,7 +238,6 @@ private fun getChunkFileSpec(
val objectSpec = TypeSpec.objectBuilder(chunkClassName).also { typeObject -> val objectSpec = TypeSpec.objectBuilder(chunkClassName).also { typeObject ->
typeObject.addModifiers(KModifier.PRIVATE) typeObject.addModifiers(KModifier.PRIVATE)
typeObject.addAnnotation(experimentalAnnotation)
val properties = idToResources.keys.map { resName -> val properties = idToResources.keys.map { resName ->
PropertySpec.builder(resName, type.getClassName()) PropertySpec.builder(resName, type.getClassName())
.delegate("\nlazy·{ init_$resName() }") .delegate("\nlazy·{ init_$resName() }")
@ -250,14 +250,12 @@ private fun getChunkFileSpec(
idToResources.forEach { (resName, items) -> idToResources.forEach { (resName, items) ->
val accessor = PropertySpec.builder(resName, type.getClassName(), resModifier) val accessor = PropertySpec.builder(resName, type.getClassName(), resModifier)
.receiver(ClassName(packageName, "Res", type.accessorName)) .receiver(ClassName(packageName, "Res", type.accessorName))
.addAnnotation(experimentalAnnotation)
.getter(FunSpec.getterBuilder().addStatement("return $chunkClassName.$resName").build()) .getter(FunSpec.getterBuilder().addStatement("return $chunkClassName.$resName").build())
.build() .build()
chunkFile.addProperty(accessor) chunkFile.addProperty(accessor)
val initializer = FunSpec.builder("init_$resName") val initializer = FunSpec.builder("init_$resName")
.addModifiers(KModifier.PRIVATE) .addModifiers(KModifier.PRIVATE)
.addAnnotation(experimentalAnnotation)
.returns(type.getClassName()) .returns(type.getClassName())
.addStatement( .addStatement(
CodeBlock.builder() CodeBlock.builder()

4
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
@ExperimentalResourceApi
private object AndroidMainString0 { private object AndroidMainString0 {
public val android_str: StringResource by public val android_str: StringResource by
lazy { init_android_str() } lazy { init_android_str() }
} }
@ExperimentalResourceApi
public val Res.string.android_str: StringResource public val Res.string.android_str: StringResource
get() = AndroidMainString0.android_str get() = AndroidMainString0.android_str
@ExperimentalResourceApi
private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:android_str", "android_str", "string:android_str", "android_str",
setOf( setOf(

10
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 kotlin.OptIn
import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.ExperimentalResourceApi
@ExperimentalResourceApi
private object CommonMainDrawable0 { private object CommonMainDrawable0 {
public val _3_strange_name: DrawableResource by public val _3_strange_name: DrawableResource by
lazy { init__3_strange_name() } lazy { init__3_strange_name() }
@ -21,11 +19,9 @@ private object CommonMainDrawable0 {
lazy { init_vector_2() } lazy { init_vector_2() }
} }
@ExperimentalResourceApi
public val Res.drawable._3_strange_name: DrawableResource public val Res.drawable._3_strange_name: DrawableResource
get() = CommonMainDrawable0._3_strange_name get() = CommonMainDrawable0._3_strange_name
@ExperimentalResourceApi
private fun init__3_strange_name(): DrawableResource = private fun init__3_strange_name(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:_3_strange_name", "drawable:_3_strange_name",
@ -34,11 +30,9 @@ private fun init__3_strange_name(): DrawableResource =
) )
) )
@ExperimentalResourceApi
public val Res.drawable.camelCaseName: DrawableResource public val Res.drawable.camelCaseName: DrawableResource
get() = CommonMainDrawable0.camelCaseName get() = CommonMainDrawable0.camelCaseName
@ExperimentalResourceApi
private fun init_camelCaseName(): DrawableResource = private fun init_camelCaseName(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:camelCaseName", "drawable:camelCaseName",
@ -47,11 +41,9 @@ private fun init_camelCaseName(): DrawableResource =
) )
) )
@ExperimentalResourceApi
public val Res.drawable.vector: DrawableResource public val Res.drawable.vector: DrawableResource
get() = CommonMainDrawable0.vector get() = CommonMainDrawable0.vector
@ExperimentalResourceApi
private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector", "drawable:vector",
setOf( setOf(
@ -72,11 +64,9 @@ private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.Dr
) )
) )
@ExperimentalResourceApi
public val Res.drawable.vector_2: DrawableResource public val Res.drawable.vector_2: DrawableResource
get() = CommonMainDrawable0.vector_2 get() = CommonMainDrawable0.vector_2
@ExperimentalResourceApi
private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector_2", "drawable:vector_2",
setOf( setOf(

4
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.FontResource import org.jetbrains.compose.resources.FontResource
@ExperimentalResourceApi
private object CommonMainFont0 { private object CommonMainFont0 {
public val emptyFont: FontResource by public val emptyFont: FontResource by
lazy { init_emptyFont() } lazy { init_emptyFont() }
} }
@ExperimentalResourceApi
public val Res.font.emptyFont: FontResource public val Res.font.emptyFont: FontResource
get() = CommonMainFont0.emptyFont get() = CommonMainFont0.emptyFont
@ExperimentalResourceApi
private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource( private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource(
"font:emptyFont", "font:emptyFont",
setOf( setOf(

4
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.PluralStringResource import org.jetbrains.compose.resources.PluralStringResource
@ExperimentalResourceApi
private object CommonMainPlurals0 { private object CommonMainPlurals0 {
public val numberOfSongsAvailable: PluralStringResource by public val numberOfSongsAvailable: PluralStringResource by
lazy { init_numberOfSongsAvailable() } lazy { init_numberOfSongsAvailable() }
} }
@ExperimentalResourceApi
public val Res.plurals.numberOfSongsAvailable: PluralStringResource public val Res.plurals.numberOfSongsAvailable: PluralStringResource
get() = CommonMainPlurals0.numberOfSongsAvailable get() = CommonMainPlurals0.numberOfSongsAvailable
@ExperimentalResourceApi
private fun init_numberOfSongsAvailable(): PluralStringResource = private fun init_numberOfSongsAvailable(): PluralStringResource =
org.jetbrains.compose.resources.PluralStringResource( org.jetbrains.compose.resources.PluralStringResource(
"plurals:numberOfSongsAvailable", "numberOfSongsAvailable", "plurals:numberOfSongsAvailable", "numberOfSongsAvailable",

16
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
@ExperimentalResourceApi
private object CommonMainString0 { private object CommonMainString0 {
public val PascalCase: StringResource by public val PascalCase: StringResource by
lazy { init_PascalCase() } lazy { init_PascalCase() }
@ -30,11 +28,9 @@ private object CommonMainString0 {
lazy { init_str_template() } lazy { init_str_template() }
} }
@ExperimentalResourceApi
public val Res.string.PascalCase: StringResource public val Res.string.PascalCase: StringResource
get() = CommonMainString0.PascalCase get() = CommonMainString0.PascalCase
@ExperimentalResourceApi
private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:PascalCase", "PascalCase", "string:PascalCase", "PascalCase",
setOf( setOf(
@ -43,11 +39,9 @@ private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.
) )
) )
@ExperimentalResourceApi
public val Res.string._1_kebab_case: StringResource public val Res.string._1_kebab_case: StringResource
get() = CommonMainString0._1_kebab_case get() = CommonMainString0._1_kebab_case
@ExperimentalResourceApi
private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:_1_kebab_case", "_1_kebab_case", "string:_1_kebab_case", "_1_kebab_case",
setOf( setOf(
@ -56,11 +50,9 @@ private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resourc
) )
) )
@ExperimentalResourceApi
public val Res.string.app_name: StringResource public val Res.string.app_name: StringResource
get() = CommonMainString0.app_name get() = CommonMainString0.app_name
@ExperimentalResourceApi
private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:app_name", "app_name", "string:app_name", "app_name",
setOf( setOf(
@ -69,11 +61,9 @@ private fun init_app_name(): StringResource = org.jetbrains.compose.resources.St
) )
) )
@ExperimentalResourceApi
public val Res.string.camelCase: StringResource public val Res.string.camelCase: StringResource
get() = CommonMainString0.camelCase get() = CommonMainString0.camelCase
@ExperimentalResourceApi
private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:camelCase", "camelCase", "string:camelCase", "camelCase",
setOf( setOf(
@ -82,11 +72,9 @@ private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.S
) )
) )
@ExperimentalResourceApi
public val Res.string.hello: StringResource public val Res.string.hello: StringResource
get() = CommonMainString0.hello get() = CommonMainString0.hello
@ExperimentalResourceApi
private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:hello", "hello", "string:hello", "hello",
setOf( setOf(
@ -95,11 +83,9 @@ private fun init_hello(): StringResource = org.jetbrains.compose.resources.Strin
) )
) )
@ExperimentalResourceApi
public val Res.string.multi_line: StringResource public val Res.string.multi_line: StringResource
get() = CommonMainString0.multi_line get() = CommonMainString0.multi_line
@ExperimentalResourceApi
private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:multi_line", "multi_line", "string:multi_line", "multi_line",
setOf( setOf(
@ -108,11 +94,9 @@ private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.
) )
) )
@ExperimentalResourceApi
public val Res.string.str_template: StringResource public val Res.string.str_template: StringResource
get() = CommonMainString0.str_template get() = CommonMainString0.str_template
@ExperimentalResourceApi
private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:str_template", "str_template", "string:str_template", "str_template",
setOf( setOf(

5
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.getResourceUri
import org.jetbrains.compose.resources.readResourceBytes import org.jetbrains.compose.resources.readResourceBytes
@ExperimentalResourceApi
public object Res { public object Res {
/** /**
* Reads the content of the resource file at the specified path and returns it as a byte array. * 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. * @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. * @return The content of the file as a byte array.
*/ */
@ExperimentalResourceApi
public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) 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. * @param path The path of the file in the compose resource's directory.
* @return The URI string of the file. * @return The URI string of the file.
*/ */
@ExperimentalResourceApi
public fun getUri(path: String): String = getResourceUri("" + path) public fun getUri(path: String): String = getResourceUri("" + path)
public object drawable public object drawable
@ -43,4 +44,4 @@ public object Res {
public object plurals public object plurals
public object font public object font
} }

4
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
@ExperimentalResourceApi
private object DesktopMainString0 { private object DesktopMainString0 {
public val desktop_str: StringResource by public val desktop_str: StringResource by
lazy { init_desktop_str() } lazy { init_desktop_str() }
} }
@ExperimentalResourceApi
public val Res.string.desktop_str: StringResource public val Res.string.desktop_str: StringResource
get() = DesktopMainString0.desktop_str get() = DesktopMainString0.desktop_str
@ExperimentalResourceApi
private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:desktop_str", "desktop_str", "string:desktop_str", "desktop_str",
setOf( setOf(

4
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
@ExperimentalResourceApi
private object AndroidMainString0 { private object AndroidMainString0 {
public val android_str: StringResource by public val android_str: StringResource by
lazy { init_android_str() } lazy { init_android_str() }
} }
@ExperimentalResourceApi
internal val Res.string.android_str: StringResource internal val Res.string.android_str: StringResource
get() = AndroidMainString0.android_str get() = AndroidMainString0.android_str
@ExperimentalResourceApi
private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:android_str", "android_str", "string:android_str", "android_str",
setOf( setOf(

10
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 kotlin.OptIn
import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.ExperimentalResourceApi
@ExperimentalResourceApi
private object CommonMainDrawable0 { private object CommonMainDrawable0 {
public val _3_strange_name: DrawableResource by public val _3_strange_name: DrawableResource by
lazy { init__3_strange_name() } lazy { init__3_strange_name() }
@ -21,11 +19,9 @@ private object CommonMainDrawable0 {
lazy { init_vector_2() } lazy { init_vector_2() }
} }
@ExperimentalResourceApi
internal val Res.drawable._3_strange_name: DrawableResource internal val Res.drawable._3_strange_name: DrawableResource
get() = CommonMainDrawable0._3_strange_name get() = CommonMainDrawable0._3_strange_name
@ExperimentalResourceApi
private fun init__3_strange_name(): DrawableResource = private fun init__3_strange_name(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:_3_strange_name", "drawable:_3_strange_name",
@ -34,11 +30,9 @@ private fun init__3_strange_name(): DrawableResource =
) )
) )
@ExperimentalResourceApi
internal val Res.drawable.camelCaseName: DrawableResource internal val Res.drawable.camelCaseName: DrawableResource
get() = CommonMainDrawable0.camelCaseName get() = CommonMainDrawable0.camelCaseName
@ExperimentalResourceApi
private fun init_camelCaseName(): DrawableResource = private fun init_camelCaseName(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:camelCaseName", "drawable:camelCaseName",
@ -47,11 +41,9 @@ private fun init_camelCaseName(): DrawableResource =
) )
) )
@ExperimentalResourceApi
internal val Res.drawable.vector: DrawableResource internal val Res.drawable.vector: DrawableResource
get() = CommonMainDrawable0.vector get() = CommonMainDrawable0.vector
@ExperimentalResourceApi
private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector", "drawable:vector",
setOf( setOf(
@ -72,11 +64,9 @@ private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.Dr
) )
) )
@ExperimentalResourceApi
internal val Res.drawable.vector_2: DrawableResource internal val Res.drawable.vector_2: DrawableResource
get() = CommonMainDrawable0.vector_2 get() = CommonMainDrawable0.vector_2
@ExperimentalResourceApi
private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector_2", "drawable:vector_2",
setOf( setOf(

4
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.FontResource import org.jetbrains.compose.resources.FontResource
@ExperimentalResourceApi
private object CommonMainFont0 { private object CommonMainFont0 {
public val emptyFont: FontResource by public val emptyFont: FontResource by
lazy { init_emptyFont() } lazy { init_emptyFont() }
} }
@ExperimentalResourceApi
internal val Res.font.emptyFont: FontResource internal val Res.font.emptyFont: FontResource
get() = CommonMainFont0.emptyFont get() = CommonMainFont0.emptyFont
@ExperimentalResourceApi
private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource( private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource(
"font:emptyFont", "font:emptyFont",
setOf( setOf(

4
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.PluralStringResource import org.jetbrains.compose.resources.PluralStringResource
@ExperimentalResourceApi
private object CommonMainPlurals0 { private object CommonMainPlurals0 {
public val numberOfSongsAvailable: PluralStringResource by public val numberOfSongsAvailable: PluralStringResource by
lazy { init_numberOfSongsAvailable() } lazy { init_numberOfSongsAvailable() }
} }
@ExperimentalResourceApi
internal val Res.plurals.numberOfSongsAvailable: PluralStringResource internal val Res.plurals.numberOfSongsAvailable: PluralStringResource
get() = CommonMainPlurals0.numberOfSongsAvailable get() = CommonMainPlurals0.numberOfSongsAvailable
@ExperimentalResourceApi
private fun init_numberOfSongsAvailable(): PluralStringResource = private fun init_numberOfSongsAvailable(): PluralStringResource =
org.jetbrains.compose.resources.PluralStringResource( org.jetbrains.compose.resources.PluralStringResource(
"plurals:numberOfSongsAvailable", "numberOfSongsAvailable", "plurals:numberOfSongsAvailable", "numberOfSongsAvailable",

16
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
@ExperimentalResourceApi
private object CommonMainString0 { private object CommonMainString0 {
public val PascalCase: StringResource by public val PascalCase: StringResource by
lazy { init_PascalCase() } lazy { init_PascalCase() }
@ -30,11 +28,9 @@ private object CommonMainString0 {
lazy { init_str_template() } lazy { init_str_template() }
} }
@ExperimentalResourceApi
internal val Res.string.PascalCase: StringResource internal val Res.string.PascalCase: StringResource
get() = CommonMainString0.PascalCase get() = CommonMainString0.PascalCase
@ExperimentalResourceApi
private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:PascalCase", "PascalCase", "string:PascalCase", "PascalCase",
setOf( setOf(
@ -43,11 +39,9 @@ private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.
) )
) )
@ExperimentalResourceApi
internal val Res.string._1_kebab_case: StringResource internal val Res.string._1_kebab_case: StringResource
get() = CommonMainString0._1_kebab_case get() = CommonMainString0._1_kebab_case
@ExperimentalResourceApi
private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:_1_kebab_case", "_1_kebab_case", "string:_1_kebab_case", "_1_kebab_case",
setOf( setOf(
@ -56,11 +50,9 @@ private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resourc
) )
) )
@ExperimentalResourceApi
internal val Res.string.app_name: StringResource internal val Res.string.app_name: StringResource
get() = CommonMainString0.app_name get() = CommonMainString0.app_name
@ExperimentalResourceApi
private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:app_name", "app_name", "string:app_name", "app_name",
setOf( setOf(
@ -69,11 +61,9 @@ private fun init_app_name(): StringResource = org.jetbrains.compose.resources.St
) )
) )
@ExperimentalResourceApi
internal val Res.string.camelCase: StringResource internal val Res.string.camelCase: StringResource
get() = CommonMainString0.camelCase get() = CommonMainString0.camelCase
@ExperimentalResourceApi
private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:camelCase", "camelCase", "string:camelCase", "camelCase",
setOf( setOf(
@ -82,11 +72,9 @@ private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.S
) )
) )
@ExperimentalResourceApi
internal val Res.string.hello: StringResource internal val Res.string.hello: StringResource
get() = CommonMainString0.hello get() = CommonMainString0.hello
@ExperimentalResourceApi
private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:hello", "hello", "string:hello", "hello",
setOf( setOf(
@ -95,11 +83,9 @@ private fun init_hello(): StringResource = org.jetbrains.compose.resources.Strin
) )
) )
@ExperimentalResourceApi
internal val Res.string.multi_line: StringResource internal val Res.string.multi_line: StringResource
get() = CommonMainString0.multi_line get() = CommonMainString0.multi_line
@ExperimentalResourceApi
private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:multi_line", "multi_line", "string:multi_line", "multi_line",
setOf( setOf(
@ -108,11 +94,9 @@ private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.
) )
) )
@ExperimentalResourceApi
internal val Res.string.str_template: StringResource internal val Res.string.str_template: StringResource
get() = CommonMainString0.str_template get() = CommonMainString0.str_template
@ExperimentalResourceApi
private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:str_template", "str_template", "string:str_template", "str_template",
setOf( setOf(

3
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.getResourceUri
import org.jetbrains.compose.resources.readResourceBytes import org.jetbrains.compose.resources.readResourceBytes
@ExperimentalResourceApi
internal object Res { internal object Res {
/** /**
* Reads the content of the resource file at the specified path and returns it as a byte array. * 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. * @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. * @return The content of the file as a byte array.
*/ */
@ExperimentalResourceApi
public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) 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. * @param path The path of the file in the compose resource's directory.
* @return The URI string of the file. * @return The URI string of the file.
*/ */
@ExperimentalResourceApi
public fun getUri(path: String): String = getResourceUri("" + path) public fun getUri(path: String): String = getResourceUri("" + path)
public object drawable public object drawable

4
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
@ExperimentalResourceApi
private object DesktopMainString0 { private object DesktopMainString0 {
public val desktop_str: StringResource by public val desktop_str: StringResource by
lazy { init_desktop_str() } lazy { init_desktop_str() }
} }
@ExperimentalResourceApi
internal val Res.string.desktop_str: StringResource internal val Res.string.desktop_str: StringResource
get() = DesktopMainString0.desktop_str get() = DesktopMainString0.desktop_str
@ExperimentalResourceApi
private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:desktop_str", "desktop_str", "string:desktop_str", "desktop_str",
setOf( setOf(

3
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.getResourceUri
import org.jetbrains.compose.resources.readResourceBytes import org.jetbrains.compose.resources.readResourceBytes
@ExperimentalResourceApi
internal object Res { internal object Res {
/** /**
* Reads the content of the resource file at the specified path and returns it as a byte array. * 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. * @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. * @return The content of the file as a byte array.
*/ */
@ExperimentalResourceApi
public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) 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. * @param path The path of the file in the compose resource's directory.
* @return The URI string of the file. * @return The URI string of the file.
*/ */
@ExperimentalResourceApi
public fun getUri(path: String): String = getResourceUri("" + path) public fun getUri(path: String): String = getResourceUri("" + path)
public object drawable public object drawable

3
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.getResourceUri
import org.jetbrains.compose.resources.readResourceBytes import org.jetbrains.compose.resources.readResourceBytes
@ExperimentalResourceApi
internal object Res { internal object Res {
/** /**
* Reads the content of the resource file at the specified path and returns it as a byte array. * 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. * @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. * @return The content of the file as a byte array.
*/ */
@ExperimentalResourceApi
public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) 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. * @param path The path of the file in the compose resource's directory.
* @return The URI string of the file. * @return The URI string of the file.
*/ */
@ExperimentalResourceApi
public fun getUri(path: String): String = getResourceUri("" + path) public fun getUri(path: String): String = getResourceUri("" + path)
public object drawable public object drawable

4
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 kotlin.OptIn
import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.ExperimentalResourceApi
@ExperimentalResourceApi
private object MainDrawable0 { private object MainDrawable0 {
public val vector: DrawableResource by public val vector: DrawableResource by
lazy { init_vector() } lazy { init_vector() }
} }
@ExperimentalResourceApi
internal val Res.drawable.vector: DrawableResource internal val Res.drawable.vector: DrawableResource
get() = MainDrawable0.vector get() = MainDrawable0.vector
@ExperimentalResourceApi
private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector", "drawable:vector",
setOf( setOf(

Loading…
Cancel
Save