Skip to content

Commit

Permalink
updated Markdown Renderer library with Wasm support
Browse files Browse the repository at this point in the history
  • Loading branch information
joreilly committed Apr 5, 2024
1 parent 97efa25 commit bfb2b5a
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 42 deletions.
5 changes: 1 addition & 4 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ kotlin {

implementation(libs.kotlinx.coroutines)

implementation(libs.koalaplot)
implementation(libs.markdown.renderer)
api(libs.compose.window.size)

api(libs.generativeai)
Expand All @@ -70,20 +70,17 @@ kotlin {

implementation(libs.voyager)
implementation(libs.mpfilepicker)
implementation(libs.markdown.renderer)
}

desktopMain.dependencies {
implementation(compose.desktop.currentOs)
implementation(libs.ktor.client.java)
implementation(libs.mpfilepicker)
implementation(libs.markdown.renderer)
}

appleMain.dependencies {
implementation(libs.ktor.client.darwin)
implementation(libs.mpfilepicker)
implementation(libs.markdown.renderer)
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions composeApp/src/androidMain/kotlin/actual.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ actual fun ByteArray.toComposeImageBitmap(): ImageBitmap {
}


@Composable
actual fun GeminiMarkdown(content: String) {
Markdown(content)
}


@OptIn(ExperimentalEncodingApi::class)
@Composable
actual fun ImagePicker(
Expand Down
3 changes: 2 additions & 1 deletion composeApp/src/commonMain/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.unit.dp
import com.mikepenz.markdown.m3.Markdown
import dev.shreyaspatil.ai.client.generativeai.type.GenerateContentResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onCompletion
Expand Down Expand Up @@ -158,7 +159,7 @@ fun App() {
CircularProgressIndicator()
}
} else {
GeminiMarkdown(content)
Markdown(content)
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions composeApp/src/commonMain/kotlin/expect.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ expect fun ByteArray.toComposeImageBitmap(): ImageBitmap

typealias ImageFileImported = (filePath: String, data: ByteArray?) -> Unit



@Composable
expect fun GeminiMarkdown(content: String)

@Composable
expect fun ImagePicker(
show: Boolean,
Expand Down
5 changes: 0 additions & 5 deletions composeApp/src/desktopMain/kotlin/actual.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import org.jetbrains.skia.Image

actual fun ByteArray.toComposeImageBitmap(): ImageBitmap = Image.makeFromEncoded(this).toComposeImageBitmap()

@Composable
actual fun GeminiMarkdown(content: String) {
Markdown(content)
}

@Composable
actual fun ImagePicker(
show: Boolean,
Expand Down
5 changes: 0 additions & 5 deletions composeApp/src/iosMain/kotlin/actual.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ actual fun ByteArray.toComposeImageBitmap(): ImageBitmap {
return Image.makeFromEncoded(this).toComposeImageBitmap()
}

@Composable
actual fun GeminiMarkdown(content: String) {
Markdown(content)
}

@Composable
actual fun ImagePicker(
show: Boolean,
Expand Down
8 changes: 0 additions & 8 deletions composeApp/src/wasmJsMain/kotlin/actual.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.graphics.ImageBitmap
Expand All @@ -14,20 +13,13 @@ import org.w3c.files.get
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine
import kotlin.io.encoding.ExperimentalEncodingApi


actual fun ByteArray.toComposeImageBitmap(): ImageBitmap {
return Image.makeFromEncoded(this).toComposeImageBitmap()
}

@Composable
actual fun GeminiMarkdown(content: String) {
Text(content)
}


@OptIn(ExperimentalEncodingApi::class)
@Composable
actual fun ImagePicker(
show: Boolean,
Expand Down
14 changes: 6 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ androidx-core-ktx = "1.12.0"
androidx-espresso-core = "3.5.1"
androidx-material = "1.11.0"
androidx-test-junit = "1.1.5"
compose = "1.6.2"
compose = "1.6.4"
compose-compiler = "1.5.8"
compose-plugin = "1.6.0"
compose-plugin = "1.6.1"
composeWindowSize = "0.5.0"
generativeai = "0.2.1-1.0.0-wasm"
horologist = "0.6.3"
imageLoader = "1.7.7"
generativeai = "0.2.2-1.0.0-wasm"
horologist = "0.6.6"
imageLoader = "1.7.8"
junit = "4.13.2"
koalaplot = "0.5.1"
kotlin = "1.9.22"
kotlinx-coroutines = "1.8.0"
ktor = "3.0.0-wasm2"
voyager= "1.0.0"
buildkonfig = "0.15.1"
mpFilePicker = "3.1.0"
markdownRenderer = "0.13.0"
markdownRenderer = "0.14.0"
wearCompose = "1.3.0"

[libraries]
Expand Down Expand Up @@ -74,7 +73,6 @@ ktor-client-okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.r

voyager = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyager" }
imageLoader = { module = "io.github.qdsfdhvh:image-loader", version.ref = "imageLoader" }
koalaplot = { module = "io.github.koalaplot:koalaplot-core", version.ref = "koalaplot" }
desugar = "com.android.tools:desugar_jdk_libs:2.0.4"

[bundles]
Expand Down

0 comments on commit bfb2b5a

Please sign in to comment.