ComposeGears / Valkyrie

SVG/XML to Compose ImageVector: IntelliJ IDEA / Android Studio plugin + build-in previewer without compilation, CLI tool
Apache License 2.0
451 stars 7 forks source link

Incompatible with K2 #134

Closed lisonge closed 3 months ago

lisonge commented 3 months ago

Plugin 'Valkyrie - SVG to ImageVector' wasn't loaded because it's incompatible with the Kotlin plugin in K2 mode

image

Android Studio Koala Feature Drop | 2024.1.2 RC 1
Build #AI-241.18034.62.2412.12169539, built on August 1, 2024
Runtime version: 17.0.11+0--11852314 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
Kotlin Plugin: K2 Kotlin Mode (Alpha)
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16
Registry:
  debugger.new.tool.window.layout=true
  ide.experimental.ui=true
Non-Bundled Plugins:
  com.intellij.marketplace (241.18034.106)
  com.nasller.CodeGlancePro (1.8.5)
  izhangzhihao.rainbow.brackets (2024.2.6-241)
  com.github.copilot (1.5.19.6527)
  mobi.hsz.idea.gitignore (4.5.3)

first thank your great wrok

I found that this plugin can only be used in Android Studio. Is it possible to use Kotlin/JS or Kotlin/WASM to export the core functionality of this plugin as a library, so that it can be used in a browser? This way, others can perform the conversion online by simply opening a browser.

This is because each user's version of Android Studio is different, leading to compatibility issues. Additionally, on my device, Android Studio often has bugs where it fails to highlight code and shows errors for unused variables. Therefore, if the plugin's conversion functionality could be used in a browser, it would be great.

lisonge commented 3 months ago

the following is the example that js invoke kotlin code by kotlin multiplatform in my open source project

https://github.com/gkd-kit/gkd/blob/8e3246a9a639e4c4f2a9418d2a53d3eefdcb44b0/selector/build.gradle.kts#L12

https://github.com/gkd-kit/inspect/blob/a92aba9298c2fe5ef1495608671bdf37aa23204a/src/utils/selector.ts#L23

egorikftp commented 3 months ago

Hello, will check K2 mode support 🙂

Speaking about WASM, it's not possible right now due to I use https://maven.google.com/web/index.html?q=sdk-common#com.android.tools:sdk-common:31.5.2 jvm only dependency for conversion (the same as used in Android Studio).

egorikftp commented 3 months ago

Ref: https://kotlin.github.io/analysis-api/migrating-from-k1.html#declaring-compatibility-with-the-k2-kotlin-mode

lisonge commented 3 months ago

Speaking about WASM, it's not possible

What I mean is that we only need to release a Kotlin Multiplatform library with a single function that converts an XML/SVG formatted string into a Compose ImageVector formatted string. It's simply converting one string into another, without involving any platform-specific code.

vkatz commented 3 months ago

Speaking about WASM, it's not possible

What I mean is that we only need to release a Kotlin Multiplatform library with a single function that converts an XML/SVG formatted string into a Compose ImageVector formatted string. It's simply converting one string into another, without involving any platform-specific code.

There is not just fun(string)->string Under the hood there are svg & xml parsers libs that works on jvm and does not support WASM (yet) So we cant just enable wasm support and make 1 fun (to rule them all)

As option you can wait for CLI (command line tool) feature(#25) and use it

lisonge commented 3 months ago

ok thanks

I'm not sure if you can replace the underlying XML parsing library with one that supports Kotlin Multiplatform, but I guess that might be a bit of a big task. So, let's leave it as it is for now. If I'm interested later, I might consider implementing this library myself

Goooler commented 3 months ago
  1. We have to fix the K2 compatibility, which is the issue reported.
  2. Something else sounds like a new feature should be filed to a new one.
egorikftp commented 3 months ago

K2 should be available in 0.6.1. Please note, plugin can be installed manually and everything will work. Compatibility problem introduced by jetbrains marketplace 😑

egorikftp commented 3 months ago

issue not fixed

image

UPD: Based on documentation

Starting from IntelliJ 2024.2.1 (Preview), the following setting in the plugin.xml can be used to declare compatibility with the K2 mode:

this will be available only starting from 2024.2.1 (RC now)

image

In this version everything works as expected.

Screenshot 2024-08-21 at 16 29 45