From c8425dc2b01f4f9d28b72442435edc93d56934c5 Mon Sep 17 00:00:00 2001 From: Sajid Ali Date: Sat, 7 Jun 2025 00:52:26 +0500 Subject: [PATCH 1/5] Add support for tvOS and update dependencies Updated the build configuration to include support for tvOS by setting deployment targets and adjusting Kotlin opt-ins. Also, updated Gradle and library versions to their latest stable releases as of commit `9b4c5f6`. This change ensures compatibility with new platforms while leveraging the latest features and improvements in dependencies. --- firebase-app/build.gradle.kts | 23 ++++- .../kotlin/dev/gitlive/firebase/firebase.kt | 0 firebase-common-internal/build.gradle.kts | 3 + .../firebase/internal/EncodedObject.kt | 0 .../gitlive/firebase/internal/_decoders.kt | 1 + .../gitlive/firebase/internal/_encoders.kt | 0 .../gitlive/firebase/internal/serializers.kt | 3 + firebase-common/build.gradle.kts | 3 + firebase-database/build.gradle.kts | 9 +- .../gitlive/firebase/database/ServerValue.kt | 0 .../dev/gitlive/firebase/database/database.kt | 0 .../dev/gitlive/firebase/database/database.kt | 0 .../dev/gitlive/firebase/database/database.kt | 91 ++++++++++--------- gradle/libs.versions.toml | 27 +++--- gradle/wrapper/gradle-wrapper.properties | 3 +- test-utils/build.gradle.kts | 3 + .../kotlin/dev/gitlive/firebase/TestUtils.kt | 3 +- 17 files changed, 104 insertions(+), 65 deletions(-) rename firebase-app/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firebase.kt (100%) rename firebase-common-internal/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt (100%) rename firebase-common-internal/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/internal/_decoders.kt (98%) rename firebase-common-internal/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/internal/_encoders.kt (100%) rename firebase-database/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/database/ServerValue.kt (100%) rename firebase-database/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/database/database.kt (100%) rename firebase-database/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/database/database.kt (100%) rename test-utils/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/TestUtils.kt (94%) diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index b98d62ede..e51f7272f 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -21,7 +21,7 @@ android { val compileSdkVersion: Int by project compileSdk = compileSdkVersion - namespace="dev.gitlive.firebase" + namespace = "dev.gitlive.firebase" defaultConfig { minSdk = minSdkVersion @@ -80,9 +80,13 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() framework { baseName = "FirebaseApp" } @@ -118,7 +122,10 @@ kotlin { this.apiVersion = libs.versions.settings.api.get() this.languageVersion = libs.versions.settings.language.get() progressiveMode = true - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } @@ -150,19 +157,25 @@ kotlin { if (project.property("firebase-app.skipIosTests") == "true") { tasks.forEach { - if (it.name.contains("ios", true) && it.name.contains("test", true)) { it.enabled = false } + if (it.name.contains("ios", true) && it.name.contains("test", true)) { + it.enabled = false + } } } if (project.property("firebase-app.skipJvmTests") == "true") { tasks.forEach { - if (it.name.contains("jvm", true) && it.name.contains("test", true)) { it.enabled = false } + if (it.name.contains("jvm", true) && it.name.contains("test", true)) { + it.enabled = false + } } } if (project.property("firebase-app.skipJsTests") == "true") { tasks.forEach { - if (it.name.contains("js", true) && it.name.contains("test", true)) { it.enabled = false } + if (it.name.contains("js", true) && it.name.contains("test", true)) { + it.enabled = false + } } } diff --git a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt similarity index 100% rename from firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt rename to firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt diff --git a/firebase-common-internal/build.gradle.kts b/firebase-common-internal/build.gradle.kts index 9f2b857f1..00ba45cd2 100644 --- a/firebase-common-internal/build.gradle.kts +++ b/firebase-common-internal/build.gradle.kts @@ -80,6 +80,9 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() } js(IR) { diff --git a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt similarity index 100% rename from firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt rename to firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt diff --git a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt similarity index 98% rename from firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt rename to firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 00400b622..81dca8d8b 100644 --- a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.encoding.CompositeDecoder import kotlinx.serialization.descriptors.PolymorphicKind import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.descriptors.StructureKind +import kotlin.collections.get public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, polymorphicIsNested: Boolean): CompositeDecoder = when (descriptor.kind) { StructureKind.CLASS, StructureKind.OBJECT -> decodeAsMap(false) diff --git a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt similarity index 100% rename from firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt rename to firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_encoders.kt diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt index 41f319f88..ea55fb51f 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/serializers.kt @@ -2,9 +2,12 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ +@file:OptIn(SealedSerializationApi::class) + package dev.gitlive.firebase.internal import kotlinx.serialization.KSerializer +import kotlinx.serialization.SealedSerializationApi import kotlinx.serialization.SerializationException import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.builtins.serializer diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 8b7d9f37c..da0ed78be 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -79,6 +79,9 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() } js(IR) { diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 625017011..7145fd530 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -81,8 +81,12 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() framework { baseName = "FirebaseDatabase" } @@ -121,7 +125,10 @@ kotlin { optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.coroutines.FlowPreview") optIn("kotlinx.serialization.InternalSerializationApi") - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } diff --git a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt similarity index 100% rename from firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt rename to firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt diff --git a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt similarity index 100% rename from firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt rename to firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt diff --git a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/appleTest/kotlin/dev/gitlive/firebase/database/database.kt similarity index 100% rename from firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt rename to firebase-database/src/appleTest/kotlin/dev/gitlive/firebase/database/database.kt diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt index f4f38d8f7..ce737c3c8 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -4,34 +4,12 @@ package dev.gitlive.firebase.database -import dev.gitlive.firebase.DecodeSettings -import dev.gitlive.firebase.EncodeDecodeSettingsBuilder -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseApp -import dev.gitlive.firebase.database.externals.CancelCallback -import dev.gitlive.firebase.database.externals.ChangeSnapshotCallback -import dev.gitlive.firebase.database.externals.Database -import dev.gitlive.firebase.database.externals.child -import dev.gitlive.firebase.database.externals.connectDatabaseEmulator -import dev.gitlive.firebase.database.externals.enableLogging -import dev.gitlive.firebase.database.externals.getDatabase -import dev.gitlive.firebase.database.externals.onChildAdded -import dev.gitlive.firebase.database.externals.onChildChanged -import dev.gitlive.firebase.database.externals.onChildMoved -import dev.gitlive.firebase.database.externals.onChildRemoved -import dev.gitlive.firebase.database.externals.onDisconnect -import dev.gitlive.firebase.database.externals.onValue -import dev.gitlive.firebase.database.externals.push -import dev.gitlive.firebase.database.externals.query -import dev.gitlive.firebase.database.externals.ref -import dev.gitlive.firebase.database.externals.remove -import dev.gitlive.firebase.database.externals.set -import dev.gitlive.firebase.database.externals.update +import dev.gitlive.firebase.* +import dev.gitlive.firebase.database.externals.* import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.internal.decode import dev.gitlive.firebase.internal.js import dev.gitlive.firebase.internal.reencodeTransformation -import dev.gitlive.firebase.js import kotlinx.coroutines.asDeferred import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.coroutineScope @@ -73,12 +51,16 @@ public actual fun Firebase.database(url: String): FirebaseDatabase = public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js, url = url)) } -public val FirebaseDatabase.js get() = js +public val FirebaseDatabase.js: Database get() = js public actual class FirebaseDatabase internal constructor(internal val js: Database) { - public actual fun reference(path: String): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } - public actual fun reference(): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } + public actual fun reference(path: String): DatabaseReference = + rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } + + public actual fun reference(): DatabaseReference = + rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } + public actual fun setPersistenceEnabled(enabled: Boolean) {} public actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) {} public actual fun setLoggingEnabled(enabled: Boolean): Unit = rethrow { enableLogging(enabled) } @@ -148,27 +130,36 @@ public actual open class Query internal actual constructor( awaitClose { rethrow { unsubscribes.forEach { it.invoke() } } } } - public actual fun startAt(value: String, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: String, key: String?): Query = + Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Double, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Double, key: String?): Query = + Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Boolean, key: String?): Query = + Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun endAt(value: String, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: String, key: String?): Query = + Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Double, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Double, key: String?): Query = + Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Boolean, key: String?): Query = + Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) public actual fun limitToFirst(limit: Int): Query = Query(query(publicJs, jsLimitToFirst(limit)), database) public actual fun limitToLast(limit: Int): Query = Query(query(publicJs, jsLimitToLast(limit)), database) - public actual fun equalTo(value: String, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: String, key: String?): Query = + Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Double, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Double, key: String?): Query = + Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Boolean, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Boolean, key: String?): Query = + Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) override fun toString(): String = publicJs.toString() } @@ -193,7 +184,11 @@ internal actual class NativeDatabaseReference internal constructor( actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = rethrow { update(js, encodedUpdate.js).awaitWhileOnline(database) } - actual suspend fun runTransaction(strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit, transactionUpdate: (currentData: T) -> T): DataSnapshot = DataSnapshot( + actual suspend fun runTransaction( + strategy: KSerializer, + buildSettings: EncodeDecodeSettingsBuilder.() -> Unit, + transactionUpdate: (currentData: T) -> T + ): DataSnapshot = DataSnapshot( jsRunTransaction(js, transactionUpdate = { currentData -> reencodeTransformation(strategy, currentData ?: json(), buildSettings, transactionUpdate) }).awaitWhileOnline(database).snapshot, @@ -207,15 +202,19 @@ public actual class DataSnapshot internal constructor( internal val js: JsDataSnapshot, public val database: Database, ) { - public actual val value: Any? get() { - check(!hasChildren) { "DataSnapshot.value can only be used for primitive values (snapshots without children)" } - return js.`val`() - } + public actual val value: Any? + get() { + check(!hasChildren) { "DataSnapshot.value can only be used for primitive values (snapshots without children)" } + return js.`val`() + } public actual inline fun value(): T = rethrow { decode(value = publicJs.`val`()) } - public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = + public actual inline fun value( + strategy: DeserializationStrategy, + buildSettings: DecodeSettings.Builder.() -> Unit + ): T = rethrow { decode(strategy, publicJs.`val`(), buildSettings) } public actual val exists: Boolean get() = rethrow { js.exists() } @@ -252,8 +251,12 @@ internal actual class NativeOnDisconnect internal constructor( public val OnDisconnect.js: dev.gitlive.firebase.database.externals.OnDisconnect get() = native.js public val OnDisconnect.database: Database get() = native.database -public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) { - public constructor(error: dynamic) : this("${error.code ?: "UNKNOWN"}: ${error.message}", error.unsafeCast()) +public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : + RuntimeException(message, cause) { + public constructor(error: dynamic) : this( + "${error.code ?: "UNKNOWN"}: ${error.message}", + error.unsafeCast() + ) } @PublishedApi diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1b38073d8..2b7344e2f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,25 +1,26 @@ [versions] -agp = "8.6.0" +agp = "8.9.3" androidx-test-core = "1.6.1" androidx-test-junit = "1.2.1" androidx-test-runner = "1.6.2" -ben-manes-versions = "0.51.0" -firebase-bom = "33.10.0" -gitlive-firebase-java-sdk = "0.4.6" +ben-manes-versions = "0.52.0" +firebase-bom = "33.15.0" +gitlive-firebase-java-sdk = "0.4.8" gson = "2.11.0" junit = "4.13.2" -kotlin = "2.0.21" -kotlinx-coroutines = "1.9.0" -kotlinx-serialization = "1.7.2" -kotlinx-binarycompatibilityvalidator = "0.16.3" +kotlin = "2.2.0-RC2" +kotlinx-coroutines = "1.10.2" +kotlinx-serialization = "1.8.1" +kotlinx-binarycompatibilityvalidator = "0.17.0" kotlinx-datetime = "0.6.1" -kotlinter = "4.4.1" -settings-api = "2.0" -settings-language = "2.0" -firebase-cocoapods = "11.4.0" +kotlinter = "5.1.1" +settings-api = "2.2" +settings-language = "2.2" +firebase-cocoapods = "11.14.0" ios-deploymentTarget = "13.0" +tvos-deploymentTarget = "13.0" test-logger-plugin = "4.0.0" -dokka = "1.9.20" +dokka = "2.0.0" [libraries] android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9355b4155..fab51dd8c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ +#Sat Jun 07 00:15:39 PKT 2025 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index aca6eb343..fed29b8fa 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -77,6 +77,9 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosX64() + tvosArm64() + tvosSimulatorArm64() } js(IR) { diff --git a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/appleMain/kotlin/dev/gitlive/firebase/TestUtils.kt similarity index 94% rename from test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt rename to test-utils/src/appleMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 1bd12ad92..971625fc8 100644 --- a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/appleMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -14,6 +14,7 @@ import platform.Foundation.NSDefaultRunLoopMode import platform.Foundation.NSRunLoop import platform.Foundation.create import platform.Foundation.runMode +import kotlin.test.assertEquals actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { val testRun = MainScope().async { test() } @@ -30,5 +31,5 @@ actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) = runBlock actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) actual fun nativeListOf(vararg elements: Any?): Any = listOf(*elements) actual fun nativeAssertEquals(expected: Any?, actual: Any?) { - kotlin.test.assertEquals(expected, actual) + assertEquals(expected, actual) } From 2dc2f997e81c9244fcede63ca221afb48ba6352e Mon Sep 17 00:00:00 2001 From: sajidalidev <10349422+sajidalidev@users.noreply.github.com> Date: Fri, 6 Jun 2025 19:55:54 +0000 Subject: [PATCH 2/5] Apply automatic changes --- .../gitlive/firebase/analytics/analytics.kt | 3 +- .../gitlive/firebase/analytics/analytics.kt | 3 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/firebase.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/firebase.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 18 ++--- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 21 ++---- .../dev/gitlive/firebase/auth/credentials.kt | 6 +- .../kotlin/dev/gitlive/firebase/auth/user.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 33 ++++------ .../dev/gitlive/firebase/auth/credentials.kt | 9 +-- .../dev/gitlive/firebase/auth/multifactor.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 18 ++--- .../gitlive/firebase/internal/_decoders.kt | 3 +- .../gitlive/firebase/internal/_decoders.kt | 3 +- .../dev/gitlive/firebase/internal/decoders.kt | 40 ++++------- .../dev/gitlive/firebase/internal/encoders.kt | 12 ++-- .../gitlive/firebase/internal/_decoders.kt | 3 +- .../remoteconfig/FirebaseRemoteConfig.kt | 3 +- .../remoteconfig/FirebaseRemoteConfig.kt | 9 +-- .../remoteconfig/FirebaseRemoteConfig.kt | 3 +- .../firebase/crashlytics/crashlytics.kt | 3 +- .../firebase/crashlytics/crashlytics.kt | 3 +- .../gitlive/firebase/database/ServerValue.kt | 3 +- .../dev/gitlive/firebase/database/database.kt | 42 +++++------- .../gitlive/firebase/database/ServerValue.kt | 3 +- .../dev/gitlive/firebase/database/database.kt | 15 ++--- .../gitlive/firebase/database/ServerValue.kt | 3 +- .../dev/gitlive/firebase/database/database.kt | 66 +++++++------------ .../gitlive/firebase/firestore/FieldValue.kt | 3 +- .../gitlive/firebase/firestore/GeoPoint.kt | 3 +- .../gitlive/firebase/firestore/Timestamp.kt | 3 +- .../gitlive/firebase/firestore/firestore.kt | 3 +- .../NativeCollectionReferenceWrapper.kt | 6 +- .../internal/NativeDocumentReference.kt | 6 +- .../NativeFirebaseFirestoreWrapper.kt | 18 ++--- .../firestore/internal/NativeQueryWrapper.kt | 3 +- .../internal/NativeTransactionWrapper.kt | 6 +- .../internal/NativeWriteBatchWrapper.kt | 3 +- .../firebase/firestore/LocalCacheSettings.kt | 12 ++-- .../gitlive/firebase/firestore/Timestamp.kt | 7 +- .../gitlive/firebase/firestore/encoders.kt | 11 ++-- .../gitlive/firebase/firestore/firestore.kt | 24 +++---- .../dev/gitlive/firebase/firestore/helpers.kt | 5 +- .../gitlive/firebase/firestore/FieldValue.kt | 3 +- .../gitlive/firebase/firestore/GeoPoint.kt | 3 +- .../gitlive/firebase/firestore/Timestamp.kt | 3 +- .../NativeCollectionReferenceWrapper.kt | 6 +- .../internal/NativeDocumentReference.kt | 20 +++--- .../internal/NativeDocumentSnapshotWrapper.kt | 17 ++--- .../NativeFirebaseFirestoreWrapper.kt | 22 +++---- .../firestore/internal/NativeQueryWrapper.kt | 3 +- .../internal/NativeTransactionWrapper.kt | 6 +- .../internal/NativeWriteBatchWrapper.kt | 3 +- .../firebase/firestore/ContextSwitchTest.kt | 35 +++++----- .../gitlive/firebase/firestore/FieldValue.kt | 7 +- .../gitlive/firebase/firestore/GeoPoint.kt | 3 +- .../gitlive/firebase/firestore/Timestamp.kt | 3 +- .../gitlive/firebase/firestore/firestore.kt | 13 ++-- .../internal/NativeDocumentReference.kt | 13 ++-- .../internal/NativeDocumentSnapshotWrapper.kt | 3 +- .../NativeFirebaseFirestoreWrapper.kt | 19 +++--- .../internal/NativeTransactionWrapper.kt | 8 +-- .../internal/NativeWriteBatchWrapper.kt | 5 +- .../gitlive/firebase/firestore/firestore.kt | 3 +- .../gitlive/firebase/functions/functions.kt | 18 ++--- .../gitlive/firebase/functions/functions.kt | 12 ++-- .../gitlive/firebase/functions/functions.kt | 18 ++--- .../firebase/installations/installations.kt | 3 +- .../firebase/installations/installations.kt | 6 +- .../dev/gitlive/firebase/perf/performance.kt | 3 +- .../dev/gitlive/firebase/perf/performance.kt | 3 +- .../kotlin/dev/gitlive/firebase/TestUtils.kt | 3 +- 73 files changed, 276 insertions(+), 486 deletions(-) diff --git a/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index b41f10c69..1eb6c2fdf 100644 --- a/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -13,8 +13,7 @@ import kotlin.time.Duration public actual val Firebase.analytics: FirebaseAnalytics get() = FirebaseAnalytics(com.google.firebase.Firebase.analytics) -public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = - FirebaseAnalytics(com.google.firebase.Firebase.analytics) +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(com.google.firebase.Firebase.analytics) public val FirebaseAnalytics.android: com.google.firebase.analytics.FirebaseAnalytics get() = android diff --git a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index a27b8e367..99294b939 100644 --- a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -11,8 +11,7 @@ import kotlin.time.Duration public actual val Firebase.analytics: FirebaseAnalytics get() = FirebaseAnalytics(getAnalytics()) -public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = - FirebaseAnalytics(getAnalytics(app.js)) +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(getAnalytics(app.js)) public val FirebaseAnalytics.js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics get() = js diff --git a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt index 2efc65e03..dbe1b8113 100644 --- a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -19,17 +19,13 @@ public val FirebaseApp.android: com.google.firebase.FirebaseApp get() = android public actual val Firebase.app: FirebaseApp get() = FirebaseApp(com.google.firebase.FirebaseApp.getInstance()) -public actual fun Firebase.app(name: String): FirebaseApp = - FirebaseApp(com.google.firebase.FirebaseApp.getInstance(name)) +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.getInstance(name)) -public actual fun Firebase.initialize(context: Any?): FirebaseApp? = - com.google.firebase.FirebaseApp.initializeApp(context as Context)?.let { FirebaseApp(it) } +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = com.google.firebase.FirebaseApp.initializeApp(context as Context)?.let { FirebaseApp(it) } -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = - FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid(), name)) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid(), name)) -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = - FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid())) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid())) public actual data class FirebaseApp internal constructor(internal val android: com.google.firebase.FirebaseApp) { actual val name: String diff --git a/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt index ca9d48359..6a8411792 100644 --- a/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -17,17 +17,13 @@ public val FirebaseApp.ios: FIRApp get() = ios public actual val Firebase.app: FirebaseApp get() = FirebaseApp(FIRApp.defaultApp()!!) -public actual fun Firebase.app(name: String): FirebaseApp = - FirebaseApp(FIRApp.appNamed(name)!!) +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(FIRApp.appNamed(name)!!) -public actual fun Firebase.initialize(context: Any?): FirebaseApp? = - FIRApp.configure().let { app } +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = FIRApp.configure().let { app } -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = - FIRApp.configureWithName(name, options.toIos()).let { app(name) } +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FIRApp.configureWithName(name, options.toIos()).let { app(name) } -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = - FIRApp.configureWithOptions(options.toIos()).let { app } +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FIRApp.configureWithOptions(options.toIos()).let { app } public actual data class FirebaseApp internal constructor(internal val ios: FIRApp) { actual val name: String diff --git a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt index d51f28633..c3d2c29e2 100644 --- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -14,17 +14,13 @@ import dev.gitlive.firebase.externals.FirebaseApp as JsFirebaseApp public actual val Firebase.app: FirebaseApp get() = FirebaseApp(getApp()) -public actual fun Firebase.app(name: String): FirebaseApp = - FirebaseApp(getApp(name)) +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(getApp(name)) -public actual fun Firebase.initialize(context: Any?): FirebaseApp? = - throw UnsupportedOperationException("Cannot initialize firebase without options in JS") +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = throw UnsupportedOperationException("Cannot initialize firebase without options in JS") -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = - FirebaseApp(initializeApp(options.toJson(), name)) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(initializeApp(options.toJson(), name)) -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = - FirebaseApp(initializeApp(options.toJson())) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(initializeApp(options.toJson())) public val FirebaseApp.js: JsFirebaseApp get() = js diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt index cc4f2957d..9ba017627 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -23,8 +23,7 @@ public val FirebaseAuth.android: com.google.firebase.auth.FirebaseAuth get() = c public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = - FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) { public actual val currentUser: FirebaseUser? @@ -55,8 +54,7 @@ public actual class FirebaseAuth internal constructor(internal val android: com. android.confirmPasswordReset(code, newPassword).await() } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.createUserWithEmailAndPassword(email, password).await()) + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.createUserWithEmailAndPassword(email, password).await()) @Suppress("DEPRECATION") public actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() @@ -71,19 +69,15 @@ public actual class FirebaseAuth internal constructor(internal val android: com. public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link) - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.signInWithEmailAndPassword(email, password).await()) + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.signInWithEmailAndPassword(email, password).await()) - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - AuthResult(android.signInWithCustomToken(token).await()) + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(android.signInWithCustomToken(token).await()) public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await()) - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - AuthResult(android.signInWithCredential(authCredential.android).await()) + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(android.signInWithCredential(authCredential.android).await()) - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - AuthResult(android.signInWithEmailLink(email, link).await()) + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(android.signInWithEmailLink(email, link).await()) public actual suspend fun signOut(): Unit = android.signOut() diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 30ff27bc1..e392bbbe3 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -53,12 +53,10 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) public actual suspend fun applyActionCode(code: String): Unit = ios.await { applyActionCode(code, it) } public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = ios.await { confirmPasswordResetWithCode(code, newPassword, it) } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) }) + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) }) @Suppress("UNCHECKED_CAST") - public actual suspend fun fetchSignInMethodsForEmail(email: String): List = - ios.awaitResult?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List + public actual suspend fun fetchSignInMethodsForEmail(email: String): List = ios.awaitResult?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { ios.await { actionCodeSettings?.let { actionSettings -> sendPasswordResetWithEmail(email, actionSettings.toIos(), it) } ?: sendPasswordResetWithEmail(email = email, completion = it) } @@ -68,20 +66,15 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) public actual fun isSignInWithEmailLink(link: String): Boolean = ios.isSignInWithEmailLink(link) - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) }) + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) }) - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - AuthResult(ios.awaitResult { signInWithCustomToken(token, it) }) + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(ios.awaitResult { signInWithCustomToken(token, it) }) - public actual suspend fun signInAnonymously(): AuthResult = - AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) }) + public actual suspend fun signInAnonymously(): AuthResult = AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) }) - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) }) + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) }) - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) }) + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) }) public actual suspend fun signOut(): Unit = ios.throwError { signOut(it) } diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 5a2084bb9..431d0aa3a 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -18,14 +18,12 @@ public actual object EmailAuthProvider { public actual fun credential( email: String, password: String, - ): AuthCredential = - AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password)) + ): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password)) public actual fun credentialWithLink( email: String, emailLink: String, - ): AuthCredential = - AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink)) + ): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink)) } public actual object FacebookAuthProvider { diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt index d37fc20c0..a5c91fadb 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -40,21 +40,17 @@ public actual class FirebaseUser internal constructor(internal val ios: FIRUser) public actual suspend fun reload(): Unit = ios.await { reloadWithCompletion(it) } - public actual suspend fun getIdToken(forceRefresh: Boolean): String? = - ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) } + public actual suspend fun getIdToken(forceRefresh: Boolean): String? = ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) } - public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = - AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) }) + public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) }) - public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = - AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) }) + public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) }) public actual suspend fun reauthenticate(credential: AuthCredential) { ios.awaitResult { reauthenticateWithCredential(credential.ios, it) } } - public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = - AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }) + public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }) public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?): Unit = ios.await { actionCodeSettings?.let { settings -> sendEmailVerificationWithActionCodeSettings(settings.toIos(), it) } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 4d0223d28..74d3cc0c4 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -41,8 +41,7 @@ import dev.gitlive.firebase.auth.externals.AdditionalUserInfo as JsAdditionalUse public actual val Firebase.auth: FirebaseAuth get() = rethrow { FirebaseAuth(getAuth()) } -public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = - rethrow { FirebaseAuth(getAuth(app.js)) } +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = rethrow { FirebaseAuth(getAuth(app.js)) } public val FirebaseAuth.js: Auth get() = js @@ -74,41 +73,31 @@ public actual class FirebaseAuth internal constructor(internal val js: Auth) { public actual suspend fun applyActionCode(code: String): Unit = rethrow { applyActionCode(js, code).await() } public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = rethrow { confirmPasswordReset(js, code, newPassword).await() } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) } + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) } public actual suspend fun fetchSignInMethodsForEmail(email: String): List = rethrow { fetchSignInMethodsForEmail(js, email).await().asList() } - public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit = - rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() } + public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit = rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() } - public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = - rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() } + public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() } public actual fun isSignInWithEmailLink(link: String): Boolean = rethrow { isSignInWithEmailLink(js, link) } - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) } + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) } - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - rethrow { AuthResult(signInWithCustomToken(js, token).await()) } + public actual suspend fun signInWithCustomToken(token: String): AuthResult = rethrow { AuthResult(signInWithCustomToken(js, token).await()) } - public actual suspend fun signInAnonymously(): AuthResult = - rethrow { AuthResult(signInAnonymously(js).await()) } + public actual suspend fun signInAnonymously(): AuthResult = rethrow { AuthResult(signInAnonymously(js).await()) } - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) } + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) } - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) } + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) } public actual suspend fun signOut(): Unit = rethrow { signOut(js).await() } - public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = - rethrow { updateCurrentUser(js, user.js).await() } + public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = rethrow { updateCurrentUser(js, user.js).await() } - public actual suspend fun verifyPasswordResetCode(code: String): String = - rethrow { verifyPasswordResetCode(js, code).await() } + public actual suspend fun verifyPasswordResetCode(code: String): String = rethrow { verifyPasswordResetCode(js, code).await() } public actual suspend fun checkActionCode(code: String): T = rethrow { val result = checkActionCode(js, code).await() diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 112099734..3ed643d77 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -23,8 +23,7 @@ public actual class PhoneAuthCredential(js: JsAuthCredential) : AuthCredential(j public actual class OAuthCredential(js: JsAuthCredential) : AuthCredential(js) public actual object EmailAuthProvider { - public actual fun credential(email: String, password: String): AuthCredential = - AuthCredential(EmailAuthProvider.credential(email, password)) + public actual fun credential(email: String, password: String): AuthCredential = AuthCredential(EmailAuthProvider.credential(email, password)) public actual fun credentialWithLink( email: String, @@ -33,13 +32,11 @@ public actual object EmailAuthProvider { } public actual object FacebookAuthProvider { - public actual fun credential(accessToken: String): AuthCredential = - AuthCredential(FacebookAuthProvider.credential(accessToken)) + public actual fun credential(accessToken: String): AuthCredential = AuthCredential(FacebookAuthProvider.credential(accessToken)) } public actual object GithubAuthProvider { - public actual fun credential(token: String): AuthCredential = - AuthCredential(GithubAuthProvider.credential(token)) + public actual fun credential(token: String): AuthCredential = AuthCredential(GithubAuthProvider.credential(token)) } public actual object GoogleAuthProvider { diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 36daf9f4f..b7c6406b0 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -13,14 +13,10 @@ public val MultiFactor.js get() = js public actual class MultiFactor(internal val js: MultiFactorUser) { public actual val enrolledFactors: List get() = rethrow { js.enrolledFactors.map { MultiFactorInfo(it) } } - public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = - rethrow { js.enroll(multiFactorAssertion.js, displayName).await() } - public actual suspend fun getSession(): MultiFactorSession = - rethrow { MultiFactorSession(js.getSession().await()) } - public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = - rethrow { js.unenroll(multiFactorInfo.js).await() } - public actual suspend fun unenroll(factorUid: String): Unit = - rethrow { js.unenroll(factorUid).await() } + public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = rethrow { js.enroll(multiFactorAssertion.js, displayName).await() } + public actual suspend fun getSession(): MultiFactorSession = rethrow { MultiFactorSession(js.getSession().await()) } + public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = rethrow { js.unenroll(multiFactorInfo.js).await() } + public actual suspend fun unenroll(factorUid: String): Unit = rethrow { js.unenroll(factorUid).await() } } public val MultiFactorInfo.js get() = js diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 21043d4d4..06f013ef0 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -21,8 +21,7 @@ import kotlinx.coroutines.tasks.await public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -public actual fun Firebase.auth(app: FirebaseApp) = - FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) +public actual fun Firebase.auth(app: FirebaseApp) = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) { public actual val currentUser: FirebaseUser? @@ -61,8 +60,7 @@ public actual class FirebaseAuth internal constructor(internal val android: com. android.confirmPasswordReset(code, newPassword).await() } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.createUserWithEmailAndPassword(email, password).await()) + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.createUserWithEmailAndPassword(email, password).await()) public actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() @@ -76,19 +74,15 @@ public actual class FirebaseAuth internal constructor(internal val android: com. public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link) - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.signInWithEmailAndPassword(email, password).await()) + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.signInWithEmailAndPassword(email, password).await()) - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - AuthResult(android.signInWithCustomToken(token).await()) + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(android.signInWithCustomToken(token).await()) public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await()) - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - AuthResult(android.signInWithCredential(authCredential.android).await()) + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(android.signInWithCredential(authCredential.android).await()) - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - AuthResult(android.signInWithEmailLink(email, link).await()) + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(android.signInWithEmailLink(email, link).await()) public actual suspend fun signOut() { android.signOut() diff --git a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 77644ccfe..cd0647c41 100644 --- a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -26,8 +26,7 @@ public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } -public actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as? Map<*, *>).orEmpty()[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = (value as? Map<*, *>).orEmpty()[discriminator] as String private fun FirebaseDecoder.decodeAsMap(isNestedPolymorphic: Boolean): CompositeDecoder = (value as? Map<*, *>).orEmpty().let { map -> FirebaseClassDecoder(map.size, settings, { map.containsKey(it) }) { desc, index -> diff --git a/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 81dca8d8b..e2c043a82 100644 --- a/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -20,8 +20,7 @@ public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } -public actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as? Map<*, *>).orEmpty()[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = (value as? Map<*, *>).orEmpty()[discriminator] as String private fun FirebaseDecoder.decodeAsList(): CompositeDecoder = (value as? List<*>).orEmpty().let { FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index] } diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt index 084bc4f62..a9a92413d 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt @@ -16,8 +16,7 @@ import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.serializer public inline fun decode(value: Any?): T = decode(value) {} -public inline fun decode(value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) +public inline fun decode(value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) @PublishedApi internal inline fun decode(value: Any?, decodeSettings: DecodeSettings): T { @@ -25,8 +24,7 @@ internal inline fun decode(value: Any?, decodeSettings: DecodeSettin return decode(strategy as DeserializationStrategy, value, decodeSettings) } public fun decode(strategy: DeserializationStrategy, value: Any?): T = decode(strategy, value) {} -public inline fun decode(strategy: DeserializationStrategy, value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) +public inline fun decode(strategy: DeserializationStrategy, value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) @PublishedApi internal fun decode(strategy: DeserializationStrategy, value: Any?, decodeSettings: DecodeSettings): T { @@ -114,26 +112,19 @@ public open class FirebaseCompositeDecoder( deserializer.deserialize(FirebaseDecoder(it, settings)) } - override fun decodeBooleanElement(descriptor: SerialDescriptor, index: Int): Boolean = - decodeElement(descriptor, index, ::decodeBoolean) + override fun decodeBooleanElement(descriptor: SerialDescriptor, index: Int): Boolean = decodeElement(descriptor, index, ::decodeBoolean) - override fun decodeByteElement(descriptor: SerialDescriptor, index: Int): Byte = - decodeElement(descriptor, index, ::decodeByte) + override fun decodeByteElement(descriptor: SerialDescriptor, index: Int): Byte = decodeElement(descriptor, index, ::decodeByte) - override fun decodeCharElement(descriptor: SerialDescriptor, index: Int): Char = - decodeElement(descriptor, index, ::decodeChar) + override fun decodeCharElement(descriptor: SerialDescriptor, index: Int): Char = decodeElement(descriptor, index, ::decodeChar) - override fun decodeDoubleElement(descriptor: SerialDescriptor, index: Int): Double = - decodeElement(descriptor, index, ::decodeDouble) + override fun decodeDoubleElement(descriptor: SerialDescriptor, index: Int): Double = decodeElement(descriptor, index, ::decodeDouble) - override fun decodeFloatElement(descriptor: SerialDescriptor, index: Int): Float = - decodeElement(descriptor, index, ::decodeFloat) + override fun decodeFloatElement(descriptor: SerialDescriptor, index: Int): Float = decodeElement(descriptor, index, ::decodeFloat) - override fun decodeIntElement(descriptor: SerialDescriptor, index: Int): Int = - decodeElement(descriptor, index, ::decodeInt) + override fun decodeIntElement(descriptor: SerialDescriptor, index: Int): Int = decodeElement(descriptor, index, ::decodeInt) - override fun decodeLongElement(descriptor: SerialDescriptor, index: Int): Long = - decodeElement(descriptor, index, ::decodeLong) + override fun decodeLongElement(descriptor: SerialDescriptor, index: Int): Long = decodeElement(descriptor, index, ::decodeLong) override fun decodeNullableSerializableElement( descriptor: SerialDescriptor, @@ -149,19 +140,16 @@ public open class FirebaseCompositeDecoder( } } - override fun decodeShortElement(descriptor: SerialDescriptor, index: Int): Short = - decodeElement(descriptor, index, ::decodeShort) + override fun decodeShortElement(descriptor: SerialDescriptor, index: Int): Short = decodeElement(descriptor, index, ::decodeShort) - override fun decodeStringElement(descriptor: SerialDescriptor, index: Int): String = - decodeElement(descriptor, index, ::decodeString) + override fun decodeStringElement(descriptor: SerialDescriptor, index: Int): String = decodeElement(descriptor, index, ::decodeString) override fun endStructure(descriptor: SerialDescriptor) {} @ExperimentalSerializationApi - override fun decodeInlineElement(descriptor: SerialDescriptor, index: Int): Decoder = - decodeElement(descriptor, index) { - FirebaseDecoder(it, settings) - } + override fun decodeInlineElement(descriptor: SerialDescriptor, index: Int): Decoder = decodeElement(descriptor, index) { + FirebaseDecoder(it, settings) + } private fun decodeElement(descriptor: SerialDescriptor, index: Int, decoder: (Any?) -> T): T = try { decoder(get(descriptor, index)) diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt index c6c9e4abf..2e621e832 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt @@ -17,20 +17,17 @@ public fun encode(strategy: SerializationStrategy, value: T, shouldEncode this.encodeDefaults = shouldEncodeElementDefault } -public inline fun encode(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = - encode(strategy, value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) +public inline fun encode(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = encode(strategy, value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) @PublishedApi -internal fun encode(strategy: SerializationStrategy, value: T, encodeSettings: EncodeSettings): Any? = - FirebaseEncoder(encodeSettings).apply { encodeSerializableValue(strategy, value) }.value +internal fun encode(strategy: SerializationStrategy, value: T, encodeSettings: EncodeSettings): Any? = FirebaseEncoder(encodeSettings).apply { encodeSerializableValue(strategy, value) }.value @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("encode(value) { this.encodeDefaults = shouldEncodeElementDefault }")) public inline fun encode(value: T, shouldEncodeElementDefault: Boolean): Any? = encode(value) { this.encodeDefaults = shouldEncodeElementDefault } -public inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Any? = - encode(value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) +public inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Any? = encode(value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) /** * Encodes data as an [EncodedObject]. @@ -230,8 +227,7 @@ public open class FirebaseCompositeEncoder( override fun encodeStringElement(descriptor: SerialDescriptor, index: Int, value: String): Unit = set(descriptor, index, value) @ExperimentalSerializationApi - override fun encodeInlineElement(descriptor: SerialDescriptor, index: Int): Encoder = - FirebaseEncoder(settings) + override fun encodeInlineElement(descriptor: SerialDescriptor, index: Int): Encoder = FirebaseEncoder(settings) public fun encodePolymorphicClassDiscriminator(discriminator: String, type: String) { setPolymorphicType(discriminator, type) diff --git a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 05701df40..c5aae4fdb 100644 --- a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -39,8 +39,7 @@ public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, } @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") -public actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as Json)[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = (value as Json)[discriminator] as String private fun FirebaseDecoder.decodeAsList(): CompositeDecoder = (value as Array<*>).let { FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index] } diff --git a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index bfb420515..a381156dc 100644 --- a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -21,8 +21,7 @@ public val FirebaseRemoteConfig.android: AndroidFirebaseRemoteConfig get() = And public actual val Firebase.remoteConfig: FirebaseRemoteConfig get() = FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance()) -public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = - FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(app.android)) +public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(app.android)) public actual class FirebaseRemoteConfig internal constructor(internal val android: AndroidFirebaseRemoteConfig) { public actual val all: Map diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 1a247d9b4..13e1effd4 100644 --- a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -57,8 +57,7 @@ public actual class FirebaseRemoteConfig internal constructor(internal val ios: public actual suspend fun activate(): Boolean = ios.awaitResult { activateWithCompletion(it) } - public actual suspend fun ensureInitialized(): Unit = - ios.await { ensureInitializedWithCompletionHandler(it) } + public actual suspend fun ensureInitialized(): Unit = ios.await { ensureInitializedWithCompletionHandler(it) } public actual suspend fun fetch(minimumFetchInterval: Duration?) { if (minimumFetchInterval != null) { @@ -77,11 +76,9 @@ public actual class FirebaseRemoteConfig internal constructor(internal val ios: return status == FIRRemoteConfigFetchAndActivateStatus.FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote } - public actual fun getKeysByPrefix(prefix: String): Set = - all.keys.filter { it.startsWith(prefix) }.toSet() + public actual fun getKeysByPrefix(prefix: String): Set = all.keys.filter { it.startsWith(prefix) }.toSet() - public actual fun getValue(key: String): FirebaseRemoteConfigValue = - FirebaseRemoteConfigValue(ios.configValueForKey(key)) + public actual fun getValue(key: String): FirebaseRemoteConfigValue = FirebaseRemoteConfigValue(ios.configValueForKey(key)) public actual suspend fun reset() { // not implemented for iOS target diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 01fb0b75a..36e5b9a46 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -36,8 +36,7 @@ public actual class FirebaseRemoteConfig internal constructor(internal val js: R public actual suspend fun activate(): Boolean = rethrow { activate(js).await() } public actual suspend fun ensureInitialized(): Unit = rethrow { ensureInitialized(js).await() } - public actual suspend fun fetch(minimumFetchInterval: Duration?): Unit = - rethrow { fetchConfig(js).await() } + public actual suspend fun fetch(minimumFetchInterval: Duration?): Unit = rethrow { fetchConfig(js).await() } public actual suspend fun fetchAndActivate(): Boolean = rethrow { fetchAndActivate(js).await() } diff --git a/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 0d56d2e1d..c749baa59 100644 --- a/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -11,8 +11,7 @@ public val FirebaseCrashlytics.android: com.google.firebase.crashlytics.Firebase public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance()) -public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = - FirebaseCrashlytics(app.android.get(com.google.firebase.crashlytics.FirebaseCrashlytics::class.java)) +public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = FirebaseCrashlytics(app.android.get(com.google.firebase.crashlytics.FirebaseCrashlytics::class.java)) public actual class FirebaseCrashlytics internal constructor(internal val android: com.google.firebase.crashlytics.FirebaseCrashlytics) { diff --git a/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 5445ceb6e..2454d0436 100644 --- a/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -12,8 +12,7 @@ public val FirebaseCrashlytics.ios: FIRCrashlytics get() = FIRCrashlytics.crashl public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) -public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = - FirebaseCrashlytics(FIRCrashlytics.crashlytics()) +public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) public actual class FirebaseCrashlytics internal constructor(internal val ios: FIRCrashlytics) { diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index f14b0b5b5..91eb328b5 100644 --- a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -14,8 +14,7 @@ public actual class ServerValue internal actual constructor( public actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta)) } - override fun equals(other: Any?): Boolean = - this === other || other is ServerValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is ServerValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "ServerValue($nativeValue)" } 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 561f3215a..2fac17c2a 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 @@ -44,29 +44,25 @@ import kotlin.time.Duration.Companion.seconds public val FirebaseDatabase.android: com.google.firebase.database.FirebaseDatabase get() = com.google.firebase.database.FirebaseDatabase.getInstance() -internal suspend fun Task.awaitWhileOnline(database: FirebaseDatabase): T = - merge( - flow { emit(await()) }, - database - .reference(".info/connected") - .valueEvents - .debounce(2.seconds) - .filterNot { it.value() } - .map { throw DatabaseException("Database not connected", null) }, - ) - .first() +internal suspend fun Task.awaitWhileOnline(database: FirebaseDatabase): T = merge( + flow { emit(await()) }, + database + .reference(".info/connected") + .valueEvents + .debounce(2.seconds) + .filterNot { it.value() } + .map { throw DatabaseException("Database not connected", null) }, +) + .first() public actual val Firebase.database: FirebaseDatabase by lazy { FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance()) } -public actual fun Firebase.database(url: String): FirebaseDatabase = - FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(url)) +public actual fun Firebase.database(url: String): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(url)) -public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = - FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android)) +public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android)) -public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = - FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android, url)) +public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android, url)) public actual class FirebaseDatabase internal constructor(internal val android: com.google.firebase.database.FirebaseDatabase) { @@ -80,11 +76,9 @@ public actual class FirebaseDatabase internal constructor(internal val android: private var persistenceEnabled = true - public actual fun reference(path: String): DatabaseReference = - DatabaseReference(NativeDatabaseReference(android.getReference(path), persistenceEnabled)) + public actual fun reference(path: String): DatabaseReference = DatabaseReference(NativeDatabaseReference(android.getReference(path), persistenceEnabled)) - public actual fun reference(): DatabaseReference = - DatabaseReference(NativeDatabaseReference(android.reference, persistenceEnabled)) + public actual fun reference(): DatabaseReference = DatabaseReference(NativeDatabaseReference(android.reference, persistenceEnabled)) public actual fun setPersistenceEnabled(enabled: Boolean) { android.setPersistenceEnabled(enabled) @@ -287,11 +281,9 @@ public actual class DataSnapshot internal constructor( public actual val value: Any? get() = android.value - public actual inline fun value(): T = - decode(value = publicAndroid.value) + public actual inline fun value(): T = decode(value = publicAndroid.value) - public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicAndroid.value, buildSettings) + public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicAndroid.value, buildSettings) public actual fun child(path: String): DataSnapshot = DataSnapshot(android.child(path), persistenceEnabled) public actual val hasChildren: Boolean get() = android.hasChildren() diff --git a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index 2ce33a91d..35cb37701 100644 --- a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -18,8 +18,7 @@ public actual class ServerValue internal actual constructor( public actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta as NSNumber)) } - override fun equals(other: Any?): Boolean = - this === other || other is ServerValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is ServerValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "ServerValue($nativeValue)" } diff --git a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt index c75290154..458462025 100644 --- a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -49,8 +49,7 @@ public val FirebaseDatabase.ios: FIRDatabase get() = FIRDatabase.database() public actual val Firebase.database: FirebaseDatabase by lazy { FirebaseDatabase(FIRDatabase.database()) } -public actual fun Firebase.database(url: String): FirebaseDatabase = - FirebaseDatabase(FIRDatabase.databaseWithURL(url)) +public actual fun Firebase.database(url: String): FirebaseDatabase = FirebaseDatabase(FIRDatabase.databaseWithURL(url)) public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase( FIRDatabase.databaseForApp(app.ios as objcnames.classes.FIRApp), @@ -62,11 +61,9 @@ public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseData public actual class FirebaseDatabase internal constructor(internal val ios: FIRDatabase) { - public actual fun reference(path: String): DatabaseReference = - DatabaseReference(NativeDatabaseReference(ios.referenceWithPath(path), ios.persistenceEnabled)) + public actual fun reference(path: String): DatabaseReference = DatabaseReference(NativeDatabaseReference(ios.referenceWithPath(path), ios.persistenceEnabled)) - public actual fun reference(): DatabaseReference = - DatabaseReference(NativeDatabaseReference(ios.reference(), ios.persistenceEnabled)) + public actual fun reference(): DatabaseReference = DatabaseReference(NativeDatabaseReference(ios.reference(), ios.persistenceEnabled)) public actual fun setPersistenceEnabled(enabled: Boolean) { ios.persistenceEnabled = enabled @@ -231,11 +228,9 @@ public actual class DataSnapshot internal constructor( public actual val value: Any? get() = ios.value - public actual inline fun value(): T = - decode(value = publicIos.value) + public actual inline fun value(): T = decode(value = publicIos.value) - public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicIos.value, buildSettings) + public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicIos.value, buildSettings) public actual fun child(path: String): DataSnapshot = DataSnapshot(ios.childSnapshotForPath(path), persistenceEnabled) public actual val hasChildren: Boolean get() = ios.hasChildren() diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index d2af58f7a..19e67f5c3 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -14,8 +14,7 @@ public actual class ServerValue internal actual constructor( public actual fun increment(delta: Double): ServerValue = ServerValue(jsIncrement(delta)) } - override fun equals(other: Any?): Boolean = - this === other || other is ServerValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is ServerValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "ServerValue($nativeValue)" } diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt index ce737c3c8..992e29443 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -42,24 +42,19 @@ import dev.gitlive.firebase.database.js as publicJs public actual val Firebase.database: FirebaseDatabase get() = rethrow { FirebaseDatabase(getDatabase()) } -public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = - rethrow { FirebaseDatabase(getDatabase(app = app.js)) } +public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js)) } -public actual fun Firebase.database(url: String): FirebaseDatabase = - rethrow { FirebaseDatabase(getDatabase(url = url)) } +public actual fun Firebase.database(url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(url = url)) } -public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = - rethrow { FirebaseDatabase(getDatabase(app = app.js, url = url)) } +public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js, url = url)) } public val FirebaseDatabase.js: Database get() = js public actual class FirebaseDatabase internal constructor(internal val js: Database) { - public actual fun reference(path: String): DatabaseReference = - rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } + public actual fun reference(path: String): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } - public actual fun reference(): DatabaseReference = - rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } + public actual fun reference(): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } public actual fun setPersistenceEnabled(enabled: Boolean) {} public actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) {} @@ -130,36 +125,27 @@ public actual open class Query internal actual constructor( awaitClose { rethrow { unsubscribes.forEach { it.invoke() } } } } - public actual fun startAt(value: String, key: String?): Query = - Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: String, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Double, key: String?): Query = - Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Double, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Boolean, key: String?): Query = - Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun endAt(value: String, key: String?): Query = - Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: String, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Double, key: String?): Query = - Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Double, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Boolean, key: String?): Query = - Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) public actual fun limitToFirst(limit: Int): Query = Query(query(publicJs, jsLimitToFirst(limit)), database) public actual fun limitToLast(limit: Int): Query = Query(query(publicJs, jsLimitToLast(limit)), database) - public actual fun equalTo(value: String, key: String?): Query = - Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: String, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Double, key: String?): Query = - Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Double, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Boolean, key: String?): Query = - Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Boolean, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) override fun toString(): String = publicJs.toString() } @@ -181,13 +167,12 @@ internal actual class NativeDatabaseReference internal constructor( set(js, encodedValue).awaitWhileOnline(database) } - actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = - rethrow { update(js, encodedUpdate.js).awaitWhileOnline(database) } + actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = rethrow { update(js, encodedUpdate.js).awaitWhileOnline(database) } actual suspend fun runTransaction( strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit, - transactionUpdate: (currentData: T) -> T + transactionUpdate: (currentData: T) -> T, ): DataSnapshot = DataSnapshot( jsRunTransaction(js, transactionUpdate = { currentData -> reencodeTransformation(strategy, currentData ?: json(), buildSettings, transactionUpdate) @@ -208,14 +193,12 @@ public actual class DataSnapshot internal constructor( return js.`val`() } - public actual inline fun value(): T = - rethrow { decode(value = publicJs.`val`()) } + public actual inline fun value(): T = rethrow { decode(value = publicJs.`val`()) } public actual inline fun value( strategy: DeserializationStrategy, - buildSettings: DecodeSettings.Builder.() -> Unit - ): T = - rethrow { decode(strategy, publicJs.`val`(), buildSettings) } + buildSettings: DecodeSettings.Builder.() -> Unit, + ): T = rethrow { decode(strategy, publicJs.`val`(), buildSettings) } public actual val exists: Boolean get() = rethrow { js.exists() } public actual val key: String? get() = rethrow { js.key } @@ -241,21 +224,18 @@ internal actual class NativeOnDisconnect internal constructor( actual suspend fun removeValue() = rethrow { js.remove().awaitWhileOnline(database) } actual suspend fun cancel() = rethrow { js.cancel().awaitWhileOnline(database) } - actual suspend fun setEncodedValue(encodedValue: Any?) = - rethrow { js.set(encodedValue).awaitWhileOnline(database) } + actual suspend fun setEncodedValue(encodedValue: Any?) = rethrow { js.set(encodedValue).awaitWhileOnline(database) } - actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = - rethrow { js.update(encodedUpdate.js).awaitWhileOnline(database) } + actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = rethrow { js.update(encodedUpdate.js).awaitWhileOnline(database) } } public val OnDisconnect.js: dev.gitlive.firebase.database.externals.OnDisconnect get() = native.js public val OnDisconnect.database: Database get() = native.database -public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : - RuntimeException(message, cause) { +public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) { public constructor(error: dynamic) : this( "${error.code ?: "UNKNOWN"}: ${error.message}", - error.unsafeCast() + error.unsafeCast(), ) } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index 2c324b45f..c8945c6aa 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -11,8 +11,7 @@ public actual class FieldValue internal actual constructor(internal actual val n init { require(nativeValue is NativeFieldValue) } - override fun equals(other: Any?): Boolean = - this === other || other is FieldValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is FieldValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index dcf73b20d..25326b01a 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -12,8 +12,7 @@ public actual class GeoPoint internal actual constructor(internal actual val nat public actual val latitude: Double = nativeValue.latitude public actual val longitude: Double = nativeValue.longitude - override fun equals(other: Any?): Boolean = - this === other || other is GeoPoint && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index 61388745b..aa4d76c2f 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -21,8 +21,7 @@ public actual class Timestamp internal actual constructor( public actual val seconds: Long = nativeValue.seconds public actual val nanoseconds: Int = nativeValue.nanoseconds - override fun equals(other: Any?): Boolean = - this === other || other is Timestamp && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() 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 01106caae..ea5d231ed 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 @@ -36,8 +36,7 @@ public val FirebaseFirestore.android: AndroidFirebaseFirestore get() = AndroidFi public actual val Firebase.firestore: FirebaseFirestore get() = FirebaseFirestore(AndroidFirebaseFirestore.getInstance()) -public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = - FirebaseFirestore(AndroidFirebaseFirestore.getInstance(app.android)) +public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = FirebaseFirestore(AndroidFirebaseFirestore.getInstance(app.android)) public val LocalCacheSettings.android: AndroidLocalCacheSettings get() = when (this) { is LocalCacheSettings.Persistent -> androidPersistentCacheSettings { diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index d6b73afb0..f3e137f5a 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -16,9 +16,7 @@ internal actual class NativeCollectionReferenceWrapper internal actual construct actual val parent: NativeDocumentReference? get() = native.parent?.let { NativeDocumentReference(it) } - actual fun document(documentPath: String) = - NativeDocumentReference(native.document(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.document(documentPath)) - actual suspend fun addEncoded(data: EncodedObject) = - NativeDocumentReference(native.add(data.android).await()) + actual suspend fun addEncoded(data: EncodedObject) = NativeDocumentReference(native.add(data.android).await()) } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index cb91ffd74..0c11b1d80 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -28,8 +28,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual fun collection(collectionPath: String) = android.collection(collectionPath) - actual suspend fun get(source: Source) = - android.get(source.toAndroidSource()).await() + actual suspend fun get(source: Source) = android.get(source.toAndroidSource()).await() actual suspend fun setEncoded(encodedData: EncodedObject, setOptions: SetOptions) { val task = ( @@ -68,8 +67,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati exception?.let { close(exception) } } - override fun equals(other: Any?): Boolean = - this === other || other is NativeDocumentReference && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is NativeDocumentReference && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index c3f08216a..ce36357f3 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -14,13 +14,11 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v actual fun collectionGroup(collectionId: String) = native.collectionGroup(collectionId) - actual fun document(documentPath: String) = - NativeDocumentReference(native.document(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.document(documentPath)) actual fun batch() = native.batch() - actual fun setLoggingEnabled(loggingEnabled: Boolean) = - com.google.firebase.firestore.FirebaseFirestore.setLoggingEnabled(loggingEnabled) + actual fun setLoggingEnabled(loggingEnabled: Boolean) = com.google.firebase.firestore.FirebaseFirestore.setLoggingEnabled(loggingEnabled) actual fun applySettings(settings: FirebaseFirestoreSettings) { native.firestoreSettings = firestoreSettings { @@ -31,19 +29,15 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v callbackExecutorMap[native] = settings.callbackExecutor } - actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T): T = - native.runTransaction { runBlocking { it.func() } }.await() + actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T): T = native.runTransaction { runBlocking { it.func() } }.await() - actual suspend fun clearPersistence() = - native.clearPersistence().await().run { } + actual suspend fun clearPersistence() = native.clearPersistence().await().run { } actual fun useEmulator(host: String, port: Int) { native.useEmulator(host, port) } - actual suspend fun disableNetwork() = - native.disableNetwork().await().run { } + actual suspend fun disableNetwork() = native.disableNetwork().await().run { } - actual suspend fun enableNetwork() = - native.enableNetwork().await().run { } + actual suspend fun enableNetwork() = native.enableNetwork().await().run { } } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 5dc17f72b..bd03aeddd 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -38,8 +38,7 @@ internal actual open class NativeQueryWrapper internal actual constructor(actual awaitClose { listener.remove() } } - actual suspend fun get(source: Source): QuerySnapshot = - QuerySnapshot(native.get(source.toAndroidSource()).await()) + actual suspend fun get(source: Source): QuerySnapshot = QuerySnapshot(native.get(source.toAndroidSource()).await()) actual fun where(filter: Filter) = native.where(filter.toAndroidFilter()) diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 4b8219703..775ad3257 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -37,9 +37,7 @@ internal actual class NativeTransactionWrapper internal actual constructor(actua native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } - actual fun delete(documentRef: DocumentReference) = - native.delete(documentRef.android).let { this } + actual fun delete(documentRef: DocumentReference) = native.delete(documentRef.android).let { this } - actual suspend fun get(documentRef: DocumentReference) = - NativeDocumentSnapshotWrapper(native.get(documentRef.android)) + actual suspend fun get(documentRef: DocumentReference) = NativeDocumentSnapshotWrapper(native.get(documentRef.android)) } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index 9aa34f700..4f73b8579 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -39,8 +39,7 @@ internal actual class NativeWriteBatchWrapper internal actual constructor(actual native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } - actual fun delete(documentRef: DocumentReference) = - native.delete(documentRef.android).let { this } + actual fun delete(documentRef: DocumentReference) = native.delete(documentRef.android).let { this } actual suspend fun commit() { native.commit().await() diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt index 04096c94a..cf6178fb8 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt @@ -56,14 +56,10 @@ public sealed interface MemoryGarbageCollectorSettings { public typealias MemoryEagerGcSettings = MemoryGarbageCollectorSettings.Eager public typealias MemoryLruGcSettings = MemoryGarbageCollectorSettings.LRUGC -public fun memoryCacheSettings(builder: LocalCacheSettings.Memory.Builder.() -> Unit): LocalCacheSettings.Memory = - LocalCacheSettings.Memory.newBuilder().apply(builder).build() +public fun memoryCacheSettings(builder: LocalCacheSettings.Memory.Builder.() -> Unit): LocalCacheSettings.Memory = LocalCacheSettings.Memory.newBuilder().apply(builder).build() -public fun memoryEagerGcSettings(builder: MemoryGarbageCollectorSettings.Eager.Builder.() -> Unit): MemoryGarbageCollectorSettings.Eager = - MemoryGarbageCollectorSettings.Eager.newBuilder().apply(builder).build() +public fun memoryEagerGcSettings(builder: MemoryGarbageCollectorSettings.Eager.Builder.() -> Unit): MemoryGarbageCollectorSettings.Eager = MemoryGarbageCollectorSettings.Eager.newBuilder().apply(builder).build() -public fun memoryLruGcSettings(builder: MemoryGarbageCollectorSettings.LRUGC.Builder.() -> Unit): MemoryGarbageCollectorSettings.LRUGC = - MemoryGarbageCollectorSettings.LRUGC.newBuilder().apply(builder).build() +public fun memoryLruGcSettings(builder: MemoryGarbageCollectorSettings.LRUGC.Builder.() -> Unit): MemoryGarbageCollectorSettings.LRUGC = MemoryGarbageCollectorSettings.LRUGC.newBuilder().apply(builder).build() -public fun persistentCacheSettings(builder: LocalCacheSettings.Persistent.Builder.() -> Unit): LocalCacheSettings.Persistent = - LocalCacheSettings.Persistent.newBuilder().apply(builder).build() +public fun persistentCacheSettings(builder: LocalCacheSettings.Persistent.Builder.() -> Unit): LocalCacheSettings.Persistent = LocalCacheSettings.Persistent.newBuilder().apply(builder).build() diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index 13a37a7e7..b9b63175d 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -33,10 +33,9 @@ public expect class Timestamp internal constructor(nativeValue: NativeTimestamp) public data object ServerTimestamp : BaseTimestamp } -public fun Timestamp.Companion.fromDuration(duration: Duration): Timestamp = - duration.toComponents { seconds, nanoseconds -> - Timestamp(seconds, nanoseconds) - } +public fun Timestamp.Companion.fromDuration(duration: Duration): Timestamp = duration.toComponents { seconds, nanoseconds -> + Timestamp(seconds, nanoseconds) +} public fun Timestamp.toDuration(): Duration = seconds.seconds + nanoseconds.nanoseconds public fun Timestamp.Companion.fromMilliseconds(milliseconds: Double): Timestamp = fromDuration(milliseconds.milliseconds) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt index 54410b4ef..308e758ce 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt @@ -7,9 +7,8 @@ import dev.gitlive.firebase.EncodeSettings internal expect fun isSpecialValue(value: Any): Boolean @PublishedApi -internal inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = - if (value?.let(::isSpecialValue) == true) { - value - } else { - dev.gitlive.firebase.internal.encode(value, buildSettings) - } +internal inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = if (value?.let(::isSpecialValue) == true) { + value +} else { + dev.gitlive.firebase.internal.encode(value, buildSettings) +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index bf4723e49..05dae934b 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -306,43 +306,37 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, merge: Boolean = false): WriteBatch = set(documentRef, data, merge) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) + public inline fun set(documentRef: DocumentReference, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFields: String): WriteBatch = set(documentRef, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) + public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): WriteBatch = set(documentRef, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) + public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults }")) public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false): WriteBatch = set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String): WriteBatch = set(documentRef, strategy, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): WriteBatch = set(documentRef, strategy, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @PublishedApi internal fun setEncoded(documentRef: DocumentReference, encodedData: EncodedObject, setOptions: SetOptions): WriteBatch = WriteBatch(nativeWrapper.setEncoded(documentRef, encodedData, setOptions)) @@ -351,15 +345,13 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na public inline fun update(documentRef: DocumentReference, data: T, encodeDefaults: Boolean): WriteBatch = update(documentRef, data) { this.encodeDefaults = encodeDefaults } - public inline fun update(documentRef: DocumentReference, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - updateEncoded(documentRef, encodeAsObject(data, buildSettings)) + public inline fun update(documentRef: DocumentReference, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncoded(documentRef, encodeAsObject(data, buildSettings)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults }")) public fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean): WriteBatch = update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults } - public inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - updateEncoded(documentRef, encodeAsObject(strategy, data, buildSettings)) + public inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncoded(documentRef, encodeAsObject(strategy, data, buildSettings)) @JvmName("updateField") public inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt index 766836a76..494d50cea 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt @@ -25,9 +25,8 @@ internal inline fun encodeFieldAndValue( fieldsAndValues: Array>, encodeField: (T) -> K, encodeValue: (Any?) -> Any?, -): List>? = - fieldsAndValues.takeUnless { fieldsAndValues.isEmpty() } - ?.map { (field, value) -> encodeField(field) to value?.let { encodeValue(it) } } +): List>? = fieldsAndValues.takeUnless { fieldsAndValues.isEmpty() } + ?.map { (field, value) -> encodeField(field) to value?.let { encodeValue(it) } } internal fun List>.performUpdate( update: (K, Any?, Array) -> R, diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index 9eb6a8589..a1e9a49ec 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -12,8 +12,7 @@ public actual class FieldValue internal actual constructor(internal actual val n init { require(nativeValue is NativeFieldValue) } - override fun equals(other: Any?): Boolean = - this === other || other is FieldValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is FieldValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 5dc0fa8aa..a9bcf2e7f 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -13,8 +13,7 @@ public actual class GeoPoint internal actual constructor(internal actual val nat public actual val latitude: Double = nativeValue.latitude public actual val longitude: Double = nativeValue.longitude - override fun equals(other: Any?): Boolean = - this === other || other is GeoPoint && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index 8497833e8..49505e776 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -20,8 +20,7 @@ public actual class Timestamp internal actual constructor( public actual val seconds: Long = nativeValue.seconds public actual val nanoseconds: Int = nativeValue.nanoseconds - override fun equals(other: Any?): Boolean = - this === other || other is Timestamp && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index 15513316c..38070eab2 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -14,9 +14,7 @@ internal actual class NativeCollectionReferenceWrapper internal actual construct actual val parent get() = native.parent?.let { NativeDocumentReference(it) } - actual fun document(documentPath: String) = - NativeDocumentReference(native.documentWithPath(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.documentWithPath(documentPath)) - actual suspend fun addEncoded(data: EncodedObject) = - NativeDocumentReference(await { native.addDocumentWithData(data.ios, it) }) + actual suspend fun addEncoded(data: EncodedObject) = NativeDocumentReference(await { native.addDocumentWithData(data.ios, it) }) } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index 98856556b..d7f330fff 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -35,8 +35,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual fun collection(collectionPath: String) = ios.collectionWithPath(collectionPath) - actual suspend fun get(source: Source) = - awaitResult { ios.getDocumentWithSource(source.toIosSource(), it) } + actual suspend fun get(source: Source) = awaitResult { ios.getDocumentWithSource(source.toIosSource(), it) } actual suspend fun setEncoded(encodedData: EncodedObject, setOptions: SetOptions) = await { when (setOptions) { @@ -55,15 +54,13 @@ internal actual class NativeDocumentReference actual constructor(actual val nati ios.updateData(encodedData.ios, it) } - actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) = - await { - ios.updateData(encodedFieldsAndValues.toMap(), it) - } + actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) = await { + ios.updateData(encodedFieldsAndValues.toMap(), it) + } - actual suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) = - await { - ios.updateData(encodedFieldsAndValues.toMap(), it) - } + actual suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) = await { + ios.updateData(encodedFieldsAndValues.toMap(), it) + } actual suspend fun delete() = await { ios.deleteDocumentWithCompletion(it) } @@ -75,8 +72,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati awaitClose { listener.remove() } } - override fun equals(other: Any?): Boolean = - this === other || other is NativeDocumentReference && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is NativeDocumentReference && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index 36594699d..ad7cb69f2 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -13,18 +13,15 @@ internal actual class NativeDocumentSnapshotWrapper actual constructor(actual va actual val reference get() = NativeDocumentReference(native.reference) - actual fun getEncoded(field: String, serverTimestampBehavior: ServerTimestampBehavior): Any? = - native.valueForField(field, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } + actual fun getEncoded(field: String, serverTimestampBehavior: ServerTimestampBehavior): Any? = native.valueForField(field, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } // Despite its name implying otherwise, valueForField accepts both a String representation of a Field and a FIRFieldPath - actual fun getEncoded(fieldPath: EncodedFieldPath, serverTimestampBehavior: ServerTimestampBehavior): Any? = - native.valueForField(fieldPath, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } - - actual fun encodedData(serverTimestampBehavior: ServerTimestampBehavior): Any? = - native.dataWithServerTimestampBehavior(serverTimestampBehavior.toIos()) - ?.mapValues { (_, value) -> - value?.takeIf { it !is NSNull } - } + actual fun getEncoded(fieldPath: EncodedFieldPath, serverTimestampBehavior: ServerTimestampBehavior): Any? = native.valueForField(fieldPath, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } + + actual fun encodedData(serverTimestampBehavior: ServerTimestampBehavior): Any? = native.dataWithServerTimestampBehavior(serverTimestampBehavior.toIos()) + ?.mapValues { (_, value) -> + value?.takeIf { it !is NSNull } + } actual fun contains(field: String) = native.valueForField(field) != null actual fun contains(fieldPath: EncodedFieldPath) = native.valueForField(fieldPath) != null diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index 50e59c0ad..4d802acec 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -15,28 +15,24 @@ internal actual class NativeFirebaseFirestoreWrapper internal actual constructor actual fun collectionGroup(collectionId: String) = native.collectionGroupWithID(collectionId) - actual fun document(documentPath: String) = - NativeDocumentReference(native.documentWithPath(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.documentWithPath(documentPath)) actual fun batch() = native.batch() - actual fun setLoggingEnabled(loggingEnabled: Boolean): Unit = - FIRFirestore.enableLogging(loggingEnabled) + actual fun setLoggingEnabled(loggingEnabled: Boolean): Unit = FIRFirestore.enableLogging(loggingEnabled) actual fun applySettings(settings: FirebaseFirestoreSettings) { native.settings = settings.ios } - actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = - awaitResult { - native.runTransactionWithBlock( - { transaction, _ -> runBlocking { transaction!!.func() } }, - it, - ) - } as T + actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = awaitResult { + native.runTransactionWithBlock( + { transaction, _ -> runBlocking { transaction!!.func() } }, + it, + ) + } as T - actual suspend fun clearPersistence() = - await { native.clearPersistenceWithCompletion(it) } + actual suspend fun clearPersistence() = await { native.clearPersistenceWithCompletion(it) } actual fun useEmulator(host: String, port: Int) { native.useEmulatorWithHost(host, port.toLong()) diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 30f01b7f1..788eb8ade 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -19,8 +19,7 @@ internal actual open class NativeQueryWrapper internal actual constructor(actual actual fun limit(limit: Number) = native.queryLimitedTo(limit.toLong()) - actual suspend fun get(source: Source) = - QuerySnapshot(awaitResult { native.getDocumentsWithSource(source.toIosSource(), it) }) + actual suspend fun get(source: Source) = QuerySnapshot(awaitResult { native.getDocumentsWithSource(source.toIosSource(), it) }) actual val snapshots get() = callbackFlow { val listener = native.addSnapshotListener { snapshot, error -> diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index a9fe0014d..6771da276 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -38,9 +38,7 @@ internal actual class NativeTransactionWrapper actual constructor(actual val nat documentRef.ios, ).let { this } - actual fun delete(documentRef: DocumentReference) = - native.deleteDocument(documentRef.ios).let { this } + actual fun delete(documentRef: DocumentReference) = native.deleteDocument(documentRef.ios).let { this } - actual suspend fun get(documentRef: DocumentReference) = - throwError { NativeDocumentSnapshotWrapper(native.getDocument(documentRef.ios, it)!!) } + actual suspend fun get(documentRef: DocumentReference) = throwError { NativeDocumentSnapshotWrapper(native.getDocument(documentRef.ios, it)!!) } } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index f1551cecf..081c8302b 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -39,8 +39,7 @@ internal actual class NativeWriteBatchWrapper actual constructor(actual val nati documentRef.ios, ).let { this } - actual fun delete(documentRef: DocumentReference) = - native.deleteDocument(documentRef.ios).let { this } + actual fun delete(documentRef: DocumentReference) = native.deleteDocument(documentRef.ios).let { this } actual suspend fun commit() = await { native.commitWithCompletion(it) } } diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt index e7c6fc04f..640b38fb3 100644 --- a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt +++ b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt @@ -33,27 +33,26 @@ private val backgroundContext = newSingleThreadContext("background") * @param create a block for object creation * @param test a block to perform test on a thread different from the one used in [create] */ -fun runTestWithContextSwitch(create: suspend CoroutineScope.() -> T, test: suspend CoroutineScope.(T) -> Unit) = - runBlocking { - val testRun = MainScope().async { - val objMain = create() - withContext(backgroundContext) { - test(objMain) - } - val objBcg = withContext(backgroundContext) { - create() - } - test(objBcg) +fun runTestWithContextSwitch(create: suspend CoroutineScope.() -> T, test: suspend CoroutineScope.(T) -> Unit) = runBlocking { + val testRun = MainScope().async { + val objMain = create() + withContext(backgroundContext) { + test(objMain) } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()), - ) - yield() + val objBcg = withContext(backgroundContext) { + create() } - testRun.await() + test(objBcg) + } + while (testRun.isActive) { + NSRunLoop.mainRunLoop.runMode( + NSDefaultRunLoopMode, + beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()), + ) + yield() } + testRun.await() +} class ContextSwitchTest { diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index 5407e19d6..f33eb606d 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -16,10 +16,9 @@ public actual class FieldValue internal actual constructor(internal actual val n init { require(nativeValue is NativeFieldValue) } - override fun equals(other: Any?): Boolean = - this === other || - other is FieldValue && - (nativeValue as NativeFieldValue).isEqual(other.nativeValue as NativeFieldValue) + override fun equals(other: Any?): Boolean = this === other || + other is FieldValue && + (nativeValue as NativeFieldValue).isEqual(other.nativeValue as NativeFieldValue) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 0818e403c..83248b38a 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -12,8 +12,7 @@ public actual class GeoPoint internal actual constructor(internal actual val nat public actual val latitude: Double by nativeValue::latitude public actual val longitude: Double by nativeValue::longitude - override fun equals(other: Any?): Boolean = - this === other || other is GeoPoint && nativeValue.isEqual(other.nativeValue) + override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue.isEqual(other.nativeValue) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "GeoPoint[lat=$latitude,long=$longitude]" } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index bc18327ba..28d7077e8 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -19,8 +19,7 @@ public actual class Timestamp internal actual constructor( public actual val seconds: Long = nativeValue.seconds.toLong() public actual val nanoseconds: Int = nativeValue.nanoseconds.toInt() - override fun equals(other: Any?): Boolean = - this === other || other is Timestamp && nativeValue.isEqual(other.nativeValue) + override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue.isEqual(other.nativeValue) override fun hashCode(): Int = nativeValue.toMillis().hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 752e53a3c..156f66246 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -35,8 +35,7 @@ import dev.gitlive.firebase.firestore.externals.documentId as jsDocumentId public actual val Firebase.firestore: FirebaseFirestore get() = rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(getApp())) } -public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = - rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(app.js)) } +public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(app.js)) } internal actual data class NativeFirebaseFirestore(val js: JsFirestore) @@ -271,11 +270,9 @@ internal fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "") } // from: https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509/8 -internal fun entriesOf(jsObject: dynamic): List> = - (js("Object.entries") as (dynamic) -> Array>) - .invoke(jsObject) - .map { entry -> entry[0] as String to entry[1] } +internal fun entriesOf(jsObject: dynamic): List> = (js("Object.entries") as (dynamic) -> Array>) + .invoke(jsObject) + .map { entry -> entry[0] as String to entry[1] } // from: https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509/8 -internal fun mapOf(jsObject: dynamic): Map = - entriesOf(jsObject).toMap() +internal fun mapOf(jsObject: dynamic): Map = entriesOf(jsObject).toMap() diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index 5065defa2..e93181308 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -95,13 +95,12 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual suspend fun delete() = rethrow { deleteDoc(js).await() } - override fun equals(other: Any?): Boolean = - this === other || - other is NativeDocumentReference && - refEqual( - nativeValue, - other.nativeValue, - ) + override fun equals(other: Any?): Boolean = this === other || + other is NativeDocumentReference && + refEqual( + nativeValue, + other.nativeValue, + ) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "DocumentReference(path=$path)" } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index bf6e967a6..a994d1efb 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -34,6 +34,5 @@ internal actual class NativeDocumentSnapshotWrapper internal actual constructor( actual val exists get() = rethrow { js.exists() } actual val metadata: SnapshotMetadata get() = SnapshotMetadata(js.metadata) - fun getTimestampsOptions(serverTimestampBehavior: ServerTimestampBehavior) = - json("serverTimestamps" to serverTimestampBehavior.name.lowercase()) + fun getTimestampsOptions(serverTimestampBehavior: ServerTimestampBehavior) = json("serverTimestamps" to serverTimestampBehavior.name.lowercase()) } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index c8c1a31ae..d895afec1 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -94,24 +94,21 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( actual fun batch() = rethrow { NativeWriteBatch(writeBatch(js)) } - actual fun setLoggingEnabled(loggingEnabled: Boolean) = - rethrow { setLogLevel(if (loggingEnabled) "error" else "silent") } + actual fun setLoggingEnabled(loggingEnabled: Boolean) = rethrow { setLogLevel(if (loggingEnabled) "error" else "silent") } actual fun applySettings(settings: FirebaseFirestoreSettings) { this.settings = settings } @OptIn(DelicateCoroutinesApi::class) - actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = - rethrow { - dev.gitlive.firebase.firestore.externals.runTransaction( - js, - { GlobalScope.promise { NativeTransaction(it).func() } }, - ).await() - } + actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = rethrow { + dev.gitlive.firebase.firestore.externals.runTransaction( + js, + { GlobalScope.promise { NativeTransaction(it).func() } }, + ).await() + } - actual suspend fun clearPersistence() = - rethrow { clearIndexedDbPersistence(js).await() } + actual suspend fun clearPersistence() = rethrow { clearIndexedDbPersistence(js).await() } actual fun useEmulator(host: String, port: Int) = rethrow { if (settings != null) { diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 59ba9896d..8509a9db7 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -47,10 +47,8 @@ internal actual class NativeTransactionWrapper internal actual constructor(actua } }.let { this } - actual fun delete(documentRef: DocumentReference) = - rethrow { js.delete(documentRef.js) } - .let { this } + actual fun delete(documentRef: DocumentReference) = rethrow { js.delete(documentRef.js) } + .let { this } - actual suspend fun get(documentRef: DocumentReference) = - rethrow { NativeDocumentSnapshotWrapper(js.get(documentRef.js).await()) } + actual suspend fun get(documentRef: DocumentReference) = rethrow { NativeDocumentSnapshotWrapper(js.get(documentRef.js).await()) } } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index e97cc31ab..4bd929e93 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -44,9 +44,8 @@ internal actual class NativeWriteBatchWrapper internal actual constructor(actual } }.let { this } - actual fun delete(documentRef: DocumentReference) = - rethrow { js.delete(documentRef.js) } - .let { this } + actual fun delete(documentRef: DocumentReference) = rethrow { js.delete(documentRef.js) } + .let { this } actual suspend fun commit() = rethrow { js.commit().await() } } diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 9c6ba0d4c..a8c56abf9 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -13,5 +13,4 @@ actual val context: Any = Unit actual fun encodedAsMap(encoded: Any?): Map = (js("Object").entries(encoded) as Array>).associate { it[0] as String to it[1] } -actual fun Map.asEncoded(): Any = - json(*entries.map { (key, value) -> key to value }.toTypedArray()) +actual fun Map.asEncoded(): Any = json(*entries.map { (key, value) -> key to value }.toTypedArray()) 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 00b1a3dab..591602228 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 @@ -22,18 +22,14 @@ public val FirebaseFunctions.android: com.google.firebase.functions.FirebaseFunc public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance()) -public actual fun Firebase.functions(region: String): FirebaseFunctions = - FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(region)) +public actual fun Firebase.functions(region: String): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(region)) -public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = - FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android)) +public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android)) -public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = - FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android, region)) +public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android, region)) public actual data class FirebaseFunctions internal constructor(internal val android: com.google.firebase.functions.FirebaseFunctions) { - public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = - HttpsCallableReference(android.getHttpsCallable(name).apply { timeout?.let { setTimeout(it.inWholeMilliseconds, TimeUnit.MILLISECONDS) } }.native) + public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = HttpsCallableReference(android.getHttpsCallable(name).apply { timeout?.let { setTimeout(it.inWholeMilliseconds, TimeUnit.MILLISECONDS) } }.native) public actual fun useEmulator(host: String, port: Int) { android.useEmulator(host, port) @@ -53,11 +49,9 @@ public val HttpsCallableResult.android: com.google.firebase.functions.HttpsCalla public actual class HttpsCallableResult(internal val android: com.google.firebase.functions.HttpsCallableResult) { - public actual inline fun data(): T = - decode(value = publicAndroid.data) + public actual inline fun data(): T = decode(value = publicAndroid.data) - public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicAndroid.data, buildSettings) + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicAndroid.data, buildSettings) } public actual typealias FirebaseFunctionsException = com.google.firebase.functions.FirebaseFunctionsException 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 d002f93b4..3f22a9bd3 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 @@ -27,8 +27,7 @@ public val FirebaseFunctions.ios: FIRFunctions get() = FIRFunctions.functions() public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(FIRFunctions.functions()) -public actual fun Firebase.functions(region: String): FirebaseFunctions = - FirebaseFunctions(FIRFunctions.functionsForRegion(region)) +public actual fun Firebase.functions(region: String): FirebaseFunctions = FirebaseFunctions(FIRFunctions.functionsForRegion(region)) public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = FirebaseFunctions( FIRFunctions.functionsForApp(app.ios as objcnames.classes.FIRApp), @@ -42,8 +41,7 @@ public actual fun Firebase.functions( ) public actual data class FirebaseFunctions internal constructor(internal val ios: FIRFunctions) { - public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = - HttpsCallableReference(ios.HTTPSCallableWithName(name).apply { timeout?.let { setTimeoutInterval(it.toDouble(DurationUnit.SECONDS)) } }.native) + public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = HttpsCallableReference(ios.HTTPSCallableWithName(name).apply { timeout?.let { setTimeoutInterval(it.toDouble(DurationUnit.SECONDS)) } }.native) public actual fun useEmulator(host: String, port: Int) { ios.useEmulatorWithHost(host, port.toLong()) @@ -63,11 +61,9 @@ public val HttpsCallableResult.ios: FIRHTTPSCallableResult get() = ios public actual class HttpsCallableResult(internal val ios: FIRHTTPSCallableResult) { - public actual inline fun data(): T = - decode(value = publicIos.data()) + public actual inline fun data(): T = decode(value = publicIos.data()) - public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicIos.data(), buildSettings) + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicIos.data(), buildSettings) } public actual class FirebaseFunctionsException(message: String, public val code: FunctionsExceptionCode, public val details: Any?) : FirebaseException(message) 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 5797002cb..47a543a5c 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 @@ -29,20 +29,16 @@ import dev.gitlive.firebase.functions.js as publicJs public actual val Firebase.functions: FirebaseFunctions get() = rethrow { FirebaseFunctions(getFunctions()) } -public actual fun Firebase.functions(region: String): FirebaseFunctions = - rethrow { FirebaseFunctions(getFunctions(regionOrCustomDomain = region)) } +public actual fun Firebase.functions(region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(regionOrCustomDomain = region)) } -public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = - rethrow { FirebaseFunctions(getFunctions(app.js)) } +public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js)) } -public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = - rethrow { FirebaseFunctions(getFunctions(app.js, region)) } +public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js, region)) } public val FirebaseFunctions.js get() = js public actual class FirebaseFunctions internal constructor(internal val js: Functions) { - public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = - rethrow { HttpsCallableReference(httpsCallable(js, name, timeout?.let { json("timeout" to timeout.toDouble(DurationUnit.MILLISECONDS)) }).native) } + public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = rethrow { HttpsCallableReference(httpsCallable(js, name, timeout?.let { json("timeout" to timeout.toDouble(DurationUnit.MILLISECONDS)) }).native) } public actual fun useEmulator(host: String, port: Int) { connectFunctionsEmulator(js, host, port) @@ -66,11 +62,9 @@ public val HttpsCallableResult.js: JsHttpsCallableResult get() = js public actual class HttpsCallableResult(internal val js: JsHttpsCallableResult) { - public actual inline fun data(): T = - rethrow { decode(value = publicJs.data) } + public actual inline fun data(): T = rethrow { decode(value = publicJs.data) } - public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - rethrow { decode(strategy, publicJs.data, buildSettings) } + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = rethrow { decode(strategy, publicJs.data, buildSettings) } } public actual class FirebaseFunctionsException(cause: Throwable, public val code: FunctionsExceptionCode, public val details: Any?) : FirebaseException(cause.message, cause) diff --git a/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt index f9c0d3224..fe17f9ffd 100644 --- a/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -18,8 +18,7 @@ public actual class FirebaseInstallations internal constructor(internal val andr public actual suspend fun getId(): String = android.id.await() - public actual suspend fun getToken(forceRefresh: Boolean): String = - android.getToken(forceRefresh).await().token + public actual suspend fun getToken(forceRefresh: Boolean): String = android.getToken(forceRefresh).await().token } public actual typealias FirebaseInstallationsException = com.google.firebase.installations.FirebaseInstallationsException diff --git a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt index de34f3637..8650b1bee 100644 --- a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -10,8 +10,7 @@ import kotlinx.coroutines.await public actual val Firebase.installations: FirebaseInstallations get() = rethrow { FirebaseInstallations(getInstallations()) } -public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = - rethrow { FirebaseInstallations(getInstallations(app.js)) } +public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = rethrow { FirebaseInstallations(getInstallations(app.js)) } public val FirebaseInstallations.js get() = js @@ -21,8 +20,7 @@ public actual class FirebaseInstallations internal constructor(internal val js: public actual suspend fun getId(): String = rethrow { getId(js).await() } - public actual suspend fun getToken(forceRefresh: Boolean): String = - rethrow { getToken(js, forceRefresh).await() } + public actual suspend fun getToken(forceRefresh: Boolean): String = rethrow { getToken(js, forceRefresh).await() } } public actual open class FirebaseInstallationsException(code: String?, cause: Throwable) : FirebaseException(code, cause) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt index a4e4d3d47..bdc922fd4 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -10,8 +10,7 @@ public val FirebasePerformance.android: com.google.firebase.perf.FirebasePerform public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(com.google.firebase.perf.FirebasePerformance.getInstance()) -public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = - FirebasePerformance(app.publicAndroid.get(com.google.firebase.perf.FirebasePerformance::class.java)) +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(app.publicAndroid.get(com.google.firebase.perf.FirebasePerformance::class.java)) public actual class FirebasePerformance(internal val android: com.google.firebase.perf.FirebasePerformance) { diff --git a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt index 527660077..661a86814 100644 --- a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -11,8 +11,7 @@ public val FirebasePerformance.ios: FIRPerformance get() = FIRPerformance.shared public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(FIRPerformance.sharedInstance()) -public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = - FirebasePerformance(FIRPerformance.sharedInstance()) +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(FIRPerformance.sharedInstance()) public actual class FirebasePerformance(internal val ios: FIRPerformance) { diff --git a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 5f87d1686..2b7d65021 100644 --- a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -8,8 +8,7 @@ import kotlinx.coroutines.CoroutineScope import kotlin.js.json import kotlin.time.Duration.Companion.minutes -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = - kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) { kotlinx.coroutines.test.runTest { action() } } From aa17978f0e912dcea28d309f1367e32ccdb91682 Mon Sep 17 00:00:00 2001 From: Sajid Ali Date: Sat, 7 Jun 2025 14:27:34 +0500 Subject: [PATCH 3/5] Add macOS Support and Extend Platform Coverage Updated the build configuration to include support for macOS by setting appropriate deployment targets. Enhanced platform coverage by adding macOS targets to existing iOS, tvOS, and Kotlin opt-ins. Updated Gradle and library versions to their latest stable releases, ensuring compatibility with new platforms while leveraging recent improvements in dependencies. --- firebase-analytics/build.gradle.kts | 13 +- .../gitlive/firebase/analytics/analytics.kt | 0 .../gitlive/firebase/analytics/analytics.kt | 0 firebase-app/build.gradle.kts | 4 + .../kotlin/dev/gitlive/firebase/firebase.kt | 0 .../dev/gitlive/firebase/auth/multifactor.kt | 17 +- .../kotlin/dev/gitlive/firebase/auth/user.kt | 6 +- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 +- firebase-common-internal/build.gradle.kts | 2 + firebase-common/build.gradle.kts | 2 + firebase-config/build.gradle.kts | 13 +- .../remoteconfig/FirebaseRemoteConfig.kt | 0 .../remoteconfig/FirebaseRemoteConfigValue.kt | 0 .../firebase/remoteconfig/NSDataExtension.kt | 0 .../remoteconfig/NSDataExtensionTest.kt | 0 .../firebase/remoteconfig/RemoteConfig.kt | 0 .../remoteconfig/FirebaseRemoteConfig.kt | 2 +- .../remoteconfig/FirebaseRemoteConfigValue.kt | 2 +- firebase-crashlytics/build.gradle.kts | 13 +- .../firebase/crashlytics/crashlytics.kt | 0 .../firebase/crashlytics/crashlytics.kt | 0 firebase-database/build.gradle.kts | 4 + firebase-firestore/build.gradle.kts | 13 +- .../gitlive/firebase/firestore/FieldValue.kt | 0 .../gitlive/firebase/firestore/GeoPoint.kt | 0 .../gitlive/firebase/firestore/Timestamp.kt | 0 .../gitlive/firebase/firestore/_encoders.kt | 0 .../gitlive/firebase/firestore/firestore.kt | 0 .../NativeCollectionReferenceWrapper.kt | 0 .../internal/NativeDocumentReference.kt | 0 .../internal/NativeDocumentSnapshotWrapper.kt | 0 .../NativeFirebaseFirestoreWrapper.kt | 0 .../firestore/internal/NativeQueryWrapper.kt | 0 .../internal/NativeTransactionWrapper.kt | 0 .../internal/NativeWriteBatchWrapper.kt | 0 .../firebase/firestore/internal/Source.kt | 0 .../firebase/firestore/internal/throwError.kt | 0 .../firebase/firestore/ContextSwitchTest.kt | 0 .../dev/gitlive/firebase/firestore/Ignore.kt | 0 .../gitlive/firebase/firestore/firestore.kt | 0 firebase-functions/build.gradle.kts | 13 +- .../gitlive/firebase/functions/functions.kt | 0 .../gitlive/firebase/functions/functions.kt | 148 ++++++++++++++---- firebase-installations/build.gradle.kts | 13 +- .../firebase/installations/installations.kt | 0 .../firebase/installations/installations.kt | 2 +- firebase-messaging/build.gradle.kts | 13 +- .../gitlive/firebase/messaging/messaging.kt | 0 .../gitlive/firebase/messaging/messaging.kt | 0 firebase-perf/build.gradle.kts | 10 +- .../gitlive/firebase/perf/metrics/Trace.kt | 0 .../dev/gitlive/firebase/perf/performance.kt | 0 .../dev/gitlive/firebase/perf/performance.kt | 0 .../gitlive/firebase/perf/metrics/Trace.kt | 2 +- .../dev/gitlive/firebase/perf/performance.kt | 2 +- firebase-storage/build.gradle.kts | 13 +- .../dev/gitlive/firebase/storage/storage.kt | 0 .../gitlive/firebase/storage/storage.ios.kt | 0 .../dev/gitlive/firebase/storage/storage.kt | 0 .../dev/gitlive/firebase/storage/storage.kt | 4 +- gradle/libs.versions.toml | 1 + test-utils/build.gradle.kts | 2 + 62 files changed, 259 insertions(+), 57 deletions(-) rename firebase-analytics/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/analytics/analytics.kt (100%) rename firebase-analytics/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/analytics/analytics.kt (100%) rename firebase-app/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/firebase.kt (100%) rename firebase-config/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt (100%) rename firebase-config/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt (100%) rename firebase-config/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt (100%) rename firebase-config/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtensionTest.kt (100%) rename firebase-config/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt (100%) rename firebase-crashlytics/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt (100%) rename firebase-crashlytics/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/_encoders.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/firestore.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt (100%) rename firebase-firestore/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt (100%) rename firebase-firestore/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt (100%) rename firebase-firestore/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/firestore/Ignore.kt (100%) rename firebase-firestore/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/firestore/firestore.kt (100%) rename firebase-functions/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/functions/functions.kt (100%) rename firebase-installations/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/installations/installations.kt (100%) rename firebase-messaging/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/messaging/messaging.kt (100%) rename firebase-messaging/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/messaging/messaging.kt (100%) rename firebase-perf/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt (100%) rename firebase-perf/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/perf/performance.kt (100%) rename firebase-perf/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/perf/performance.kt (100%) rename firebase-storage/src/{iosMain => appleMain}/kotlin/dev/gitlive/firebase/storage/storage.kt (100%) rename firebase-storage/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/storage/storage.ios.kt (100%) rename firebase-storage/src/{iosTest => appleTest}/kotlin/dev/gitlive/firebase/storage/storage.kt (100%) diff --git a/firebase-analytics/build.gradle.kts b/firebase-analytics/build.gradle.kts index d5ec0a598..20d4332fc 100644 --- a/firebase-analytics/build.gradle.kts +++ b/firebase-analytics/build.gradle.kts @@ -79,8 +79,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseAnalytics" } @@ -116,7 +123,11 @@ kotlin { this.apiVersion = libs.versions.settings.api.get() this.languageVersion = libs.versions.settings.language.get() progressiveMode = true - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } diff --git a/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/appleMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt similarity index 100% rename from firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt rename to firebase-analytics/src/appleMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt diff --git a/firebase-analytics/src/iosTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/appleTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt similarity index 100% rename from firebase-analytics/src/iosTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt rename to firebase-analytics/src/appleTest/kotlin/dev/gitlive/firebase/analytics/analytics.kt diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index e51f7272f..8adb1b87b 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -83,10 +83,13 @@ kotlin { tvosArm64() tvosX64() tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseApp" } @@ -125,6 +128,7 @@ kotlin { if (name.lowercase().contains("ios") || name.lowercase().contains("apple") || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } diff --git a/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/appleTest/kotlin/dev/gitlive/firebase/firebase.kt similarity index 100% rename from firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt rename to firebase-app/src/appleTest/kotlin/dev/gitlive/firebase/firebase.kt diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 36daf9f4f..64ab57171 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -8,22 +8,26 @@ import dev.gitlive.firebase.auth.externals.MultiFactorInfo as JsMultiFactorInfo import dev.gitlive.firebase.auth.externals.MultiFactorResolver as JsMultiFactorResolver import dev.gitlive.firebase.auth.externals.MultiFactorSession as JsMultiFactorSession -public val MultiFactor.js get() = js +public val MultiFactor.js: MultiFactorUser get() = js public actual class MultiFactor(internal val js: MultiFactorUser) { public actual val enrolledFactors: List get() = rethrow { js.enrolledFactors.map { MultiFactorInfo(it) } } + public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = rethrow { js.enroll(multiFactorAssertion.js, displayName).await() } + public actual suspend fun getSession(): MultiFactorSession = rethrow { MultiFactorSession(js.getSession().await()) } + public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = rethrow { js.unenroll(multiFactorInfo.js).await() } + public actual suspend fun unenroll(factorUid: String): Unit = rethrow { js.unenroll(factorUid).await() } } -public val MultiFactorInfo.js get() = js +public val MultiFactorInfo.js: JsMultiFactorInfo get() = js public actual class MultiFactorInfo(internal val js: JsMultiFactorInfo) { public actual val displayName: String? @@ -36,23 +40,24 @@ public actual class MultiFactorInfo(internal val js: JsMultiFactorInfo) { get() = rethrow { js.uid } } -public val MultiFactorAssertion.js get() = js +public val MultiFactorAssertion.js: JsMultiFactorAssertion get() = js public actual class MultiFactorAssertion(internal val js: JsMultiFactorAssertion) { public actual val factorId: String get() = rethrow { js.factorId } } -public val MultiFactorSession.js get() = js +public val MultiFactorSession.js: JsMultiFactorSession get() = js public actual class MultiFactorSession(internal val js: JsMultiFactorSession) -public val MultiFactorResolver.js get() = js +public val MultiFactorResolver.js: JsMultiFactorResolver get() = js public actual class MultiFactorResolver(internal val js: JsMultiFactorResolver) { public actual val auth: FirebaseAuth = rethrow { FirebaseAuth(js.auth) } public actual val hints: List = rethrow { js.hints.map { MultiFactorInfo(it) } } public actual val session: MultiFactorSession = rethrow { MultiFactorSession(js.session) } - public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = rethrow { AuthResult(js.resolveSignIn(assertion.js).await()) } + public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = + rethrow { AuthResult(js.resolveSignIn(assertion.js).await()) } } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt index 179cff18f..42f8f5a08 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -6,7 +6,7 @@ import kotlin.js.Date import dev.gitlive.firebase.auth.externals.UserInfo as JsUserInfo import kotlin.js.json -public val FirebaseUser.js get() = js +public val FirebaseUser.js: User get() = js public actual class FirebaseUser internal constructor(internal val js: User) { public actual val uid: String @@ -57,7 +57,7 @@ public actual class FirebaseUser internal constructor(internal val js: User) { public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?): Unit = rethrow { verifyBeforeUpdateEmail(js, newEmail, actionCodeSettings?.toJson()).await() } } -public val UserInfo.js get() = js +public val UserInfo.js: JsUserInfo get() = js public actual class UserInfo(internal val js: JsUserInfo) { public actual val displayName: String? @@ -74,7 +74,7 @@ public actual class UserInfo(internal val js: JsUserInfo) { get() = rethrow { js.uid } } -public val UserMetaData.js get() = js +public val UserMetaData.js: UserMetadata get() = js public actual class UserMetaData(internal val js: UserMetadata) { public actual val creationTime: Double? diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 21043d4d4..d549e7cc6 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -21,7 +21,7 @@ import kotlinx.coroutines.tasks.await public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -public actual fun Firebase.auth(app: FirebaseApp) = +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) { diff --git a/firebase-common-internal/build.gradle.kts b/firebase-common-internal/build.gradle.kts index 00ba45cd2..5a945a28b 100644 --- a/firebase-common-internal/build.gradle.kts +++ b/firebase-common-internal/build.gradle.kts @@ -83,6 +83,8 @@ kotlin { tvosArm64() tvosX64() tvosSimulatorArm64() + macosArm64() + macosX64() } js(IR) { diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index da0ed78be..570cbde47 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -82,6 +82,8 @@ kotlin { tvosArm64() tvosX64() tvosSimulatorArm64() + macosArm64() + macosX64() } js(IR) { diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index f942264e4..8e4698a57 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -79,8 +79,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseConfig" } @@ -110,7 +117,11 @@ kotlin { this.languageVersion = libs.versions.settings.language.get() progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") optIn("kotlinx.cinterop.BetaInteropApi") } diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt similarity index 100% rename from firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt rename to firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt b/firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt similarity index 100% rename from firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt rename to firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt b/firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt similarity index 100% rename from firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt rename to firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtension.kt diff --git a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtensionTest.kt b/firebase-config/src/appleTest/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtensionTest.kt similarity index 100% rename from firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtensionTest.kt rename to firebase-config/src/appleTest/kotlin/dev/gitlive/firebase/remoteconfig/NSDataExtensionTest.kt diff --git a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/appleTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt similarity index 100% rename from firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt rename to firebase-config/src/appleTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 01fb0b75a..6dc1fec07 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -18,7 +18,7 @@ public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig FirebaseRemoteConfig(getRemoteConfig(app.js)) } -public val FirebaseRemoteConfig.js get() = js +public val FirebaseRemoteConfig.js: RemoteConfig get() = js public actual class FirebaseRemoteConfig internal constructor(internal val js: RemoteConfig) { public actual val all: Map diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt index 9cea39324..4cf0ae035 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt @@ -2,7 +2,7 @@ package dev.gitlive.firebase.remoteconfig import dev.gitlive.firebase.remoteconfig.externals.Value -public val FirebaseRemoteConfigValue.js get() = js +public val FirebaseRemoteConfigValue.js: Value get() = js public actual class FirebaseRemoteConfigValue(internal val js: Value) { public actual fun asBoolean(): Boolean = rethrow { js.asBoolean() } diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index f6741a6b7..2d3001208 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -80,8 +80,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseCrashlytics" } @@ -100,7 +107,11 @@ kotlin { this.languageVersion = libs.versions.settings.language.get() progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } diff --git a/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/appleMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt similarity index 100% rename from firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt rename to firebase-crashlytics/src/appleMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt diff --git a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/appleTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt similarity index 100% rename from firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt rename to firebase-crashlytics/src/appleTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 7145fd530..b85231936 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -84,9 +84,12 @@ kotlin { tvosArm64() tvosX64() tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseDatabase" } @@ -128,6 +131,7 @@ kotlin { if (name.lowercase().contains("ios") || name.lowercase().contains("apple") || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 56d85981a..4c7a62bc5 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -83,8 +83,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseFirestore" } @@ -138,7 +145,11 @@ kotlin { optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") optIn("kotlinx.serialization.ExperimentalSerializationApi") - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") optIn("kotlinx.cinterop.BetaInteropApi") } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/Source.kt diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt similarity index 100% rename from firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt rename to firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/throwError.kt diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt b/firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt similarity index 100% rename from firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt rename to firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt b/firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt similarity index 100% rename from firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt rename to firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/Ignore.kt diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt similarity index 100% rename from firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt rename to firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 21a24dd94..a1b883e1a 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -80,8 +80,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseFunctions" } @@ -119,7 +126,11 @@ kotlin { progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } diff --git a/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/appleMain/kotlin/dev/gitlive/firebase/functions/functions.kt similarity index 100% rename from firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt rename to firebase-functions/src/appleMain/kotlin/dev/gitlive/firebase/functions/functions.kt 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 5797002cb..9ed840305 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 @@ -6,18 +6,9 @@ package dev.gitlive.firebase.functions -import dev.gitlive.firebase.DecodeSettings -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseApp -import dev.gitlive.firebase.FirebaseException -import dev.gitlive.firebase.functions.externals.Functions -import dev.gitlive.firebase.functions.externals.HttpsCallable -import dev.gitlive.firebase.functions.externals.connectFunctionsEmulator -import dev.gitlive.firebase.functions.externals.getFunctions -import dev.gitlive.firebase.functions.externals.httpsCallable -import dev.gitlive.firebase.functions.externals.invoke +import dev.gitlive.firebase.* +import dev.gitlive.firebase.functions.externals.* import dev.gitlive.firebase.internal.decode -import dev.gitlive.firebase.js import kotlinx.coroutines.await import kotlinx.serialization.DeserializationStrategy import kotlin.js.json @@ -38,11 +29,18 @@ public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js, region)) } -public val FirebaseFunctions.js get() = js +public val FirebaseFunctions.js: Functions get() = js public actual class FirebaseFunctions internal constructor(internal val js: Functions) { public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = - rethrow { HttpsCallableReference(httpsCallable(js, name, timeout?.let { json("timeout" to timeout.toDouble(DurationUnit.MILLISECONDS)) }).native) } + rethrow { + HttpsCallableReference( + httpsCallable( + js, + name, + timeout?.let { json("timeout" to timeout.toDouble(DurationUnit.MILLISECONDS)) }).native + ) + } public actual fun useEmulator(host: String, port: Int) { connectFunctionsEmulator(js, host, port) @@ -54,6 +52,7 @@ internal actual data class NativeHttpsCallableReference(val js: HttpsCallable) { actual suspend fun invoke(encodedData: Any): HttpsCallableResult = rethrow { HttpsCallableResult(js(encodedData).await()) } + actual suspend fun invoke(): HttpsCallableResult = rethrow { HttpsCallableResult(js().await()) } } @@ -69,11 +68,18 @@ public actual class HttpsCallableResult(internal val js: JsHttpsCallableResult) public actual inline fun data(): T = rethrow { decode(value = publicJs.data) } - public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = + public actual inline fun data( + strategy: DeserializationStrategy, + buildSettings: DecodeSettings.Builder.() -> Unit + ): T = rethrow { decode(strategy, publicJs.data, buildSettings) } } -public actual class FirebaseFunctionsException(cause: Throwable, public val code: FunctionsExceptionCode, public val details: Any?) : FirebaseException(cause.message, cause) +public actual class FirebaseFunctionsException( + cause: Throwable, + public val code: FunctionsExceptionCode, + public val details: Any? +) : FirebaseException(cause.message, cause) public actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code @@ -119,22 +125,102 @@ internal fun errorToException(e: dynamic): FirebaseFunctionsException = (e?.code .lowercase() .let { when { - "cancelled" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.CANCELLED, e.details) - "invalid-argument" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.INVALID_ARGUMENT, e.details) - "deadline-exceeded" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.DEADLINE_EXCEEDED, e.details) - "not-found" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.NOT_FOUND, e.details) - "already-exists" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.ALREADY_EXISTS, e.details) - "permission-denied" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.PERMISSION_DENIED, e.details) - "resource-exhausted" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.RESOURCE_EXHAUSTED, e.details) - "failed-precondition" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.FAILED_PRECONDITION, e.details) - "aborted" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.ABORTED, e.details) - "out-of-range" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.OUT_OF_RANGE, e.details) - "unimplemented" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNIMPLEMENTED, e.details) - "internal" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.INTERNAL, e.details) - "unavailable" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNAVAILABLE, e.details) - "data-loss" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.DATA_LOSS, e.details) - "unauthenticated" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNAUTHENTICATED, e.details) - "unknown" in it -> FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNKNOWN, e.details) + "cancelled" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.CANCELLED, + e.details + ) + + "invalid-argument" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.INVALID_ARGUMENT, + e.details + ) + + "deadline-exceeded" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.DEADLINE_EXCEEDED, + e.details + ) + + "not-found" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.NOT_FOUND, + e.details + ) + + "already-exists" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.ALREADY_EXISTS, + e.details + ) + + "permission-denied" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.PERMISSION_DENIED, + e.details + ) + + "resource-exhausted" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.RESOURCE_EXHAUSTED, + e.details + ) + + "failed-precondition" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.FAILED_PRECONDITION, + e.details + ) + + "aborted" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.ABORTED, + e.details + ) + + "out-of-range" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.OUT_OF_RANGE, + e.details + ) + + "unimplemented" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.UNIMPLEMENTED, + e.details + ) + + "internal" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.INTERNAL, + e.details + ) + + "unavailable" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.UNAVAILABLE, + e.details + ) + + "data-loss" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.DATA_LOSS, + e.details + ) + + "unauthenticated" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.UNAUTHENTICATED, + e.details + ) + + "unknown" in it -> FirebaseFunctionsException( + e.unsafeCast(), + FunctionsExceptionCode.UNKNOWN, + e.details + ) + else -> { println("Unknown error code in ${JSON.stringify(e)}") FirebaseFunctionsException(e.unsafeCast(), FunctionsExceptionCode.UNKNOWN, e.details) diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index c98103ac7..807a0756e 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -79,8 +79,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseInstallations" } @@ -116,7 +123,11 @@ kotlin { this.apiVersion = libs.versions.settings.api.get() this.languageVersion = libs.versions.settings.language.get() progressiveMode = true - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } diff --git a/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/appleMain/kotlin/dev/gitlive/firebase/installations/installations.kt similarity index 100% rename from firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt rename to firebase-installations/src/appleMain/kotlin/dev/gitlive/firebase/installations/installations.kt diff --git a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt index de34f3637..e91813663 100644 --- a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -13,7 +13,7 @@ public actual val Firebase.installations: FirebaseInstallations public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = rethrow { FirebaseInstallations(getInstallations(app.js)) } -public val FirebaseInstallations.js get() = js +public val FirebaseInstallations.js: Installations get() = js public actual class FirebaseInstallations internal constructor(internal val js: Installations) { diff --git a/firebase-messaging/build.gradle.kts b/firebase-messaging/build.gradle.kts index f5bf9a81b..0bc52ceaf 100644 --- a/firebase-messaging/build.gradle.kts +++ b/firebase-messaging/build.gradle.kts @@ -79,8 +79,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseMessaging" } @@ -117,7 +124,11 @@ kotlin { this.languageVersion = libs.versions.settings.language.get() progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") optIn("kotlinx.cinterop.BetaInteropApi") } diff --git a/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/appleMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt similarity index 100% rename from firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt rename to firebase-messaging/src/appleMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt diff --git a/firebase-messaging/src/iosTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/appleTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt similarity index 100% rename from firebase-messaging/src/iosTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt rename to firebase-messaging/src/appleTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index c62c9f5c5..5b08d1437 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -80,8 +80,13 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() framework { baseName = "FirebasePerformance" } @@ -111,7 +116,10 @@ kotlin { this.languageVersion = libs.versions.settings.language.get() progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } diff --git a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt similarity index 100% rename from firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt rename to firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt diff --git a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/performance.kt similarity index 100% rename from firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/performance.kt rename to firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/performance.kt diff --git a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/appleTest/kotlin/dev/gitlive/firebase/perf/performance.kt similarity index 100% rename from firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt rename to firebase-perf/src/appleTest/kotlin/dev/gitlive/firebase/perf/performance.kt diff --git a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index fd0582711..476dafec3 100644 --- a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,7 +3,7 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.perf.externals.PerformanceTrace import dev.gitlive.firebase.perf.rethrow -public val Trace.js get() = js +public val Trace.js: PerformanceTrace get() = js public actual class Trace internal constructor(internal val js: PerformanceTrace) { diff --git a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt index be5144a10..ba401c6f4 100644 --- a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -18,7 +18,7 @@ public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(getPerformance(app.js)) } -public val FirebasePerformance.js get() = js +public val FirebasePerformance.js: JsFirebasePerformance get() = js public actual class FirebasePerformance internal constructor(internal val js: JsFirebasePerformance) { diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index dacfd1143..0a1e273ba 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -79,8 +79,15 @@ kotlin { iosArm64() iosX64() iosSimulatorArm64() + tvosArm64() + tvosX64() + tvosSimulatorArm64() + macosArm64() + macosX64() cocoapods { ios.deploymentTarget = libs.versions.ios.deploymentTarget.get() + tvos.deploymentTarget = libs.versions.tvos.deploymentTarget.get() + osx.deploymentTarget = libs.versions.macos.deploymentTarget.get() framework { baseName = "FirebaseStorage" } @@ -116,7 +123,11 @@ kotlin { this.apiVersion = libs.versions.settings.api.get() this.languageVersion = libs.versions.settings.language.get() progressiveMode = true - if (name.lowercase().contains("ios")) { + if (name.lowercase().contains("ios") + || name.lowercase().contains("apple") + || name.lowercase().contains("tvos") + || name.lowercase().contains("macos") + ) { optIn("kotlinx.cinterop.ExperimentalForeignApi") } } diff --git a/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/appleMain/kotlin/dev/gitlive/firebase/storage/storage.kt similarity index 100% rename from firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt rename to firebase-storage/src/appleMain/kotlin/dev/gitlive/firebase/storage/storage.kt diff --git a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt b/firebase-storage/src/appleTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt similarity index 100% rename from firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt rename to firebase-storage/src/appleTest/kotlin/dev/gitlive/firebase/storage/storage.ios.kt diff --git a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/appleTest/kotlin/dev/gitlive/firebase/storage/storage.kt similarity index 100% rename from firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt rename to firebase-storage/src/appleTest/kotlin/dev/gitlive/firebase/storage/storage.kt diff --git a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt index 5337601ae..92b673fc3 100644 --- a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -30,7 +30,7 @@ public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = Firebase public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = FirebaseStorage(getStorage(app.js, url)) -public val FirebaseStorage.js get() = js +public val FirebaseStorage.js: dev.gitlive.firebase.storage.externals.FirebaseStorage get() = js public actual class FirebaseStorage(internal val js: dev.gitlive.firebase.storage.externals.FirebaseStorage) { public actual val maxOperationRetryTime: Duration = js.maxOperationRetryTime.milliseconds @@ -55,7 +55,7 @@ public actual class FirebaseStorage(internal val js: dev.gitlive.firebase.storag public actual fun getReferenceFromUrl(fullUrl: String): StorageReference = rethrow { StorageReference(ref(js, fullUrl)) } } -public val StorageReference.js get() = js +public val StorageReference.js: dev.gitlive.firebase.storage.externals.StorageReference get() = js public actual class StorageReference(internal val js: dev.gitlive.firebase.storage.externals.StorageReference) { public actual val path: String get() = js.fullPath diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2b7344e2f..46cc8c93c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,6 +19,7 @@ settings-language = "2.2" firebase-cocoapods = "11.14.0" ios-deploymentTarget = "13.0" tvos-deploymentTarget = "13.0" +macos-deploymentTarget = "10.15" test-logger-plugin = "4.0.0" dokka = "2.0.0" diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index fed29b8fa..ad549587c 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -80,6 +80,8 @@ kotlin { tvosX64() tvosArm64() tvosSimulatorArm64() + macosArm64() + macosX64() } js(IR) { From 12072876f6f936e2d087edf008366db1c2b35083 Mon Sep 17 00:00:00 2001 From: sajidalidev <10349422+sajidalidev@users.noreply.github.com> Date: Sat, 7 Jun 2025 09:33:19 +0000 Subject: [PATCH 4/5] Apply automatic changes --- .../dev/gitlive/firebase/auth/multifactor.kt | 15 ++--- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 3 +- .../gitlive/firebase/functions/functions.kt | 57 +++++++++---------- 3 files changed, 34 insertions(+), 41 deletions(-) diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 64ab57171..27ba5a183 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -14,17 +14,13 @@ public actual class MultiFactor(internal val js: MultiFactorUser) { public actual val enrolledFactors: List get() = rethrow { js.enrolledFactors.map { MultiFactorInfo(it) } } - public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = - rethrow { js.enroll(multiFactorAssertion.js, displayName).await() } + public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = rethrow { js.enroll(multiFactorAssertion.js, displayName).await() } - public actual suspend fun getSession(): MultiFactorSession = - rethrow { MultiFactorSession(js.getSession().await()) } + public actual suspend fun getSession(): MultiFactorSession = rethrow { MultiFactorSession(js.getSession().await()) } - public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = - rethrow { js.unenroll(multiFactorInfo.js).await() } + public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = rethrow { js.unenroll(multiFactorInfo.js).await() } - public actual suspend fun unenroll(factorUid: String): Unit = - rethrow { js.unenroll(factorUid).await() } + public actual suspend fun unenroll(factorUid: String): Unit = rethrow { js.unenroll(factorUid).await() } } public val MultiFactorInfo.js: JsMultiFactorInfo get() = js @@ -58,6 +54,5 @@ public actual class MultiFactorResolver(internal val js: JsMultiFactorResolver) public actual val hints: List = rethrow { js.hints.map { MultiFactorInfo(it) } } public actual val session: MultiFactorSession = rethrow { MultiFactorSession(js.session) } - public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = - rethrow { AuthResult(js.resolveSignIn(assertion.js).await()) } + public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = rethrow { AuthResult(js.resolveSignIn(assertion.js).await()) } } diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 11821d16b..5c5f1e9e2 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -21,8 +21,7 @@ import kotlinx.coroutines.tasks.await public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = - FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) { public actual val currentUser: FirebaseUser? 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 44f0e0972..aa1c49e16 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 @@ -29,15 +29,15 @@ public actual fun Firebase.functions(app: FirebaseApp, region: String): Firebase public val FirebaseFunctions.js: Functions get() = js public actual class FirebaseFunctions internal constructor(internal val js: Functions) { - public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = - rethrow { - HttpsCallableReference( - httpsCallable( - js, - name, - timeout?.let { json("timeout" to timeout.toDouble(DurationUnit.MILLISECONDS)) }).native - ) - } + public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = rethrow { + HttpsCallableReference( + httpsCallable( + js, + name, + timeout?.let { json("timeout" to timeout.toDouble(DurationUnit.MILLISECONDS)) }, + ).native, + ) + } public actual fun useEmulator(host: String, port: Int) { connectFunctionsEmulator(js, host, port) @@ -66,15 +66,14 @@ public actual class HttpsCallableResult(internal val js: JsHttpsCallableResult) public actual inline fun data( strategy: DeserializationStrategy, - buildSettings: DecodeSettings.Builder.() -> Unit - ): T = - rethrow { decode(strategy, publicJs.data, buildSettings) } + buildSettings: DecodeSettings.Builder.() -> Unit, + ): T = rethrow { decode(strategy, publicJs.data, buildSettings) } } public actual class FirebaseFunctionsException( cause: Throwable, public val code: FunctionsExceptionCode, - public val details: Any? + public val details: Any?, ) : FirebaseException(cause.message, cause) public actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code @@ -124,97 +123,97 @@ internal fun errorToException(e: dynamic): FirebaseFunctionsException = (e?.code "cancelled" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.CANCELLED, - e.details + e.details, ) "invalid-argument" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.INVALID_ARGUMENT, - e.details + e.details, ) "deadline-exceeded" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.DEADLINE_EXCEEDED, - e.details + e.details, ) "not-found" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.NOT_FOUND, - e.details + e.details, ) "already-exists" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.ALREADY_EXISTS, - e.details + e.details, ) "permission-denied" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.PERMISSION_DENIED, - e.details + e.details, ) "resource-exhausted" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.RESOURCE_EXHAUSTED, - e.details + e.details, ) "failed-precondition" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.FAILED_PRECONDITION, - e.details + e.details, ) "aborted" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.ABORTED, - e.details + e.details, ) "out-of-range" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.OUT_OF_RANGE, - e.details + e.details, ) "unimplemented" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.UNIMPLEMENTED, - e.details + e.details, ) "internal" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.INTERNAL, - e.details + e.details, ) "unavailable" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.UNAVAILABLE, - e.details + e.details, ) "data-loss" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.DATA_LOSS, - e.details + e.details, ) "unauthenticated" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.UNAUTHENTICATED, - e.details + e.details, ) "unknown" in it -> FirebaseFunctionsException( e.unsafeCast(), FunctionsExceptionCode.UNKNOWN, - e.details + e.details, ) else -> { From 239632edaaff3916b8a6afdf344e7a6357504357 Mon Sep 17 00:00:00 2001 From: sajidalidev <10349422+sajidalidev@users.noreply.github.com> Date: Fri, 6 Jun 2025 19:55:54 +0000 Subject: [PATCH 5/5] Apply automatic changes --- .../gitlive/firebase/analytics/analytics.kt | 3 +- .../gitlive/firebase/analytics/analytics.kt | 3 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/firebase.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/firebase.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 18 ++--- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 21 ++---- .../dev/gitlive/firebase/auth/credentials.kt | 6 +- .../kotlin/dev/gitlive/firebase/auth/user.kt | 12 ++-- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 33 ++++------ .../dev/gitlive/firebase/auth/credentials.kt | 9 +-- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 15 ++--- .../gitlive/firebase/internal/_decoders.kt | 3 +- .../gitlive/firebase/internal/_decoders.kt | 3 +- .../dev/gitlive/firebase/internal/decoders.kt | 40 ++++------- .../dev/gitlive/firebase/internal/encoders.kt | 12 ++-- .../gitlive/firebase/internal/_decoders.kt | 3 +- .../remoteconfig/FirebaseRemoteConfig.kt | 3 +- .../remoteconfig/FirebaseRemoteConfig.kt | 9 +-- .../remoteconfig/FirebaseRemoteConfig.kt | 3 +- .../firebase/crashlytics/crashlytics.kt | 3 +- .../firebase/crashlytics/crashlytics.kt | 3 +- .../gitlive/firebase/database/ServerValue.kt | 3 +- .../dev/gitlive/firebase/database/database.kt | 42 +++++------- .../gitlive/firebase/database/ServerValue.kt | 3 +- .../dev/gitlive/firebase/database/database.kt | 15 ++--- .../gitlive/firebase/database/ServerValue.kt | 3 +- .../dev/gitlive/firebase/database/database.kt | 66 +++++++------------ .../gitlive/firebase/firestore/FieldValue.kt | 3 +- .../gitlive/firebase/firestore/GeoPoint.kt | 3 +- .../gitlive/firebase/firestore/Timestamp.kt | 3 +- .../gitlive/firebase/firestore/firestore.kt | 3 +- .../NativeCollectionReferenceWrapper.kt | 6 +- .../internal/NativeDocumentReference.kt | 6 +- .../NativeFirebaseFirestoreWrapper.kt | 18 ++--- .../firestore/internal/NativeQueryWrapper.kt | 3 +- .../internal/NativeTransactionWrapper.kt | 6 +- .../internal/NativeWriteBatchWrapper.kt | 3 +- .../gitlive/firebase/firestore/FieldValue.kt | 3 +- .../gitlive/firebase/firestore/GeoPoint.kt | 3 +- .../gitlive/firebase/firestore/Timestamp.kt | 3 +- .../NativeCollectionReferenceWrapper.kt | 6 +- .../internal/NativeDocumentReference.kt | 20 +++--- .../internal/NativeDocumentSnapshotWrapper.kt | 17 ++--- .../NativeFirebaseFirestoreWrapper.kt | 22 +++---- .../firestore/internal/NativeQueryWrapper.kt | 3 +- .../internal/NativeTransactionWrapper.kt | 6 +- .../internal/NativeWriteBatchWrapper.kt | 3 +- .../firebase/firestore/ContextSwitchTest.kt | 35 +++++----- .../firebase/firestore/LocalCacheSettings.kt | 12 ++-- .../gitlive/firebase/firestore/Timestamp.kt | 7 +- .../gitlive/firebase/firestore/encoders.kt | 11 ++-- .../gitlive/firebase/firestore/firestore.kt | 24 +++---- .../dev/gitlive/firebase/firestore/helpers.kt | 5 +- .../gitlive/firebase/firestore/FieldValue.kt | 7 +- .../gitlive/firebase/firestore/GeoPoint.kt | 3 +- .../gitlive/firebase/firestore/Timestamp.kt | 3 +- .../gitlive/firebase/firestore/firestore.kt | 13 ++-- .../internal/NativeDocumentReference.kt | 13 ++-- .../internal/NativeDocumentSnapshotWrapper.kt | 3 +- .../NativeFirebaseFirestoreWrapper.kt | 19 +++--- .../internal/NativeTransactionWrapper.kt | 8 +-- .../internal/NativeWriteBatchWrapper.kt | 5 +- .../gitlive/firebase/firestore/firestore.kt | 3 +- .../gitlive/firebase/functions/functions.kt | 18 ++--- .../gitlive/firebase/functions/functions.kt | 12 ++-- .../gitlive/firebase/functions/functions.kt | 12 ++-- .../firebase/installations/installations.kt | 3 +- .../firebase/installations/installations.kt | 6 +- .../dev/gitlive/firebase/perf/performance.kt | 3 +- .../dev/gitlive/firebase/perf/performance.kt | 3 +- .../kotlin/dev/gitlive/firebase/TestUtils.kt | 3 +- 72 files changed, 269 insertions(+), 472 deletions(-) diff --git a/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index b41f10c69..1eb6c2fdf 100644 --- a/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/androidMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -13,8 +13,7 @@ import kotlin.time.Duration public actual val Firebase.analytics: FirebaseAnalytics get() = FirebaseAnalytics(com.google.firebase.Firebase.analytics) -public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = - FirebaseAnalytics(com.google.firebase.Firebase.analytics) +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(com.google.firebase.Firebase.analytics) public val FirebaseAnalytics.android: com.google.firebase.analytics.FirebaseAnalytics get() = android diff --git a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index a27b8e367..99294b939 100644 --- a/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/jsMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -11,8 +11,7 @@ import kotlin.time.Duration public actual val Firebase.analytics: FirebaseAnalytics get() = FirebaseAnalytics(getAnalytics()) -public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = - FirebaseAnalytics(getAnalytics(app.js)) +public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(getAnalytics(app.js)) public val FirebaseAnalytics.js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics get() = js diff --git a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt index 2efc65e03..dbe1b8113 100644 --- a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -19,17 +19,13 @@ public val FirebaseApp.android: com.google.firebase.FirebaseApp get() = android public actual val Firebase.app: FirebaseApp get() = FirebaseApp(com.google.firebase.FirebaseApp.getInstance()) -public actual fun Firebase.app(name: String): FirebaseApp = - FirebaseApp(com.google.firebase.FirebaseApp.getInstance(name)) +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.getInstance(name)) -public actual fun Firebase.initialize(context: Any?): FirebaseApp? = - com.google.firebase.FirebaseApp.initializeApp(context as Context)?.let { FirebaseApp(it) } +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = com.google.firebase.FirebaseApp.initializeApp(context as Context)?.let { FirebaseApp(it) } -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = - FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid(), name)) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid(), name)) -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = - FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid())) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid())) public actual data class FirebaseApp internal constructor(internal val android: com.google.firebase.FirebaseApp) { actual val name: String diff --git a/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt index ca9d48359..6a8411792 100644 --- a/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/appleMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -17,17 +17,13 @@ public val FirebaseApp.ios: FIRApp get() = ios public actual val Firebase.app: FirebaseApp get() = FirebaseApp(FIRApp.defaultApp()!!) -public actual fun Firebase.app(name: String): FirebaseApp = - FirebaseApp(FIRApp.appNamed(name)!!) +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(FIRApp.appNamed(name)!!) -public actual fun Firebase.initialize(context: Any?): FirebaseApp? = - FIRApp.configure().let { app } +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = FIRApp.configure().let { app } -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = - FIRApp.configureWithName(name, options.toIos()).let { app(name) } +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FIRApp.configureWithName(name, options.toIos()).let { app(name) } -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = - FIRApp.configureWithOptions(options.toIos()).let { app } +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FIRApp.configureWithOptions(options.toIos()).let { app } public actual data class FirebaseApp internal constructor(internal val ios: FIRApp) { actual val name: String diff --git a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt index d51f28633..c3d2c29e2 100644 --- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -14,17 +14,13 @@ import dev.gitlive.firebase.externals.FirebaseApp as JsFirebaseApp public actual val Firebase.app: FirebaseApp get() = FirebaseApp(getApp()) -public actual fun Firebase.app(name: String): FirebaseApp = - FirebaseApp(getApp(name)) +public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(getApp(name)) -public actual fun Firebase.initialize(context: Any?): FirebaseApp? = - throw UnsupportedOperationException("Cannot initialize firebase without options in JS") +public actual fun Firebase.initialize(context: Any?): FirebaseApp? = throw UnsupportedOperationException("Cannot initialize firebase without options in JS") -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = - FirebaseApp(initializeApp(options.toJson(), name)) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(initializeApp(options.toJson(), name)) -public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = - FirebaseApp(initializeApp(options.toJson())) +public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(initializeApp(options.toJson())) public val FirebaseApp.js: JsFirebaseApp get() = js diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt index cc4f2957d..9ba017627 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -23,8 +23,7 @@ public val FirebaseAuth.android: com.google.firebase.auth.FirebaseAuth get() = c public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = - FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) { public actual val currentUser: FirebaseUser? @@ -55,8 +54,7 @@ public actual class FirebaseAuth internal constructor(internal val android: com. android.confirmPasswordReset(code, newPassword).await() } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.createUserWithEmailAndPassword(email, password).await()) + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.createUserWithEmailAndPassword(email, password).await()) @Suppress("DEPRECATION") public actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() @@ -71,19 +69,15 @@ public actual class FirebaseAuth internal constructor(internal val android: com. public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link) - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.signInWithEmailAndPassword(email, password).await()) + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.signInWithEmailAndPassword(email, password).await()) - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - AuthResult(android.signInWithCustomToken(token).await()) + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(android.signInWithCustomToken(token).await()) public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await()) - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - AuthResult(android.signInWithCredential(authCredential.android).await()) + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(android.signInWithCredential(authCredential.android).await()) - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - AuthResult(android.signInWithEmailLink(email, link).await()) + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(android.signInWithEmailLink(email, link).await()) public actual suspend fun signOut(): Unit = android.signOut() diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 30ff27bc1..e392bbbe3 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -53,12 +53,10 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) public actual suspend fun applyActionCode(code: String): Unit = ios.await { applyActionCode(code, it) } public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = ios.await { confirmPasswordResetWithCode(code, newPassword, it) } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) }) + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) }) @Suppress("UNCHECKED_CAST") - public actual suspend fun fetchSignInMethodsForEmail(email: String): List = - ios.awaitResult?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List + public actual suspend fun fetchSignInMethodsForEmail(email: String): List = ios.awaitResult?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { ios.await { actionCodeSettings?.let { actionSettings -> sendPasswordResetWithEmail(email, actionSettings.toIos(), it) } ?: sendPasswordResetWithEmail(email = email, completion = it) } @@ -68,20 +66,15 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) public actual fun isSignInWithEmailLink(link: String): Boolean = ios.isSignInWithEmailLink(link) - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) }) + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) }) - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - AuthResult(ios.awaitResult { signInWithCustomToken(token, it) }) + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(ios.awaitResult { signInWithCustomToken(token, it) }) - public actual suspend fun signInAnonymously(): AuthResult = - AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) }) + public actual suspend fun signInAnonymously(): AuthResult = AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) }) - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) }) + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) }) - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) }) + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) }) public actual suspend fun signOut(): Unit = ios.throwError { signOut(it) } diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 5a2084bb9..431d0aa3a 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -18,14 +18,12 @@ public actual object EmailAuthProvider { public actual fun credential( email: String, password: String, - ): AuthCredential = - AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password)) + ): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password)) public actual fun credentialWithLink( email: String, emailLink: String, - ): AuthCredential = - AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink)) + ): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink)) } public actual object FacebookAuthProvider { diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt index d37fc20c0..a5c91fadb 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -40,21 +40,17 @@ public actual class FirebaseUser internal constructor(internal val ios: FIRUser) public actual suspend fun reload(): Unit = ios.await { reloadWithCompletion(it) } - public actual suspend fun getIdToken(forceRefresh: Boolean): String? = - ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) } + public actual suspend fun getIdToken(forceRefresh: Boolean): String? = ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) } - public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = - AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) }) + public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) }) - public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = - AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) }) + public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) }) public actual suspend fun reauthenticate(credential: AuthCredential) { ios.awaitResult { reauthenticateWithCredential(credential.ios, it) } } - public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = - AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }) + public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }) public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?): Unit = ios.await { actionCodeSettings?.let { settings -> sendEmailVerificationWithActionCodeSettings(settings.toIos(), it) } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 4d0223d28..74d3cc0c4 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -41,8 +41,7 @@ import dev.gitlive.firebase.auth.externals.AdditionalUserInfo as JsAdditionalUse public actual val Firebase.auth: FirebaseAuth get() = rethrow { FirebaseAuth(getAuth()) } -public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = - rethrow { FirebaseAuth(getAuth(app.js)) } +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = rethrow { FirebaseAuth(getAuth(app.js)) } public val FirebaseAuth.js: Auth get() = js @@ -74,41 +73,31 @@ public actual class FirebaseAuth internal constructor(internal val js: Auth) { public actual suspend fun applyActionCode(code: String): Unit = rethrow { applyActionCode(js, code).await() } public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = rethrow { confirmPasswordReset(js, code, newPassword).await() } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) } + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) } public actual suspend fun fetchSignInMethodsForEmail(email: String): List = rethrow { fetchSignInMethodsForEmail(js, email).await().asList() } - public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit = - rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() } + public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit = rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() } - public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = - rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() } + public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() } public actual fun isSignInWithEmailLink(link: String): Boolean = rethrow { isSignInWithEmailLink(js, link) } - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) } + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) } - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - rethrow { AuthResult(signInWithCustomToken(js, token).await()) } + public actual suspend fun signInWithCustomToken(token: String): AuthResult = rethrow { AuthResult(signInWithCustomToken(js, token).await()) } - public actual suspend fun signInAnonymously(): AuthResult = - rethrow { AuthResult(signInAnonymously(js).await()) } + public actual suspend fun signInAnonymously(): AuthResult = rethrow { AuthResult(signInAnonymously(js).await()) } - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) } + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) } - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) } + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) } public actual suspend fun signOut(): Unit = rethrow { signOut(js).await() } - public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = - rethrow { updateCurrentUser(js, user.js).await() } + public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = rethrow { updateCurrentUser(js, user.js).await() } - public actual suspend fun verifyPasswordResetCode(code: String): String = - rethrow { verifyPasswordResetCode(js, code).await() } + public actual suspend fun verifyPasswordResetCode(code: String): String = rethrow { verifyPasswordResetCode(js, code).await() } public actual suspend fun checkActionCode(code: String): T = rethrow { val result = checkActionCode(js, code).await() diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 112099734..3ed643d77 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -23,8 +23,7 @@ public actual class PhoneAuthCredential(js: JsAuthCredential) : AuthCredential(j public actual class OAuthCredential(js: JsAuthCredential) : AuthCredential(js) public actual object EmailAuthProvider { - public actual fun credential(email: String, password: String): AuthCredential = - AuthCredential(EmailAuthProvider.credential(email, password)) + public actual fun credential(email: String, password: String): AuthCredential = AuthCredential(EmailAuthProvider.credential(email, password)) public actual fun credentialWithLink( email: String, @@ -33,13 +32,11 @@ public actual object EmailAuthProvider { } public actual object FacebookAuthProvider { - public actual fun credential(accessToken: String): AuthCredential = - AuthCredential(FacebookAuthProvider.credential(accessToken)) + public actual fun credential(accessToken: String): AuthCredential = AuthCredential(FacebookAuthProvider.credential(accessToken)) } public actual object GithubAuthProvider { - public actual fun credential(token: String): AuthCredential = - AuthCredential(GithubAuthProvider.credential(token)) + public actual fun credential(token: String): AuthCredential = AuthCredential(GithubAuthProvider.credential(token)) } public actual object GoogleAuthProvider { diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index d549e7cc6..11821d16b 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -61,8 +61,7 @@ public actual class FirebaseAuth internal constructor(internal val android: com. android.confirmPasswordReset(code, newPassword).await() } - public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.createUserWithEmailAndPassword(email, password).await()) + public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.createUserWithEmailAndPassword(email, password).await()) public actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() @@ -76,19 +75,15 @@ public actual class FirebaseAuth internal constructor(internal val android: com. public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link) - public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = - AuthResult(android.signInWithEmailAndPassword(email, password).await()) + public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.signInWithEmailAndPassword(email, password).await()) - public actual suspend fun signInWithCustomToken(token: String): AuthResult = - AuthResult(android.signInWithCustomToken(token).await()) + public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(android.signInWithCustomToken(token).await()) public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await()) - public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = - AuthResult(android.signInWithCredential(authCredential.android).await()) + public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(android.signInWithCredential(authCredential.android).await()) - public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = - AuthResult(android.signInWithEmailLink(email, link).await()) + public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(android.signInWithEmailLink(email, link).await()) public actual suspend fun signOut() { android.signOut() diff --git a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 77644ccfe..cd0647c41 100644 --- a/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -26,8 +26,7 @@ public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } -public actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as? Map<*, *>).orEmpty()[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = (value as? Map<*, *>).orEmpty()[discriminator] as String private fun FirebaseDecoder.decodeAsMap(isNestedPolymorphic: Boolean): CompositeDecoder = (value as? Map<*, *>).orEmpty().let { map -> FirebaseClassDecoder(map.size, settings, { map.containsKey(it) }) { desc, index -> diff --git a/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 81dca8d8b..e2c043a82 100644 --- a/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/appleMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -20,8 +20,7 @@ public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet") } -public actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as? Map<*, *>).orEmpty()[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = (value as? Map<*, *>).orEmpty()[discriminator] as String private fun FirebaseDecoder.decodeAsList(): CompositeDecoder = (value as? List<*>).orEmpty().let { FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index] } diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt index 084bc4f62..a9a92413d 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/decoders.kt @@ -16,8 +16,7 @@ import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.serializer public inline fun decode(value: Any?): T = decode(value) {} -public inline fun decode(value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) +public inline fun decode(value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) @PublishedApi internal inline fun decode(value: Any?, decodeSettings: DecodeSettings): T { @@ -25,8 +24,7 @@ internal inline fun decode(value: Any?, decodeSettings: DecodeSettin return decode(strategy as DeserializationStrategy, value, decodeSettings) } public fun decode(strategy: DeserializationStrategy, value: Any?): T = decode(strategy, value) {} -public inline fun decode(strategy: DeserializationStrategy, value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) +public inline fun decode(strategy: DeserializationStrategy, value: Any?, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, value, DecodeSettingsImpl.Builder().apply(buildSettings).buildDecodeSettings()) @PublishedApi internal fun decode(strategy: DeserializationStrategy, value: Any?, decodeSettings: DecodeSettings): T { @@ -114,26 +112,19 @@ public open class FirebaseCompositeDecoder( deserializer.deserialize(FirebaseDecoder(it, settings)) } - override fun decodeBooleanElement(descriptor: SerialDescriptor, index: Int): Boolean = - decodeElement(descriptor, index, ::decodeBoolean) + override fun decodeBooleanElement(descriptor: SerialDescriptor, index: Int): Boolean = decodeElement(descriptor, index, ::decodeBoolean) - override fun decodeByteElement(descriptor: SerialDescriptor, index: Int): Byte = - decodeElement(descriptor, index, ::decodeByte) + override fun decodeByteElement(descriptor: SerialDescriptor, index: Int): Byte = decodeElement(descriptor, index, ::decodeByte) - override fun decodeCharElement(descriptor: SerialDescriptor, index: Int): Char = - decodeElement(descriptor, index, ::decodeChar) + override fun decodeCharElement(descriptor: SerialDescriptor, index: Int): Char = decodeElement(descriptor, index, ::decodeChar) - override fun decodeDoubleElement(descriptor: SerialDescriptor, index: Int): Double = - decodeElement(descriptor, index, ::decodeDouble) + override fun decodeDoubleElement(descriptor: SerialDescriptor, index: Int): Double = decodeElement(descriptor, index, ::decodeDouble) - override fun decodeFloatElement(descriptor: SerialDescriptor, index: Int): Float = - decodeElement(descriptor, index, ::decodeFloat) + override fun decodeFloatElement(descriptor: SerialDescriptor, index: Int): Float = decodeElement(descriptor, index, ::decodeFloat) - override fun decodeIntElement(descriptor: SerialDescriptor, index: Int): Int = - decodeElement(descriptor, index, ::decodeInt) + override fun decodeIntElement(descriptor: SerialDescriptor, index: Int): Int = decodeElement(descriptor, index, ::decodeInt) - override fun decodeLongElement(descriptor: SerialDescriptor, index: Int): Long = - decodeElement(descriptor, index, ::decodeLong) + override fun decodeLongElement(descriptor: SerialDescriptor, index: Int): Long = decodeElement(descriptor, index, ::decodeLong) override fun decodeNullableSerializableElement( descriptor: SerialDescriptor, @@ -149,19 +140,16 @@ public open class FirebaseCompositeDecoder( } } - override fun decodeShortElement(descriptor: SerialDescriptor, index: Int): Short = - decodeElement(descriptor, index, ::decodeShort) + override fun decodeShortElement(descriptor: SerialDescriptor, index: Int): Short = decodeElement(descriptor, index, ::decodeShort) - override fun decodeStringElement(descriptor: SerialDescriptor, index: Int): String = - decodeElement(descriptor, index, ::decodeString) + override fun decodeStringElement(descriptor: SerialDescriptor, index: Int): String = decodeElement(descriptor, index, ::decodeString) override fun endStructure(descriptor: SerialDescriptor) {} @ExperimentalSerializationApi - override fun decodeInlineElement(descriptor: SerialDescriptor, index: Int): Decoder = - decodeElement(descriptor, index) { - FirebaseDecoder(it, settings) - } + override fun decodeInlineElement(descriptor: SerialDescriptor, index: Int): Decoder = decodeElement(descriptor, index) { + FirebaseDecoder(it, settings) + } private fun decodeElement(descriptor: SerialDescriptor, index: Int, decoder: (Any?) -> T): T = try { decoder(get(descriptor, index)) diff --git a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt index c6c9e4abf..2e621e832 100644 --- a/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt +++ b/firebase-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/encoders.kt @@ -17,20 +17,17 @@ public fun encode(strategy: SerializationStrategy, value: T, shouldEncode this.encodeDefaults = shouldEncodeElementDefault } -public inline fun encode(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = - encode(strategy, value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) +public inline fun encode(strategy: SerializationStrategy, value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = encode(strategy, value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) @PublishedApi -internal fun encode(strategy: SerializationStrategy, value: T, encodeSettings: EncodeSettings): Any? = - FirebaseEncoder(encodeSettings).apply { encodeSerializableValue(strategy, value) }.value +internal fun encode(strategy: SerializationStrategy, value: T, encodeSettings: EncodeSettings): Any? = FirebaseEncoder(encodeSettings).apply { encodeSerializableValue(strategy, value) }.value @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("encode(value) { this.encodeDefaults = shouldEncodeElementDefault }")) public inline fun encode(value: T, shouldEncodeElementDefault: Boolean): Any? = encode(value) { this.encodeDefaults = shouldEncodeElementDefault } -public inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Any? = - encode(value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) +public inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): Any? = encode(value, EncodeSettingsImpl.Builder().apply(buildSettings).buildEncodeSettings()) /** * Encodes data as an [EncodedObject]. @@ -230,8 +227,7 @@ public open class FirebaseCompositeEncoder( override fun encodeStringElement(descriptor: SerialDescriptor, index: Int, value: String): Unit = set(descriptor, index, value) @ExperimentalSerializationApi - override fun encodeInlineElement(descriptor: SerialDescriptor, index: Int): Encoder = - FirebaseEncoder(settings) + override fun encodeInlineElement(descriptor: SerialDescriptor, index: Int): Encoder = FirebaseEncoder(settings) public fun encodePolymorphicClassDiscriminator(discriminator: String, type: String) { setPolymorphicType(discriminator, type) diff --git a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 05701df40..c5aae4fdb 100644 --- a/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/jsMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -39,8 +39,7 @@ public actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, } @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") -public actual fun getPolymorphicType(value: Any?, discriminator: String): String = - (value as Json)[discriminator] as String +public actual fun getPolymorphicType(value: Any?, discriminator: String): String = (value as Json)[discriminator] as String private fun FirebaseDecoder.decodeAsList(): CompositeDecoder = (value as Array<*>).let { FirebaseCompositeDecoder(it.size, settings) { _, index -> it[index] } diff --git a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index bfb420515..a381156dc 100644 --- a/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/androidMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -21,8 +21,7 @@ public val FirebaseRemoteConfig.android: AndroidFirebaseRemoteConfig get() = And public actual val Firebase.remoteConfig: FirebaseRemoteConfig get() = FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance()) -public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = - FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(app.android)) +public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = FirebaseRemoteConfig(com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(app.android)) public actual class FirebaseRemoteConfig internal constructor(internal val android: AndroidFirebaseRemoteConfig) { public actual val all: Map diff --git a/firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 1a247d9b4..13e1effd4 100644 --- a/firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/appleMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -57,8 +57,7 @@ public actual class FirebaseRemoteConfig internal constructor(internal val ios: public actual suspend fun activate(): Boolean = ios.awaitResult { activateWithCompletion(it) } - public actual suspend fun ensureInitialized(): Unit = - ios.await { ensureInitializedWithCompletionHandler(it) } + public actual suspend fun ensureInitialized(): Unit = ios.await { ensureInitializedWithCompletionHandler(it) } public actual suspend fun fetch(minimumFetchInterval: Duration?) { if (minimumFetchInterval != null) { @@ -77,11 +76,9 @@ public actual class FirebaseRemoteConfig internal constructor(internal val ios: return status == FIRRemoteConfigFetchAndActivateStatus.FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote } - public actual fun getKeysByPrefix(prefix: String): Set = - all.keys.filter { it.startsWith(prefix) }.toSet() + public actual fun getKeysByPrefix(prefix: String): Set = all.keys.filter { it.startsWith(prefix) }.toSet() - public actual fun getValue(key: String): FirebaseRemoteConfigValue = - FirebaseRemoteConfigValue(ios.configValueForKey(key)) + public actual fun getValue(key: String): FirebaseRemoteConfigValue = FirebaseRemoteConfigValue(ios.configValueForKey(key)) public actual suspend fun reset() { // not implemented for iOS target diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 6dc1fec07..d6192cdc1 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -36,8 +36,7 @@ public actual class FirebaseRemoteConfig internal constructor(internal val js: R public actual suspend fun activate(): Boolean = rethrow { activate(js).await() } public actual suspend fun ensureInitialized(): Unit = rethrow { ensureInitialized(js).await() } - public actual suspend fun fetch(minimumFetchInterval: Duration?): Unit = - rethrow { fetchConfig(js).await() } + public actual suspend fun fetch(minimumFetchInterval: Duration?): Unit = rethrow { fetchConfig(js).await() } public actual suspend fun fetchAndActivate(): Boolean = rethrow { fetchAndActivate(js).await() } diff --git a/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 0d56d2e1d..c749baa59 100644 --- a/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -11,8 +11,7 @@ public val FirebaseCrashlytics.android: com.google.firebase.crashlytics.Firebase public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance()) -public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = - FirebaseCrashlytics(app.android.get(com.google.firebase.crashlytics.FirebaseCrashlytics::class.java)) +public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = FirebaseCrashlytics(app.android.get(com.google.firebase.crashlytics.FirebaseCrashlytics::class.java)) public actual class FirebaseCrashlytics internal constructor(internal val android: com.google.firebase.crashlytics.FirebaseCrashlytics) { diff --git a/firebase-crashlytics/src/appleMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/appleMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 5445ceb6e..2454d0436 100644 --- a/firebase-crashlytics/src/appleMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/appleMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -12,8 +12,7 @@ public val FirebaseCrashlytics.ios: FIRCrashlytics get() = FIRCrashlytics.crashl public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) -public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = - FirebaseCrashlytics(FIRCrashlytics.crashlytics()) +public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) public actual class FirebaseCrashlytics internal constructor(internal val ios: FIRCrashlytics) { diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index f14b0b5b5..91eb328b5 100644 --- a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -14,8 +14,7 @@ public actual class ServerValue internal actual constructor( public actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta)) } - override fun equals(other: Any?): Boolean = - this === other || other is ServerValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is ServerValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "ServerValue($nativeValue)" } 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 561f3215a..2fac17c2a 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 @@ -44,29 +44,25 @@ import kotlin.time.Duration.Companion.seconds public val FirebaseDatabase.android: com.google.firebase.database.FirebaseDatabase get() = com.google.firebase.database.FirebaseDatabase.getInstance() -internal suspend fun Task.awaitWhileOnline(database: FirebaseDatabase): T = - merge( - flow { emit(await()) }, - database - .reference(".info/connected") - .valueEvents - .debounce(2.seconds) - .filterNot { it.value() } - .map { throw DatabaseException("Database not connected", null) }, - ) - .first() +internal suspend fun Task.awaitWhileOnline(database: FirebaseDatabase): T = merge( + flow { emit(await()) }, + database + .reference(".info/connected") + .valueEvents + .debounce(2.seconds) + .filterNot { it.value() } + .map { throw DatabaseException("Database not connected", null) }, +) + .first() public actual val Firebase.database: FirebaseDatabase by lazy { FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance()) } -public actual fun Firebase.database(url: String): FirebaseDatabase = - FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(url)) +public actual fun Firebase.database(url: String): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(url)) -public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = - FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android)) +public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android)) -public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = - FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android, url)) +public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = FirebaseDatabase.getInstance(com.google.firebase.database.FirebaseDatabase.getInstance(app.android, url)) public actual class FirebaseDatabase internal constructor(internal val android: com.google.firebase.database.FirebaseDatabase) { @@ -80,11 +76,9 @@ public actual class FirebaseDatabase internal constructor(internal val android: private var persistenceEnabled = true - public actual fun reference(path: String): DatabaseReference = - DatabaseReference(NativeDatabaseReference(android.getReference(path), persistenceEnabled)) + public actual fun reference(path: String): DatabaseReference = DatabaseReference(NativeDatabaseReference(android.getReference(path), persistenceEnabled)) - public actual fun reference(): DatabaseReference = - DatabaseReference(NativeDatabaseReference(android.reference, persistenceEnabled)) + public actual fun reference(): DatabaseReference = DatabaseReference(NativeDatabaseReference(android.reference, persistenceEnabled)) public actual fun setPersistenceEnabled(enabled: Boolean) { android.setPersistenceEnabled(enabled) @@ -287,11 +281,9 @@ public actual class DataSnapshot internal constructor( public actual val value: Any? get() = android.value - public actual inline fun value(): T = - decode(value = publicAndroid.value) + public actual inline fun value(): T = decode(value = publicAndroid.value) - public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicAndroid.value, buildSettings) + public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicAndroid.value, buildSettings) public actual fun child(path: String): DataSnapshot = DataSnapshot(android.child(path), persistenceEnabled) public actual val hasChildren: Boolean get() = android.hasChildren() diff --git a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index 2ce33a91d..35cb37701 100644 --- a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -18,8 +18,7 @@ public actual class ServerValue internal actual constructor( public actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta as NSNumber)) } - override fun equals(other: Any?): Boolean = - this === other || other is ServerValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is ServerValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "ServerValue($nativeValue)" } diff --git a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt index c75290154..458462025 100644 --- a/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/appleMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -49,8 +49,7 @@ public val FirebaseDatabase.ios: FIRDatabase get() = FIRDatabase.database() public actual val Firebase.database: FirebaseDatabase by lazy { FirebaseDatabase(FIRDatabase.database()) } -public actual fun Firebase.database(url: String): FirebaseDatabase = - FirebaseDatabase(FIRDatabase.databaseWithURL(url)) +public actual fun Firebase.database(url: String): FirebaseDatabase = FirebaseDatabase(FIRDatabase.databaseWithURL(url)) public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = FirebaseDatabase( FIRDatabase.databaseForApp(app.ios as objcnames.classes.FIRApp), @@ -62,11 +61,9 @@ public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseData public actual class FirebaseDatabase internal constructor(internal val ios: FIRDatabase) { - public actual fun reference(path: String): DatabaseReference = - DatabaseReference(NativeDatabaseReference(ios.referenceWithPath(path), ios.persistenceEnabled)) + public actual fun reference(path: String): DatabaseReference = DatabaseReference(NativeDatabaseReference(ios.referenceWithPath(path), ios.persistenceEnabled)) - public actual fun reference(): DatabaseReference = - DatabaseReference(NativeDatabaseReference(ios.reference(), ios.persistenceEnabled)) + public actual fun reference(): DatabaseReference = DatabaseReference(NativeDatabaseReference(ios.reference(), ios.persistenceEnabled)) public actual fun setPersistenceEnabled(enabled: Boolean) { ios.persistenceEnabled = enabled @@ -231,11 +228,9 @@ public actual class DataSnapshot internal constructor( public actual val value: Any? get() = ios.value - public actual inline fun value(): T = - decode(value = publicIos.value) + public actual inline fun value(): T = decode(value = publicIos.value) - public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicIos.value, buildSettings) + public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicIos.value, buildSettings) public actual fun child(path: String): DataSnapshot = DataSnapshot(ios.childSnapshotForPath(path), persistenceEnabled) public actual val hasChildren: Boolean get() = ios.hasChildren() diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index d2af58f7a..19e67f5c3 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -14,8 +14,7 @@ public actual class ServerValue internal actual constructor( public actual fun increment(delta: Double): ServerValue = ServerValue(jsIncrement(delta)) } - override fun equals(other: Any?): Boolean = - this === other || other is ServerValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is ServerValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "ServerValue($nativeValue)" } diff --git a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt index ce737c3c8..992e29443 100644 --- a/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -42,24 +42,19 @@ import dev.gitlive.firebase.database.js as publicJs public actual val Firebase.database: FirebaseDatabase get() = rethrow { FirebaseDatabase(getDatabase()) } -public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = - rethrow { FirebaseDatabase(getDatabase(app = app.js)) } +public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js)) } -public actual fun Firebase.database(url: String): FirebaseDatabase = - rethrow { FirebaseDatabase(getDatabase(url = url)) } +public actual fun Firebase.database(url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(url = url)) } -public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = - rethrow { FirebaseDatabase(getDatabase(app = app.js, url = url)) } +public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js, url = url)) } public val FirebaseDatabase.js: Database get() = js public actual class FirebaseDatabase internal constructor(internal val js: Database) { - public actual fun reference(path: String): DatabaseReference = - rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } + public actual fun reference(path: String): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } - public actual fun reference(): DatabaseReference = - rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } + public actual fun reference(): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } public actual fun setPersistenceEnabled(enabled: Boolean) {} public actual fun setPersistenceCacheSizeBytes(cacheSizeInBytes: Long) {} @@ -130,36 +125,27 @@ public actual open class Query internal actual constructor( awaitClose { rethrow { unsubscribes.forEach { it.invoke() } } } } - public actual fun startAt(value: String, key: String?): Query = - Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: String, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Double, key: String?): Query = - Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Double, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Boolean, key: String?): Query = - Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun endAt(value: String, key: String?): Query = - Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: String, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Double, key: String?): Query = - Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Double, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Boolean, key: String?): Query = - Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) public actual fun limitToFirst(limit: Int): Query = Query(query(publicJs, jsLimitToFirst(limit)), database) public actual fun limitToLast(limit: Int): Query = Query(query(publicJs, jsLimitToLast(limit)), database) - public actual fun equalTo(value: String, key: String?): Query = - Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: String, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Double, key: String?): Query = - Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Double, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Boolean, key: String?): Query = - Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Boolean, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) override fun toString(): String = publicJs.toString() } @@ -181,13 +167,12 @@ internal actual class NativeDatabaseReference internal constructor( set(js, encodedValue).awaitWhileOnline(database) } - actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = - rethrow { update(js, encodedUpdate.js).awaitWhileOnline(database) } + actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = rethrow { update(js, encodedUpdate.js).awaitWhileOnline(database) } actual suspend fun runTransaction( strategy: KSerializer, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit, - transactionUpdate: (currentData: T) -> T + transactionUpdate: (currentData: T) -> T, ): DataSnapshot = DataSnapshot( jsRunTransaction(js, transactionUpdate = { currentData -> reencodeTransformation(strategy, currentData ?: json(), buildSettings, transactionUpdate) @@ -208,14 +193,12 @@ public actual class DataSnapshot internal constructor( return js.`val`() } - public actual inline fun value(): T = - rethrow { decode(value = publicJs.`val`()) } + public actual inline fun value(): T = rethrow { decode(value = publicJs.`val`()) } public actual inline fun value( strategy: DeserializationStrategy, - buildSettings: DecodeSettings.Builder.() -> Unit - ): T = - rethrow { decode(strategy, publicJs.`val`(), buildSettings) } + buildSettings: DecodeSettings.Builder.() -> Unit, + ): T = rethrow { decode(strategy, publicJs.`val`(), buildSettings) } public actual val exists: Boolean get() = rethrow { js.exists() } public actual val key: String? get() = rethrow { js.key } @@ -241,21 +224,18 @@ internal actual class NativeOnDisconnect internal constructor( actual suspend fun removeValue() = rethrow { js.remove().awaitWhileOnline(database) } actual suspend fun cancel() = rethrow { js.cancel().awaitWhileOnline(database) } - actual suspend fun setEncodedValue(encodedValue: Any?) = - rethrow { js.set(encodedValue).awaitWhileOnline(database) } + actual suspend fun setEncodedValue(encodedValue: Any?) = rethrow { js.set(encodedValue).awaitWhileOnline(database) } - actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = - rethrow { js.update(encodedUpdate.js).awaitWhileOnline(database) } + actual suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) = rethrow { js.update(encodedUpdate.js).awaitWhileOnline(database) } } public val OnDisconnect.js: dev.gitlive.firebase.database.externals.OnDisconnect get() = native.js public val OnDisconnect.database: Database get() = native.database -public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : - RuntimeException(message, cause) { +public actual class DatabaseException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) { public constructor(error: dynamic) : this( "${error.code ?: "UNKNOWN"}: ${error.message}", - error.unsafeCast() + error.unsafeCast(), ) } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index 2c324b45f..c8945c6aa 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -11,8 +11,7 @@ public actual class FieldValue internal actual constructor(internal actual val n init { require(nativeValue is NativeFieldValue) } - override fun equals(other: Any?): Boolean = - this === other || other is FieldValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is FieldValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index dcf73b20d..25326b01a 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -12,8 +12,7 @@ public actual class GeoPoint internal actual constructor(internal actual val nat public actual val latitude: Double = nativeValue.latitude public actual val longitude: Double = nativeValue.longitude - override fun equals(other: Any?): Boolean = - this === other || other is GeoPoint && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index 61388745b..aa4d76c2f 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -21,8 +21,7 @@ public actual class Timestamp internal actual constructor( public actual val seconds: Long = nativeValue.seconds public actual val nanoseconds: Int = nativeValue.nanoseconds - override fun equals(other: Any?): Boolean = - this === other || other is Timestamp && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() 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 01106caae..ea5d231ed 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 @@ -36,8 +36,7 @@ public val FirebaseFirestore.android: AndroidFirebaseFirestore get() = AndroidFi public actual val Firebase.firestore: FirebaseFirestore get() = FirebaseFirestore(AndroidFirebaseFirestore.getInstance()) -public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = - FirebaseFirestore(AndroidFirebaseFirestore.getInstance(app.android)) +public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = FirebaseFirestore(AndroidFirebaseFirestore.getInstance(app.android)) public val LocalCacheSettings.android: AndroidLocalCacheSettings get() = when (this) { is LocalCacheSettings.Persistent -> androidPersistentCacheSettings { diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index d6b73afb0..f3e137f5a 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -16,9 +16,7 @@ internal actual class NativeCollectionReferenceWrapper internal actual construct actual val parent: NativeDocumentReference? get() = native.parent?.let { NativeDocumentReference(it) } - actual fun document(documentPath: String) = - NativeDocumentReference(native.document(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.document(documentPath)) - actual suspend fun addEncoded(data: EncodedObject) = - NativeDocumentReference(native.add(data.android).await()) + actual suspend fun addEncoded(data: EncodedObject) = NativeDocumentReference(native.add(data.android).await()) } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index cb91ffd74..0c11b1d80 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -28,8 +28,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual fun collection(collectionPath: String) = android.collection(collectionPath) - actual suspend fun get(source: Source) = - android.get(source.toAndroidSource()).await() + actual suspend fun get(source: Source) = android.get(source.toAndroidSource()).await() actual suspend fun setEncoded(encodedData: EncodedObject, setOptions: SetOptions) { val task = ( @@ -68,8 +67,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati exception?.let { close(exception) } } - override fun equals(other: Any?): Boolean = - this === other || other is NativeDocumentReference && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is NativeDocumentReference && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index c3f08216a..ce36357f3 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -14,13 +14,11 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v actual fun collectionGroup(collectionId: String) = native.collectionGroup(collectionId) - actual fun document(documentPath: String) = - NativeDocumentReference(native.document(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.document(documentPath)) actual fun batch() = native.batch() - actual fun setLoggingEnabled(loggingEnabled: Boolean) = - com.google.firebase.firestore.FirebaseFirestore.setLoggingEnabled(loggingEnabled) + actual fun setLoggingEnabled(loggingEnabled: Boolean) = com.google.firebase.firestore.FirebaseFirestore.setLoggingEnabled(loggingEnabled) actual fun applySettings(settings: FirebaseFirestoreSettings) { native.firestoreSettings = firestoreSettings { @@ -31,19 +29,15 @@ internal actual class NativeFirebaseFirestoreWrapper actual constructor(actual v callbackExecutorMap[native] = settings.callbackExecutor } - actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T): T = - native.runTransaction { runBlocking { it.func() } }.await() + actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T): T = native.runTransaction { runBlocking { it.func() } }.await() - actual suspend fun clearPersistence() = - native.clearPersistence().await().run { } + actual suspend fun clearPersistence() = native.clearPersistence().await().run { } actual fun useEmulator(host: String, port: Int) { native.useEmulator(host, port) } - actual suspend fun disableNetwork() = - native.disableNetwork().await().run { } + actual suspend fun disableNetwork() = native.disableNetwork().await().run { } - actual suspend fun enableNetwork() = - native.enableNetwork().await().run { } + actual suspend fun enableNetwork() = native.enableNetwork().await().run { } } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 5dc17f72b..bd03aeddd 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -38,8 +38,7 @@ internal actual open class NativeQueryWrapper internal actual constructor(actual awaitClose { listener.remove() } } - actual suspend fun get(source: Source): QuerySnapshot = - QuerySnapshot(native.get(source.toAndroidSource()).await()) + actual suspend fun get(source: Source): QuerySnapshot = QuerySnapshot(native.get(source.toAndroidSource()).await()) actual fun where(filter: Filter) = native.where(filter.toAndroidFilter()) diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 4b8219703..775ad3257 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -37,9 +37,7 @@ internal actual class NativeTransactionWrapper internal actual constructor(actua native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } - actual fun delete(documentRef: DocumentReference) = - native.delete(documentRef.android).let { this } + actual fun delete(documentRef: DocumentReference) = native.delete(documentRef.android).let { this } - actual suspend fun get(documentRef: DocumentReference) = - NativeDocumentSnapshotWrapper(native.get(documentRef.android)) + actual suspend fun get(documentRef: DocumentReference) = NativeDocumentSnapshotWrapper(native.get(documentRef.android)) } diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index 9aa34f700..4f73b8579 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -39,8 +39,7 @@ internal actual class NativeWriteBatchWrapper internal actual constructor(actual native.update(documentRef.android, field, value, *moreFieldsAndValues) }.let { this } - actual fun delete(documentRef: DocumentReference) = - native.delete(documentRef.android).let { this } + actual fun delete(documentRef: DocumentReference) = native.delete(documentRef.android).let { this } actual suspend fun commit() { native.commit().await() diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index 9eb6a8589..a1e9a49ec 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -12,8 +12,7 @@ public actual class FieldValue internal actual constructor(internal actual val n init { require(nativeValue is NativeFieldValue) } - override fun equals(other: Any?): Boolean = - this === other || other is FieldValue && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is FieldValue && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 5dc0fa8aa..a9bcf2e7f 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -13,8 +13,7 @@ public actual class GeoPoint internal actual constructor(internal actual val nat public actual val latitude: Double = nativeValue.latitude public actual val longitude: Double = nativeValue.longitude - override fun equals(other: Any?): Boolean = - this === other || other is GeoPoint && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() } diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index 8497833e8..49505e776 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -20,8 +20,7 @@ public actual class Timestamp internal actual constructor( public actual val seconds: Long = nativeValue.seconds public actual val nanoseconds: Int = nativeValue.nanoseconds - override fun equals(other: Any?): Boolean = - this === other || other is Timestamp && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt index 15513316c..38070eab2 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeCollectionReferenceWrapper.kt @@ -14,9 +14,7 @@ internal actual class NativeCollectionReferenceWrapper internal actual construct actual val parent get() = native.parent?.let { NativeDocumentReference(it) } - actual fun document(documentPath: String) = - NativeDocumentReference(native.documentWithPath(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.documentWithPath(documentPath)) - actual suspend fun addEncoded(data: EncodedObject) = - NativeDocumentReference(await { native.addDocumentWithData(data.ios, it) }) + actual suspend fun addEncoded(data: EncodedObject) = NativeDocumentReference(await { native.addDocumentWithData(data.ios, it) }) } diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index 98856556b..d7f330fff 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -35,8 +35,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual fun collection(collectionPath: String) = ios.collectionWithPath(collectionPath) - actual suspend fun get(source: Source) = - awaitResult { ios.getDocumentWithSource(source.toIosSource(), it) } + actual suspend fun get(source: Source) = awaitResult { ios.getDocumentWithSource(source.toIosSource(), it) } actual suspend fun setEncoded(encodedData: EncodedObject, setOptions: SetOptions) = await { when (setOptions) { @@ -55,15 +54,13 @@ internal actual class NativeDocumentReference actual constructor(actual val nati ios.updateData(encodedData.ios, it) } - actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) = - await { - ios.updateData(encodedFieldsAndValues.toMap(), it) - } + actual suspend fun updateEncodedFieldsAndValues(encodedFieldsAndValues: List>) = await { + ios.updateData(encodedFieldsAndValues.toMap(), it) + } - actual suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) = - await { - ios.updateData(encodedFieldsAndValues.toMap(), it) - } + actual suspend fun updateEncodedFieldPathsAndValues(encodedFieldsAndValues: List>) = await { + ios.updateData(encodedFieldsAndValues.toMap(), it) + } actual suspend fun delete() = await { ios.deleteDocumentWithCompletion(it) } @@ -75,8 +72,7 @@ internal actual class NativeDocumentReference actual constructor(actual val nati awaitClose { listener.remove() } } - override fun equals(other: Any?): Boolean = - this === other || other is NativeDocumentReference && nativeValue == other.nativeValue + override fun equals(other: Any?): Boolean = this === other || other is NativeDocumentReference && nativeValue == other.nativeValue override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() } diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index 36594699d..ad7cb69f2 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -13,18 +13,15 @@ internal actual class NativeDocumentSnapshotWrapper actual constructor(actual va actual val reference get() = NativeDocumentReference(native.reference) - actual fun getEncoded(field: String, serverTimestampBehavior: ServerTimestampBehavior): Any? = - native.valueForField(field, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } + actual fun getEncoded(field: String, serverTimestampBehavior: ServerTimestampBehavior): Any? = native.valueForField(field, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } // Despite its name implying otherwise, valueForField accepts both a String representation of a Field and a FIRFieldPath - actual fun getEncoded(fieldPath: EncodedFieldPath, serverTimestampBehavior: ServerTimestampBehavior): Any? = - native.valueForField(fieldPath, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } - - actual fun encodedData(serverTimestampBehavior: ServerTimestampBehavior): Any? = - native.dataWithServerTimestampBehavior(serverTimestampBehavior.toIos()) - ?.mapValues { (_, value) -> - value?.takeIf { it !is NSNull } - } + actual fun getEncoded(fieldPath: EncodedFieldPath, serverTimestampBehavior: ServerTimestampBehavior): Any? = native.valueForField(fieldPath, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } + + actual fun encodedData(serverTimestampBehavior: ServerTimestampBehavior): Any? = native.dataWithServerTimestampBehavior(serverTimestampBehavior.toIos()) + ?.mapValues { (_, value) -> + value?.takeIf { it !is NSNull } + } actual fun contains(field: String) = native.valueForField(field) != null actual fun contains(fieldPath: EncodedFieldPath) = native.valueForField(fieldPath) != null diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index 50e59c0ad..4d802acec 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -15,28 +15,24 @@ internal actual class NativeFirebaseFirestoreWrapper internal actual constructor actual fun collectionGroup(collectionId: String) = native.collectionGroupWithID(collectionId) - actual fun document(documentPath: String) = - NativeDocumentReference(native.documentWithPath(documentPath)) + actual fun document(documentPath: String) = NativeDocumentReference(native.documentWithPath(documentPath)) actual fun batch() = native.batch() - actual fun setLoggingEnabled(loggingEnabled: Boolean): Unit = - FIRFirestore.enableLogging(loggingEnabled) + actual fun setLoggingEnabled(loggingEnabled: Boolean): Unit = FIRFirestore.enableLogging(loggingEnabled) actual fun applySettings(settings: FirebaseFirestoreSettings) { native.settings = settings.ios } - actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = - awaitResult { - native.runTransactionWithBlock( - { transaction, _ -> runBlocking { transaction!!.func() } }, - it, - ) - } as T + actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = awaitResult { + native.runTransactionWithBlock( + { transaction, _ -> runBlocking { transaction!!.func() } }, + it, + ) + } as T - actual suspend fun clearPersistence() = - await { native.clearPersistenceWithCompletion(it) } + actual suspend fun clearPersistence() = await { native.clearPersistenceWithCompletion(it) } actual fun useEmulator(host: String, port: Int) { native.useEmulatorWithHost(host, port.toLong()) diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt index 30f01b7f1..788eb8ade 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeQueryWrapper.kt @@ -19,8 +19,7 @@ internal actual open class NativeQueryWrapper internal actual constructor(actual actual fun limit(limit: Number) = native.queryLimitedTo(limit.toLong()) - actual suspend fun get(source: Source) = - QuerySnapshot(awaitResult { native.getDocumentsWithSource(source.toIosSource(), it) }) + actual suspend fun get(source: Source) = QuerySnapshot(awaitResult { native.getDocumentsWithSource(source.toIosSource(), it) }) actual val snapshots get() = callbackFlow { val listener = native.addSnapshotListener { snapshot, error -> diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index a9fe0014d..6771da276 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -38,9 +38,7 @@ internal actual class NativeTransactionWrapper actual constructor(actual val nat documentRef.ios, ).let { this } - actual fun delete(documentRef: DocumentReference) = - native.deleteDocument(documentRef.ios).let { this } + actual fun delete(documentRef: DocumentReference) = native.deleteDocument(documentRef.ios).let { this } - actual suspend fun get(documentRef: DocumentReference) = - throwError { NativeDocumentSnapshotWrapper(native.getDocument(documentRef.ios, it)!!) } + actual suspend fun get(documentRef: DocumentReference) = throwError { NativeDocumentSnapshotWrapper(native.getDocument(documentRef.ios, it)!!) } } diff --git a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index f1551cecf..081c8302b 100644 --- a/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/appleMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -39,8 +39,7 @@ internal actual class NativeWriteBatchWrapper actual constructor(actual val nati documentRef.ios, ).let { this } - actual fun delete(documentRef: DocumentReference) = - native.deleteDocument(documentRef.ios).let { this } + actual fun delete(documentRef: DocumentReference) = native.deleteDocument(documentRef.ios).let { this } actual suspend fun commit() = await { native.commitWithCompletion(it) } } diff --git a/firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt b/firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt index e7c6fc04f..640b38fb3 100644 --- a/firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt +++ b/firebase-firestore/src/appleTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt @@ -33,27 +33,26 @@ private val backgroundContext = newSingleThreadContext("background") * @param create a block for object creation * @param test a block to perform test on a thread different from the one used in [create] */ -fun runTestWithContextSwitch(create: suspend CoroutineScope.() -> T, test: suspend CoroutineScope.(T) -> Unit) = - runBlocking { - val testRun = MainScope().async { - val objMain = create() - withContext(backgroundContext) { - test(objMain) - } - val objBcg = withContext(backgroundContext) { - create() - } - test(objBcg) +fun runTestWithContextSwitch(create: suspend CoroutineScope.() -> T, test: suspend CoroutineScope.(T) -> Unit) = runBlocking { + val testRun = MainScope().async { + val objMain = create() + withContext(backgroundContext) { + test(objMain) } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()), - ) - yield() + val objBcg = withContext(backgroundContext) { + create() } - testRun.await() + test(objBcg) + } + while (testRun.isActive) { + NSRunLoop.mainRunLoop.runMode( + NSDefaultRunLoopMode, + beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()), + ) + yield() } + testRun.await() +} class ContextSwitchTest { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt index 04096c94a..cf6178fb8 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/LocalCacheSettings.kt @@ -56,14 +56,10 @@ public sealed interface MemoryGarbageCollectorSettings { public typealias MemoryEagerGcSettings = MemoryGarbageCollectorSettings.Eager public typealias MemoryLruGcSettings = MemoryGarbageCollectorSettings.LRUGC -public fun memoryCacheSettings(builder: LocalCacheSettings.Memory.Builder.() -> Unit): LocalCacheSettings.Memory = - LocalCacheSettings.Memory.newBuilder().apply(builder).build() +public fun memoryCacheSettings(builder: LocalCacheSettings.Memory.Builder.() -> Unit): LocalCacheSettings.Memory = LocalCacheSettings.Memory.newBuilder().apply(builder).build() -public fun memoryEagerGcSettings(builder: MemoryGarbageCollectorSettings.Eager.Builder.() -> Unit): MemoryGarbageCollectorSettings.Eager = - MemoryGarbageCollectorSettings.Eager.newBuilder().apply(builder).build() +public fun memoryEagerGcSettings(builder: MemoryGarbageCollectorSettings.Eager.Builder.() -> Unit): MemoryGarbageCollectorSettings.Eager = MemoryGarbageCollectorSettings.Eager.newBuilder().apply(builder).build() -public fun memoryLruGcSettings(builder: MemoryGarbageCollectorSettings.LRUGC.Builder.() -> Unit): MemoryGarbageCollectorSettings.LRUGC = - MemoryGarbageCollectorSettings.LRUGC.newBuilder().apply(builder).build() +public fun memoryLruGcSettings(builder: MemoryGarbageCollectorSettings.LRUGC.Builder.() -> Unit): MemoryGarbageCollectorSettings.LRUGC = MemoryGarbageCollectorSettings.LRUGC.newBuilder().apply(builder).build() -public fun persistentCacheSettings(builder: LocalCacheSettings.Persistent.Builder.() -> Unit): LocalCacheSettings.Persistent = - LocalCacheSettings.Persistent.newBuilder().apply(builder).build() +public fun persistentCacheSettings(builder: LocalCacheSettings.Persistent.Builder.() -> Unit): LocalCacheSettings.Persistent = LocalCacheSettings.Persistent.newBuilder().apply(builder).build() diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index 13a37a7e7..b9b63175d 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -33,10 +33,9 @@ public expect class Timestamp internal constructor(nativeValue: NativeTimestamp) public data object ServerTimestamp : BaseTimestamp } -public fun Timestamp.Companion.fromDuration(duration: Duration): Timestamp = - duration.toComponents { seconds, nanoseconds -> - Timestamp(seconds, nanoseconds) - } +public fun Timestamp.Companion.fromDuration(duration: Duration): Timestamp = duration.toComponents { seconds, nanoseconds -> + Timestamp(seconds, nanoseconds) +} public fun Timestamp.toDuration(): Duration = seconds.seconds + nanoseconds.nanoseconds public fun Timestamp.Companion.fromMilliseconds(milliseconds: Double): Timestamp = fromDuration(milliseconds.milliseconds) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt index 54410b4ef..308e758ce 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/encoders.kt @@ -7,9 +7,8 @@ import dev.gitlive.firebase.EncodeSettings internal expect fun isSpecialValue(value: Any): Boolean @PublishedApi -internal inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = - if (value?.let(::isSpecialValue) == true) { - value - } else { - dev.gitlive.firebase.internal.encode(value, buildSettings) - } +internal inline fun encode(value: T, buildSettings: EncodeSettings.Builder.() -> Unit): Any? = if (value?.let(::isSpecialValue) == true) { + value +} else { + dev.gitlive.firebase.internal.encode(value, buildSettings) +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index bf4723e49..05dae934b 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -306,43 +306,37 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, merge: Boolean = false): WriteBatch = set(documentRef, data, merge) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) + public inline fun set(documentRef: DocumentReference, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFields: String): WriteBatch = set(documentRef, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) + public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) public inline fun set(documentRef: DocumentReference, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): WriteBatch = set(documentRef, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) + public inline fun set(documentRef: DocumentReference, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults }")) public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, merge: Boolean = false): WriteBatch = set(documentRef, strategy, data, merge) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, merge: Boolean = false, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), if (merge) SetOptions.Merge else SetOptions.Overwrite) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFields) { this.encodeDefaults = encodeDefaults }")) public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFields: String): WriteBatch = set(documentRef, strategy, data, *mergeFields) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFields: String, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFields(mergeFields.asList())) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("set(documentRef, strategy, data, mergeFieldPaths) { this.encodeDefaults = encodeDefaults }")) public fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean, vararg mergeFieldPaths: FieldPath): WriteBatch = set(documentRef, strategy, data, *mergeFieldPaths) { this.encodeDefaults = encodeDefaults } - public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) + public inline fun set(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, vararg mergeFieldPaths: FieldPath, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = setEncoded(documentRef, encodeAsObject(strategy, data, buildSettings), SetOptions.MergeFieldPaths(mergeFieldPaths.asList())) @PublishedApi internal fun setEncoded(documentRef: DocumentReference, encodedData: EncodedObject, setOptions: SetOptions): WriteBatch = WriteBatch(nativeWrapper.setEncoded(documentRef, encodedData, setOptions)) @@ -351,15 +345,13 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na public inline fun update(documentRef: DocumentReference, data: T, encodeDefaults: Boolean): WriteBatch = update(documentRef, data) { this.encodeDefaults = encodeDefaults } - public inline fun update(documentRef: DocumentReference, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - updateEncoded(documentRef, encodeAsObject(data, buildSettings)) + public inline fun update(documentRef: DocumentReference, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncoded(documentRef, encodeAsObject(data, buildSettings)) @Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults }")) public fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, encodeDefaults: Boolean): WriteBatch = update(documentRef, strategy, data) { this.encodeDefaults = encodeDefaults } - public inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = - updateEncoded(documentRef, encodeAsObject(strategy, data, buildSettings)) + public inline fun update(documentRef: DocumentReference, strategy: SerializationStrategy, data: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncoded(documentRef, encodeAsObject(strategy, data, buildSettings)) @JvmName("updateField") public inline fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit = {}): WriteBatch = updateEncodedFieldsAndValues(documentRef, encodeFieldAndValue(fieldsAndValues, buildSettings).orEmpty()) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt index 766836a76..494d50cea 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/helpers.kt @@ -25,9 +25,8 @@ internal inline fun encodeFieldAndValue( fieldsAndValues: Array>, encodeField: (T) -> K, encodeValue: (Any?) -> Any?, -): List>? = - fieldsAndValues.takeUnless { fieldsAndValues.isEmpty() } - ?.map { (field, value) -> encodeField(field) to value?.let { encodeValue(it) } } +): List>? = fieldsAndValues.takeUnless { fieldsAndValues.isEmpty() } + ?.map { (field, value) -> encodeField(field) to value?.let { encodeValue(it) } } internal fun List>.performUpdate( update: (K, Any?, Array) -> R, diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt index 5407e19d6..f33eb606d 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt @@ -16,10 +16,9 @@ public actual class FieldValue internal actual constructor(internal actual val n init { require(nativeValue is NativeFieldValue) } - override fun equals(other: Any?): Boolean = - this === other || - other is FieldValue && - (nativeValue as NativeFieldValue).isEqual(other.nativeValue as NativeFieldValue) + override fun equals(other: Any?): Boolean = this === other || + other is FieldValue && + (nativeValue as NativeFieldValue).isEqual(other.nativeValue as NativeFieldValue) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index 0818e403c..83248b38a 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -12,8 +12,7 @@ public actual class GeoPoint internal actual constructor(internal actual val nat public actual val latitude: Double by nativeValue::latitude public actual val longitude: Double by nativeValue::longitude - override fun equals(other: Any?): Boolean = - this === other || other is GeoPoint && nativeValue.isEqual(other.nativeValue) + override fun equals(other: Any?): Boolean = this === other || other is GeoPoint && nativeValue.isEqual(other.nativeValue) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "GeoPoint[lat=$latitude,long=$longitude]" } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index bc18327ba..28d7077e8 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -19,8 +19,7 @@ public actual class Timestamp internal actual constructor( public actual val seconds: Long = nativeValue.seconds.toLong() public actual val nanoseconds: Int = nativeValue.nanoseconds.toInt() - override fun equals(other: Any?): Boolean = - this === other || other is Timestamp && nativeValue.isEqual(other.nativeValue) + override fun equals(other: Any?): Boolean = this === other || other is Timestamp && nativeValue.isEqual(other.nativeValue) override fun hashCode(): Int = nativeValue.toMillis().hashCode() override fun toString(): String = nativeValue.toString() diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 752e53a3c..156f66246 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -35,8 +35,7 @@ import dev.gitlive.firebase.firestore.externals.documentId as jsDocumentId public actual val Firebase.firestore: FirebaseFirestore get() = rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(getApp())) } -public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = - rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(app.js)) } +public actual fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore = rethrow { FirebaseFirestore(NativeFirebaseFirestoreWrapper(app.js)) } internal actual data class NativeFirebaseFirestore(val js: JsFirestore) @@ -271,11 +270,9 @@ internal fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "") } // from: https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509/8 -internal fun entriesOf(jsObject: dynamic): List> = - (js("Object.entries") as (dynamic) -> Array>) - .invoke(jsObject) - .map { entry -> entry[0] as String to entry[1] } +internal fun entriesOf(jsObject: dynamic): List> = (js("Object.entries") as (dynamic) -> Array>) + .invoke(jsObject) + .map { entry -> entry[0] as String to entry[1] } // from: https://discuss.kotlinlang.org/t/how-to-access-native-js-object-as-a-map-string-any/509/8 -internal fun mapOf(jsObject: dynamic): Map = - entriesOf(jsObject).toMap() +internal fun mapOf(jsObject: dynamic): Map = entriesOf(jsObject).toMap() diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt index 5065defa2..e93181308 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentReference.kt @@ -95,13 +95,12 @@ internal actual class NativeDocumentReference actual constructor(actual val nati actual suspend fun delete() = rethrow { deleteDoc(js).await() } - override fun equals(other: Any?): Boolean = - this === other || - other is NativeDocumentReference && - refEqual( - nativeValue, - other.nativeValue, - ) + override fun equals(other: Any?): Boolean = this === other || + other is NativeDocumentReference && + refEqual( + nativeValue, + other.nativeValue, + ) override fun hashCode(): Int = nativeValue.hashCode() override fun toString(): String = "DocumentReference(path=$path)" } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt index bf6e967a6..a994d1efb 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeDocumentSnapshotWrapper.kt @@ -34,6 +34,5 @@ internal actual class NativeDocumentSnapshotWrapper internal actual constructor( actual val exists get() = rethrow { js.exists() } actual val metadata: SnapshotMetadata get() = SnapshotMetadata(js.metadata) - fun getTimestampsOptions(serverTimestampBehavior: ServerTimestampBehavior) = - json("serverTimestamps" to serverTimestampBehavior.name.lowercase()) + fun getTimestampsOptions(serverTimestampBehavior: ServerTimestampBehavior) = json("serverTimestamps" to serverTimestampBehavior.name.lowercase()) } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt index c8c1a31ae..d895afec1 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeFirebaseFirestoreWrapper.kt @@ -94,24 +94,21 @@ internal actual class NativeFirebaseFirestoreWrapper internal constructor( actual fun batch() = rethrow { NativeWriteBatch(writeBatch(js)) } - actual fun setLoggingEnabled(loggingEnabled: Boolean) = - rethrow { setLogLevel(if (loggingEnabled) "error" else "silent") } + actual fun setLoggingEnabled(loggingEnabled: Boolean) = rethrow { setLogLevel(if (loggingEnabled) "error" else "silent") } actual fun applySettings(settings: FirebaseFirestoreSettings) { this.settings = settings } @OptIn(DelicateCoroutinesApi::class) - actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = - rethrow { - dev.gitlive.firebase.firestore.externals.runTransaction( - js, - { GlobalScope.promise { NativeTransaction(it).func() } }, - ).await() - } + actual suspend fun runTransaction(func: suspend NativeTransaction.() -> T) = rethrow { + dev.gitlive.firebase.firestore.externals.runTransaction( + js, + { GlobalScope.promise { NativeTransaction(it).func() } }, + ).await() + } - actual suspend fun clearPersistence() = - rethrow { clearIndexedDbPersistence(js).await() } + actual suspend fun clearPersistence() = rethrow { clearIndexedDbPersistence(js).await() } actual fun useEmulator(host: String, port: Int) = rethrow { if (settings != null) { diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt index 59ba9896d..8509a9db7 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeTransactionWrapper.kt @@ -47,10 +47,8 @@ internal actual class NativeTransactionWrapper internal actual constructor(actua } }.let { this } - actual fun delete(documentRef: DocumentReference) = - rethrow { js.delete(documentRef.js) } - .let { this } + actual fun delete(documentRef: DocumentReference) = rethrow { js.delete(documentRef.js) } + .let { this } - actual suspend fun get(documentRef: DocumentReference) = - rethrow { NativeDocumentSnapshotWrapper(js.get(documentRef.js).await()) } + actual suspend fun get(documentRef: DocumentReference) = rethrow { NativeDocumentSnapshotWrapper(js.get(documentRef.js).await()) } } diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt index e97cc31ab..4bd929e93 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/internal/NativeWriteBatchWrapper.kt @@ -44,9 +44,8 @@ internal actual class NativeWriteBatchWrapper internal actual constructor(actual } }.let { this } - actual fun delete(documentRef: DocumentReference) = - rethrow { js.delete(documentRef.js) } - .let { this } + actual fun delete(documentRef: DocumentReference) = rethrow { js.delete(documentRef.js) } + .let { this } actual suspend fun commit() = rethrow { js.commit().await() } } diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 9c6ba0d4c..a8c56abf9 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -13,5 +13,4 @@ actual val context: Any = Unit actual fun encodedAsMap(encoded: Any?): Map = (js("Object").entries(encoded) as Array>).associate { it[0] as String to it[1] } -actual fun Map.asEncoded(): Any = - json(*entries.map { (key, value) -> key to value }.toTypedArray()) +actual fun Map.asEncoded(): Any = json(*entries.map { (key, value) -> key to value }.toTypedArray()) 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 00b1a3dab..591602228 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 @@ -22,18 +22,14 @@ public val FirebaseFunctions.android: com.google.firebase.functions.FirebaseFunc public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance()) -public actual fun Firebase.functions(region: String): FirebaseFunctions = - FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(region)) +public actual fun Firebase.functions(region: String): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(region)) -public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = - FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android)) +public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android)) -public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = - FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android, region)) +public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance(app.android, region)) public actual data class FirebaseFunctions internal constructor(internal val android: com.google.firebase.functions.FirebaseFunctions) { - public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = - HttpsCallableReference(android.getHttpsCallable(name).apply { timeout?.let { setTimeout(it.inWholeMilliseconds, TimeUnit.MILLISECONDS) } }.native) + public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = HttpsCallableReference(android.getHttpsCallable(name).apply { timeout?.let { setTimeout(it.inWholeMilliseconds, TimeUnit.MILLISECONDS) } }.native) public actual fun useEmulator(host: String, port: Int) { android.useEmulator(host, port) @@ -53,11 +49,9 @@ public val HttpsCallableResult.android: com.google.firebase.functions.HttpsCalla public actual class HttpsCallableResult(internal val android: com.google.firebase.functions.HttpsCallableResult) { - public actual inline fun data(): T = - decode(value = publicAndroid.data) + public actual inline fun data(): T = decode(value = publicAndroid.data) - public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicAndroid.data, buildSettings) + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicAndroid.data, buildSettings) } public actual typealias FirebaseFunctionsException = com.google.firebase.functions.FirebaseFunctionsException diff --git a/firebase-functions/src/appleMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/appleMain/kotlin/dev/gitlive/firebase/functions/functions.kt index d002f93b4..3f22a9bd3 100644 --- a/firebase-functions/src/appleMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/appleMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -27,8 +27,7 @@ public val FirebaseFunctions.ios: FIRFunctions get() = FIRFunctions.functions() public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(FIRFunctions.functions()) -public actual fun Firebase.functions(region: String): FirebaseFunctions = - FirebaseFunctions(FIRFunctions.functionsForRegion(region)) +public actual fun Firebase.functions(region: String): FirebaseFunctions = FirebaseFunctions(FIRFunctions.functionsForRegion(region)) public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = FirebaseFunctions( FIRFunctions.functionsForApp(app.ios as objcnames.classes.FIRApp), @@ -42,8 +41,7 @@ public actual fun Firebase.functions( ) public actual data class FirebaseFunctions internal constructor(internal val ios: FIRFunctions) { - public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = - HttpsCallableReference(ios.HTTPSCallableWithName(name).apply { timeout?.let { setTimeoutInterval(it.toDouble(DurationUnit.SECONDS)) } }.native) + public actual fun httpsCallable(name: String, timeout: Duration?): HttpsCallableReference = HttpsCallableReference(ios.HTTPSCallableWithName(name).apply { timeout?.let { setTimeoutInterval(it.toDouble(DurationUnit.SECONDS)) } }.native) public actual fun useEmulator(host: String, port: Int) { ios.useEmulatorWithHost(host, port.toLong()) @@ -63,11 +61,9 @@ public val HttpsCallableResult.ios: FIRHTTPSCallableResult get() = ios public actual class HttpsCallableResult(internal val ios: FIRHTTPSCallableResult) { - public actual inline fun data(): T = - decode(value = publicIos.data()) + public actual inline fun data(): T = decode(value = publicIos.data()) - public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, publicIos.data(), buildSettings) + public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = decode(strategy, publicIos.data(), buildSettings) } public actual class FirebaseFunctionsException(message: String, public val code: FunctionsExceptionCode, public val details: Any?) : FirebaseException(message) 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 9ed840305..44f0e0972 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 @@ -20,14 +20,11 @@ import dev.gitlive.firebase.functions.js as publicJs public actual val Firebase.functions: FirebaseFunctions get() = rethrow { FirebaseFunctions(getFunctions()) } -public actual fun Firebase.functions(region: String): FirebaseFunctions = - rethrow { FirebaseFunctions(getFunctions(regionOrCustomDomain = region)) } +public actual fun Firebase.functions(region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(regionOrCustomDomain = region)) } -public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = - rethrow { FirebaseFunctions(getFunctions(app.js)) } +public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js)) } -public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = - rethrow { FirebaseFunctions(getFunctions(app.js, region)) } +public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js, region)) } public val FirebaseFunctions.js: Functions get() = js @@ -65,8 +62,7 @@ public val HttpsCallableResult.js: JsHttpsCallableResult get() = js public actual class HttpsCallableResult(internal val js: JsHttpsCallableResult) { - public actual inline fun data(): T = - rethrow { decode(value = publicJs.data) } + public actual inline fun data(): T = rethrow { decode(value = publicJs.data) } public actual inline fun data( strategy: DeserializationStrategy, diff --git a/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt index f9c0d3224..fe17f9ffd 100644 --- a/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/androidMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -18,8 +18,7 @@ public actual class FirebaseInstallations internal constructor(internal val andr public actual suspend fun getId(): String = android.id.await() - public actual suspend fun getToken(forceRefresh: Boolean): String = - android.getToken(forceRefresh).await().token + public actual suspend fun getToken(forceRefresh: Boolean): String = android.getToken(forceRefresh).await().token } public actual typealias FirebaseInstallationsException = com.google.firebase.installations.FirebaseInstallationsException diff --git a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt index e91813663..7e97350f3 100644 --- a/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -10,8 +10,7 @@ import kotlinx.coroutines.await public actual val Firebase.installations: FirebaseInstallations get() = rethrow { FirebaseInstallations(getInstallations()) } -public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = - rethrow { FirebaseInstallations(getInstallations(app.js)) } +public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = rethrow { FirebaseInstallations(getInstallations(app.js)) } public val FirebaseInstallations.js: Installations get() = js @@ -21,8 +20,7 @@ public actual class FirebaseInstallations internal constructor(internal val js: public actual suspend fun getId(): String = rethrow { getId(js).await() } - public actual suspend fun getToken(forceRefresh: Boolean): String = - rethrow { getToken(js, forceRefresh).await() } + public actual suspend fun getToken(forceRefresh: Boolean): String = rethrow { getToken(js, forceRefresh).await() } } public actual open class FirebaseInstallationsException(code: String?, cause: Throwable) : FirebaseException(code, cause) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt index a4e4d3d47..bdc922fd4 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -10,8 +10,7 @@ public val FirebasePerformance.android: com.google.firebase.perf.FirebasePerform public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(com.google.firebase.perf.FirebasePerformance.getInstance()) -public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = - FirebasePerformance(app.publicAndroid.get(com.google.firebase.perf.FirebasePerformance::class.java)) +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(app.publicAndroid.get(com.google.firebase.perf.FirebasePerformance::class.java)) public actual class FirebasePerformance(internal val android: com.google.firebase.perf.FirebasePerformance) { diff --git a/firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/performance.kt index 527660077..661a86814 100644 --- a/firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/appleMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -11,8 +11,7 @@ public val FirebasePerformance.ios: FIRPerformance get() = FIRPerformance.shared public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(FIRPerformance.sharedInstance()) -public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = - FirebasePerformance(FIRPerformance.sharedInstance()) +public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(FIRPerformance.sharedInstance()) public actual class FirebasePerformance(internal val ios: FIRPerformance) { diff --git a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 5f87d1686..2b7d65021 100644 --- a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -8,8 +8,7 @@ import kotlinx.coroutines.CoroutineScope import kotlin.js.json import kotlin.time.Duration.Companion.minutes -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = - kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) { kotlinx.coroutines.test.runTest { action() } }