From e70763bdff51d02badf2601616df29146cea9d7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:47:03 +0000 Subject: [PATCH 1/2] Bump org.jmailen.kotlinter from 4.4.1 to 4.5.0 Bumps org.jmailen.kotlinter from 4.4.1 to 4.5.0. --- updated-dependencies: - dependency-name: org.jmailen.kotlinter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8123749bc..af96cbbdb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ kotlinx-coroutines = "1.9.0-RC.2" kotlinx-serialization = "1.7.2" kotlinx-binarycompatibilityvalidator = "0.16.3" kotlinx-datetime = "0.6.1" -kotlinter = "4.4.1" +kotlinter = "4.5.0" settings-api = "2.0" settings-language = "2.0" firebase-cocoapods = "11.2.0" From 9b16b8e743815118c5fcfa617e2703abb5ffc0d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 9 Dec 2024 21:49:25 +0000 Subject: [PATCH 2/2] 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 +- .../dev/gitlive/firebase/internal/decoders.kt | 40 +++++++----------- .../dev/gitlive/firebase/internal/encoders.kt | 12 ++---- .../gitlive/firebase/internal/_decoders.kt | 3 +- .../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 | 24 ++++------- .../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, 261 insertions(+), 459 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/iosMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt index ca9d48359..6a8411792 100644 --- a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/iosMain/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/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/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt index 00400b622..860af2087 100644 --- a/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt +++ b/firebase-common-internal/src/iosMain/kotlin/dev/gitlive/firebase/internal/_decoders.kt @@ -19,8 +19,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/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/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index 2ce33a91d..35cb37701 100644 --- a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/iosMain/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/iosMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt index c75290154..458462025 100644 --- a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/iosMain/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 f4f38d8f7..ba76dfdd7 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 @@ -64,14 +64,11 @@ 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 get() = js @@ -190,8 +187,7 @@ 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): DataSnapshot = DataSnapshot( jsRunTransaction(js, transactionUpdate = { currentData -> @@ -212,11 +208,9 @@ 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) } + 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() } public actual val key: String? get() = rethrow { js.key } @@ -242,11 +236,9 @@ 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 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() } }