generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 480
Closed
Labels
Description
Background
Currently, xiuper-ui is a JVM-only module (using kotlin("jvm") plugin), which means:
- NanoDSL parser and IR generation are only available on JVM platforms
StatefulNanoRenderercannot be used on wasmJs, JS, iOS, Android platforms- The wasmJs version of
NanoDSLBlockRendererhas to use a simplified implementation without live preview
Goal
Convert xiuper-ui to a Kotlin Multiplatform module to enable:
- ✅ Full NanoDSL parsing on all platforms (JVM, wasmJs, JS, Android, iOS)
- ✅ Live UI preview with
StatefulNanoRendereron wasmJs and other platforms - ✅ Unified codebase across all platforms
Analysis
Core Code (Platform-agnostic, can move to commonMain)
NanoDSL.kt- Main DSL facadeNanoIR.kt,NanoIRConverter.kt- IR representation and conversionIndentParser.kt,NanoParser.kt- Parser implementationNanoSpec.kt,NanoSpecV1.kt- DSL specificationNanoNode.kt,Binding.kt- AST nodesNanoAction.kt,NanoActionHandler.kt- Action handlingNanoState.kt,NanoStateManager.kt- State managementNanoRenderer.kt,HtmlRenderer.kt,NanoRenderContext.kt- RenderingPromptTemplate.kt- Prompt templatesEvaluator.kt- Evaluation framework
JVM-Specific Code (needs expect/actual)
- ConfigLoader.kt - Uses
File,System.getProperty("user.home") - DslEvalRunner.kt - Uses
File,System.getenv(),KotlinLogging - DslToHtmlRenderer.kt - Uses
File - DslValidator.kt - Uses
File - TestSuite.kt, TestCase.kt - Uses
System.currentTimeMillis() - SuiteFileFormat.kt - Uses
File
Implementation Plan
-
Step 1: Convert build.gradle.kts from
kotlin("jvm")tokotlin("multiplatform")- Configure source sets:
commonMain,jvmMain,wasmJsMain,androidMain,iosMain - Move dependencies to appropriate source sets
- Configure source sets:
-
Step 2: Restructure source code
- Create
src/commonMain/kotlindirectory - Move core code (NanoDSL, parser, IR, etc.) to
commonMain - Keep existing code in
src/main/kotlin→ rename tosrc/jvmMain/kotlin
- Create
-
Step 3: Create expect/actual for platform-specific APIs
- Create
expectdeclarations incommonMainfor:- File I/O operations
- System properties (
user.home, environment variables) - Current timestamp
- Logging
- Implement
actualinjvmMain(existing JVM implementation) - Implement
actualinwasmJsMain(stub or browser-compatible implementation)
- Create
-
Step 4: Update mpp-ui to use multiplatform xiuper-ui
- Update
NanoDSLBlockRenderer.wasmJs.ktto use full parser and renderer - Remove simplified wasmJs implementation
- Test on all platforms
- Update
-
Step 5: Build and test
- Run
./gradlew :xiuper-ui:buildto ensure all platforms compile - Run
./gradlew :mpp-ui:wasmJsBrowserProductionWebpackto test wasmJs - Verify NanoDSL live preview works on wasmJs
- Run
Benefits
- Unified codebase: Same NanoDSL parser and renderer across all platforms
- Better user experience: Live preview on web (wasmJs) and mobile platforms
- Easier maintenance: No need to maintain separate implementations
- Future-proof: Easy to add new platforms (iOS, Android, etc.)
Related Files
xiuper-ui/build.gradle.ktsmpp-ui/src/wasmJsMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/NanoDSLBlockRenderer.wasmJs.ktmpp-ui/src/jvmMain/kotlin/cc/unitmesh/devins/ui/compose/sketch/NanoDSLBlockRenderer.jvm.kt
References
- Kotlin Multiplatform documentation: https://kotlinlang.org/docs/multiplatform.html
- expect/actual mechanism: https://kotlinlang.org/docs/multiplatform-connect-to-apis.html
Reactions are currently unavailable