diff --git a/README.md b/README.md index 117567d1d..b7f2b17f2 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,16 @@ The following libraries are available for the various Firebase products. | Service or Product | Gradle Dependency | API Coverage | |---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.10.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) | -| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.10.0/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) | -| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.10.0/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) | -| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.10.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) | -| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.10.0/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) | -| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.10.0/pom) | [![40%](https://img.shields.io/badge/-40%25-orange?style=flat-square)](/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt) | -| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.10.0/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) | -| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.10.0/pom) | [![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square)](/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt) | -| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.10.0/pom) | [![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt) | -| [Crashlytics](https://firebase.google.com/docs/crashlytics) | [`dev.gitlive:firebase-crashlytics:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-crashlytics/1.10.0/pom) | [![80%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt) | +| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.10.4/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) | +| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.10.4/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) | +| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.10.4/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) | +| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.10.4/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) | +| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.10.4/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) | +| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.10.4/pom) | [![40%](https://img.shields.io/badge/-40%25-orange?style=flat-square)](/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt) | +| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.10.4/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) | +| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.10.4/pom) | [![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square)](/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt) | +| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.10.4/pom) | [![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt) | +| [Crashlytics](https://firebase.google.com/docs/crashlytics) | [`dev.gitlive:firebase-crashlytics:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-crashlytics/1.10.4/pom) | [![80%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt) | Is the Firebase library or API you need missing? [Create an issue](https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/new?labels=API+coverage&template=increase-api-coverage.md&title=Add+%5Bclass+name%5D.%5Bfunction+name%5D+to+%5Blibrary+name%5D+for+%5Bplatform+names%5D) to request additional API coverage or be awesome and [submit a PR](https://github.com/GitLiveApp/firebase-kotlin-sdk/fork) diff --git a/build.gradle.kts b/build.gradle.kts index 8f5edb200..6c256648d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent +import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask repositories { google() @@ -51,8 +52,6 @@ tasks { subprojects { - group = "dev.gitlive" - apply(plugin = "com.adarshr.test-logger") repositories { @@ -118,7 +117,7 @@ subprojects { "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") if (this@afterEvaluate.name != "firebase-crashlytics") { - "jvmMainApi"("dev.gitlive:firebase-java-sdk:0.1.1") + "jvmMainApi"("dev.gitlive:firebase-java-sdk:0.1.2") "jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") { exclude("com.google.android.gms") } @@ -149,6 +148,7 @@ subprojects { repositories { maven { url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") + credentials { username = project.findProperty("sonatypeUsername") as String? ?: System.getenv("sonatypeUsername") password = project.findProperty("sonatypePassword") as String? ?: System.getenv("sonatypePassword") @@ -197,6 +197,10 @@ subprojects { } } + + tasks.withType(AbstractPublishToMaven::class.java).configureEach { + dependsOn(tasks.withType(Sign::class.java)) + } } tasks.withType { diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index f420c7771..084431b7e 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -1,3 +1,6 @@ +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -46,7 +49,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -64,7 +76,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { @@ -109,6 +122,9 @@ kotlin { this.apiVersion = apiVersion this.languageVersion = languageVersion progressiveMode = true + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -118,7 +134,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -130,24 +146,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-app/package.json b/firebase-app/package.json index b50a079b5..7725a328d 100644 --- a/firebase-app/package.json +++ b/firebase-app/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-app", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-app.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-common": "1.10.1", + "@gitlive/firebase-common": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index e55bb0e77..07f2f9fce 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -60,7 +62,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -70,7 +81,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -137,7 +149,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -148,21 +160,6 @@ kotlin { api("com.google.firebase:firebase-auth-ktx") } } - - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-auth/package.json b/firebase-auth/package.json index ca9c8c177..8f9f047e8 100644 --- a/firebase-auth/package.json +++ b/firebase-auth/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-auth", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-auth.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index c6b799551..b25a4e849 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -44,7 +46,16 @@ android { kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -69,7 +80,8 @@ kotlin { val supportIosTarget = project.property("skipIosTarget") != "true" if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() } @@ -117,7 +129,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -129,21 +141,6 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } - getByName("jsMain") { dependencies { api(npm("firebase", "10.4.0")) @@ -154,7 +151,7 @@ kotlin { kotlin.srcDir("src/androidMain/kotlin") } - val jvmTest by getting { + getByName("jvmTest") { dependencies { implementation(kotlin("test-junit")) } diff --git a/firebase-common/package.json b/firebase-common/package.json index 7e9e38f26..163d7ec0f 100644 --- a/firebase-common/package.json +++ b/firebase-common/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-common", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-common.js", "scripts": { diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 4290f8cbd..e933e165f 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -60,7 +62,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -83,7 +94,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -132,7 +144,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -144,24 +156,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-config/package.json b/firebase-config/package.json index bac1afa9f..78d6c9b43 100644 --- a/firebase-config/package.json +++ b/firebase-config/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-config", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-config.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 0a6d57bef..f2ce134ee 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -47,7 +49,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -70,7 +81,8 @@ kotlin { // } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -93,6 +105,9 @@ kotlin { this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -103,7 +118,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -115,25 +130,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - // getByName("jvmMain") { // kotlin.srcDir("src/androidMain/kotlin") // } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by sourceSets.getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-crashlytics/package.json b/firebase-crashlytics/package.json index a2528a17f..845bef8a8 100644 --- a/firebase-crashlytics/package.json +++ b/firebase-crashlytics/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-crashlytics", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-crashlytics.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt b/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt index 36d363bba..92aba8ea9 100644 --- a/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt +++ b/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt @@ -58,4 +58,4 @@ actual class FirebaseCrashlytics { } } -actual open class FirebaseCrashlyticsException : FirebaseException() \ No newline at end of file +actual open class FirebaseCrashlyticsException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 526bbb90c..0477b63e3 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -52,7 +54,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -75,7 +86,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -122,6 +134,9 @@ kotlin { optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.coroutines.FlowPreview") optIn("kotlinx.serialization.InternalSerializationApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -132,7 +147,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -146,21 +161,6 @@ kotlin { getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-database/package.json b/firebase-database/package.json index c72c583fb..2251ea0f5 100644 --- a/firebase-database/package.json +++ b/firebase-database/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-database", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-database.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt index bdc6aa398..086087c4c 100644 --- a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -38,7 +38,7 @@ suspend fun Task.awaitWhileOnline(database: FirebaseDatabase): T = .reference(".info/connected") .valueEvents .debounce(2.seconds) - .filter { !it.value() } + .filterNot { it.value() } .map { throw DatabaseException("Database not connected", null) } ) .first() diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index f7d39ff7a..2e830f1eb 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -49,7 +51,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -72,10 +83,11 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { - ios.deploymentTarget = "11.0" + ios.deploymentTarget = "12.0" framework { baseName = "FirebaseFirestore" } @@ -140,7 +152,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -148,24 +160,9 @@ kotlin { getByName("androidMain") { dependencies { - api("com.google.firebase:firebase-firestore-ktx") + api("com.google.firebase:firebase-firestore") } } - - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-firestore/package.json b/firebase-firestore/package.json index 9ad0a0155..02a96298c 100644 --- a/firebase-firestore/package.json +++ b/firebase-firestore/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-firestore", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-firestore.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt index 1c6be4a86..d12bda859 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt @@ -1,6 +1,7 @@ package dev.gitlive.firebase.firestore -actual fun isSpecialValue(value: Any) = when(value) { +@PublishedApi +internal actual fun isSpecialValue(value: Any) = when(value) { is NativeFieldValue, is NativeGeoPoint, is NativeTimestamp, diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index dc36f231f..eb2b0d5fa 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -11,11 +11,11 @@ import com.google.firebase.firestore.MemoryEagerGcSettings import com.google.firebase.firestore.MemoryLruGcSettings import com.google.firebase.firestore.MetadataChanges import com.google.firebase.firestore.PersistentCacheSettings -import com.google.firebase.firestore.ktx.firestoreSettings -import com.google.firebase.firestore.ktx.memoryCacheSettings -import com.google.firebase.firestore.ktx.memoryEagerGcSettings -import com.google.firebase.firestore.ktx.memoryLruGcSettings -import com.google.firebase.firestore.ktx.persistentCacheSettings +import com.google.firebase.firestore.firestoreSettings +import com.google.firebase.firestore.memoryCacheSettings +import com.google.firebase.firestore.memoryEagerGcSettings +import com.google.firebase.firestore.memoryLruGcSettings +import com.google.firebase.firestore.persistentCacheSettings import dev.gitlive.firebase.* import kotlinx.coroutines.* import kotlinx.coroutines.channels.awaitClose diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt index 68f1a2ab9..7dc8c4587 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt @@ -2,7 +2,8 @@ package dev.gitlive.firebase.firestore import cocoapods.FirebaseFirestore.FIRFieldValue -actual fun isSpecialValue(value: Any) = when(value) { +@PublishedApi +internal actual fun isSpecialValue(value: Any) = when(value) { is FIRFieldValue, is NativeGeoPoint, is NativeTimestamp, diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt index f191ea2d1..485920fe2 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt @@ -1,6 +1,7 @@ package dev.gitlive.firebase.firestore -actual fun isSpecialValue(value: Any) = when(value) { +@PublishedApi +internal actual fun isSpecialValue(value: Any) = when(value) { is NativeFieldValue, is NativeGeoPoint, is NativeTimestamp, diff --git a/firebase-firestore/src/jvmMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/jvmMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt index 1c6be4a86..d12bda859 100644 --- a/firebase-firestore/src/jvmMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt +++ b/firebase-firestore/src/jvmMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt @@ -1,6 +1,7 @@ package dev.gitlive.firebase.firestore -actual fun isSpecialValue(value: Any) = when(value) { +@PublishedApi +internal actual fun isSpecialValue(value: Any) = when(value) { is NativeFieldValue, is NativeGeoPoint, is NativeTimestamp, diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 3d4902db9..5b0ba1531 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -46,7 +48,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -56,7 +67,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -66,6 +78,7 @@ kotlin { noPodspec() pod("FirebaseFunctions") { version = "10.15.0" + extraOpts += listOf("-compiler-option", "-fmodules") } } } @@ -110,6 +123,9 @@ kotlin { progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -120,7 +136,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -132,24 +148,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-functions/package.json b/firebase-functions/package.json index a11c484e1..c18b774e4 100644 --- a/firebase-functions/package.json +++ b/firebase-functions/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-functions", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-functions.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 94bcdd94b..5c744950a 100644 --- a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -49,3 +49,10 @@ actual class HttpsCallableResult constructor(val android: com.google.firebase.fu } actual typealias FirebaseFunctionsException = com.google.firebase.functions.FirebaseFunctionsException + +actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code + +actual val FirebaseFunctionsException.details: Any? get() = details + +actual typealias FunctionsExceptionCode = com.google.firebase.functions.FirebaseFunctionsException.Code + diff --git a/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt index ffa6770e0..edb57bed3 100644 --- a/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -46,3 +46,29 @@ expect fun Firebase.functions(app: FirebaseApp): FirebaseFunctions expect fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions expect class FirebaseFunctionsException: FirebaseException + +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") +expect val FirebaseFunctionsException.code: FunctionsExceptionCode + +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") +expect val FirebaseFunctionsException.details: Any? + +expect enum class FunctionsExceptionCode { + OK, + CANCELLED, + UNKNOWN, + INVALID_ARGUMENT, + DEADLINE_EXCEEDED, + NOT_FOUND, + ALREADY_EXISTS, + PERMISSION_DENIED, + RESOURCE_EXHAUSTED, + FAILED_PRECONDITION, + ABORTED, + OUT_OF_RANGE, + UNIMPLEMENTED, + INTERNAL, + UNAVAILABLE, + DATA_LOSS, + UNAUTHENTICATED +} diff --git a/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt index f8bde60cd..7184e4836 100644 --- a/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -4,18 +4,14 @@ package dev.gitlive.firebase.functions -import cocoapods.FirebaseFunctions.* -import dev.gitlive.firebase.DecodeSettings -import dev.gitlive.firebase.EncodeSettings -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseApp -import dev.gitlive.firebase.FirebaseException -import dev.gitlive.firebase.decode -import dev.gitlive.firebase.encode +import cocoapods.FirebaseFunctions.FIRFunctions +import cocoapods.FirebaseFunctions.FIRHTTPSCallable +import cocoapods.FirebaseFunctions.FIRHTTPSCallableResult +import dev.gitlive.firebase.* import kotlinx.coroutines.CompletableDeferred import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.SerializationStrategy -import platform.Foundation.* +import platform.Foundation.NSError actual val Firebase.functions get() = FirebaseFunctions(FIRFunctions.functions()) @@ -58,7 +54,55 @@ actual class HttpsCallableResult constructor(val ios: FIRHTTPSCallableResult) { decode(strategy, ios.data(), decodeSettings) } -actual class FirebaseFunctionsException(message: String): FirebaseException(message) +actual class FirebaseFunctionsException(message: String, val code: FunctionsExceptionCode, val details: Any?) : FirebaseException(message) + +actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code + +actual val FirebaseFunctionsException.details: Any? get() = details + +actual enum class FunctionsExceptionCode { + OK, + CANCELLED, + UNKNOWN, + INVALID_ARGUMENT, + DEADLINE_EXCEEDED, + NOT_FOUND, + ALREADY_EXISTS, + PERMISSION_DENIED, + RESOURCE_EXHAUSTED, + FAILED_PRECONDITION, + ABORTED, + OUT_OF_RANGE, + UNIMPLEMENTED, + INTERNAL, + UNAVAILABLE, + DATA_LOSS, + UNAUTHENTICATED +} +//todo uncomment once https://github.com/firebase/firebase-ios-sdk/issues/11862 fixed +fun NSError.toException() = when(domain) { +// FIRFunctionsErrorDomain -> when(code) { +// FIRFunctionsErrorCodeOK -> FunctionsExceptionCode.OK +// FIRFunctionsErrorCodeCancelled -> FunctionsExceptionCode.CANCELLED +// FIRFunctionsErrorCodeUnknown -> FunctionsExceptionCode.UNKNOWN +// FIRFunctionsErrorCodeInvalidArgument -> FunctionsExceptionCode.INVALID_ARGUMENT +// FIRFunctionsErrorCodeDeadlineExceeded -> FunctionsExceptionCode.DEADLINE_EXCEEDED +// FIRFunctionsErrorCodeNotFound -> FunctionsExceptionCode.NOT_FOUND +// FIRFunctionsErrorCodeAlreadyExists -> FunctionsExceptionCode.ALREADY_EXISTS +// FIRFunctionsErrorCodePermissionDenied -> FunctionsExceptionCode.PERMISSION_DENIED +// FIRFunctionsErrorCodeResourceExhausted -> FunctionsExceptionCode.RESOURCE_EXHAUSTED +// FIRFunctionsErrorCodeFailedPrecondition -> FunctionsExceptionCode.FAILED_PRECONDITION +// FIRFunctionsErrorCodeAborted -> FunctionsExceptionCode.ABORTED +// FIRFunctionsErrorCodeOutOfRange -> FunctionsExceptionCode.OUT_OF_RANGE +// FIRFunctionsErrorCodeUnimplemented -> FunctionsExceptionCode.UNIMPLEMENTED +// FIRFunctionsErrorCodeInternal -> FunctionsExceptionCode.INTERNAL +// FIRFunctionsErrorCodeUnavailable -> FunctionsExceptionCode.UNAVAILABLE +// FIRFunctionsErrorCodeDataLoss -> FunctionsExceptionCode.DATA_LOSS +// FIRFunctionsErrorCodeUnauthenticated -> FunctionsExceptionCode.UNAUTHENTICATED +// else -> FunctionsExceptionCode.UNKNOWN +// } + else -> FunctionsExceptionCode.UNKNOWN +}.let { FirebaseFunctionsException(description!!, it, null/*userInfo[FIRFunctionsErrorDetails]*/) } suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() @@ -66,7 +110,7 @@ suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Uni if(error == null) { job.complete(Unit) } else { - job.completeExceptionally(FirebaseFunctionsException(error.localizedDescription)) + job.completeExceptionally(error.toException()) } } function(callback) @@ -79,7 +123,7 @@ suspend inline fun T.awaitResult(function: T.(callback: (R?, NSEr if(error == null) { job.complete(result) } else { - job.completeExceptionally(FirebaseFunctionsException(error.localizedDescription)) + job.completeExceptionally(error.toException()) } } function(callback) diff --git a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 75f80d3a1..4db0c0284 100644 --- a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -9,7 +9,6 @@ import dev.gitlive.firebase.functions.externals.* import kotlinx.coroutines.await import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.SerializationStrategy -import org.w3c.dom.url.URL import kotlin.js.json import dev.gitlive.firebase.functions.externals.HttpsCallableResult as JsHttpsCallableResult @@ -53,7 +52,31 @@ actual class HttpsCallableResult constructor(val js: JsHttpsCallableResult) { } -actual open class FirebaseFunctionsException(code: String?, cause: Throwable): FirebaseException(code, cause) +actual class FirebaseFunctionsException(cause: Throwable, val code: FunctionsExceptionCode, val details: Any?) : FirebaseException(cause.message, cause) + +actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code + +actual val FirebaseFunctionsException.details: Any? get() = details + +actual enum class FunctionsExceptionCode { + OK, + CANCELLED, + UNKNOWN, + INVALID_ARGUMENT, + DEADLINE_EXCEEDED, + NOT_FOUND, + ALREADY_EXISTS, + PERMISSION_DENIED, + RESOURCE_EXHAUSTED, + FAILED_PRECONDITION, + ABORTED, + OUT_OF_RANGE, + UNIMPLEMENTED, + INTERNAL, + UNAVAILABLE, + DATA_LOSS, + UNAUTHENTICATED +} inline fun T.rethrow(function: T.() -> R): R = dev.gitlive.firebase.functions.rethrow { function() } @@ -63,6 +86,34 @@ inline fun rethrow(function: () -> R): R { } catch (e: Exception) { throw e } catch(e: dynamic) { - throw FirebaseFunctionsException(e.code as String?, e) + throw errorToException(e) } } + +fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "") + .toString() + .lowercase() + .let { + when { + "cancelled" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.CANCELLED, e.details) + "invalid-argument" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.INVALID_ARGUMENT, e.details) + "deadline-exceeded" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.DEADLINE_EXCEEDED, e.details) + "not-found" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.NOT_FOUND, e.details) + "already-exists" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.ALREADY_EXISTS, e.details) + "permission-denied" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.PERMISSION_DENIED, e.details) + "resource-exhausted" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.RESOURCE_EXHAUSTED, e.details) + "failed-precondition" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.FAILED_PRECONDITION, e.details) + "aborted" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.ABORTED, e.details) + "out-of-range" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.OUT_OF_RANGE, e.details) + "unimplemented" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNIMPLEMENTED, e.details) + "internal" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.INTERNAL, e.details) + "unavailable" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNAVAILABLE, e.details) + "data-loss" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.DATA_LOSS, e.details) + "unauthenticated" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNAUTHENTICATED, e.details) + "unknown" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNKNOWN, e.details) + else -> { + println("Unknown error code in ${JSON.stringify(e)}") + FirebaseFunctionsException(e, FunctionsExceptionCode.UNKNOWN, e.details) + } + } + } diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index 858a4bf9b..f0d5c0cc2 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -46,7 +48,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -69,7 +80,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -113,6 +125,9 @@ kotlin { this.apiVersion = apiVersion this.languageVersion = languageVersion progressiveMode = true + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -123,7 +138,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -135,24 +150,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-installations/package.json b/firebase-installations/package.json index ecdc9e65a..af5d99226 100644 --- a/firebase-installations/package.json +++ b/firebase-installations/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-installations", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-installations.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index fd57f9bc5..e79a99ded 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -47,7 +49,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -70,7 +81,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -106,6 +118,9 @@ kotlin { this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -116,7 +131,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -128,25 +143,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - // getByName("jvmMain") { // kotlin.srcDir("src/androidMain/kotlin") // } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by sourceSets.getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-perf/package.json b/firebase-perf/package.json index 29798b347..e53193deb 100644 --- a/firebase-perf/package.json +++ b/firebase-perf/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-perf", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-perf.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt index f77c9e0cb..941a3bd8a 100644 --- a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt +++ b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt @@ -28,4 +28,4 @@ actual class FirebasePerformance { } -actual open class FirebasePerformanceException : FirebaseException() \ No newline at end of file +actual open class FirebasePerformanceException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index bd183e6e5..1afcfefdb 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2023 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -46,7 +48,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -69,7 +80,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -79,6 +91,7 @@ kotlin { noPodspec() pod("FirebaseStorage") { version = "10.15.0" + extraOpts += listOf("-compiler-option", "-fmodules") } } } @@ -113,6 +126,9 @@ kotlin { this.apiVersion = apiVersion this.languageVersion = languageVersion progressiveMode = true + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -123,7 +139,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -134,21 +150,6 @@ kotlin { api("com.google.firebase:firebase-storage") } } - - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-storage/package.json b/firebase-storage/package.json index b48bc7b14..92ff99ae6 100644 --- a/firebase-storage/package.json +++ b/firebase-storage/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-storage", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-storage.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt b/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt index 2d1f07ca4..cc61e378b 100644 --- a/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt +++ b/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt @@ -85,4 +85,4 @@ actual class ListResult { } actual class File -actual class FirebaseStorageException : FirebaseException() \ No newline at end of file +actual class FirebaseStorageException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ab4e01cb9..f0a770c3d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,23 +49,23 @@ firebase-perf.skipJsTests=false firebase-storage.skipJsTests=false # Versions: -firebase-app.version=1.10.1 -firebase-auth.version=1.10.1 -firebase-common.version=1.10.1 -firebase-config.version=1.10.1 -firebase-database.version=1.10.1 -firebase-firestore.version=1.10.1 -firebase-functions.version=1.10.1 -firebase-installations.version=1.10.1 -firebase-perf.version=1.10.1 -firebase-crashlytics.version=1.10.1 -firebase-storage.version=1.10.1 +firebase-app.version=1.10.4 +firebase-auth.version=1.10.4 +firebase-common.version=1.10.4 +firebase-config.version=1.10.4 +firebase-database.version=1.10.4 +firebase-firestore.version=1.10.4 +firebase-functions.version=1.10.4 +firebase-installations.version=1.10.4 +firebase-perf.version=1.10.4 +firebase-crashlytics.version=1.10.4 +firebase-storage.version=1.10.4 # Dependencies Versions: -gradlePluginVersion=8.1.1 -kotlinVersion=1.9.10 +gradlePluginVersion=8.1.3 +kotlinVersion=1.9.20 coroutinesVersion=1.7.3 serializationVersion=1.6.0 -firebaseBoMVersion=32.2.3 +firebaseBoMVersion=32.5.0 apiVersion=1.8 languageVersion=1.9 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae08049a..e411586a5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 9b3874310..17041ee0b 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -41,6 +41,13 @@ android { kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { publishAllLibraryVariants() compilations.configureEach { @@ -66,7 +73,8 @@ kotlin { val supportIosTarget = project.property("skipIosTarget") != "true" if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() } @@ -97,15 +105,6 @@ kotlin { kotlin.srcDir("src/androidMain/kotlin") } - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } - getByName("jsMain") { dependencies { implementation(kotlin("test-js"))