Motivation
Android apps need to render formspec forms as native Jetpack Compose UI. A Kotlin package mirroring formspec-swift's architecture — hidden Android WebView bridge, Compose-native state, composable component map — provides full spec compliance without reimplementing the engine in Kotlin.
Architecture
Three layers (mirrors formspec-swift):
- Bridge — Hidden Android
WebView loads the same HTML bundle as Swift (shared packages/formspec-bridge/). Kotlin sends EngineCommand JSON via evaluateJavascript(), receives EngineEvent JSON via @JavascriptInterface.
- State —
@Stable classes (FieldState, FormState) backed by Compose mutableStateOf() / StateFlow. @Immutable on LayoutNode.
- Renderer —
FormspecForm composable walks the LayoutNode tree. Component map (Map<String, @Composable (FieldState) -> Unit>) provides default Material 3 components, overridable by the consumer.
Scope
- Kotlin package (Maven:
org.formspec:formspec-kotlin)
- Android API 26+ minimum (WebView WASM support,
onRenderProcessGone)
- Compose 1.5+ / Compose BOM 2024+
- Hidden Android WebView bridge sharing HTML bundle with Swift
- @Stable/@immutable state objects with Compose snapshot integration
- Auto-renderer with Material 3 default components
- ProGuard
consumer-rules.pro for @JavascriptInterface
- NOT KMP/Compose Multiplatform (Rust WASM is the shared layer; platform binding is ~500 lines)
Status
ADR accepted (0053). No implementation yet.
Key References
- ADR:
thoughts/adr/0053-formspec-kotlin.md
- Swift design spec (architecture model):
thoughts/specs/2026-03-25-formspec-swift-design.md
Key Decisions (from ADR 0053)
- Separate Kotlin package, not KMP — platform WebView binding is minimal
- API 26+ for WASM WebView support
- Shared HTML bundle from formspec-bridge
- Lifecycle-aware: bridge tied to ViewModel, survives config changes
- ProGuard rules required for JS interface
Acceptance Criteria
Part of #4
Motivation
Android apps need to render formspec forms as native Jetpack Compose UI. A Kotlin package mirroring formspec-swift's architecture — hidden Android WebView bridge, Compose-native state, composable component map — provides full spec compliance without reimplementing the engine in Kotlin.
Architecture
Three layers (mirrors formspec-swift):
WebViewloads the same HTML bundle as Swift (sharedpackages/formspec-bridge/). Kotlin sendsEngineCommandJSON viaevaluateJavascript(), receivesEngineEventJSON via@JavascriptInterface.@Stableclasses (FieldState,FormState) backed by ComposemutableStateOf()/StateFlow.@ImmutableonLayoutNode.FormspecFormcomposable walks theLayoutNodetree. Component map (Map<String, @Composable (FieldState) -> Unit>) provides default Material 3 components, overridable by the consumer.Scope
org.formspec:formspec-kotlin)onRenderProcessGone)consumer-rules.profor@JavascriptInterfaceStatus
ADR accepted (0053). No implementation yet.
Key References
thoughts/adr/0053-formspec-kotlin.mdthoughts/specs/2026-03-25-formspec-swift-design.mdKey Decisions (from ADR 0053)
Acceptance Criteria
Part of #4