diff --git a/README.md b/README.md index 9e9749202..b22454db5 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ It uses the Firebase J ### Accessing the underlying Firebase SDK -In some cases you might want to access the underlying official Firebase SDK in platform specific code, for example when the common API is missing the functionality you need. For this purpose each class in the SDK has `android`, `ios` and `js` properties which holds the equivalent object of the underlying official Firebase SDK. For *JVM*, as the `firebase-java-sdk` is a direct port of the Firebase Android SDK, is it also accessed via the `android` property. +In some cases you might want to access the underlying official Firebase SDK in platform specific code, for example when the common API is missing the functionality you need. For this purpose each class in the SDK has `android`, `ios` and `js` extension properties that hold the equivalent object of the underlying official Firebase SDK. For *JVM*, as the `firebase-java-sdk` is a direct port of the Firebase Android SDK, is it also accessed via the `android` property. These properties are only accessible from the equivalent target's source set. For example to disable persistence in Cloud Firestore on Android you can write the following in your Android specific code (e.g. `androidMain` or `androidTest`): diff --git a/firebase-analytics/api/android/firebase-analytics.api b/firebase-analytics/api/android/firebase-analytics.api index 207fb178c..80e01f521 100644 --- a/firebase-analytics/api/android/firebase-analytics.api +++ b/firebase-analytics/api/android/firebase-analytics.api @@ -12,7 +12,6 @@ public final class dev/gitlive/firebase/analytics/AnalyticsKt { public final class dev/gitlive/firebase/analytics/FirebaseAnalytics { public fun (Lcom/google/firebase/analytics/FirebaseAnalytics;)V - public final fun getAndroid ()Lcom/google/firebase/analytics/FirebaseAnalytics; public final fun getSessionId (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun logEvent (Ljava/lang/String;Ljava/util/Map;)V public static synthetic fun logEvent$default (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)V @@ -207,5 +206,6 @@ public final class dev/gitlive/firebase/analytics/FirebaseAnalyticsUserProperty public final class dev/gitlive/firebase/analytics/analyticsAndroid { public static final fun analytics (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics; public static final fun getAnalytics (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/analytics/FirebaseAnalytics; + public static final fun getAndroid (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;)Lcom/google/firebase/analytics/FirebaseAnalytics; } diff --git a/firebase-analytics/package.json b/firebase-analytics/package.json index b178df35c..da4f8da37 100644 --- a/firebase-analytics/package.json +++ b/firebase-analytics/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-analytics", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-analytics.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" 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 6bb66ab35..b41f10c69 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 @@ -16,7 +16,9 @@ public actual val Firebase.analytics: FirebaseAnalytics public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(com.google.firebase.Firebase.analytics) -public actual class FirebaseAnalytics(public val android: com.google.firebase.analytics.FirebaseAnalytics) { +public val FirebaseAnalytics.android: com.google.firebase.analytics.FirebaseAnalytics get() = android + +public actual class FirebaseAnalytics(internal val android: com.google.firebase.analytics.FirebaseAnalytics) { public actual fun logEvent(name: String, parameters: Map?) { android.logEvent(name, parameters?.toBundle()) } diff --git a/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt b/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt index 2b98485f5..70133e694 100644 --- a/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt +++ b/firebase-analytics/src/iosMain/kotlin/dev/gitlive/firebase/analytics/analytics.kt @@ -15,7 +15,9 @@ public actual val Firebase.analytics: FirebaseAnalytics public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(FIRAnalytics) -public actual class FirebaseAnalytics(public val ios: FIRAnalytics.Companion) { +public val FirebaseAnalytics.ios: FIRAnalytics.Companion get() = ios + +public actual class FirebaseAnalytics(internal val ios: FIRAnalytics.Companion) { public actual fun logEvent(name: String, parameters: Map?) { val mappedParameters: Map? = parameters?.map { it.key to it.value }?.toMap() ios.logEventWithName(name, mappedParameters) 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 cbad07eee..a27b8e367 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 @@ -4,6 +4,7 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.analytics.externals.getAnalytics +import dev.gitlive.firebase.js import kotlinx.coroutines.await import kotlin.time.Duration @@ -13,7 +14,9 @@ public actual val Firebase.analytics: FirebaseAnalytics public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(getAnalytics(app.js)) -public actual class FirebaseAnalytics(public val js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics) { +public val FirebaseAnalytics.js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics get() = js + +public actual class FirebaseAnalytics(internal val js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics) { public actual fun logEvent( name: String, parameters: Map?, diff --git a/firebase-app/api/android/firebase-app.api b/firebase-app/api/android/firebase-app.api index 3aa3adbc2..966ca6540 100644 --- a/firebase-app/api/android/firebase-app.api +++ b/firebase-app/api/android/firebase-app.api @@ -7,12 +7,10 @@ public final class dev/gitlive/firebase/Firebase { } public final class dev/gitlive/firebase/FirebaseApp { - public final fun component1 ()Lcom/google/firebase/FirebaseApp; public final fun copy (Lcom/google/firebase/FirebaseApp;)Ldev/gitlive/firebase/FirebaseApp; public static synthetic fun copy$default (Ldev/gitlive/firebase/FirebaseApp;Lcom/google/firebase/FirebaseApp;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun equals (Ljava/lang/Object;)Z - public final fun getAndroid ()Lcom/google/firebase/FirebaseApp; public final fun getName ()Ljava/lang/String; public final fun getOptions ()Ldev/gitlive/firebase/FirebaseOptions; public fun hashCode ()I @@ -23,6 +21,7 @@ public final class dev/gitlive/firebase/FirebaseKt { public static final fun app (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseApp; public static final fun apps (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ljava/util/List; public static synthetic fun apps$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;ILjava/lang/Object;)Ljava/util/List; + public static final fun getAndroid (Ldev/gitlive/firebase/FirebaseApp;)Lcom/google/firebase/FirebaseApp; public static final fun getApp (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/FirebaseApp; public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;)Ldev/gitlive/firebase/FirebaseApp; diff --git a/firebase-app/api/jvm/firebase-app.api b/firebase-app/api/jvm/firebase-app.api index 3aa3adbc2..966ca6540 100644 --- a/firebase-app/api/jvm/firebase-app.api +++ b/firebase-app/api/jvm/firebase-app.api @@ -7,12 +7,10 @@ public final class dev/gitlive/firebase/Firebase { } public final class dev/gitlive/firebase/FirebaseApp { - public final fun component1 ()Lcom/google/firebase/FirebaseApp; public final fun copy (Lcom/google/firebase/FirebaseApp;)Ldev/gitlive/firebase/FirebaseApp; public static synthetic fun copy$default (Ldev/gitlive/firebase/FirebaseApp;Lcom/google/firebase/FirebaseApp;ILjava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun equals (Ljava/lang/Object;)Z - public final fun getAndroid ()Lcom/google/firebase/FirebaseApp; public final fun getName ()Ljava/lang/String; public final fun getOptions ()Ldev/gitlive/firebase/FirebaseOptions; public fun hashCode ()I @@ -23,6 +21,7 @@ public final class dev/gitlive/firebase/FirebaseKt { public static final fun app (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/FirebaseApp; public static final fun apps (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ljava/util/List; public static synthetic fun apps$default (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;ILjava/lang/Object;)Ljava/util/List; + public static final fun getAndroid (Ldev/gitlive/firebase/FirebaseApp;)Lcom/google/firebase/FirebaseApp; public static final fun getApp (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/FirebaseApp; public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;)Ldev/gitlive/firebase/FirebaseApp; public static final fun initialize (Ldev/gitlive/firebase/Firebase;Ljava/lang/Object;Ldev/gitlive/firebase/FirebaseOptions;)Ldev/gitlive/firebase/FirebaseApp; diff --git a/firebase-app/package.json b/firebase-app/package.json index 2f2153bf8..9fceec0af 100644 --- a/firebase-app/package.json +++ b/firebase-app/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-app", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-app.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-common": "1.13.0", + "@gitlive/firebase-common": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" 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 7a51b210c..2efc65e03 100644 --- a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -14,6 +14,8 @@ public actual typealias FirebaseTooManyRequestsException = com.google.firebase.F public actual typealias FirebaseApiNotAvailableException = com.google.firebase.FirebaseApiNotAvailableException +public val FirebaseApp.android: com.google.firebase.FirebaseApp get() = android + public actual val Firebase.app: FirebaseApp get() = FirebaseApp(com.google.firebase.FirebaseApp.getInstance()) @@ -29,7 +31,7 @@ public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, n 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(val android: com.google.firebase.FirebaseApp) { +public actual data class FirebaseApp internal constructor(internal val android: com.google.firebase.FirebaseApp) { actual val name: String get() = android.name actual val options: FirebaseOptions 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 b770afdc8..ca9d48359 100644 --- a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -12,6 +12,8 @@ public actual open class FirebaseNetworkException(message: String) : FirebaseExc public actual open class FirebaseTooManyRequestsException(message: String) : FirebaseException(message) public actual open class FirebaseApiNotAvailableException(message: String) : FirebaseException(message) +public val FirebaseApp.ios: FIRApp get() = ios + public actual val Firebase.app: FirebaseApp get() = FirebaseApp(FIRApp.defaultApp()!!) @@ -27,7 +29,7 @@ public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, n public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FIRApp.configureWithOptions(options.toIos()).let { app } -public actual data class FirebaseApp internal constructor(val ios: FIRApp) { +public actual data class FirebaseApp internal constructor(internal val ios: FIRApp) { actual val name: String get() = ios.name actual val options: FirebaseOptions 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 1d9797bbd..d51f28633 100644 --- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -26,7 +26,9 @@ public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, n public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(initializeApp(options.toJson())) -public actual class FirebaseApp internal constructor(public val js: JsFirebaseApp) { +public val FirebaseApp.js: JsFirebaseApp get() = js + +public actual class FirebaseApp internal constructor(internal val js: JsFirebaseApp) { public actual val name: String get() = js.name public actual val options: FirebaseOptions diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api index cc211e626..2b74dac8b 100644 --- a/firebase-auth/api/android/firebase-auth.api +++ b/firebase-auth/api/android/firebase-auth.api @@ -74,18 +74,20 @@ public class dev/gitlive/firebase/auth/AuthCredential { } public final class dev/gitlive/firebase/auth/AuthResult { - public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; } public final class dev/gitlive/firebase/auth/AuthTokenResult { public fun (Lcom/google/firebase/auth/GetTokenResult;)V - public final fun getAndroid ()Lcom/google/firebase/auth/GetTokenResult; public final fun getClaims ()Ljava/util/Map; public final fun getSignInProvider ()Ljava/lang/String; public final fun getToken ()Ljava/lang/String; } +public final class dev/gitlive/firebase/auth/CredentialsKt { + public static final fun getAndroid (Lcom/google/firebase/auth/OAuthProvider;)Lcom/google/firebase/auth/OAuthProvider; +} + public final class dev/gitlive/firebase/auth/EmailAuthProvider { public static final field INSTANCE Ldev/gitlive/firebase/auth/EmailAuthProvider; public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; @@ -103,7 +105,6 @@ public final class dev/gitlive/firebase/auth/FirebaseAuth { public final fun confirmPasswordReset (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun createUserWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun fetchSignInMethodsForEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseAuth; public final fun getAuthStateChanged ()Lkotlinx/coroutines/flow/Flow; public final fun getCurrentUser ()Ldev/gitlive/firebase/auth/FirebaseUser; public final fun getIdTokenChanged ()Lkotlinx/coroutines/flow/Flow; @@ -126,7 +127,6 @@ public final class dev/gitlive/firebase/auth/FirebaseAuth { public final class dev/gitlive/firebase/auth/FirebaseUser { public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUser; public final fun getDisplayName ()Ljava/lang/String; public final fun getEmail ()Ljava/lang/String; public final fun getIdToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -169,7 +169,6 @@ public final class dev/gitlive/firebase/auth/GoogleAuthProvider { public final class dev/gitlive/firebase/auth/MultiFactor { public fun (Lcom/google/firebase/auth/MultiFactor;)V public final fun enroll (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactor; public final fun getEnrolledFactors ()Ljava/util/List; public final fun getSession (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun unenroll (Ldev/gitlive/firebase/auth/MultiFactorInfo;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -178,13 +177,11 @@ public final class dev/gitlive/firebase/auth/MultiFactor { public final class dev/gitlive/firebase/auth/MultiFactorAssertion { public fun (Lcom/google/firebase/auth/MultiFactorAssertion;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorAssertion; public final fun getFactorId ()Ljava/lang/String; } public final class dev/gitlive/firebase/auth/MultiFactorInfo { public fun (Lcom/google/firebase/auth/MultiFactorInfo;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorInfo; public final fun getDisplayName ()Ljava/lang/String; public final fun getEnrollmentTime ()D public final fun getFactorId ()Ljava/lang/String; @@ -193,7 +190,6 @@ public final class dev/gitlive/firebase/auth/MultiFactorInfo { public final class dev/gitlive/firebase/auth/MultiFactorResolver { public fun (Lcom/google/firebase/auth/MultiFactorResolver;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorResolver; public final fun getAuth ()Ldev/gitlive/firebase/auth/FirebaseAuth; public final fun getHints ()Ljava/util/List; public final fun getSession ()Ldev/gitlive/firebase/auth/MultiFactorSession; @@ -202,7 +198,14 @@ public final class dev/gitlive/firebase/auth/MultiFactorResolver { public final class dev/gitlive/firebase/auth/MultiFactorSession { public fun (Lcom/google/firebase/auth/MultiFactorSession;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorSession; +} + +public final class dev/gitlive/firebase/auth/MultifactorKt { + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactor;)Lcom/google/firebase/auth/MultiFactor; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorAssertion;)Lcom/google/firebase/auth/MultiFactorAssertion; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorInfo;)Lcom/google/firebase/auth/MultiFactorInfo; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorResolver;)Lcom/google/firebase/auth/MultiFactorResolver; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorSession;)Lcom/google/firebase/auth/MultiFactorSession; } public final class dev/gitlive/firebase/auth/OAuthCredential : dev/gitlive/firebase/auth/AuthCredential { @@ -216,7 +219,6 @@ public final class dev/gitlive/firebase/auth/OAuthProvider { public fun (Lcom/google/firebase/auth/OAuthProvider;)V public fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;)V public synthetic fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getAndroid ()Lcom/google/firebase/auth/OAuthProvider; } public final class dev/gitlive/firebase/auth/OAuthProvider$Companion { @@ -254,7 +256,6 @@ public final class dev/gitlive/firebase/auth/TwitterAuthProvider { public final class dev/gitlive/firebase/auth/UserInfo { public fun (Lcom/google/firebase/auth/UserInfo;)V - public final fun getAndroid ()Lcom/google/firebase/auth/UserInfo; public final fun getDisplayName ()Ljava/lang/String; public final fun getEmail ()Ljava/lang/String; public final fun getPhoneNumber ()Ljava/lang/String; @@ -263,15 +264,23 @@ public final class dev/gitlive/firebase/auth/UserInfo { public final fun getUid ()Ljava/lang/String; } +public final class dev/gitlive/firebase/auth/UserKt { + public static final fun getAndroid (Ldev/gitlive/firebase/auth/FirebaseUser;)Lcom/google/firebase/auth/FirebaseUser; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserInfo;)Lcom/google/firebase/auth/UserInfo; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserMetaData;)Lcom/google/firebase/auth/FirebaseUserMetadata; +} + public final class dev/gitlive/firebase/auth/UserMetaData { public fun (Lcom/google/firebase/auth/FirebaseUserMetadata;)V - public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUserMetadata; public final fun getCreationTime ()Ljava/lang/Double; public final fun getLastSignInTime ()Ljava/lang/Double; } public final class dev/gitlive/firebase/auth/android { public static final fun auth (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/auth/FirebaseAuth; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/AuthResult;)Lcom/google/firebase/auth/AuthResult; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/AuthTokenResult;)Lcom/google/firebase/auth/GetTokenResult; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/FirebaseAuth;)Lcom/google/firebase/auth/FirebaseAuth; public static final fun getAuth (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/auth/FirebaseAuth; } diff --git a/firebase-auth/api/jvm/firebase-auth.api b/firebase-auth/api/jvm/firebase-auth.api index 3afffeac4..170ac9afa 100644 --- a/firebase-auth/api/jvm/firebase-auth.api +++ b/firebase-auth/api/jvm/firebase-auth.api @@ -74,18 +74,21 @@ public class dev/gitlive/firebase/auth/AuthCredential { } public final class dev/gitlive/firebase/auth/AuthResult { - public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; } public final class dev/gitlive/firebase/auth/AuthTokenResult { public fun (Lcom/google/firebase/auth/GetTokenResult;)V - public final fun getAndroid ()Lcom/google/firebase/auth/GetTokenResult; public final fun getClaims ()Ljava/util/Map; public final fun getSignInProvider ()Ljava/lang/String; public final fun getToken ()Ljava/lang/String; } +public final class dev/gitlive/firebase/auth/CredentialsKt { + public static final fun getAndroid (Lcom/google/firebase/auth/OAuthProvider;)Lcom/google/firebase/auth/OAuthProvider; + public static final fun getAndroid (Lcom/google/firebase/auth/PhoneAuthProvider;)Lcom/google/firebase/auth/PhoneAuthProvider; +} + public final class dev/gitlive/firebase/auth/EmailAuthProvider { public static final field INSTANCE Ldev/gitlive/firebase/auth/EmailAuthProvider; public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential; @@ -103,7 +106,6 @@ public final class dev/gitlive/firebase/auth/FirebaseAuth { public final fun confirmPasswordReset (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun createUserWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun fetchSignInMethodsForEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseAuth; public final fun getAuthStateChanged ()Lkotlinx/coroutines/flow/Flow; public final fun getCurrentUser ()Ldev/gitlive/firebase/auth/FirebaseUser; public final fun getIdTokenChanged ()Lkotlinx/coroutines/flow/Flow; @@ -126,7 +128,6 @@ public final class dev/gitlive/firebase/auth/FirebaseAuth { public final class dev/gitlive/firebase/auth/FirebaseUser { public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUser; public final fun getDisplayName ()Ljava/lang/String; public final fun getEmail ()Ljava/lang/String; public final fun getIdToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -169,7 +170,6 @@ public final class dev/gitlive/firebase/auth/GoogleAuthProvider { public final class dev/gitlive/firebase/auth/MultiFactor { public fun (Lcom/google/firebase/auth/MultiFactor;)V public final fun enroll (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactor; public final fun getEnrolledFactors ()Ljava/util/List; public final fun getSession (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun unenroll (Ldev/gitlive/firebase/auth/MultiFactorInfo;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -178,13 +178,11 @@ public final class dev/gitlive/firebase/auth/MultiFactor { public final class dev/gitlive/firebase/auth/MultiFactorAssertion { public fun (Lcom/google/firebase/auth/MultiFactorAssertion;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorAssertion; public final fun getFactorId ()Ljava/lang/String; } public final class dev/gitlive/firebase/auth/MultiFactorInfo { public fun (Lcom/google/firebase/auth/MultiFactorInfo;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorInfo; public final fun getDisplayName ()Ljava/lang/String; public final fun getEnrollmentTime ()D public final fun getFactorId ()Ljava/lang/String; @@ -193,7 +191,6 @@ public final class dev/gitlive/firebase/auth/MultiFactorInfo { public final class dev/gitlive/firebase/auth/MultiFactorResolver { public fun (Lcom/google/firebase/auth/MultiFactorResolver;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorResolver; public final fun getAuth ()Ldev/gitlive/firebase/auth/FirebaseAuth; public final fun getHints ()Ljava/util/List; public final fun getSession ()Ldev/gitlive/firebase/auth/MultiFactorSession; @@ -202,7 +199,14 @@ public final class dev/gitlive/firebase/auth/MultiFactorResolver { public final class dev/gitlive/firebase/auth/MultiFactorSession { public fun (Lcom/google/firebase/auth/MultiFactorSession;)V - public final fun getAndroid ()Lcom/google/firebase/auth/MultiFactorSession; +} + +public final class dev/gitlive/firebase/auth/MultifactorKt { + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactor;)Lcom/google/firebase/auth/MultiFactor; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorAssertion;)Lcom/google/firebase/auth/MultiFactorAssertion; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorInfo;)Lcom/google/firebase/auth/MultiFactorInfo; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorResolver;)Lcom/google/firebase/auth/MultiFactorResolver; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorSession;)Lcom/google/firebase/auth/MultiFactorSession; } public final class dev/gitlive/firebase/auth/OAuthCredential : dev/gitlive/firebase/auth/AuthCredential { @@ -216,7 +220,6 @@ public final class dev/gitlive/firebase/auth/OAuthProvider { public fun (Lcom/google/firebase/auth/OAuthProvider;)V public fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;)V public synthetic fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun getAndroid ()Lcom/google/firebase/auth/OAuthProvider; } public final class dev/gitlive/firebase/auth/OAuthProvider$Companion { @@ -235,7 +238,6 @@ public final class dev/gitlive/firebase/auth/PhoneAuthProvider { public fun (Ldev/gitlive/firebase/auth/FirebaseAuth;)V public synthetic fun (Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/PhoneAuthCredential; - public final fun getAndroid ()Lcom/google/firebase/auth/PhoneAuthProvider; public final fun verifyPhoneNumber (Ljava/lang/String;Ldev/gitlive/firebase/auth/PhoneVerificationProvider;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } @@ -254,7 +256,6 @@ public final class dev/gitlive/firebase/auth/TwitterAuthProvider { public final class dev/gitlive/firebase/auth/UserInfo { public fun (Lcom/google/firebase/auth/UserInfo;)V - public final fun getAndroid ()Lcom/google/firebase/auth/UserInfo; public final fun getDisplayName ()Ljava/lang/String; public final fun getEmail ()Ljava/lang/String; public final fun getPhoneNumber ()Ljava/lang/String; @@ -263,15 +264,22 @@ public final class dev/gitlive/firebase/auth/UserInfo { public final fun getUid ()Ljava/lang/String; } +public final class dev/gitlive/firebase/auth/UserKt { + public static final fun getAndroid (Ldev/gitlive/firebase/auth/FirebaseUser;)Lcom/google/firebase/auth/FirebaseUser; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserInfo;)Lcom/google/firebase/auth/UserInfo; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserMetaData;)Lcom/google/firebase/auth/FirebaseUserMetadata; +} + public final class dev/gitlive/firebase/auth/UserMetaData { public fun (Lcom/google/firebase/auth/FirebaseUserMetadata;)V - public final fun getAndroid ()Lcom/google/firebase/auth/FirebaseUserMetadata; public final fun getCreationTime ()Ljava/lang/Double; public final fun getLastSignInTime ()Ljava/lang/Double; } public final class dev/gitlive/firebase/auth/android { public static final fun auth (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/auth/FirebaseAuth; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/AuthResult;)Lcom/google/firebase/auth/AuthResult; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/AuthTokenResult;)Lcom/google/firebase/auth/GetTokenResult; public static final fun getAuth (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/auth/FirebaseAuth; } diff --git a/firebase-auth/package.json b/firebase-auth/package.json index 8a499285a..23da53f91 100644 --- a/firebase-auth/package.json +++ b/firebase-auth/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-auth", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-auth.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" 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 3bd7ae6f2..fec2e73a0 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 @@ -12,18 +12,21 @@ import com.google.firebase.auth.ActionCodeResult.* import com.google.firebase.auth.FirebaseAuth.AuthStateListener import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android as publicAndroid import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.tasks.await +public val FirebaseAuth.android: com.google.firebase.auth.FirebaseAuth get() = com.google.firebase.auth.FirebaseAuth.getInstance() + 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.android)) + FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) -public actual class FirebaseAuth internal constructor(public val android: com.google.firebase.auth.FirebaseAuth) { +public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) { public actual val currentUser: FirebaseUser? get() = android.currentUser?.let { FirebaseUser(it) } @@ -113,12 +116,16 @@ public actual class FirebaseAuth internal constructor(public val android: com.go public actual fun useEmulator(host: String, port: Int): Unit = android.useEmulator(host, port) } -public actual class AuthResult internal constructor(public val android: com.google.firebase.auth.AuthResult) { +public val AuthResult.android: com.google.firebase.auth.AuthResult get() = android + +public actual class AuthResult internal constructor(internal val android: com.google.firebase.auth.AuthResult) { public actual val user: FirebaseUser? get() = android.user?.let { FirebaseUser(it) } } -public actual class AuthTokenResult(public val android: com.google.firebase.auth.GetTokenResult) { +public val AuthTokenResult.android: com.google.firebase.auth.GetTokenResult get() = android + +public actual class AuthTokenResult(internal val android: com.google.firebase.auth.GetTokenResult) { // actual val authTimestamp: Long // get() = android.authTimestamp public actual val claims: Map diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index de450c71e..8c5b95978 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -52,7 +52,9 @@ public actual object GoogleAuthProvider { } } -public actual class OAuthProvider(public val android: OAuthProvider) { +public val OAuthProvider.android: OAuthProvider get() = android + +public actual class OAuthProvider(internal val android: OAuthProvider) { public actual constructor( provider: String, diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 6b60e36a7..8a32d501f 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -6,7 +6,9 @@ package dev.gitlive.firebase.auth import kotlinx.coroutines.tasks.await -public actual class MultiFactor(public val android: com.google.firebase.auth.MultiFactor) { +public val MultiFactor.android: com.google.firebase.auth.MultiFactor get() = android + +public actual class MultiFactor(internal val android: com.google.firebase.auth.MultiFactor) { public actual val enrolledFactors: List get() = android.enrolledFactors.map { MultiFactorInfo(it) } public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) { @@ -21,7 +23,9 @@ public actual class MultiFactor(public val android: com.google.firebase.auth.Mul } } -public actual class MultiFactorInfo(public val android: com.google.firebase.auth.MultiFactorInfo) { +public val MultiFactorInfo.android: com.google.firebase.auth.MultiFactorInfo get() = android + +public actual class MultiFactorInfo(internal val android: com.google.firebase.auth.MultiFactorInfo) { public actual val displayName: String? get() = android.displayName public actual val enrollmentTime: Double @@ -32,14 +36,20 @@ public actual class MultiFactorInfo(public val android: com.google.firebase.auth get() = android.uid } -public actual class MultiFactorAssertion(public val android: com.google.firebase.auth.MultiFactorAssertion) { +public val MultiFactorAssertion.android: com.google.firebase.auth.MultiFactorAssertion get() = android + +public actual class MultiFactorAssertion(internal val android: com.google.firebase.auth.MultiFactorAssertion) { public actual val factorId: String get() = android.factorId } -public actual class MultiFactorSession(public val android: com.google.firebase.auth.MultiFactorSession) +public val MultiFactorSession.android: com.google.firebase.auth.MultiFactorSession get() = android + +public actual class MultiFactorSession(internal val android: com.google.firebase.auth.MultiFactorSession) + +public val MultiFactorResolver.android: com.google.firebase.auth.MultiFactorResolver get() = android -public actual class MultiFactorResolver(public val android: com.google.firebase.auth.MultiFactorResolver) { +public actual class MultiFactorResolver(internal val android: com.google.firebase.auth.MultiFactorResolver) { public actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth) public actual val hints: List = android.hints.map { MultiFactorInfo(it) } public actual val session: MultiFactorSession = MultiFactorSession(android.session) diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt index 8428d6a0e..8fa60207a 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -8,7 +8,9 @@ import android.net.Uri import com.google.firebase.auth.UserProfileChangeRequest import kotlinx.coroutines.tasks.await -public actual class FirebaseUser internal constructor(public val android: com.google.firebase.auth.FirebaseUser) { +public val FirebaseUser.android: com.google.firebase.auth.FirebaseUser get() = android + +public actual class FirebaseUser internal constructor(internal val android: com.google.firebase.auth.FirebaseUser) { public actual val uid: String get() = android.uid public actual val displayName: String? @@ -72,7 +74,9 @@ public actual class FirebaseUser internal constructor(public val android: com.go } } -public actual class UserInfo(public val android: com.google.firebase.auth.UserInfo) { +public val UserInfo.android: com.google.firebase.auth.UserInfo get() = android + +public actual class UserInfo(internal val android: com.google.firebase.auth.UserInfo) { public actual val displayName: String? get() = android.displayName public actual val email: String? @@ -87,7 +91,9 @@ public actual class UserInfo(public val android: com.google.firebase.auth.UserIn get() = android.uid } -public actual class UserMetaData(public val android: com.google.firebase.auth.FirebaseUserMetadata) { +public val UserMetaData.android: com.google.firebase.auth.FirebaseUserMetadata get() = android + +public actual class UserMetaData(internal val android: com.google.firebase.auth.FirebaseUserMetadata) { public actual val creationTime: Double? get() = android.creationTimestamp.toDouble() public actual val lastSignInTime: Double? 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 9e86469c9..b659b0c68 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 @@ -10,6 +10,7 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.FirebaseNetworkException import dev.gitlive.firebase.auth.ActionCodeResult.* +import dev.gitlive.firebase.ios import kotlinx.cinterop.* import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.channels.awaitClose @@ -18,6 +19,8 @@ import kotlinx.coroutines.flow.Flow import platform.Foundation.NSError import platform.Foundation.NSURL +public val FirebaseAuth.ios: FIRAuth get() = FIRAuth.auth() + public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(FIRAuth.auth()) @@ -25,7 +28,7 @@ public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth( FIRAuth.authWithApp(app.ios as objcnames.classes.FIRApp), ) -public actual class FirebaseAuth internal constructor(public val ios: FIRAuth) { +public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) { public actual val currentUser: FirebaseUser? get() = ios.currentUser?.let { FirebaseUser(it) } @@ -101,13 +104,15 @@ public actual class FirebaseAuth internal constructor(public val ios: FIRAuth) { public actual fun useEmulator(host: String, port: Int): Unit = ios.useEmulatorWithHost(host, port.toLong()) } +public val AuthResult.ios: FIRAuthDataResult get() = ios -public actual class AuthResult internal constructor(public val ios: FIRAuthDataResult) { +public actual class AuthResult internal constructor(internal val ios: FIRAuthDataResult) { public actual val user: FirebaseUser? get() = FirebaseUser(ios.user) } -public actual class AuthTokenResult(public val ios: FIRAuthTokenResult) { +public val AuthTokenResult.ios: FIRAuthTokenResult get() = ios +public actual class AuthTokenResult(internal val ios: FIRAuthTokenResult) { // actual val authTimestamp: Long // get() = ios.authDate public actual val claims: Map 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 217c4e49b..08387a0e1 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 @@ -44,7 +44,9 @@ public actual object GoogleAuthProvider { } } -public actual class OAuthProvider(public val ios: FIROAuthProvider) { +public val OAuthProvider.ios: FIROAuthProvider get() = ios + +public actual class OAuthProvider(internal val ios: FIROAuthProvider) { public actual constructor( provider: String, @@ -70,7 +72,9 @@ public actual class OAuthProvider(public val ios: FIROAuthProvider) { } } -public actual class PhoneAuthProvider(public val ios: FIRPhoneAuthProvider) { +public val PhoneAuthProvider.ios: FIRPhoneAuthProvider get() = ios + +public actual class PhoneAuthProvider(internal val ios: FIRPhoneAuthProvider) { public actual constructor(auth: FirebaseAuth) : this(FIRPhoneAuthProvider.providerWithAuth(auth.ios)) diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 8d0a5d6e5..f389b6abb 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -6,7 +6,9 @@ package dev.gitlive.firebase.auth import cocoapods.FirebaseAuth.* -public actual class MultiFactor(public val ios: FIRMultiFactor) { +public val MultiFactor.ios: FIRMultiFactor get() = ios + +public actual class MultiFactor(internal val ios: FIRMultiFactor) { public actual val enrolledFactors: List get() = ios.enrolledFactors.mapNotNull { info -> (info as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = ios.await { enrollWithAssertion(multiFactorAssertion.ios, displayName, it) } @@ -15,7 +17,9 @@ public actual class MultiFactor(public val ios: FIRMultiFactor) { public actual suspend fun unenroll(factorUid: String): Unit = ios.await { unenrollWithFactorUID(factorUid, it) } } -public actual class MultiFactorInfo(public val ios: FIRMultiFactorInfo) { +public val MultiFactorInfo.ios: FIRMultiFactorInfo get() = ios + +public actual class MultiFactorInfo(internal val ios: FIRMultiFactorInfo) { public actual val displayName: String? get() = ios.displayName public actual val enrollmentTime: Double @@ -26,14 +30,20 @@ public actual class MultiFactorInfo(public val ios: FIRMultiFactorInfo) { get() = ios.UID } -public actual class MultiFactorAssertion(public val ios: FIRMultiFactorAssertion) { +public val MultiFactorAssertion.ios: FIRMultiFactorAssertion get() = ios + +public actual class MultiFactorAssertion(internal val ios: FIRMultiFactorAssertion) { public actual val factorId: String get() = ios.factorID } -public actual class MultiFactorSession(public val ios: FIRMultiFactorSession) +public val MultiFactorSession.ios: FIRMultiFactorSession get() = ios + +public actual class MultiFactorSession(internal val ios: FIRMultiFactorSession) + +public val MultiFactorResolver.ios: FIRMultiFactorResolver get() = ios -public actual class MultiFactorResolver(public val ios: FIRMultiFactorResolver) { +public actual class MultiFactorResolver(internal val ios: FIRMultiFactorResolver) { public actual val auth: FirebaseAuth = FirebaseAuth(ios.auth) public actual val hints: List = ios.hints.mapNotNull { hint -> (hint as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } public actual val session: MultiFactorSession = MultiFactorSession(ios.session) 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 3dd735a90..f2f6c67cc 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 @@ -10,7 +10,9 @@ import cocoapods.FirebaseAuth.FIRUserInfoProtocol import cocoapods.FirebaseAuth.FIRUserMetadata import platform.Foundation.NSURL -public actual class FirebaseUser internal constructor(public val ios: FIRUser) { +public val FirebaseUser.ios: FIRUser get() = ios + +public actual class FirebaseUser internal constructor(internal val ios: FIRUser) { public actual val uid: String get() = ios.uid public actual val displayName: String? @@ -79,7 +81,9 @@ public actual class FirebaseUser internal constructor(public val ios: FIRUser) { } } -public actual class UserInfo(public val ios: FIRUserInfoProtocol) { +public val UserInfo.ios: FIRUserInfoProtocol get() = ios + +public actual class UserInfo(internal val ios: FIRUserInfoProtocol) { public actual val displayName: String? get() = ios.displayName public actual val email: String? @@ -94,7 +98,9 @@ public actual class UserInfo(public val ios: FIRUserInfoProtocol) { get() = ios.uid } -public actual class UserMetaData(public val ios: FIRUserMetadata) { +public val UserMetaData.ios: FIRUserMetadata get() = ios + +public actual class UserMetaData(internal val ios: FIRUserMetadata) { public actual val creationTime: Double? get() = ios.creationDate?.timeIntervalSinceReferenceDate public actual val lastSignInTime: Double? 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 c23c2a42b..a222d4d6e 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 @@ -8,7 +8,27 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.FirebaseNetworkException -import dev.gitlive.firebase.auth.externals.* +import dev.gitlive.firebase.auth.externals.Auth +import dev.gitlive.firebase.auth.externals.getAuth +import dev.gitlive.firebase.auth.externals.applyActionCode +import dev.gitlive.firebase.auth.externals.confirmPasswordReset +import dev.gitlive.firebase.auth.externals.createUserWithEmailAndPassword +import dev.gitlive.firebase.auth.externals.sendPasswordResetEmail +import dev.gitlive.firebase.auth.externals.fetchSignInMethodsForEmail +import dev.gitlive.firebase.auth.externals.sendSignInLinkToEmail +import dev.gitlive.firebase.auth.externals.isSignInWithEmailLink +import dev.gitlive.firebase.auth.externals.signInWithEmailAndPassword +import dev.gitlive.firebase.auth.externals.signInWithCustomToken +import dev.gitlive.firebase.auth.externals.signInAnonymously +import dev.gitlive.firebase.auth.externals.signInWithCredential +import dev.gitlive.firebase.auth.externals.signInWithEmailLink +import dev.gitlive.firebase.auth.externals.signOut +import dev.gitlive.firebase.auth.externals.updateCurrentUser +import dev.gitlive.firebase.auth.externals.verifyPasswordResetCode +import dev.gitlive.firebase.auth.externals.checkActionCode +import dev.gitlive.firebase.auth.externals.connectAuthEmulator +import dev.gitlive.firebase.auth.externals.IdTokenResult +import dev.gitlive.firebase.js import kotlinx.coroutines.await import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow @@ -22,7 +42,9 @@ public actual val Firebase.auth: FirebaseAuth public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = rethrow { FirebaseAuth(getAuth(app.js)) } -public actual class FirebaseAuth internal constructor(public val js: Auth) { +public val FirebaseAuth.js: Auth get() = js + +public actual class FirebaseAuth internal constructor(internal val js: Auth) { public actual val currentUser: FirebaseUser? get() = rethrow { js.currentUser?.let { FirebaseUser(it) } } @@ -109,12 +131,16 @@ public actual class FirebaseAuth internal constructor(public val js: Auth) { public actual fun useEmulator(host: String, port: Int): Unit = rethrow { connectAuthEmulator(js, "http://$host:$port") } } -public actual class AuthResult internal constructor(public val js: JsAuthResult) { +public val AuthResult.js: JsAuthResult get() = js + +public actual class AuthResult internal constructor(internal val js: JsAuthResult) { public actual val user: FirebaseUser? get() = rethrow { js.user?.let { FirebaseUser(it) } } } -public actual class AuthTokenResult(public val js: IdTokenResult) { +public val AuthTokenResult.js: IdTokenResult get() = js + +public actual class AuthTokenResult(internal val js: IdTokenResult) { // actual val authTimestamp: Long // get() = js.authTime public actual val claims: Map 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 cebe872d6..112099734 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 @@ -5,14 +5,16 @@ import dev.gitlive.firebase.auth.externals.EmailAuthProvider import dev.gitlive.firebase.auth.externals.FacebookAuthProvider import dev.gitlive.firebase.auth.externals.GithubAuthProvider import dev.gitlive.firebase.auth.externals.GoogleAuthProvider -import dev.gitlive.firebase.auth.externals.PhoneAuthProvider +import dev.gitlive.firebase.auth.externals.PhoneAuthProvider as JsPhoneAuthProvider import dev.gitlive.firebase.auth.externals.TwitterAuthProvider import kotlinx.coroutines.await import kotlin.js.json import dev.gitlive.firebase.auth.externals.AuthCredential as JsAuthCredential import dev.gitlive.firebase.auth.externals.OAuthProvider as JsOAuthProvider -public actual open class AuthCredential(public val js: JsAuthCredential) { +public val AuthCredential.js: JsAuthCredential get() = js + +public actual open class AuthCredential(internal val js: JsAuthCredential) { public actual val providerId: String get() = js.providerId } @@ -49,7 +51,9 @@ public actual object GoogleAuthProvider { } } -public actual class OAuthProvider(public val js: JsOAuthProvider) { +public val OAuthProvider.js: JsOAuthProvider get() = js + +public actual class OAuthProvider(internal val js: JsOAuthProvider) { public actual constructor( provider: String, @@ -78,11 +82,13 @@ public actual class OAuthProvider(public val js: JsOAuthProvider) { } } -public actual class PhoneAuthProvider(public val js: PhoneAuthProvider) { +public val PhoneAuthProvider.js: JsPhoneAuthProvider get() = js + +public actual class PhoneAuthProvider(internal val js: JsPhoneAuthProvider) { - public actual constructor(auth: FirebaseAuth) : this(PhoneAuthProvider(auth.js)) + public actual constructor(auth: FirebaseAuth) : this(JsPhoneAuthProvider(auth.js)) - public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(PhoneAuthProvider.credential(verificationId, smsCode)) + public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(JsPhoneAuthProvider.credential(verificationId, smsCode)) public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = rethrow { val verificationId = js.verifyPhoneNumber(phoneNumber, verificationProvider.verifier).await() val verificationCode = verificationProvider.getVerificationCode(verificationId) 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 ce4636ad5..36daf9f4f 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -8,7 +8,9 @@ import dev.gitlive.firebase.auth.externals.MultiFactorInfo as JsMultiFactorInfo import dev.gitlive.firebase.auth.externals.MultiFactorResolver as JsMultiFactorResolver import dev.gitlive.firebase.auth.externals.MultiFactorSession as JsMultiFactorSession -public actual class MultiFactor(public val js: MultiFactorUser) { +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 = @@ -21,7 +23,9 @@ public actual class MultiFactor(public val js: MultiFactorUser) { rethrow { js.unenroll(factorUid).await() } } -public actual class MultiFactorInfo(public val js: JsMultiFactorInfo) { +public val MultiFactorInfo.js get() = js + +public actual class MultiFactorInfo(internal val js: JsMultiFactorInfo) { public actual val displayName: String? get() = rethrow { js.displayName } public actual val enrollmentTime: Double @@ -32,14 +36,20 @@ public actual class MultiFactorInfo(public val js: JsMultiFactorInfo) { get() = rethrow { js.uid } } -public actual class MultiFactorAssertion(public val js: JsMultiFactorAssertion) { +public val MultiFactorAssertion.js get() = js + +public actual class MultiFactorAssertion(internal val js: JsMultiFactorAssertion) { public actual val factorId: String get() = rethrow { js.factorId } } -public actual class MultiFactorSession(public val js: JsMultiFactorSession) +public val MultiFactorSession.js get() = js + +public actual class MultiFactorSession(internal val js: JsMultiFactorSession) + +public val MultiFactorResolver.js get() = js -public actual class MultiFactorResolver(public val js: JsMultiFactorResolver) { +public actual class MultiFactorResolver(internal val js: JsMultiFactorResolver) { public actual val auth: FirebaseAuth = rethrow { FirebaseAuth(js.auth) } public actual val hints: List = rethrow { js.hints.map { MultiFactorInfo(it) } } public actual val session: MultiFactorSession = rethrow { MultiFactorSession(js.session) } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt index 82dcc3baf..179cff18f 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -6,7 +6,9 @@ import kotlin.js.Date import dev.gitlive.firebase.auth.externals.UserInfo as JsUserInfo import kotlin.js.json -public actual class FirebaseUser internal constructor(public val js: User) { +public val FirebaseUser.js get() = js + +public actual class FirebaseUser internal constructor(internal val js: User) { public actual val uid: String get() = rethrow { js.uid } public actual val displayName: String? @@ -55,7 +57,9 @@ public actual class FirebaseUser internal constructor(public val js: User) { public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?): Unit = rethrow { verifyBeforeUpdateEmail(js, newEmail, actionCodeSettings?.toJson()).await() } } -public actual class UserInfo(public val js: JsUserInfo) { +public val UserInfo.js get() = js + +public actual class UserInfo(internal val js: JsUserInfo) { public actual val displayName: String? get() = rethrow { js.displayName } public actual val email: String? @@ -70,7 +74,9 @@ public actual class UserInfo(public val js: JsUserInfo) { get() = rethrow { js.uid } } -public actual class UserMetaData(public val js: UserMetadata) { +public val UserMetaData.js get() = js + +public actual class UserMetaData(internal val js: UserMetadata) { public actual val creationTime: Double? get() = rethrow { js.creationTime?.let { (Date(it).getTime() / 1000.0) } } public actual val lastSignInTime: Double? diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 03716df99..670fda529 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 @@ -12,6 +12,7 @@ import com.google.firebase.auth.ActionCodeResult.* import com.google.firebase.auth.FirebaseAuth.AuthStateListener import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android as publicAndroid import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow @@ -21,9 +22,9 @@ public actual val Firebase.auth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) public actual fun Firebase.auth(app: FirebaseApp) = - FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.android)) + FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid)) -public actual class FirebaseAuth internal constructor(public val android: com.google.firebase.auth.FirebaseAuth) { +public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) { public actual val currentUser: FirebaseUser? get() = android.currentUser?.let { FirebaseUser(it) } @@ -123,12 +124,16 @@ public actual class FirebaseAuth internal constructor(public val android: com.go } } -public actual class AuthResult internal constructor(public val android: com.google.firebase.auth.AuthResult) { +public val AuthResult.android: com.google.firebase.auth.AuthResult get() = android + +public actual class AuthResult internal constructor(internal val android: com.google.firebase.auth.AuthResult) { public actual val user: FirebaseUser? get() = android.user?.let { FirebaseUser(it) } } -public actual class AuthTokenResult(public val android: com.google.firebase.auth.GetTokenResult) { +public val AuthTokenResult.android: com.google.firebase.auth.GetTokenResult get() = android + +public actual class AuthTokenResult(internal val android: com.google.firebase.auth.GetTokenResult) { // actual val authTimestamp: Long // get() = android.authTimestamp public actual val claims: Map diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 7c372681d..055f5dc9f 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -52,7 +52,9 @@ public actual object GoogleAuthProvider { } } -public actual class OAuthProvider(public val android: com.google.firebase.auth.OAuthProvider) { +public val OAuthProvider.android: com.google.firebase.auth.OAuthProvider get() = android + +public actual class OAuthProvider(internal val android: com.google.firebase.auth.OAuthProvider) { public actual constructor( provider: String, @@ -78,7 +80,9 @@ public actual class OAuthProvider(public val android: com.google.firebase.auth.O } } -public actual class PhoneAuthProvider(public val android: com.google.firebase.auth.PhoneAuthProvider) { +public val PhoneAuthProvider.android: com.google.firebase.auth.PhoneAuthProvider get() = android + +public actual class PhoneAuthProvider(internal val android: com.google.firebase.auth.PhoneAuthProvider) { public actual constructor(auth: FirebaseAuth) : this(com.google.firebase.auth.PhoneAuthProvider.getInstance(auth.android)) diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index 6b60e36a7..8a32d501f 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -6,7 +6,9 @@ package dev.gitlive.firebase.auth import kotlinx.coroutines.tasks.await -public actual class MultiFactor(public val android: com.google.firebase.auth.MultiFactor) { +public val MultiFactor.android: com.google.firebase.auth.MultiFactor get() = android + +public actual class MultiFactor(internal val android: com.google.firebase.auth.MultiFactor) { public actual val enrolledFactors: List get() = android.enrolledFactors.map { MultiFactorInfo(it) } public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) { @@ -21,7 +23,9 @@ public actual class MultiFactor(public val android: com.google.firebase.auth.Mul } } -public actual class MultiFactorInfo(public val android: com.google.firebase.auth.MultiFactorInfo) { +public val MultiFactorInfo.android: com.google.firebase.auth.MultiFactorInfo get() = android + +public actual class MultiFactorInfo(internal val android: com.google.firebase.auth.MultiFactorInfo) { public actual val displayName: String? get() = android.displayName public actual val enrollmentTime: Double @@ -32,14 +36,20 @@ public actual class MultiFactorInfo(public val android: com.google.firebase.auth get() = android.uid } -public actual class MultiFactorAssertion(public val android: com.google.firebase.auth.MultiFactorAssertion) { +public val MultiFactorAssertion.android: com.google.firebase.auth.MultiFactorAssertion get() = android + +public actual class MultiFactorAssertion(internal val android: com.google.firebase.auth.MultiFactorAssertion) { public actual val factorId: String get() = android.factorId } -public actual class MultiFactorSession(public val android: com.google.firebase.auth.MultiFactorSession) +public val MultiFactorSession.android: com.google.firebase.auth.MultiFactorSession get() = android + +public actual class MultiFactorSession(internal val android: com.google.firebase.auth.MultiFactorSession) + +public val MultiFactorResolver.android: com.google.firebase.auth.MultiFactorResolver get() = android -public actual class MultiFactorResolver(public val android: com.google.firebase.auth.MultiFactorResolver) { +public actual class MultiFactorResolver(internal val android: com.google.firebase.auth.MultiFactorResolver) { public actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth) public actual val hints: List = android.hints.map { MultiFactorInfo(it) } public actual val session: MultiFactorSession = MultiFactorSession(android.session) diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt index 812dc5ac3..480bbb67c 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -8,7 +8,9 @@ import android.net.Uri import com.google.firebase.auth.UserProfileChangeRequest import kotlinx.coroutines.tasks.await -public actual class FirebaseUser internal constructor(public val android: com.google.firebase.auth.FirebaseUser) { +public val FirebaseUser.android: com.google.firebase.auth.FirebaseUser get() = android + +public actual class FirebaseUser internal constructor(internal val android: com.google.firebase.auth.FirebaseUser) { public actual val uid: String get() = android.uid public actual val displayName: String? @@ -70,7 +72,9 @@ public actual class FirebaseUser internal constructor(public val android: com.go } } -public actual class UserInfo(public val android: com.google.firebase.auth.UserInfo) { +public val UserInfo.android: com.google.firebase.auth.UserInfo get() = android + +public actual class UserInfo(internal val android: com.google.firebase.auth.UserInfo) { public actual val displayName: String? get() = android.displayName public actual val email: String? @@ -85,7 +89,9 @@ public actual class UserInfo(public val android: com.google.firebase.auth.UserIn get() = android.uid } -public actual class UserMetaData(public val android: com.google.firebase.auth.FirebaseUserMetadata) { +public val UserMetaData.android: com.google.firebase.auth.FirebaseUserMetadata get() = android + +public actual class UserMetaData(internal val android: com.google.firebase.auth.FirebaseUserMetadata) { public actual val creationTime: Double? get() = android.creationTimestamp.toDouble() public actual val lastSignInTime: Double? diff --git a/firebase-common-internal/package.json b/firebase-common-internal/package.json index 4d43459bf..c1a555b9e 100644 --- a/firebase-common-internal/package.json +++ b/firebase-common-internal/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-common-internal", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-common-internal.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-multiplatform-sdk", "dependencies": { - "@gitlive/firebase-common": "1.13.0", + "@gitlive/firebase-common": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4", diff --git a/firebase-common/package.json b/firebase-common/package.json index 76a1013a3..ac1374d45 100644 --- a/firebase-common/package.json +++ b/firebase-common/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-common", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-common.js", "scripts": { diff --git a/firebase-config/api/android/firebase-config.api b/firebase-config/api/android/firebase-config.api index b514f6d51..d9d718ce8 100644 --- a/firebase-config/api/android/firebase-config.api +++ b/firebase-config/api/android/firebase-config.api @@ -15,7 +15,6 @@ public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig { public static synthetic fun fetch-dnQKTGw$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Lkotlin/time/Duration;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun fetchAndActivate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun getAll ()Ljava/util/Map; - public final fun getAndroid ()Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig; public final fun getInfo ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; public final fun getKeysByPrefix (Ljava/lang/String;)Ljava/util/Set; public final fun getValue (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue; @@ -83,6 +82,7 @@ public final class dev/gitlive/firebase/remoteconfig/ValueSource : java/lang/Enu } public final class dev/gitlive/firebase/remoteconfig/android { + public static final fun getAndroid (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;)Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig; public static final fun getRemoteConfig (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; public static final fun remoteConfig (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; } diff --git a/firebase-config/api/jvm/firebase-config.api b/firebase-config/api/jvm/firebase-config.api index b514f6d51..d9d718ce8 100644 --- a/firebase-config/api/jvm/firebase-config.api +++ b/firebase-config/api/jvm/firebase-config.api @@ -15,7 +15,6 @@ public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig { public static synthetic fun fetch-dnQKTGw$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Lkotlin/time/Duration;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public final fun fetchAndActivate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun getAll ()Ljava/util/Map; - public final fun getAndroid ()Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig; public final fun getInfo ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo; public final fun getKeysByPrefix (Ljava/lang/String;)Ljava/util/Set; public final fun getValue (Ljava/lang/String;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue; @@ -83,6 +82,7 @@ public final class dev/gitlive/firebase/remoteconfig/ValueSource : java/lang/Enu } public final class dev/gitlive/firebase/remoteconfig/android { + public static final fun getAndroid (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;)Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig; public static final fun getRemoteConfig (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; public static final fun remoteConfig (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig; } diff --git a/firebase-config/package.json b/firebase-config/package.json index 407e43593..69582d9fc 100644 --- a/firebase-config/package.json +++ b/firebase-config/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-config", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-config.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" 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 8c840947e..bfb420515 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 @@ -7,6 +7,7 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchThrottledExcept import com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android import kotlinx.coroutines.tasks.await import kotlinx.datetime.Instant import kotlin.time.Duration @@ -15,13 +16,15 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfig as AndroidFirebaseR import com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo as AndroidFirebaseRemoteConfigInfo import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings as AndroidFirebaseRemoteConfigSettings +public val FirebaseRemoteConfig.android: AndroidFirebaseRemoteConfig get() = AndroidFirebaseRemoteConfig.getInstance() + 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 class FirebaseRemoteConfig internal constructor(public val android: AndroidFirebaseRemoteConfig) { +public actual class FirebaseRemoteConfig internal constructor(internal val android: AndroidFirebaseRemoteConfig) { public actual val all: Map get() = android.all.mapValues { FirebaseRemoteConfigValue(it.value) } 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 45705ff0a..1a247d9b4 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 @@ -12,6 +12,7 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.app +import dev.gitlive.firebase.ios import kotlinx.coroutines.CompletableDeferred import kotlinx.datetime.Instant import kotlinx.datetime.toKotlinInstant @@ -20,6 +21,8 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit +public val FirebaseRemoteConfig.ios: FIRRemoteConfig get() = FIRRemoteConfig.remoteConfig() + public actual val Firebase.remoteConfig: FirebaseRemoteConfig get() = FirebaseRemoteConfig(FIRRemoteConfig.remoteConfig()) @@ -27,7 +30,7 @@ public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig FIRRemoteConfig.remoteConfigWithApp(Firebase.app.ios as objcnames.classes.FIRApp), ) -public actual class FirebaseRemoteConfig internal constructor(public val ios: FIRRemoteConfig) { +public actual class FirebaseRemoteConfig internal constructor(internal val ios: FIRRemoteConfig) { @Suppress("UNCHECKED_CAST") public actual val all: Map get() { 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 003195376..01fb0b75a 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 @@ -3,6 +3,7 @@ package dev.gitlive.firebase.remoteconfig import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.js import dev.gitlive.firebase.remoteconfig.externals.* import kotlinx.coroutines.await import kotlinx.datetime.Instant @@ -17,7 +18,9 @@ public actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig FirebaseRemoteConfig(getRemoteConfig(app.js)) } -public actual class FirebaseRemoteConfig internal constructor(public val js: RemoteConfig) { +public val FirebaseRemoteConfig.js get() = js + +public actual class FirebaseRemoteConfig internal constructor(internal val js: RemoteConfig) { public actual val all: Map get() = rethrow { getAllKeys().associateWith { getValue(it) } } diff --git a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt index ddec60af4..9cea39324 100644 --- a/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt +++ b/firebase-config/src/jsMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigValue.kt @@ -2,7 +2,9 @@ package dev.gitlive.firebase.remoteconfig import dev.gitlive.firebase.remoteconfig.externals.Value -public actual class FirebaseRemoteConfigValue(public val js: Value) { +public val FirebaseRemoteConfigValue.js get() = js + +public actual class FirebaseRemoteConfigValue(internal val js: Value) { public actual fun asBoolean(): Boolean = rethrow { js.asBoolean() } public actual fun asByteArray(): ByteArray = rethrow { js.asString()?.encodeToByteArray() ?: byteArrayOf() } public actual fun asDouble(): Double = rethrow { js.asNumber().toDouble() } diff --git a/firebase-crashlytics/api/firebase-crashlytics.api b/firebase-crashlytics/api/firebase-crashlytics.api index ffa13340a..5246591bc 100644 --- a/firebase-crashlytics/api/firebase-crashlytics.api +++ b/firebase-crashlytics/api/firebase-crashlytics.api @@ -1,12 +1,12 @@ public final class dev/gitlive/firebase/crashlytics/CrashlyticsKt { public static final fun crashlytics (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/crashlytics/FirebaseCrashlytics; + public static final fun getAndroid (Ldev/gitlive/firebase/crashlytics/FirebaseCrashlytics;)Lcom/google/firebase/crashlytics/FirebaseCrashlytics; public static final fun getCrashlytics (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/crashlytics/FirebaseCrashlytics; } public final class dev/gitlive/firebase/crashlytics/FirebaseCrashlytics { public final fun deleteUnsentReports ()V public final fun didCrashOnPreviousExecution ()Z - public final fun getAndroid ()Lcom/google/firebase/crashlytics/FirebaseCrashlytics; public final fun log (Ljava/lang/String;)V public final fun recordException (Ljava/lang/Throwable;)V public final fun sendUnsentReports ()V diff --git a/firebase-crashlytics/package.json b/firebase-crashlytics/package.json index 53208e075..989eda9b0 100644 --- a/firebase-crashlytics/package.json +++ b/firebase-crashlytics/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-crashlytics", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-crashlytics.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" 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 c58bcfcf5..0d56d2e1d 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 @@ -4,6 +4,9 @@ import com.google.firebase.FirebaseException import com.google.firebase.crashlytics.CustomKeysAndValues.Builder import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android + +public val FirebaseCrashlytics.android: com.google.firebase.crashlytics.FirebaseCrashlytics get() = com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance() public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(com.google.firebase.crashlytics.FirebaseCrashlytics.getInstance()) @@ -11,7 +14,7 @@ public actual val Firebase.crashlytics: FirebaseCrashlytics get() = 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(public val android: com.google.firebase.crashlytics.FirebaseCrashlytics) { +public actual class FirebaseCrashlytics internal constructor(internal val android: com.google.firebase.crashlytics.FirebaseCrashlytics) { public actual fun recordException(exception: Throwable) { android.recordException(exception) 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 55534b20c..6c6d16bec 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 @@ -7,13 +7,15 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +public val FirebaseCrashlytics.ios: FIRCrashlytics get() = FIRCrashlytics.crashlytics() + public actual val Firebase.crashlytics: FirebaseCrashlytics get() = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) public actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics = FirebaseCrashlytics(FIRCrashlytics.crashlytics()) -public actual class FirebaseCrashlytics internal constructor(public val ios: FIRCrashlytics) { +public actual class FirebaseCrashlytics internal constructor(internal val ios: FIRCrashlytics) { public actual fun recordException(exception: Throwable) { ios.recordError(exception.asNSError()) diff --git a/firebase-database/api/android/firebase-database.api b/firebase-database/api/android/firebase-database.api index 1d8df6244..7a162d831 100644 --- a/firebase-database/api/android/firebase-database.api +++ b/firebase-database/api/android/firebase-database.api @@ -24,7 +24,6 @@ public final class dev/gitlive/firebase/database/ChildEvent$Type : java/lang/Enu public final class dev/gitlive/firebase/database/DataSnapshot { public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DataSnapshot; - public final fun getAndroid ()Lcom/google/firebase/database/DataSnapshot; public final fun getChildren ()Ljava/lang/Iterable; public final fun getExists ()Z public final fun getHasChildren ()Z @@ -55,7 +54,6 @@ public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive public final class dev/gitlive/firebase/database/FirebaseDatabase { public static final field Companion Ldev/gitlive/firebase/database/FirebaseDatabase$Companion; - public final fun getAndroid ()Lcom/google/firebase/database/FirebaseDatabase; public final fun goOffline ()V public final fun goOnline ()V public final fun reference ()Ldev/gitlive/firebase/database/DatabaseReference; @@ -97,7 +95,6 @@ public class dev/gitlive/firebase/database/Query { public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; - public fun getAndroid ()Lcom/google/firebase/database/Query; public final fun getPersistenceEnabled ()Z public final fun getValueEvents ()Lkotlinx/coroutines/flow/Flow; public final fun limitToFirst (I)Ldev/gitlive/firebase/database/Query; @@ -140,8 +137,11 @@ public final class dev/gitlive/firebase/database/databaseAndroid { public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun database (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getAndroid (Ldev/gitlive/firebase/database/DataSnapshot;)Lcom/google/firebase/database/DataSnapshot; public static final fun getAndroid (Ldev/gitlive/firebase/database/DatabaseReference;)Lcom/google/firebase/database/DatabaseReference; + public static final fun getAndroid (Ldev/gitlive/firebase/database/FirebaseDatabase;)Lcom/google/firebase/database/FirebaseDatabase; public static final fun getAndroid (Ldev/gitlive/firebase/database/OnDisconnect;)Lcom/google/firebase/database/OnDisconnect; + public static final fun getAndroid (Ldev/gitlive/firebase/database/Query;)Lcom/google/firebase/database/Query; public static final fun getDatabase (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun getDatabase (Ldev/gitlive/firebase/database/OnDisconnect;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun getPersistenceEnabled (Ldev/gitlive/firebase/database/OnDisconnect;)Z diff --git a/firebase-database/api/jvm/firebase-database.api b/firebase-database/api/jvm/firebase-database.api index 1d8df6244..7a162d831 100644 --- a/firebase-database/api/jvm/firebase-database.api +++ b/firebase-database/api/jvm/firebase-database.api @@ -24,7 +24,6 @@ public final class dev/gitlive/firebase/database/ChildEvent$Type : java/lang/Enu public final class dev/gitlive/firebase/database/DataSnapshot { public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DataSnapshot; - public final fun getAndroid ()Lcom/google/firebase/database/DataSnapshot; public final fun getChildren ()Ljava/lang/Iterable; public final fun getExists ()Z public final fun getHasChildren ()Z @@ -55,7 +54,6 @@ public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive public final class dev/gitlive/firebase/database/FirebaseDatabase { public static final field Companion Ldev/gitlive/firebase/database/FirebaseDatabase$Companion; - public final fun getAndroid ()Lcom/google/firebase/database/FirebaseDatabase; public final fun goOffline ()V public final fun goOnline ()V public final fun reference ()Ldev/gitlive/firebase/database/DatabaseReference; @@ -97,7 +95,6 @@ public class dev/gitlive/firebase/database/Query { public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;DLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; public static synthetic fun equalTo$default (Ldev/gitlive/firebase/database/Query;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/database/Query; - public fun getAndroid ()Lcom/google/firebase/database/Query; public final fun getPersistenceEnabled ()Z public final fun getValueEvents ()Lkotlinx/coroutines/flow/Flow; public final fun limitToFirst (I)Ldev/gitlive/firebase/database/Query; @@ -140,8 +137,11 @@ public final class dev/gitlive/firebase/database/databaseAndroid { public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun database (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun database (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/database/FirebaseDatabase; + public static final fun getAndroid (Ldev/gitlive/firebase/database/DataSnapshot;)Lcom/google/firebase/database/DataSnapshot; public static final fun getAndroid (Ldev/gitlive/firebase/database/DatabaseReference;)Lcom/google/firebase/database/DatabaseReference; + public static final fun getAndroid (Ldev/gitlive/firebase/database/FirebaseDatabase;)Lcom/google/firebase/database/FirebaseDatabase; public static final fun getAndroid (Ldev/gitlive/firebase/database/OnDisconnect;)Lcom/google/firebase/database/OnDisconnect; + public static final fun getAndroid (Ldev/gitlive/firebase/database/Query;)Lcom/google/firebase/database/Query; public static final fun getDatabase (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun getDatabase (Ldev/gitlive/firebase/database/OnDisconnect;)Ldev/gitlive/firebase/database/FirebaseDatabase; public static final fun getPersistenceEnabled (Ldev/gitlive/firebase/database/OnDisconnect;)Z diff --git a/firebase-database/package.json b/firebase-database/package.json index f17db9688..228ba4282 100644 --- a/firebase-database/package.json +++ b/firebase-database/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-database", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-database.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt index e75004567..561f3215a 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 @@ -18,7 +18,9 @@ import dev.gitlive.firebase.EncodeDecodeSettingsBuilder import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android import dev.gitlive.firebase.database.ChildEvent.Type +import dev.gitlive.firebase.database.android as publicAndroid import dev.gitlive.firebase.internal.android import dev.gitlive.firebase.internal.decode import dev.gitlive.firebase.internal.reencodeTransformation @@ -40,6 +42,8 @@ import kotlinx.serialization.KSerializer import java.util.WeakHashMap 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()) }, @@ -64,7 +68,7 @@ public actual fun Firebase.database(app: FirebaseApp): FirebaseDatabase = 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(public val android: com.google.firebase.database.FirebaseDatabase) { +public actual class FirebaseDatabase internal constructor(internal val android: com.google.firebase.database.FirebaseDatabase) { public companion object { private val instances = WeakHashMap() @@ -113,8 +117,10 @@ internal actual open class NativeQuery( val persistenceEnabled: Boolean, ) +public val Query.android: com.google.firebase.database.Query get() = nativeQuery.android + public actual open class Query internal actual constructor( - nativeQuery: NativeQuery, + internal val nativeQuery: NativeQuery, ) { internal constructor( @@ -122,7 +128,7 @@ public actual open class Query internal actual constructor( persistenceEnabled: Boolean, ) : this(NativeQuery(android, persistenceEnabled)) - public open val android: com.google.firebase.database.Query = nativeQuery.android + internal open val android: com.google.firebase.database.Query = nativeQuery.android public val persistenceEnabled: Boolean = nativeQuery.persistenceEnabled public actual fun orderByKey(): Query = Query(android.orderByKey(), persistenceEnabled) @@ -266,9 +272,10 @@ internal actual class NativeDatabaseReference internal constructor( } public val DatabaseReference.android: com.google.firebase.database.DatabaseReference get() = nativeReference.android +public val DataSnapshot.android: com.google.firebase.database.DataSnapshot get() = android public actual class DataSnapshot internal constructor( - public val android: com.google.firebase.database.DataSnapshot, + internal val android: com.google.firebase.database.DataSnapshot, private val persistenceEnabled: Boolean, ) { @@ -281,10 +288,10 @@ public actual class DataSnapshot internal constructor( public actual val value: Any? get() = android.value public actual inline fun value(): T = - decode(value = android.value) + decode(value = publicAndroid.value) public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, android.value, buildSettings) + 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/database.kt b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt index 882dbd97a..c75290154 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 @@ -24,10 +24,12 @@ import dev.gitlive.firebase.database.ChildEvent.Type.ADDED import dev.gitlive.firebase.database.ChildEvent.Type.CHANGED import dev.gitlive.firebase.database.ChildEvent.Type.MOVED import dev.gitlive.firebase.database.ChildEvent.Type.REMOVED +import dev.gitlive.firebase.database.ios as publicIos import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.internal.decode import dev.gitlive.firebase.internal.ios import dev.gitlive.firebase.internal.reencodeTransformation +import dev.gitlive.firebase.ios import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.channels.awaitClose @@ -42,6 +44,8 @@ import kotlinx.serialization.KSerializer import platform.Foundation.NSError import platform.Foundation.allObjects +public val FirebaseDatabase.ios: FIRDatabase get() = FIRDatabase.database() + public actual val Firebase.database: FirebaseDatabase by lazy { FirebaseDatabase(FIRDatabase.database()) } @@ -56,7 +60,7 @@ public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseData FIRDatabase.databaseForApp(app.ios as objcnames.classes.FIRApp, url), ) -public actual class FirebaseDatabase internal constructor(public val ios: FIRDatabase) { +public actual class FirebaseDatabase internal constructor(internal val ios: FIRDatabase) { public actual fun reference(path: String): DatabaseReference = DatabaseReference(NativeDatabaseReference(ios.referenceWithPath(path), ios.persistenceEnabled)) @@ -101,13 +105,15 @@ internal actual open class NativeQuery( val persistenceEnabled: Boolean, ) +public val Query.ios: FIRDatabaseQuery get() = nativeQuery.ios + public actual open class Query internal actual constructor( - nativeQuery: NativeQuery, + internal val nativeQuery: NativeQuery, ) { internal constructor(ios: FIRDatabaseQuery, persistenceEnabled: Boolean) : this(NativeQuery(ios, persistenceEnabled)) - public open val ios: FIRDatabaseQuery = nativeQuery.ios + internal open val ios: FIRDatabaseQuery = nativeQuery.ios public val persistenceEnabled: Boolean = nativeQuery.persistenceEnabled public actual fun orderByKey(): Query = Query(ios.queryOrderedByKey(), persistenceEnabled) @@ -210,9 +216,10 @@ internal actual class NativeDatabaseReference internal constructor( } public val DatabaseReference.ios: FIRDatabaseReference get() = nativeReference.ios +public val DataSnapshot.ios: FIRDataSnapshot get() = ios public actual class DataSnapshot internal constructor( - public val ios: FIRDataSnapshot, + internal val ios: FIRDataSnapshot, private val persistenceEnabled: Boolean, ) { @@ -225,10 +232,10 @@ public actual class DataSnapshot internal constructor( public actual val value: Any? get() = ios.value public actual inline fun value(): T = - decode(value = ios.value) + decode(value = publicIos.value) public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, ios.value, buildSettings) + 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/database.kt b/firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt index ac74d56ba..f4f38d8f7 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 @@ -31,6 +31,7 @@ import dev.gitlive.firebase.internal.EncodedObject import dev.gitlive.firebase.internal.decode import dev.gitlive.firebase.internal.js import dev.gitlive.firebase.internal.reencodeTransformation +import dev.gitlive.firebase.js import kotlinx.coroutines.asDeferred import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.coroutineScope @@ -58,6 +59,7 @@ import dev.gitlive.firebase.database.externals.orderByKey as jsOrderByKey import dev.gitlive.firebase.database.externals.orderByValue as jsOrderByValue import dev.gitlive.firebase.database.externals.runTransaction as jsRunTransaction import dev.gitlive.firebase.database.externals.startAt as jsStartAt +import dev.gitlive.firebase.database.js as publicJs public actual val Firebase.database: FirebaseDatabase get() = rethrow { FirebaseDatabase(getDatabase()) } @@ -71,7 +73,9 @@ public actual fun Firebase.database(url: String): FirebaseDatabase = public actual fun Firebase.database(app: FirebaseApp, url: String): FirebaseDatabase = rethrow { FirebaseDatabase(getDatabase(app = app.js, url = url)) } -public actual class FirebaseDatabase internal constructor(public val js: Database) { +public val FirebaseDatabase.js get() = js + +public actual class FirebaseDatabase internal constructor(internal val js: Database) { public actual fun reference(path: String): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js, path), js)) } public actual fun reference(): DatabaseReference = rethrow { DatabaseReference(NativeDatabaseReference(ref(js), js)) } @@ -90,24 +94,25 @@ internal actual open class NativeQuery( val database: Database, ) +public val Query.js: JsQuery get() = nativeQuery.js + public actual open class Query internal actual constructor( - nativeQuery: NativeQuery, + internal val nativeQuery: NativeQuery, ) { internal constructor(js: JsQuery, database: Database) : this(NativeQuery(js, database)) - public open val js: JsQuery = nativeQuery.js public val database: Database = nativeQuery.database - public actual fun orderByKey(): Query = Query(query(js, jsOrderByKey()), database) - public actual fun orderByValue(): Query = Query(query(js, jsOrderByValue()), database) - public actual fun orderByChild(path: String): Query = Query(query(js, jsOrderByChild(path)), database) + public actual fun orderByKey(): Query = Query(query(publicJs, jsOrderByKey()), database) + public actual fun orderByValue(): Query = Query(query(publicJs, jsOrderByValue()), database) + public actual fun orderByChild(path: String): Query = Query(query(publicJs, jsOrderByChild(path)), database) public actual val valueEvents: Flow get() = callbackFlow { val unsubscribe = rethrow { onValue( - query = js, + query = publicJs, callback = { trySend(DataSnapshot(it, database)) }, cancelCallback = { close(DatabaseException(it)).run { } }, ) @@ -133,39 +138,39 @@ public actual open class Query internal actual constructor( } when (type) { - ChildEvent.Type.ADDED -> onChildAdded(js, callback, cancelCallback) - ChildEvent.Type.CHANGED -> onChildChanged(js, callback, cancelCallback) - ChildEvent.Type.MOVED -> onChildMoved(js, callback, cancelCallback) - ChildEvent.Type.REMOVED -> onChildRemoved(js, callback, cancelCallback) + ChildEvent.Type.ADDED -> onChildAdded(publicJs, callback, cancelCallback) + ChildEvent.Type.CHANGED -> onChildChanged(publicJs, callback, cancelCallback) + ChildEvent.Type.MOVED -> onChildMoved(publicJs, callback, cancelCallback) + ChildEvent.Type.REMOVED -> onChildRemoved(publicJs, callback, cancelCallback) } } } awaitClose { rethrow { unsubscribes.forEach { it.invoke() } } } } - public actual fun startAt(value: String, key: String?): Query = Query(query(js, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: String, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Double, key: String?): Query = Query(query(js, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Double, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun startAt(value: Boolean, key: String?): Query = Query(query(js, jsStartAt(value, key ?: undefined)), database) + public actual fun startAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsStartAt(value, key ?: undefined)), database) - public actual fun endAt(value: String, key: String?): Query = Query(query(js, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: String, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Double, key: String?): Query = Query(query(js, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Double, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun endAt(value: Boolean, key: String?): Query = Query(query(js, jsEndAt(value, key ?: undefined)), database) + public actual fun endAt(value: Boolean, key: String?): Query = Query(query(publicJs, jsEndAt(value, key ?: undefined)), database) - public actual fun limitToFirst(limit: Int): Query = Query(query(js, jsLimitToFirst(limit)), database) + public actual fun limitToFirst(limit: Int): Query = Query(query(publicJs, jsLimitToFirst(limit)), database) - public actual fun limitToLast(limit: Int): Query = Query(query(js, jsLimitToLast(limit)), database) + public actual fun limitToLast(limit: Int): Query = Query(query(publicJs, jsLimitToLast(limit)), database) - public actual fun equalTo(value: String, key: String?): Query = Query(query(js, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: String, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Double, key: String?): Query = Query(query(js, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Double, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - public actual fun equalTo(value: Boolean, key: String?): Query = Query(query(js, jsEqualTo(value, key ?: undefined)), database) + public actual fun equalTo(value: Boolean, key: String?): Query = Query(query(publicJs, jsEqualTo(value, key ?: undefined)), database) - override fun toString(): String = js.toString() + override fun toString(): String = publicJs.toString() } internal actual class NativeDatabaseReference internal constructor( @@ -196,8 +201,10 @@ internal actual class NativeDatabaseReference internal constructor( ) } +public val DataSnapshot.js: JsDataSnapshot get() = js + public actual class DataSnapshot internal constructor( - public val js: JsDataSnapshot, + internal val js: JsDataSnapshot, public val database: Database, ) { public actual val value: Any? get() { @@ -206,10 +213,10 @@ public actual class DataSnapshot internal constructor( } public actual inline fun value(): T = - rethrow { decode(value = js.`val`()) } + rethrow { decode(value = publicJs.`val`()) } public actual inline fun value(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - rethrow { decode(strategy, js.`val`(), buildSettings) } + rethrow { decode(strategy, publicJs.`val`(), buildSettings) } public actual val exists: Boolean get() = rethrow { js.exists() } public actual val key: String? get() = rethrow { js.key } diff --git a/firebase-firestore/api/android/firebase-firestore.api b/firebase-firestore/api/android/firebase-firestore.api index afda9143b..0d882cf48 100644 --- a/firebase-firestore/api/android/firebase-firestore.api +++ b/firebase-firestore/api/android/firebase-firestore.api @@ -38,7 +38,6 @@ public final class dev/gitlive/firebase/firestore/CollectionReference$Companion public final class dev/gitlive/firebase/firestore/DocumentChange { public fun (Lcom/google/firebase/firestore/DocumentChange;)V - public final fun getAndroid ()Lcom/google/firebase/firestore/DocumentChange; public final fun getDocument ()Ldev/gitlive/firebase/firestore/DocumentSnapshot; public final fun getNewIndex ()I public final fun getOldIndex ()I @@ -142,7 +141,6 @@ public final class dev/gitlive/firebase/firestore/FieldPath { public static final field Companion Ldev/gitlive/firebase/firestore/FieldPath$Companion; public fun ([Ljava/lang/String;)V public fun equals (Ljava/lang/Object;)Z - public final fun getAndroid ()Lcom/google/firebase/firestore/FieldPath; public final fun getDocumentId ()Ldev/gitlive/firebase/firestore/FieldPath; public final fun getEncoded ()Lcom/google/firebase/firestore/FieldPath; public fun hashCode ()I @@ -471,7 +469,6 @@ public final class dev/gitlive/firebase/firestore/Query$Companion { public final class dev/gitlive/firebase/firestore/QuerySnapshot { public fun (Lcom/google/firebase/firestore/QuerySnapshot;)V - public final fun getAndroid ()Lcom/google/firebase/firestore/QuerySnapshot; public final fun getDocumentChanges ()Ljava/util/List; public final fun getDocuments ()Ljava/util/List; public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; @@ -497,7 +494,6 @@ public final class dev/gitlive/firebase/firestore/ServerTimestampSerializer : ko public final class dev/gitlive/firebase/firestore/SnapshotMetadata { public fun (Lcom/google/firebase/firestore/SnapshotMetadata;)V - public final fun getAndroid ()Lcom/google/firebase/firestore/SnapshotMetadata; public final fun getHasPendingWrites ()Z public final fun isFromCache ()Z } @@ -782,11 +778,15 @@ public final class dev/gitlive/firebase/firestore/android { public static final fun firestoreSettings (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; public static synthetic fun firestoreSettings$default (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/CollectionReference;)Lcom/google/firebase/firestore/CollectionReference; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentChange;)Lcom/google/firebase/firestore/DocumentChange; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentReference;)Lcom/google/firebase/firestore/DocumentReference; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/DocumentSnapshot; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/FieldPath;)Lcom/google/firebase/firestore/FieldPath; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/FirebaseFirestore;)Lcom/google/firebase/firestore/FirebaseFirestore; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/LocalCacheSettings;)Lcom/google/firebase/firestore/LocalCacheSettings; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Query;)Lcom/google/firebase/firestore/Query; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/QuerySnapshot;)Lcom/google/firebase/firestore/QuerySnapshot; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/SnapshotMetadata;)Lcom/google/firebase/firestore/SnapshotMetadata; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Transaction;)Lcom/google/firebase/firestore/Transaction; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/WriteBatch;)Lcom/google/firebase/firestore/WriteBatch; public static final fun getCode (Lcom/google/firebase/firestore/FirebaseFirestoreException;)Lcom/google/firebase/firestore/FirebaseFirestoreException$Code; diff --git a/firebase-firestore/api/jvm/firebase-firestore.api b/firebase-firestore/api/jvm/firebase-firestore.api index 5aed50345..8e668f4c0 100644 --- a/firebase-firestore/api/jvm/firebase-firestore.api +++ b/firebase-firestore/api/jvm/firebase-firestore.api @@ -38,7 +38,6 @@ public final class dev/gitlive/firebase/firestore/CollectionReference$Companion public final class dev/gitlive/firebase/firestore/DocumentChange { public fun (Lcom/google/firebase/firestore/DocumentChange;)V - public final fun getAndroid ()Lcom/google/firebase/firestore/DocumentChange; public final fun getDocument ()Ldev/gitlive/firebase/firestore/DocumentSnapshot; public final fun getNewIndex ()I public final fun getOldIndex ()I @@ -142,7 +141,6 @@ public final class dev/gitlive/firebase/firestore/FieldPath { public static final field Companion Ldev/gitlive/firebase/firestore/FieldPath$Companion; public fun ([Ljava/lang/String;)V public fun equals (Ljava/lang/Object;)Z - public final fun getAndroid ()Lcom/google/firebase/firestore/FieldPath; public final fun getDocumentId ()Ldev/gitlive/firebase/firestore/FieldPath; public final fun getEncoded ()Lcom/google/firebase/firestore/FieldPath; public fun hashCode ()I @@ -471,7 +469,6 @@ public final class dev/gitlive/firebase/firestore/Query$Companion { public final class dev/gitlive/firebase/firestore/QuerySnapshot { public fun (Lcom/google/firebase/firestore/QuerySnapshot;)V - public final fun getAndroid ()Lcom/google/firebase/firestore/QuerySnapshot; public final fun getDocumentChanges ()Ljava/util/List; public final fun getDocuments ()Ljava/util/List; public final fun getMetadata ()Ldev/gitlive/firebase/firestore/SnapshotMetadata; @@ -497,7 +494,6 @@ public final class dev/gitlive/firebase/firestore/ServerTimestampSerializer : ko public final class dev/gitlive/firebase/firestore/SnapshotMetadata { public fun (Lcom/google/firebase/firestore/SnapshotMetadata;)V - public final fun getAndroid ()Lcom/google/firebase/firestore/SnapshotMetadata; public final fun getHasPendingWrites ()Z public final fun isFromCache ()Z } @@ -782,11 +778,15 @@ public final class dev/gitlive/firebase/firestore/android { public static final fun firestoreSettings (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; public static synthetic fun firestoreSettings$default (Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/FirebaseFirestoreSettings; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/CollectionReference;)Lcom/google/firebase/firestore/CollectionReference; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentChange;)Lcom/google/firebase/firestore/DocumentChange; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentReference;)Lcom/google/firebase/firestore/DocumentReference; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Lcom/google/firebase/firestore/DocumentSnapshot; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/FieldPath;)Lcom/google/firebase/firestore/FieldPath; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/FirebaseFirestore;)Lcom/google/firebase/firestore/FirebaseFirestore; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/LocalCacheSettings;)Lcom/google/firebase/firestore/LocalCacheSettings; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Query;)Lcom/google/firebase/firestore/Query; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/QuerySnapshot;)Lcom/google/firebase/firestore/QuerySnapshot; + public static final fun getAndroid (Ldev/gitlive/firebase/firestore/SnapshotMetadata;)Lcom/google/firebase/firestore/SnapshotMetadata; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/Transaction;)Lcom/google/firebase/firestore/Transaction; public static final fun getAndroid (Ldev/gitlive/firebase/firestore/WriteBatch;)Lcom/google/firebase/firestore/WriteBatch; public static final fun getCode (Lcom/google/firebase/firestore/FirebaseFirestoreException;)Lcom/google/firebase/firestore/FirebaseFirestoreException$Code; diff --git a/firebase-firestore/package.json b/firebase-firestore/package.json index 96dfbe45c..8efd2dd91 100644 --- a/firebase-firestore/package.json +++ b/firebase-firestore/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-firestore", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-firestore.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index bc096786f..01106caae 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 @@ -9,6 +9,7 @@ package dev.gitlive.firebase.firestore import com.google.android.gms.tasks.TaskExecutors import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android import dev.gitlive.firebase.firestore.internal.NativeDocumentSnapshotWrapper import java.util.concurrent.Executor import com.google.firebase.firestore.CollectionReference as AndroidCollectionReference @@ -30,6 +31,8 @@ import com.google.firebase.firestore.memoryEagerGcSettings as androidMemoryEager import com.google.firebase.firestore.memoryLruGcSettings as androidMemoryLruGcSettings import com.google.firebase.firestore.persistentCacheSettings as androidPersistentCacheSettings +public val FirebaseFirestore.android: AndroidFirebaseFirestore get() = AndroidFirebaseFirestore.getInstance() + public actual val Firebase.firestore: FirebaseFirestore get() = FirebaseFirestore(AndroidFirebaseFirestore.getInstance()) @@ -55,7 +58,6 @@ public val LocalCacheSettings.android: AndroidLocalCacheSettings get() = when (t internal actual typealias NativeFirebaseFirestore = AndroidFirebaseFirestore public operator fun FirebaseFirestore.Companion.invoke(android: AndroidFirebaseFirestore): FirebaseFirestore = FirebaseFirestore(android) -public val FirebaseFirestore.android: AndroidFirebaseFirestore get() = native public actual data class FirebaseFirestoreSettings( actual val sslEnabled: Boolean, @@ -138,7 +140,9 @@ public actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() public actual typealias FirestoreExceptionCode = AndroidFirebaseFirestoreException.Code -public actual class QuerySnapshot(public val android: AndroidQuerySnapshot) { +public val QuerySnapshot.android: AndroidQuerySnapshot get() = android + +public actual class QuerySnapshot(internal val android: AndroidQuerySnapshot) { public actual val documents: List get() = android.documents.map { DocumentSnapshot(NativeDocumentSnapshotWrapper(it)) } public actual val documentChanges: List @@ -146,7 +150,9 @@ public actual class QuerySnapshot(public val android: AndroidQuerySnapshot) { public actual val metadata: SnapshotMetadata get() = SnapshotMetadata(android.metadata) } -public actual class DocumentChange(public val android: AndroidDocumentChange) { +public val DocumentChange.android: AndroidDocumentChange get() = android + +public actual class DocumentChange(internal val android: AndroidDocumentChange) { public actual val document: DocumentSnapshot get() = DocumentSnapshot(NativeDocumentSnapshotWrapper(android.document)) public actual val newIndex: Int @@ -162,12 +168,16 @@ internal actual typealias NativeDocumentSnapshot = AndroidDocumentSnapshot public operator fun DocumentSnapshot.Companion.invoke(android: AndroidDocumentSnapshot): DocumentSnapshot = DocumentSnapshot(android) public val DocumentSnapshot.android: AndroidDocumentSnapshot get() = native -public actual class SnapshotMetadata(public val android: AndroidSnapshotMetadata) { +public val SnapshotMetadata.android: AndroidSnapshotMetadata get() = android + +public actual class SnapshotMetadata(internal val android: AndroidSnapshotMetadata) { public actual val hasPendingWrites: Boolean get() = android.hasPendingWrites() public actual val isFromCache: Boolean get() = android.isFromCache } -public actual class FieldPath private constructor(public val android: AndroidFieldPath) { +public val FieldPath.android: AndroidFieldPath get() = android + +public actual class FieldPath private constructor(internal val android: AndroidFieldPath) { public actual companion object { public actual val documentId: FieldPath = FieldPath(AndroidFieldPath.documentId()) diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 9502a39f1..605281ec0 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -12,6 +12,7 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.firestore.internal.NativeDocumentSnapshotWrapper +import dev.gitlive.firebase.ios import kotlinx.coroutines.CompletableDeferred import platform.Foundation.NSError import platform.Foundation.NSNumber @@ -19,6 +20,8 @@ import platform.Foundation.numberWithLong import platform.darwin.dispatch_get_main_queue import platform.darwin.dispatch_queue_t +public val FirebaseFirestore.ios: FIRFirestore get() = FIRFirestore.firestore() + public actual val Firebase.firestore: FirebaseFirestore get() = FirebaseFirestore(FIRFirestore.firestore()) @@ -39,7 +42,6 @@ public val LocalCacheSettings.ios: FIRLocalCacheSettingsProtocol get() = when (t internal actual typealias NativeFirebaseFirestore = FIRFirestore public operator fun FirebaseFirestore.Companion.invoke(ios: FIRFirestore): FirebaseFirestore = FirebaseFirestore(ios) -public val FirebaseFirestore.ios: FIRFirestore get() = native public actual data class FirebaseFirestoreSettings( actual val sslEnabled: Boolean, @@ -154,6 +156,8 @@ public actual enum class Direction { DESCENDING, } +public val ChangeType.ios: FIRDocumentChangeType get() = ios + public actual enum class ChangeType(internal val ios: FIRDocumentChangeType) { ADDED(FIRDocumentChangeTypeAdded), MODIFIED(FIRDocumentChangeTypeModified), @@ -184,7 +188,9 @@ public fun NSError.toException(): FirebaseFirestoreException = when (domain) { else -> FirestoreExceptionCode.UNKNOWN }.let { FirebaseFirestoreException(description!!, it) } -public actual class QuerySnapshot(public val ios: FIRQuerySnapshot) { +public val QuerySnapshot.ios: FIRQuerySnapshot get() = ios + +public actual class QuerySnapshot(internal val ios: FIRQuerySnapshot) { public actual val documents: List get() = ios.documents.map { DocumentSnapshot(NativeDocumentSnapshotWrapper(it as FIRDocumentSnapshot)) } public actual val documentChanges: List @@ -192,7 +198,9 @@ public actual class QuerySnapshot(public val ios: FIRQuerySnapshot) { public actual val metadata: SnapshotMetadata get() = SnapshotMetadata(ios.metadata) } -public actual class DocumentChange(public val ios: FIRDocumentChange) { +public val DocumentChange.ios: FIRDocumentChange get() = ios + +public actual class DocumentChange(internal val ios: FIRDocumentChange) { public actual val document: DocumentSnapshot get() = DocumentSnapshot(NativeDocumentSnapshotWrapper(ios.document)) public actual val newIndex: Int @@ -208,12 +216,16 @@ internal actual typealias NativeDocumentSnapshot = FIRDocumentSnapshot public operator fun DocumentSnapshot.Companion.invoke(ios: FIRDocumentSnapshot): DocumentSnapshot = DocumentSnapshot(ios) public val DocumentSnapshot.ios: FIRDocumentSnapshot get() = native -public actual class SnapshotMetadata(public val ios: FIRSnapshotMetadata) { +public val SnapshotMetadata.ios: FIRSnapshotMetadata get() = ios + +public actual class SnapshotMetadata(internal val ios: FIRSnapshotMetadata) { public actual val hasPendingWrites: Boolean get() = ios.pendingWrites public actual val isFromCache: Boolean get() = ios.fromCache } -public actual class FieldPath private constructor(public val ios: FIRFieldPath) { +public val FieldPath.ios: FIRFieldPath get() = ios + +public actual class FieldPath private constructor(internal val ios: FIRFieldPath) { public actual companion object { public actual val documentId: FieldPath = FieldPath(FIRFieldPath.documentID()) } 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 87912f585..752e53a3c 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 @@ -16,6 +16,7 @@ import dev.gitlive.firebase.firestore.externals.memoryLruGarbageCollector import dev.gitlive.firebase.firestore.externals.persistentLocalCache import dev.gitlive.firebase.firestore.internal.NativeDocumentSnapshotWrapper import dev.gitlive.firebase.firestore.internal.NativeFirebaseFirestoreWrapper +import dev.gitlive.firebase.js import kotlin.js.Json import kotlin.js.json import dev.gitlive.firebase.firestore.externals.Firestore as JsFirestore @@ -76,7 +77,7 @@ public actual data class FirebaseFirestoreSettings( } @Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE") - val js: Json get() = json().apply { + internal val js: Json get() = json().apply { set("ssl", sslEnabled) set("host", host) set( @@ -88,11 +89,11 @@ public actual data class FirebaseFirestoreSettings( ).asDynamic() as PersistentCacheSettings, ) is LocalCacheSettings.Memory -> { - val garbageCollecorSettings = when (val garbageCollectorSettings = cacheSettings.garbaseCollectorSettings) { + val garbageCollectorSettings = when (val garbageCollectorSettings = cacheSettings.garbaseCollectorSettings) { is MemoryGarbageCollectorSettings.Eager -> memoryEagerGarbageCollector() is MemoryGarbageCollectorSettings.LRUGC -> memoryLruGarbageCollector(json("cacheSizeBytes" to garbageCollectorSettings.sizeBytes)) } - memoryLocalCache(json("garbageCollector" to garbageCollecorSettings).asDynamic() as MemoryCacheSettings) + memoryLocalCache(json("garbageCollector" to garbageCollectorSettings).asDynamic() as MemoryCacheSettings) } }, ) @@ -142,7 +143,9 @@ public actual class FirebaseFirestoreException(cause: Throwable, public val code @Suppress("EXTENSION_SHADOWED_BY_MEMBER") public actual val FirebaseFirestoreException.code: FirestoreExceptionCode get() = code -public actual class QuerySnapshot(public val js: JsQuerySnapshot) { +public val QuerySnapshot.js: JsQuerySnapshot get() = js + +public actual class QuerySnapshot(internal val js: JsQuerySnapshot) { public actual val documents: List get() = js.docs.map { DocumentSnapshot(NativeDocumentSnapshotWrapper(it)) } public actual val documentChanges: List @@ -150,7 +153,9 @@ public actual class QuerySnapshot(public val js: JsQuerySnapshot) { public actual val metadata: SnapshotMetadata get() = SnapshotMetadata(js.metadata) } -public actual class DocumentChange(public val js: JsDocumentChange) { +public val DocumentChange.js: JsDocumentChange get() = js + +public actual class DocumentChange(internal val js: JsDocumentChange) { public actual val document: DocumentSnapshot get() = DocumentSnapshot(NativeDocumentSnapshotWrapper(js.doc)) public actual val newIndex: Int @@ -166,12 +171,16 @@ internal actual data class NativeDocumentSnapshot(val js: JsDocumentSnapshot) public operator fun DocumentSnapshot.Companion.invoke(js: JsDocumentSnapshot): DocumentSnapshot = DocumentSnapshot(NativeDocumentSnapshot(js)) public val DocumentSnapshot.js: dev.gitlive.firebase.firestore.externals.DocumentSnapshot get() = native.js -public actual class SnapshotMetadata(public val js: JsSnapshotMetadata) { +public val SnapshotMetadata.js: dev.gitlive.firebase.firestore.externals.SnapshotMetadata get() = js + +public actual class SnapshotMetadata(internal val js: JsSnapshotMetadata) { public actual val hasPendingWrites: Boolean get() = js.hasPendingWrites public actual val isFromCache: Boolean get() = js.fromCache } -public actual class FieldPath private constructor(public val js: JsFieldPath) { +public val FieldPath.js: dev.gitlive.firebase.firestore.externals.FieldPath get() = js + +public actual class FieldPath private constructor(internal val js: JsFieldPath) { public actual companion object { public actual val documentId: FieldPath = FieldPath(jsDocumentId()) diff --git a/firebase-functions/api/android/firebase-functions.api b/firebase-functions/api/android/firebase-functions.api index 571a01a1a..3d36472ff 100644 --- a/firebase-functions/api/android/firebase-functions.api +++ b/firebase-functions/api/android/firebase-functions.api @@ -2,17 +2,17 @@ public final class dev/gitlive/firebase/functions/AndroidFunctions { public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public static final fun functions (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun getAndroid (Ldev/gitlive/firebase/functions/FirebaseFunctions;)Lcom/google/firebase/functions/FirebaseFunctions; + public static final fun getAndroid (Ldev/gitlive/firebase/functions/HttpsCallableResult;)Lcom/google/firebase/functions/HttpsCallableResult; public static final fun getCode (Lcom/google/firebase/functions/FirebaseFunctionsException;)Lcom/google/firebase/functions/FirebaseFunctionsException$Code; public static final fun getDetails (Lcom/google/firebase/functions/FirebaseFunctionsException;)Ljava/lang/Object; public static final fun getFunctions (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/functions/FirebaseFunctions; } public final class dev/gitlive/firebase/functions/FirebaseFunctions { - public final fun component1 ()Lcom/google/firebase/functions/FirebaseFunctions; public final fun copy (Lcom/google/firebase/functions/FirebaseFunctions;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public static synthetic fun copy$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Lcom/google/firebase/functions/FirebaseFunctions;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public fun equals (Ljava/lang/Object;)Z - public final fun getAndroid ()Lcom/google/firebase/functions/FirebaseFunctions; public fun hashCode ()I public final fun httpsCallable-6Au4x4Y (Ljava/lang/String;Lkotlin/time/Duration;)Ldev/gitlive/firebase/functions/HttpsCallableReference; public static synthetic fun httpsCallable-6Au4x4Y$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Ljava/lang/String;Lkotlin/time/Duration;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/HttpsCallableReference; @@ -36,7 +36,6 @@ public final class dev/gitlive/firebase/functions/HttpsCallableResult { public fun (Lcom/google/firebase/functions/HttpsCallableResult;)V public final fun data (Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static synthetic fun data$default (Ldev/gitlive/firebase/functions/HttpsCallableResult;Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/functions/HttpsCallableResult; } public final class dev/gitlive/firebase/functions/NativeHttpsCallableReference { diff --git a/firebase-functions/api/jvm/firebase-functions.api b/firebase-functions/api/jvm/firebase-functions.api index 571a01a1a..3d36472ff 100644 --- a/firebase-functions/api/jvm/firebase-functions.api +++ b/firebase-functions/api/jvm/firebase-functions.api @@ -2,17 +2,17 @@ public final class dev/gitlive/firebase/functions/AndroidFunctions { public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public static final fun functions (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public static final fun functions (Ldev/gitlive/firebase/Firebase;Ljava/lang/String;)Ldev/gitlive/firebase/functions/FirebaseFunctions; + public static final fun getAndroid (Ldev/gitlive/firebase/functions/FirebaseFunctions;)Lcom/google/firebase/functions/FirebaseFunctions; + public static final fun getAndroid (Ldev/gitlive/firebase/functions/HttpsCallableResult;)Lcom/google/firebase/functions/HttpsCallableResult; public static final fun getCode (Lcom/google/firebase/functions/FirebaseFunctionsException;)Lcom/google/firebase/functions/FirebaseFunctionsException$Code; public static final fun getDetails (Lcom/google/firebase/functions/FirebaseFunctionsException;)Ljava/lang/Object; public static final fun getFunctions (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/functions/FirebaseFunctions; } public final class dev/gitlive/firebase/functions/FirebaseFunctions { - public final fun component1 ()Lcom/google/firebase/functions/FirebaseFunctions; public final fun copy (Lcom/google/firebase/functions/FirebaseFunctions;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public static synthetic fun copy$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Lcom/google/firebase/functions/FirebaseFunctions;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/FirebaseFunctions; public fun equals (Ljava/lang/Object;)Z - public final fun getAndroid ()Lcom/google/firebase/functions/FirebaseFunctions; public fun hashCode ()I public final fun httpsCallable-6Au4x4Y (Ljava/lang/String;Lkotlin/time/Duration;)Ldev/gitlive/firebase/functions/HttpsCallableReference; public static synthetic fun httpsCallable-6Au4x4Y$default (Ldev/gitlive/firebase/functions/FirebaseFunctions;Ljava/lang/String;Lkotlin/time/Duration;ILjava/lang/Object;)Ldev/gitlive/firebase/functions/HttpsCallableReference; @@ -36,7 +36,6 @@ public final class dev/gitlive/firebase/functions/HttpsCallableResult { public fun (Lcom/google/firebase/functions/HttpsCallableResult;)V public final fun data (Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static synthetic fun data$default (Ldev/gitlive/firebase/functions/HttpsCallableResult;Lkotlinx/serialization/DeserializationStrategy;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/functions/HttpsCallableResult; } public final class dev/gitlive/firebase/functions/NativeHttpsCallableReference { diff --git a/firebase-functions/package.json b/firebase-functions/package.json index 3960c0cc2..ed25dbf4e 100644 --- a/firebase-functions/package.json +++ b/firebase-functions/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-functions", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-functions.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 01f68a8eb..00b1a3dab 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 @@ -9,12 +9,16 @@ package dev.gitlive.firebase.functions import dev.gitlive.firebase.DecodeSettings import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android +import dev.gitlive.firebase.functions.android as publicAndroid import dev.gitlive.firebase.internal.decode import kotlinx.coroutines.tasks.await import kotlinx.serialization.DeserializationStrategy import java.util.concurrent.TimeUnit import kotlin.time.Duration +public val FirebaseFunctions.android: com.google.firebase.functions.FirebaseFunctions get() = com.google.firebase.functions.FirebaseFunctions.getInstance() + public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(com.google.firebase.functions.FirebaseFunctions.getInstance()) @@ -27,7 +31,7 @@ public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = 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(public val android: com.google.firebase.functions.FirebaseFunctions) { +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) @@ -45,14 +49,15 @@ internal actual data class NativeHttpsCallableReference(val android: com.google. internal val com.google.firebase.functions.HttpsCallableReference.native get() = NativeHttpsCallableReference(this) internal val HttpsCallableReference.android: com.google.firebase.functions.HttpsCallableReference get() = native.android +public val HttpsCallableResult.android: com.google.firebase.functions.HttpsCallableResult get() = android -public actual class HttpsCallableResult(public val android: com.google.firebase.functions.HttpsCallableResult) { +public actual class HttpsCallableResult(internal val android: com.google.firebase.functions.HttpsCallableResult) { public actual inline fun data(): T = - decode(value = android.data) + decode(value = publicAndroid.data) public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, android.data, buildSettings) + 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 45cfc947a..d002f93b4 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 @@ -13,13 +13,17 @@ import dev.gitlive.firebase.DecodeSettings import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.functions.ios as publicIos import dev.gitlive.firebase.internal.decode +import dev.gitlive.firebase.ios import kotlinx.coroutines.CompletableDeferred import kotlinx.serialization.DeserializationStrategy import platform.Foundation.NSError import kotlin.time.Duration import kotlin.time.DurationUnit +public val FirebaseFunctions.ios: FIRFunctions get() = FIRFunctions.functions() + public actual val Firebase.functions: FirebaseFunctions get() = FirebaseFunctions(FIRFunctions.functions()) @@ -37,7 +41,7 @@ public actual fun Firebase.functions( FIRFunctions.functionsForApp(app.ios as objcnames.classes.FIRApp, region = region), ) -public actual data class FirebaseFunctions internal constructor(public val ios: FIRFunctions) { +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) @@ -55,14 +59,15 @@ internal actual data class NativeHttpsCallableReference(val ios: FIRHTTPSCallabl internal val FIRHTTPSCallable.native get() = NativeHttpsCallableReference(this) internal val HttpsCallableReference.ios: FIRHTTPSCallable get() = native.ios +public val HttpsCallableResult.ios: FIRHTTPSCallableResult get() = ios -public actual class HttpsCallableResult(public val ios: FIRHTTPSCallableResult) { +public actual class HttpsCallableResult(internal val ios: FIRHTTPSCallableResult) { public actual inline fun data(): T = - decode(value = ios.data()) + decode(value = publicIos.data()) public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - decode(strategy, ios.data(), buildSettings) + 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 1f8abf2df..5797002cb 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 @@ -17,12 +17,14 @@ import dev.gitlive.firebase.functions.externals.getFunctions import dev.gitlive.firebase.functions.externals.httpsCallable import dev.gitlive.firebase.functions.externals.invoke import dev.gitlive.firebase.internal.decode +import dev.gitlive.firebase.js import kotlinx.coroutines.await import kotlinx.serialization.DeserializationStrategy import kotlin.js.json import kotlin.time.Duration import kotlin.time.DurationUnit import dev.gitlive.firebase.functions.externals.HttpsCallableResult as JsHttpsCallableResult +import dev.gitlive.firebase.functions.js as publicJs public actual val Firebase.functions: FirebaseFunctions get() = rethrow { FirebaseFunctions(getFunctions()) } @@ -36,7 +38,9 @@ public actual fun Firebase.functions(app: FirebaseApp): FirebaseFunctions = public actual fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions = rethrow { FirebaseFunctions(getFunctions(app.js, region)) } -public actual class FirebaseFunctions internal constructor(public val js: Functions) { +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) } @@ -58,13 +62,15 @@ internal val HttpsCallable.native: NativeHttpsCallableReference get() = NativeHt public val HttpsCallableReference.js: HttpsCallable get() = native.js -public actual class HttpsCallableResult(public val js: JsHttpsCallableResult) { +public val HttpsCallableResult.js: JsHttpsCallableResult get() = js + +public actual class HttpsCallableResult(internal val js: JsHttpsCallableResult) { public actual inline fun data(): T = - rethrow { decode(value = js.data) } + rethrow { decode(value = publicJs.data) } public actual inline fun data(strategy: DeserializationStrategy, buildSettings: DecodeSettings.Builder.() -> Unit): T = - rethrow { decode(strategy, js.data, buildSettings) } + 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/api/android/firebase-installations.api b/firebase-installations/api/android/firebase-installations.api index ae71ffadf..f4a4e0187 100644 --- a/firebase-installations/api/android/firebase-installations.api +++ b/firebase-installations/api/android/firebase-installations.api @@ -1,11 +1,11 @@ public final class dev/gitlive/firebase/installations/FirebaseInstallations { public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/installations/FirebaseInstallations; public final fun getId (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun getToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class dev/gitlive/firebase/installations/InstallationsKt { + public static final fun getAndroid (Ldev/gitlive/firebase/installations/FirebaseInstallations;)Lcom/google/firebase/installations/FirebaseInstallations; public static final fun getInstallations (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/installations/FirebaseInstallations; public static final fun installations (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/installations/FirebaseInstallations; } diff --git a/firebase-installations/api/jvm/firebase-installations.api b/firebase-installations/api/jvm/firebase-installations.api index ae71ffadf..f4a4e0187 100644 --- a/firebase-installations/api/jvm/firebase-installations.api +++ b/firebase-installations/api/jvm/firebase-installations.api @@ -1,11 +1,11 @@ public final class dev/gitlive/firebase/installations/FirebaseInstallations { public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/installations/FirebaseInstallations; public final fun getId (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun getToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class dev/gitlive/firebase/installations/InstallationsKt { + public static final fun getAndroid (Ldev/gitlive/firebase/installations/FirebaseInstallations;)Lcom/google/firebase/installations/FirebaseInstallations; public static final fun getInstallations (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/installations/FirebaseInstallations; public static final fun installations (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/installations/FirebaseInstallations; } diff --git a/firebase-installations/package.json b/firebase-installations/package.json index be8ae1397..bd98df6a8 100644 --- a/firebase-installations/package.json +++ b/firebase-installations/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-installations", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-installations.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" 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 0eab2f686..f9c0d3224 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 @@ -2,14 +2,17 @@ package dev.gitlive.firebase.installations import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android import kotlinx.coroutines.tasks.await +public val FirebaseInstallations.android: com.google.firebase.installations.FirebaseInstallations get() = com.google.firebase.installations.FirebaseInstallations.getInstance() + public actual val Firebase.installations: FirebaseInstallations get() = FirebaseInstallations(com.google.firebase.installations.FirebaseInstallations.getInstance()) public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = FirebaseInstallations(com.google.firebase.installations.FirebaseInstallations.getInstance(app.android)) -public actual class FirebaseInstallations internal constructor(public val android: com.google.firebase.installations.FirebaseInstallations) { +public actual class FirebaseInstallations internal constructor(internal val android: com.google.firebase.installations.FirebaseInstallations) { public actual suspend fun delete(): Unit = android.delete().await().let { } diff --git a/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt b/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt index f6d55b33f..00f61cd02 100644 --- a/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt +++ b/firebase-installations/src/iosMain/kotlin/dev/gitlive/firebase/installations/installations.kt @@ -4,17 +4,20 @@ import cocoapods.FirebaseInstallations.* import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.ios as publicIos import kotlinx.coroutines.CompletableDeferred import platform.Foundation.* +public val FirebaseInstallations.ios: FIRInstallations get() = FIRInstallations.installations() + public actual val Firebase.installations: FirebaseInstallations get() = FirebaseInstallations(FIRInstallations.installations()) public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = FirebaseInstallations( - FIRInstallations.installationsWithApp(app.ios as objcnames.classes.FIRApp), + FIRInstallations.installationsWithApp(app.publicIos as objcnames.classes.FIRApp), ) -public actual class FirebaseInstallations internal constructor(public val ios: FIRInstallations) { +public actual class FirebaseInstallations internal constructor(internal val ios: FIRInstallations) { public actual suspend fun delete(): Unit = ios.await { deleteWithCompletion(completion = it) } 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 c64d91fe7..de34f3637 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 @@ -4,6 +4,7 @@ import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.installations.externals.* +import dev.gitlive.firebase.js import kotlinx.coroutines.await public actual val Firebase.installations: FirebaseInstallations @@ -12,7 +13,9 @@ public actual val Firebase.installations: FirebaseInstallations public actual fun Firebase.installations(app: FirebaseApp): FirebaseInstallations = rethrow { FirebaseInstallations(getInstallations(app.js)) } -public actual class FirebaseInstallations internal constructor(public val js: Installations) { +public val FirebaseInstallations.js get() = js + +public actual class FirebaseInstallations internal constructor(internal val js: Installations) { public actual suspend fun delete(): Unit = rethrow { delete(js).await() } diff --git a/firebase-messaging/api/android/firebase-messaging.api b/firebase-messaging/api/android/firebase-messaging.api index 438484598..d9e61245a 100644 --- a/firebase-messaging/api/android/firebase-messaging.api +++ b/firebase-messaging/api/android/firebase-messaging.api @@ -1,13 +1,13 @@ public final class dev/gitlive/firebase/messaging/FirebaseMessaging { public fun (Lcom/google/firebase/messaging/FirebaseMessaging;)V public final fun deleteToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/messaging/FirebaseMessaging; public final fun getToken (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun subscribeToTopic (Ljava/lang/String;)V public final fun unsubscribeFromTopic (Ljava/lang/String;)V } public final class dev/gitlive/firebase/messaging/android { + public static final fun getAndroid (Ldev/gitlive/firebase/messaging/FirebaseMessaging;)Lcom/google/firebase/messaging/FirebaseMessaging; public static final fun getMessaging (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/messaging/FirebaseMessaging; } diff --git a/firebase-messaging/package.json b/firebase-messaging/package.json index 58cbf6caf..057b92487 100644 --- a/firebase-messaging/package.json +++ b/firebase-messaging/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-messaging", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-messaging.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index cd8b210d5..a46dfaace 100644 --- a/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -5,10 +5,12 @@ package dev.gitlive.firebase.messaging import dev.gitlive.firebase.Firebase import kotlinx.coroutines.tasks.await +public val FirebaseMessaging.android: com.google.firebase.messaging.FirebaseMessaging get() = com.google.firebase.messaging.FirebaseMessaging.getInstance() + public actual val Firebase.messaging: FirebaseMessaging get() = FirebaseMessaging(com.google.firebase.messaging.FirebaseMessaging.getInstance()) -public actual class FirebaseMessaging(public val android: com.google.firebase.messaging.FirebaseMessaging) { +public actual class FirebaseMessaging(internal val android: com.google.firebase.messaging.FirebaseMessaging) { public actual fun subscribeToTopic(topic: String) { android.subscribeToTopic(topic) } diff --git a/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index c81c08bf1..dd707d5a8 100644 --- a/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -5,10 +5,12 @@ import dev.gitlive.firebase.Firebase import kotlinx.coroutines.CompletableDeferred import platform.Foundation.NSError +public val FirebaseMessaging.ios: FIRMessaging get() = FIRMessaging.messaging() + public actual val Firebase.messaging: FirebaseMessaging get() = FirebaseMessaging(FIRMessaging.messaging()) -public actual class FirebaseMessaging(public val ios: FIRMessaging) { +public actual class FirebaseMessaging(internal val ios: FIRMessaging) { public actual fun subscribeToTopic(topic: String) { ios.subscribeToTopic(topic) } diff --git a/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt b/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt index 8a767825e..6dac0ed74 100644 --- a/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt +++ b/firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt @@ -8,7 +8,9 @@ import kotlinx.coroutines.await public actual val Firebase.messaging: FirebaseMessaging get() = FirebaseMessaging(getMessaging()) -public actual class FirebaseMessaging(public val js: Messaging) { +public val FirebaseMessaging.js: Messaging get() = js + +public actual class FirebaseMessaging(internal val js: Messaging) { public actual fun subscribeToTopic(topic: String) { // This is not supported in the JS SDK // https://firebase.google.com/docs/reference/js/messaging_.md#@firebase/messaging diff --git a/firebase-perf/api/android/firebase-perf.api b/firebase-perf/api/android/firebase-perf.api index 730cbc4d4..135ca3ad0 100644 --- a/firebase-perf/api/android/firebase-perf.api +++ b/firebase-perf/api/android/firebase-perf.api @@ -1,6 +1,5 @@ public final class dev/gitlive/firebase/perf/FirebasePerformance { public fun (Lcom/google/firebase/perf/FirebasePerformance;)V - public final fun getAndroid ()Lcom/google/firebase/perf/FirebasePerformance; public final fun isPerformanceCollectionEnabled ()Z public final fun newTrace (Ljava/lang/String;)Ldev/gitlive/firebase/perf/metrics/Trace; public final fun setPerformanceCollectionEnabled (Z)V @@ -11,6 +10,7 @@ public class dev/gitlive/firebase/perf/FirebasePerformanceException : com/google } public final class dev/gitlive/firebase/perf/PerformanceKt { + public static final fun getAndroid (Ldev/gitlive/firebase/perf/FirebasePerformance;)Lcom/google/firebase/perf/FirebasePerformance; public static final fun getPerformance (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/perf/FirebasePerformance; public static final fun performance (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/perf/FirebasePerformance; } @@ -29,6 +29,9 @@ public final class dev/gitlive/firebase/perf/metrics/Trace { } public final class dev/gitlive/firebase/perf/session/PerfSession { - public final fun getAndroid ()Lcom/google/firebase/perf/session/PerfSession; +} + +public final class dev/gitlive/firebase/perf/session/PerfSessionKt { + public static final fun getAndroid (Lcom/google/firebase/perf/session/PerfSession;)Lcom/google/firebase/perf/session/PerfSession; } diff --git a/firebase-perf/package.json b/firebase-perf/package.json index fb7615b9e..cd6e77684 100644 --- a/firebase-perf/package.json +++ b/firebase-perf/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-perf", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-perf.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" 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 ce1f6e0af..ca6e00675 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 @@ -3,15 +3,18 @@ package dev.gitlive.firebase.perf import com.google.firebase.FirebaseException import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android as publicAndroid import dev.gitlive.firebase.perf.metrics.Trace +public val FirebasePerformance.android: com.google.firebase.perf.FirebasePerformance get() = com.google.firebase.perf.FirebasePerformance.getInstance() + public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(com.google.firebase.perf.FirebasePerformance.getInstance()) public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = - FirebasePerformance(app.android.get(com.google.firebase.perf.FirebasePerformance::class.java)) + FirebasePerformance(app.publicAndroid.get(com.google.firebase.perf.FirebasePerformance::class.java)) -public actual class FirebasePerformance(public val android: com.google.firebase.perf.FirebasePerformance) { +public actual class FirebasePerformance(internal val android: com.google.firebase.perf.FirebasePerformance) { public actual fun newTrace(traceName: String): Trace = Trace(android.newTrace(traceName)) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt index 744ec782c..cc3ad8d02 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt @@ -2,4 +2,6 @@ package dev.gitlive.firebase.perf.session import com.google.firebase.perf.session.PerfSession -public class PerfSession internal constructor(public val android: PerfSession) +public val PerfSession.android: PerfSession get() = android + +public class PerfSession internal constructor(internal val android: PerfSession) diff --git a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index e3bc2781c..8e1e564ec 100644 --- a/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/iosMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -2,7 +2,9 @@ package dev.gitlive.firebase.perf.metrics import cocoapods.FirebasePerformance.FIRTrace -public actual class Trace internal constructor(public val ios: FIRTrace?) { +public val Trace.ios: FIRTrace? get() = ios + +public actual class Trace internal constructor(internal val ios: FIRTrace?) { public actual fun start() { ios?.start() 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 22d75c376..527660077 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 @@ -6,13 +6,15 @@ import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException import dev.gitlive.firebase.perf.metrics.Trace +public val FirebasePerformance.ios: FIRPerformance get() = FIRPerformance.sharedInstance() + public actual val Firebase.performance: FirebasePerformance get() = FirebasePerformance(FIRPerformance.sharedInstance()) public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(FIRPerformance.sharedInstance()) -public actual class FirebasePerformance(public val ios: FIRPerformance) { +public actual class FirebasePerformance(internal val ios: FIRPerformance) { public actual fun newTrace(traceName: String): Trace = Trace(ios.traceWithName(traceName)) diff --git a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 5974449ac..fd0582711 100644 --- a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,7 +3,9 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.perf.externals.PerformanceTrace import dev.gitlive.firebase.perf.rethrow -public actual class Trace internal constructor(private val js: PerformanceTrace) { +public val Trace.js get() = js + +public actual class Trace internal constructor(internal val js: PerformanceTrace) { public actual fun start(): Unit = rethrow { js.start() } public actual fun stop(): Unit = rethrow { js.stop() } diff --git a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt index be4696645..be5144a10 100644 --- a/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -3,6 +3,7 @@ package dev.gitlive.firebase.perf import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.js import dev.gitlive.firebase.perf.externals.getPerformance import dev.gitlive.firebase.perf.externals.trace import dev.gitlive.firebase.perf.metrics.Trace @@ -17,7 +18,9 @@ public actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance = FirebasePerformance(getPerformance(app.js)) } -public actual class FirebasePerformance internal constructor(public val js: JsFirebasePerformance) { +public val FirebasePerformance.js get() = js + +public actual class FirebasePerformance internal constructor(internal val js: JsFirebasePerformance) { public actual fun newTrace(traceName: String): Trace = rethrow { Trace(trace(js, traceName)) diff --git a/firebase-storage/api/android/firebase-storage.api b/firebase-storage/api/android/firebase-storage.api index 2a4d592c0..4715f8dcf 100644 --- a/firebase-storage/api/android/firebase-storage.api +++ b/firebase-storage/api/android/firebase-storage.api @@ -10,7 +10,6 @@ public final class dev/gitlive/firebase/storage/File { public final class dev/gitlive/firebase/storage/FirebaseStorage { public fun (Lcom/google/firebase/storage/FirebaseStorage;)V - public final fun getAndroid ()Lcom/google/firebase/storage/FirebaseStorage; public final fun getMaxOperationRetryTime-UwyO8pc ()J public final fun getMaxUploadRetryTime-UwyO8pc ()J public final fun getReference ()Ldev/gitlive/firebase/storage/StorageReference; @@ -90,7 +89,6 @@ public final class dev/gitlive/firebase/storage/StorageReference { public fun (Lcom/google/firebase/storage/StorageReference;)V public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/storage/StorageReference; public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getAndroid ()Lcom/google/firebase/storage/StorageReference; public final fun getBucket ()Ljava/lang/String; public final fun getDownloadUrl (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun getMetadata (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -109,6 +107,9 @@ public final class dev/gitlive/firebase/storage/StorageReference { } public final class dev/gitlive/firebase/storage/android { + public static final fun getAndroid (Ldev/gitlive/firebase/storage/FirebaseStorage;)Lcom/google/firebase/storage/FirebaseStorage; + public static final fun getAndroid (Ldev/gitlive/firebase/storage/ListResult;)Lcom/google/firebase/storage/ListResult; + public static final fun getAndroid (Ldev/gitlive/firebase/storage/StorageReference;)Lcom/google/firebase/storage/StorageReference; public static final fun getStorage (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/storage/FirebaseStorage; public static final fun storage (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/storage/FirebaseStorage; public static final fun storage (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;Ljava/lang/String;)Ldev/gitlive/firebase/storage/FirebaseStorage; diff --git a/firebase-storage/package.json b/firebase-storage/package.json index 0bf7a3881..07e46118b 100644 --- a/firebase-storage/package.json +++ b/firebase-storage/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-storage", - "version": "1.13.0", + "version": "2.0.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-storage.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.13.0", + "@gitlive/firebase-app": "2.0.0", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt index e0cf827ad..8d435afed 100644 --- a/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/androidMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -15,6 +15,7 @@ import com.google.firebase.storage.StorageMetadata import com.google.firebase.storage.UploadTask import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp +import dev.gitlive.firebase.android as publicAndroid import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.trySendBlocking @@ -25,15 +26,17 @@ import kotlinx.coroutines.tasks.await import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds +public val FirebaseStorage.android: com.google.firebase.storage.FirebaseStorage get() = com.google.firebase.storage.FirebaseStorage.getInstance() + public actual val Firebase.storage: FirebaseStorage get() = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance()) public actual fun Firebase.storage(url: String): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(url)) -public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.android)) +public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.publicAndroid)) -public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.android, url)) +public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = FirebaseStorage(com.google.firebase.storage.FirebaseStorage.getInstance(app.publicAndroid, url)) -public actual class FirebaseStorage(public val android: com.google.firebase.storage.FirebaseStorage) { +public actual class FirebaseStorage(internal val android: com.google.firebase.storage.FirebaseStorage) { public actual val maxOperationRetryTime: Duration = android.maxOperationRetryTimeMillis.milliseconds public actual val maxUploadRetryTime: Duration = android.maxUploadRetryTimeMillis.milliseconds @@ -54,7 +57,9 @@ public actual class FirebaseStorage(public val android: com.google.firebase.stor public actual fun reference(location: String): StorageReference = StorageReference(android.getReference(location)) } -public actual class StorageReference(public val android: com.google.firebase.storage.StorageReference) { +public val StorageReference.android: com.google.firebase.storage.StorageReference get() = android + +public actual class StorageReference(internal val android: com.google.firebase.storage.StorageReference) { public actual val name: String get() = android.name public actual val path: String get() = android.path public actual val bucket: String get() = android.bucket @@ -123,7 +128,9 @@ public actual class StorageReference(public val android: com.google.firebase.sto } } -public actual class ListResult(android: com.google.firebase.storage.ListResult) { +public val ListResult.android: com.google.firebase.storage.ListResult get() = android + +public actual class ListResult(internal val android: com.google.firebase.storage.ListResult) { public actual val prefixes: List = android.prefixes.map { StorageReference(it) } public actual val items: List = android.items.map { StorageReference(it) } public actual val pageToken: String? = android.pageToken diff --git a/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt index 586820a61..0a0c1afab 100644 --- a/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/iosMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -16,6 +16,7 @@ import cocoapods.FirebaseStorage.FIRStorageTaskStatusSuccess import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.ios import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.awaitClose @@ -30,6 +31,8 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit +public val FirebaseStorage.ios: FIRStorage get() = FIRStorage.storage() + public actual val Firebase.storage: FirebaseStorage get() = FirebaseStorage(FIRStorage.storage()) @@ -45,7 +48,7 @@ public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStora FIRStorage.storageForApp(app.ios as objcnames.classes.FIRApp, url), ) -public actual class FirebaseStorage(public val ios: FIRStorage) { +public actual class FirebaseStorage(internal val ios: FIRStorage) { public actual val maxOperationRetryTime: Duration = ios.maxOperationRetryTime().seconds public actual val maxUploadRetryTime: Duration = ios.maxUploadRetryTime().seconds @@ -66,7 +69,9 @@ public actual class FirebaseStorage(public val ios: FIRStorage) { public actual fun reference(location: String): StorageReference = StorageReference(ios.referenceWithPath(location)) } -public actual class StorageReference(public val ios: FIRStorageReference) { +public val StorageReference.ios: FIRStorageReference get() = ios + +public actual class StorageReference(internal val ios: FIRStorageReference) { public actual val name: String get() = ios.name() public actual val path: String get() = ios.fullPath() public actual val bucket: String get() = ios.bucket() @@ -142,7 +147,9 @@ public actual class StorageReference(public val ios: FIRStorageReference) { } } -public actual class ListResult(ios: FIRStorageListResult) { +public val ListResult.ios: FIRStorageListResult get() = ios + +public actual class ListResult(internal val ios: FIRStorageListResult) { public actual val prefixes: List = ios.prefixes().map { StorageReference(it as FIRStorageReference) } public actual val items: List = ios.items().map { StorageReference(it as FIRStorageReference) } public actual val pageToken: String? = ios.pageToken() diff --git a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt index 22925cd54..14a7897b3 100644 --- a/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jsMain/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -7,6 +7,7 @@ package dev.gitlive.firebase.storage import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.js import dev.gitlive.firebase.storage.externals.* import kotlinx.coroutines.await import kotlinx.coroutines.cancel @@ -29,7 +30,9 @@ public actual fun Firebase.storage(app: FirebaseApp): FirebaseStorage = Firebase public actual fun Firebase.storage(app: FirebaseApp, url: String): FirebaseStorage = FirebaseStorage(getStorage(app.js, url)) -public actual class FirebaseStorage(public val js: dev.gitlive.firebase.storage.externals.FirebaseStorage) { +public val FirebaseStorage.js get() = js + +public actual class FirebaseStorage(internal val js: dev.gitlive.firebase.storage.externals.FirebaseStorage) { public actual val maxOperationRetryTime: Duration = js.maxOperationRetryTime.milliseconds public actual val maxUploadRetryTime: Duration = js.maxUploadRetryTime.milliseconds @@ -50,7 +53,9 @@ public actual class FirebaseStorage(public val js: dev.gitlive.firebase.storage. public actual fun reference(location: String): StorageReference = rethrow { StorageReference(ref(js, location)) } } -public actual class StorageReference(public val js: dev.gitlive.firebase.storage.externals.StorageReference) { +public val StorageReference.js get() = js + +public actual class StorageReference(internal val js: dev.gitlive.firebase.storage.externals.StorageReference) { public actual val path: String get() = js.fullPath public actual val name: String get() = js.name public actual val bucket: String get() = js.bucket diff --git a/gradle.properties b/gradle.properties index f6781cbdb..01a9fd1fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -70,17 +70,17 @@ firebase-perf.skipJsTests=false firebase-storage.skipJsTests=false # Versions: -firebase-analytics.version=1.13.0 -firebase-app.version=1.13.0 -firebase-auth.version=1.13.0 -firebase-common-internal.version=1.13.0 -firebase-common.version=1.13.0 -firebase-config.version=1.13.0 -firebase-crashlytics.version=1.13.0 -firebase-database.version=1.13.0 -firebase-firestore.version=1.13.0 -firebase-functions.version=1.13.0 -firebase-installations.version=1.13.0 -firebase-messaging.version=1.13.0 -firebase-perf.version=1.13.0 -firebase-storage.version=1.13.0 +firebase-analytics.version=2.0.0 +firebase-app.version=2.0.0 +firebase-auth.version=2.0.0 +firebase-common-internal.version=2.0.0 +firebase-common.version=2.0.0 +firebase-config.version=2.0.0 +firebase-crashlytics.version=2.0.0 +firebase-database.version=2.0.0 +firebase-firestore.version=2.0.0 +firebase-functions.version=2.0.0 +firebase-installations.version=2.0.0 +firebase-messaging.version=2.0.0 +firebase-perf.version=2.0.0 +firebase-storage.version=2.0.0