Skip to content

Commit

Permalink
Merge pull request #23 from luca992/darwin
Browse files Browse the repository at this point in the history
iOS, macOS, and JS support
  • Loading branch information
luca992 authored May 24, 2023
2 parents 389316f + 398e9bf commit 19f8fac
Show file tree
Hide file tree
Showing 102 changed files with 5,771 additions and 436 deletions.
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

0 comments on commit 19f8fac

Please sign in to comment.