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 c8f4877787..960fb9f642 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 @@ -33,10 +33,16 @@ expect suspend fun readResourceBytes(path: String): ByteArray * * @return A flow that emits the content of the file as byte sub-arrays. * - * @throws IllegalArgumentException - when [byteCount] is not positive. + * @throws IllegalArgumentException When [byteCount] is not positive. */ @InternalResourceApi -expect fun getResourceAsFlow(path: String, byteCount: Int = 8192): Flow +expect fun getResourceAsFlow(path: String, byteCount: Int = DEFAULT_RESOURCE_CHUNK_SIZE): Flow + +/** + * The default size of byte array chunks emitted by flows built with [getResourceAsFlow]. + */ +@InternalResourceApi +const val DEFAULT_RESOURCE_CHUNK_SIZE: Int = 8192 internal interface ResourceReader { suspend fun read(path: String): ByteArray diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesSpec.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesSpec.kt index 75e85165b3..744aa2e5a8 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesSpec.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesSpec.kt @@ -153,6 +153,9 @@ internal fun getResFileSpecs( .build() ) + val defaultResourceChunkSize = MemberName( + "org.jetbrains.compose.resources", "DEFAULT_RESOURCE_CHUNK_SIZE" + ) val getResourceAsFlow = MemberName("org.jetbrains.compose.resources", "getResourceAsFlow") resObject.addFunction( FunSpec.builder("getAsFlow") @@ -172,13 +175,13 @@ internal fun getResFileSpecs( @return A flow that emits the content of the file as byte sub-arrays. - @throws IllegalArgumentException - when [byteCount] is not positive. + @throws IllegalArgumentException When [byteCount] is not positive. """.trimIndent() ) .addParameter("path", String::class) .addParameter( ParameterSpec.builder("byteCount", Int::class) - .defaultValue("%L", 8192) + .defaultValue("%M", defaultResourceChunkSize) .build() ) .returns(