WebView-based implementation of the viewer API for AutoDev, using compose-webview-multiplatform and Monaco Editor.
- Cross-platform WebView support (JVM, Android, iOS)
- Monaco Editor integration for code syntax highlighting
- Offline-capable viewer HTML
- Support for multiple content types (code, markdown, images, etc.)
WebViewerHost: Implementation ofViewerHostthat communicates with WebView via JavaScriptViewerWebView: Composable WebView component for displaying contentviewer.html: Embedded HTML with Monaco Editor for offline viewing
@Composable
fun MyFileViewer(filePath: String) {
val webViewState = rememberWebViewState(url = "")
val viewerHost = remember { WebViewerHost(webViewState) }
ViewerWebView(
viewerHost = viewerHost,
onReady = {
// WebView is ready, show content
val request = ViewerRequest(
type = ViewerType.CODE,
content = fileContent,
language = LanguageDetector.detectLanguage(filePath)
)
viewerHost.showContent(request)
}
)
}mpp-viewer: Core viewer APIcompose-webview-multiplatform: Cross-platform WebView componentkotlinx-serialization-json: JSON serialization for viewer requests