Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS, macOS, and js support #23

Merged
merged 77 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
629ecac
fix build
luca992 Aug 9, 2022
d01f281
Update kotlin to 1.7.10 and other dependencies. Cleanup unused
luca992 Aug 9, 2022
43f9dae
setup project for native darwin targets.
luca992 Aug 9, 2022
23a2143
Add a macOs native application sample
luca992 Aug 10, 2022
41b9bda
fix coroutines dependencies
luca992 Aug 10, 2022
d5dce9c
remove essentially what is essentially a duplicate function
luca992 Aug 10, 2022
dbdf4d4
workaround compose issue for darwin: lambda w/ null return throws error
luca992 Aug 10, 2022
faed3c0
suppress gradle build warning
luca992 Aug 10, 2022
b9fe9a8
Implement working solution for mapInput on native
luca992 Aug 10, 2022
43179b5
Implement bitmap decoder for non-jvm
luca992 Aug 10, 2022
0869df5
implement findFetcherFor and findDecoderFor for darwin
luca992 Aug 10, 2022
54cd491
add back removed "duplicate" lazyPainterResource
luca992 Aug 10, 2022
1e6774a
fix adding moko resources to native app bundle in native desktop sample
luca992 Aug 10, 2022
bda67f5
Switch between file and gallery samples on macos. load file using MR
luca992 Aug 10, 2022
9a83662
expose moko-rosources to kamel-samples
luca992 Aug 10, 2022
e3b58c0
use java 11 everywhere. gradle cleanup and add todo notes
luca992 Aug 12, 2022
fd6bf40
update compose-jb
luca992 Sep 13, 2022
a856877
update gradle
luca992 Sep 13, 2022
3f1d7fc
AGP to 7.3.0-rc01 (Must use android studio, see notes), remove todos
luca992 Sep 13, 2022
c6f5755
add iosSimulatorArm64 target
luca992 Sep 13, 2022
a448c2e
ignore all build folders properly. do not ignore codestyles
luca992 Sep 13, 2022
8027009
remove unused repos
luca992 Sep 13, 2022
550f110
convert to suspend fun
luca992 Sep 13, 2022
26c5fe8
add js web support!
luca992 Sep 13, 2022
6c152bf
cleanup/refactor
luca992 Sep 13, 2022
c7cc393
implement MappersUtils for js. move HttpFetcherTest to common.
luca992 Sep 13, 2022
7b797e9
Merge branch 'js' into darwin
luca992 Sep 13, 2022
a642b6b
update agp. Working in latest intellij eap!
luca992 Sep 29, 2022
a358b6d
don't leak compose dependencies as api
luca992 Sep 29, 2022
5455686
add ios sample
luca992 Oct 4, 2022
cea3c71
update kotlin, compose, and agp
luca992 Dec 3, 2022
1da307b
update to kotlin 1.8.20, and compose 1.40
luca992 May 6, 2023
30d445f
fix signing when publishing
luca992 May 6, 2023
9f91917
implement SvgDecoder for nonjvm
luca992 May 6, 2023
c7ed46d
create supervisor job and use now available Dispatchers.IO on native
luca992 May 6, 2023
f97d9c8
fix native tests
luca992 May 6, 2023
bfafcd0
fix js test
luca992 May 6, 2023
df3bec0
add todo notes
luca992 May 7, 2023
30746e6
implement loadXmlImageVector for nonJvm
luca992 May 7, 2023
ab1501f
refactor comments
luca992 May 7, 2023
3b49d51
revert to using LazyVerticalGrid in samples
luca992 May 7, 2023
d678c74
reduce grid padding
luca992 May 7, 2023
9cc6bdc
fix filtering for elements on js
luca992 May 7, 2023
332c551
improve darwin samples
luca992 May 7, 2023
83ff5b2
fix packaging resources files for kamel-samples web
luca992 May 7, 2023
9eae3c2
fix visibility
luca992 May 7, 2023
65a5a4a
androidSourceSetLayoutVersion=2
luca992 May 7, 2023
615684e
fix packaging resouces files on jvm
luca992 May 7, 2023
f13392c
commonize sample. fix android build
luca992 May 7, 2023
14bbaa5
jvm: fix tmp file so that lazyPainterResource can pick correct painter
luca992 May 7, 2023
960c3e2
andrd: fix tmp file so that lazyPainterResource can pick correct painter
luca992 May 7, 2023
4ffa1c1
js: fix file so that lazyPainterResource can pick correct painter
luca992 May 7, 2023
98dba5d
fix js xml
luca992 May 7, 2023
8ce5e9a
cleanup
luca992 May 7, 2023
c0730c5
example of android failing to build with moko-resources 0.22.0
luca992 May 7, 2023
297f75a
remove resourcesFetcher from nonJvm. It's not really applicable
luca992 May 7, 2023
06adcd2
fix visibility
luca992 May 7, 2023
e0c705e
cleanup removed
luca992 May 7, 2023
f6c37be
add coroutines workaround for KamelImageTest
luca992 May 7, 2023
ce4c236
cleanup
luca992 May 7, 2023
17617e6
fix testFetchingNonEmptyImageBytes for js
luca992 May 7, 2023
9f43437
cleanup
luca992 May 7, 2023
9eed5c2
remove workaround (not working) downgrade to coroutines 1.6.4
luca992 May 7, 2023
a0005cb
more moko-resources gradle task dependency fixes
luca992 May 7, 2023
220a539
fix warnings
luca992 May 7, 2023
8f4b047
another moko-resources gradle task dependency fix
luca992 May 8, 2023
0ffd67b
warning fix
luca992 May 8, 2023
2aeeb1e
Don't apply mokoResources to kamel-core
luca992 May 8, 2023
1cb670c
Dispatchers.kamel -> Dispatchers.Kamel
luca992 May 8, 2023
ebaac38
fix actual declaration not found in generated dir
Alex009 May 8, 2023
64aabeb
Merge pull request #1 from Alex009/moko22
luca992 May 8, 2023
4bf75f7
Merge branch 'moko22' into darwin
luca992 May 8, 2023
bccbe5f
remove moko-resources task dependency workaround
luca992 May 8, 2023
1fee4d4
update publishing info
luca992 May 19, 2023
9f8a514
update readme
luca992 May 24, 2023
3563f38
fix readme dependency
luca992 May 24, 2023
398e9bf
fix badges. v0.5.0
luca992 May 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
*.idea/*
*/build/*
build/
.gradle/*
*/.gradle/*
local.properties
*.iml
*.gpg
*.DS_STORE
*.DS_STORE

# IntelliJ Code Styles
!/.idea/codeStyles/

# moko-resources-generated
moko-resources-generated.js
# generated
pack-test-resources-generated.js
10 changes: 10 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Kamel

[![Version](https://img.shields.io/maven-central/v/com.alialbaali.kamel/kamel-core?label=version&color=blue)](https://search.maven.org/search?q=com.alialbaali.kamel)
[![Snapshot](https://img.shields.io/nexus/s/com.alialbaali.kamel/kamel-core?label=snapshot&server=https%3A%2F%2Foss.sonatype.org)](https://oss.sonatype.org/content/repositories/snapshots/com/alialbaali/kamel/)
[![Version](https://img.shields.io/maven-central/v/media.kamel/kamel-core?label=version&color=blue)](https://search.maven.org/search?q=media.kamel)
[![Snapshot](https://img.shields.io/nexus/s/media.kamel/kamel-core?label=snapshot&server=https%3A%2F%2Fs01.oss.sonatype.org)](https://s01.oss.sonatype.org/content/repositories/snapshots/media/kamel/)
[![License](https://img.shields.io/github/license/alialbaali/kamel)](http://www.apache.org/licenses/LICENSE-2.0)
[![Kotlin](https://img.shields.io/badge/kotlin-v1.7.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Compose](https://img.shields.io/badge/compose-v1.2.0-alpha2?logo=compose&color=blue)](http://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-v1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Compose Multiplatform](https://img.shields.io/badge/Compose%20Multiplatform-v1.4.0-blue)](https://github.com/JetBrains/compose-multiplatform)

Kamel is an asynchronous media loading library for Compose. It provides a simple, customizable and
Kamel is an asynchronous media loading library for [Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform). It provides a simple, customizable and
efficient way to load, cache, decode and display images in your application. By default, it uses
Ktor client for loading resources.

Expand Down Expand Up @@ -49,7 +49,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation("com.alialbaali.kamel:kamel-image:0.4.0")
implementation("media.kamel:kamel-image:0.5.0")
// ...
}
}
Expand All @@ -63,7 +63,7 @@ Add the dependency to the dependencies block:

```kotlin
dependencies {
implementation("com.alialbaali.kamel:kamel-image:0.4.0")
implementation("media.kamel:kamel-image:0.5.0")
// ...
}
```
Expand All @@ -90,9 +90,12 @@ lazyPainterResource(data = Url("https://www.example.com/image.jpg"))
// URI
lazyPainterResource(data = URI("https://www.example.com/image.png"))

// File
// File (JVM, Native)
lazyPainterResource(data = File("/path/to/image.png"))

// File (JS)
lazyPainterResource(data = File(org.w3c.files.File(arrayOf(blob), "/path/to/image.png")))

// URL
lazyPainterResource(data = URL("https://www.example.com/image.jpg"))

Expand Down
22 changes: 10 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven(url = "https://dl.bintray.com/kotlin/dokka")
maven(url = "https://kotlin.bintray.com/ktor")
}

dependencies {
Expand Down Expand Up @@ -57,8 +56,6 @@ allprojects {
google()
mavenCentral()
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven(url = "https://dl.bintray.com/kotlin/dokka")
maven(url = "https://kotlin.bintray.com/ktor")
}

val emptyJavadocJar by tasks.registering(Jar::class) {
Expand Down Expand Up @@ -107,14 +104,14 @@ allprojects {

name = "MavenCentral"

val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"

url = if (version.toString().endsWith("SNAPSHOT")) uri(snapshotsRepoUrl) else uri(releasesRepoUrl)

credentials {
username = rootProject.ext["ossrh.username"] as String
password = rootProject.ext["ossrh.password"] as String
username = rootProject.ext["ossrh.username"] as String? ?: ""
password = rootProject.ext["ossrh.password"] as String? ?: ""
}

}
Expand All @@ -126,15 +123,16 @@ allprojects {

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xallow-result-return-type", "-Xopt-in=kotlin.RequiresOptIn")
freeCompilerArgs = listOf("-Xallow-result-return-type")
jvmTarget = "11"
}
}

}

nexusStaging {
packageGroup = Kamel.Group
stagingProfileId = rootProject.ext["stagingProfileId"] as String
username = rootProject.ext["ossrh.username"] as String
password = rootProject.ext["ossrh.password"] as String
stagingProfileId = rootProject.ext["stagingProfileId"] as String? ?: ""
username = rootProject.ext["ossrh.username"] as String? ?: ""
password = rootProject.ext["ossrh.password"] as String? ?: ""
}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repositories {
jcenter()
mavenCentral()
}

plugins {
Expand Down
46 changes: 32 additions & 14 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,59 @@ object Dependencies {
const val KotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.Kotlin}"

object Android {
const val Appcompat = "androidx.appcompat:appcompat:${Versions.Android.Appcompat}"
const val Core = "androidx.core:core-ktx:${Versions.Android.Core}"
const val ActivityCompose = "androidx.activity:activity-compose:${Versions.Android.ActivityCompose}"
const val Appcompat = "androidx.appcompat:appcompat:${Versions.Android.Appcompat}"
const val GradlePlugin = "com.android.tools.build:gradle:${Versions.AGP}"
const val Material = "com.google.android.material:material:${Versions.Android.Material}"
const val Annotation = "androidx.annotation:annotation:${Versions.Android.Annotation}"
}

object Ktor {
const val Core = "io.ktor:ktor-client-core:${Versions.Ktor}"
const val Logging = "io.ktor:ktor-client-logging:${Versions.Ktor}"
const val Android = "io.ktor:ktor-client-android:${Versions.Ktor}"
const val Darwin = "io.ktor:ktor-client-darwin:${Versions.Ktor}"
const val Js = "io.ktor:ktor-client-js:${Versions.Ktor}"
const val CIO = "io.ktor:ktor-client-cio:${Versions.Ktor}"
}

object Coroutines {
const val Core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.Coroutines}"
const val Test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.Coroutines}"
}

object Testing {
const val Ktor = "io.ktor:ktor-client-mock:${Versions.Ktor}"
const val Coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.Coroutines}"
const val Compose = "org.jetbrains.compose.ui:ui-test-junit4:${Versions.Compose}"
const val MokoResources = "dev.icerock.moko:resources:${Versions.MokoResources}"
}

object MokoResources {
const val Core = "dev.icerock.moko:resources:${Versions.MokoResources}"
const val Test = "dev.icerock.moko:resources-test:${Versions.MokoResources}"
}

object XmlUtil {
const val Serialization = "io.github.pdvrieze.xmlutil:serialization:${Versions.XmlUtil}"
}

}

private object Versions {
object Versions {

const val Kotlin = "1.8.20"
const val Ktor = "2.3.0"
const val Coroutines = "1.6.4"
const val Compose = "1.4.0"
const val AGP = "7.4.2"
const val MokoResources = "0.22.0"
const val XmlUtil = "0.86.0"

const val Kotlin = "1.7.0"
const val Ktor = "2.0.3"
const val Coroutines = "1.6.3"
const val Compose = "1.2.0-alpha01-dev753"
const val AGP = "7.2.1"

object Android {
const val Appcompat = "1.4.2"
const val Core = "1.8.0"
const val ActivityCompose = "1.5.0"
const val Material = "1.6.1"
const val ActivityCompose = "1.7.1"
const val Appcompat = "1.6.1"
const val Material = "1.8.0"
const val Annotation = "1.6.0"
}

}
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Kamel.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object Kamel {
const val Group = "com.alialbaali.kamel"
const val Version = "0.4.1"
const val Group = "media.kamel"
const val Version = "0.5.0-SNAPSHOT"
}
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ inline val PluginDependenciesSpec.compose: PluginDependencySpec
inline val PluginDependenciesSpec.multiplatform: PluginDependencySpec
get() = kotlin("multiplatform")

inline val PluginDependenciesSpec.`nexus-staging`: PluginDependencySpec
get() = id("io.codearte.nexus-staging") version "0.22.0"
inline val PluginDependenciesSpec.mokoResources: PluginDependencySpec
get() = id("dev.icerock.mobile.multiplatform-resources") version Versions.MokoResources

inline val PluginDependenciesSpec.dokka: PluginDependencySpec
get() = id("org.jetbrains.dokka") version "1.4.20"
inline val PluginDependenciesSpec.`nexus-staging`: PluginDependencySpec
get() = id("io.codearte.nexus-staging") version "0.30.0"

inline val PluginDependenciesSpec.`android-library`: PluginDependencySpec
get() = id("com.android.library")
Expand Down
14 changes: 14 additions & 0 deletions buildSrc/src/main/kotlin/Targets.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
object Targets {

val iosTargets = arrayOf(
"iosArm64", "iosX64", "iosSimulatorArm64",
)
val macosTargets = arrayOf(
"macosX64", "macosArm64",
)
val darwinTargets = iosTargets + macosTargets
val linuxTargets = arrayOf<String>()
val mingwTargets = arrayOf<String>()
val nativeTargets = linuxTargets + darwinTargets + mingwTargets

}
14 changes: 13 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
org.gradle.jvmargs=-Xmx3g
kotlin.code.style=official
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.androidSourceSetLayoutVersion=2
compose.desktop.verbose=true

android.useAndroidX=true
kotlin.mpp.stability.nowarn=true
android.disableAutomaticComponentCreation=true
kotlin.mpp.stability.nowarn=true

org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
36 changes: 36 additions & 0 deletions gradle/pack-core-tests-resources.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/***
* How to handle Web Workers "standard" syntax with webpack:
* https://stackoverflow.com/a/41630622/1363742
*/
fun createWebpackConfig(){
val rootProjectAbsPath = rootProject.projectDir.absolutePath
val path = """"$rootProjectAbsPath/kamel-core/build/generated/moko/jsMain/iokamelcore/res""""
val webpackConfig = File(projectDir, "webpack.config.d/pack-test-resources-generated.js")
val configText =
"""const path = require('path');

const mokoResourcePath = path.resolve($path);

config.module.rules.push(
{
test: /\.(.*)/,
include: [
path.resolve(mokoResourcePath)
],
type: 'asset/resource'
}
);

config.resolve.modules.push(
path.resolve(mokoResourcePath)
);"""
webpackConfig.writeText(configText)
}

tasks.create("createPackResourcesWebpackConfig") {
doFirst {
createWebpackConfig()
}
}

tasks.getByName("jsJar").dependsOn("createPackResourcesWebpackConfig")
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sun Jul 10 06:06:14 TRT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading