JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.15k stars 1.17k forks source link

Canvas/Wasm: NotImplementedError AnnotatedString.transform #3262

Closed eygraber closed 1 year ago

eygraber commented 1 year ago

Describe the bug When running the following code in Canvas/Wasm I get a NotImplementedError for AnnotatedString.tranform:

VisualTransformation {
  TransformedText(
    AnnotatedString.Builder("#").apply {
      append(it.toUpperCase())
    }.toAnnotatedString(),
    object : OffsetMapping {
      override fun originalToTransformed(offset: Int) = offset + 1

      override fun transformedToOriginal(offset: Int) = when(offset) {
        0 -> 0
        else -> offset - 1
      }
    }
  )
}

Affected platforms

Versions

Uncaught Error
    at kotlin.captureStackTrace (ht-material-showcase-webApp-wasm.uninstantiated.mjs:20:44)
    at <dev.ht2.material:webApp>.kotlin.captureStackTrace__externalAdapter (Throwable.kt:47:9)
    at <dev.ht2.material:webApp>.kotlin.Throwable.<init> (Throwable.kt:25:51)
    at <dev.ht2.material:webApp>.kotlin.Throwable.<init> (Throwable.kt:19:37)
    at <dev.ht2.material:webApp>.kotlin.Error.<init> (Exceptions.kt:10:51)
    at <dev.ht2.material:webApp>.kotlin.NotImplementedError.<init> (Standard.kt:15:90)
    at <dev.ht2.material:webApp>.androidx.compose.ui.text.transform (JsAnnotatedString.kt:30:11)
    at <dev.ht2.material:webApp>.androidx.compose.ui.text.toUpperCase (AnnotatedString.kt:828:12)
    at <dev.ht2.material:webApp>.androidx.compose.ui.text.toUpperCase$default (AnnotatedString.kt:827:1)
eygraber commented 1 year ago

Not sure if this is a regression of https://github.com/JetBrains/compose-multiplatform/issues/3139 because I don't know where 1.4.0-dev-wasm08 is in relation to that fix.

MatkovIvan commented 1 year ago

I believe that native implementation should fit wasm too, but for some reason it wasn't used there. Probably just some mess in sourcesets.

Thanks for the report, we'll take a look

eymar commented 1 year ago

It's fixed in 1.4.0-dev-wasm09. It expects kotlin 1.9.0.

eymar commented 1 year ago

Feel free to add more questions or reopen if necessary

okushnikov commented 3 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.