diff --git a/build.gradle.kts b/build.gradle.kts index 241d9727a..2441b6cfd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ buildscript { } } dependencies { - classpath("com.android.tools.build:gradle:4.0.2") + classpath("com.android.tools.build:gradle:4.1.1") classpath("de.undercouch:gradle-download-task:4.1.1") classpath("com.adarshr:gradle-test-logger-plugin:2.0.0") } diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index 9d3d535f1..478d245e1 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -68,7 +68,7 @@ kotlin { } val androidMain by getting { dependencies { - api("com.google.firebase:firebase-common:19.4.0") + api("com.google.firebase:firebase-common:19.5.0") } } diff --git a/firebase-app/package.json b/firebase-app/package.json index 1f30c3d1f..9a830107d 100644 --- a/firebase-app/package.json +++ b/firebase-app/package.json @@ -23,8 +23,8 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-common": "1.1.0", - "firebase": "8.2.0", + "@gitlive/firebase-common": "1.2.0", + "firebase": "8.2.3", "kotlin": "1.4.21", "kotlinx-coroutines-core": "1.4.2" } diff --git a/firebase-app/src/iosMain/c_interop/Cartfile b/firebase-app/src/iosMain/c_interop/Cartfile index 2e44ace87..419db3b7c 100644 --- a/firebase-app/src/iosMain/c_interop/Cartfile +++ b/firebase-app/src/iosMain/c_interop/Cartfile @@ -1 +1 @@ -binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 7.3.0 \ No newline at end of file +binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 7.4.0 \ No newline at end of file diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index e4d54587f..0de4b4231 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -102,7 +102,7 @@ kotlin { val androidMain by getting { dependencies { - api("com.google.firebase:firebase-auth:20.0.1") + api("com.google.firebase:firebase-auth:20.0.2") } } diff --git a/firebase-auth/package.json b/firebase-auth/package.json index ef2b5a7f0..74867976a 100644 --- a/firebase-auth/package.json +++ b/firebase-auth/package.json @@ -23,8 +23,8 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.1.0", - "firebase": "8.2.0", + "@gitlive/firebase-app": "1.2.0", + "firebase": "8.2.3", "kotlin": "1.4.21", "kotlinx-coroutines-core": "1.4.2" } diff --git a/firebase-auth/src/iosMain/c_interop/Cartfile b/firebase-auth/src/iosMain/c_interop/Cartfile index 6510454a0..b6a1566ba 100644 --- a/firebase-auth/src/iosMain/c_interop/Cartfile +++ b/firebase-auth/src/iosMain/c_interop/Cartfile @@ -1 +1 @@ -binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json" == 7.3.0 \ No newline at end of file +binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json" == 7.4.0 \ No newline at end of file diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 2995ef400..b08a31760 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -68,7 +68,7 @@ kotlin { } val androidMain by getting { dependencies { - api("com.google.firebase:firebase-common:19.4.0") + api("com.google.firebase:firebase-common:19.5.0") } } val jsMain by getting { diff --git a/firebase-common/package.json b/firebase-common/package.json index f5c816999..777aa61ae 100644 --- a/firebase-common/package.json +++ b/firebase-common/package.json @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-multiplatform-sdk", "dependencies": { - "firebase": "8.2.0", + "firebase": "8.2.3", "kotlin": "1.4.21", "kotlinx-coroutines-core": "1.4.2", "kotlinx-serialization-kotlinx-serialization-runtime": "1.0.1" diff --git a/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt b/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt index f9d96901f..9a5c799c9 100644 --- a/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt +++ b/firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt @@ -344,6 +344,8 @@ external object firebase { fun enablePersistence(): Promise fun clearPersistence(): Promise fun useEmulator(host: String, port: Int) + fun disableNetwork(): Promise + fun enableNetwork(): Promise } open class Timestamp { diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index bef15ffbf..9996457ce 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -76,7 +76,7 @@ kotlin { } val androidMain by getting { dependencies { - api("com.google.firebase:firebase-database:19.5.1") + api("com.google.firebase:firebase-database:19.6.0") } } val jsMain by getting {} diff --git a/firebase-database/package.json b/firebase-database/package.json index 83e4ccfe9..7790e9e26 100644 --- a/firebase-database/package.json +++ b/firebase-database/package.json @@ -23,8 +23,8 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.1.0", - "firebase": "8.2.0", + "@gitlive/firebase-app": "1.2.0", + "firebase": "8.2.3", "kotlin": "1.4.21", "kotlinx-coroutines-core": "1.4.2" } diff --git a/firebase-database/src/iosMain/c_interop/Cartfile b/firebase-database/src/iosMain/c_interop/Cartfile index 6de16de82..f4dc88d0b 100644 --- a/firebase-database/src/iosMain/c_interop/Cartfile +++ b/firebase-database/src/iosMain/c_interop/Cartfile @@ -1 +1 @@ -binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDatabaseBinary.json" == 7.3.0 \ No newline at end of file +binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseDatabaseBinary.json" == 7.4.0 \ No newline at end of file diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 119dad85f..6432bab98 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -78,7 +78,7 @@ kotlin { } val androidMain by getting { dependencies { - api("com.google.firebase:firebase-firestore:22.0.0") + api("com.google.firebase:firebase-firestore:22.0.1") implementation("com.android.support:multidex:1.0.3") } } diff --git a/firebase-firestore/package.json b/firebase-firestore/package.json index d9f3c3de6..fb1676fac 100644 --- a/firebase-firestore/package.json +++ b/firebase-firestore/package.json @@ -23,8 +23,8 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.1.0", - "firebase": "8.2.0", + "@gitlive/firebase-app": "1.2.0", + "firebase": "8.2.3", "kotlin": "1.4.21", "kotlinx-coroutines-core": "1.4.2" } 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 85d872074..2092be07b 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 @@ -7,17 +7,14 @@ package dev.gitlive.firebase.firestore import com.google.firebase.Timestamp import com.google.firebase.firestore.FieldValue -import com.google.firebase.firestore.FirebaseFirestoreSettings import com.google.firebase.firestore.SetOptions import dev.gitlive.firebase.* -import dev.gitlive.firebase.firestore.encode import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.runBlocking import kotlinx.coroutines.tasks.await import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.SerializationStrategy -import kotlinx.serialization.serializer @PublishedApi internal inline fun decode(value: Any?): T = @@ -41,12 +38,6 @@ actual fun Firebase.firestore(app: FirebaseApp) = actual class FirebaseFirestore(val android: com.google.firebase.firestore.FirebaseFirestore) { -// actual var settings: FirebaseFirestoreSettings -// get() = android.firestoreSettings.run { FirebaseFirestoreSettings(isPersistenceEnabled) } -// set(value) { -// android.firestoreSettings = value.run { Builder().setPersistenceEnabled(persistenceEnabled).build() } -// } - actual fun collection(collectionPath: String) = CollectionReference(android.collection(collectionPath)) actual fun document(documentPath: String) = DocumentReference(android.document(documentPath)) @@ -60,15 +51,30 @@ actual class FirebaseFirestore(val android: com.google.firebase.firestore.Fireba android.runTransaction { runBlocking { Transaction(it).func() } }.await() actual suspend fun clearPersistence() = - android.clearPersistence().await() - .run { Unit } + android.clearPersistence().await().run { } actual fun useEmulator(host: String, port: Int) { android.useEmulator(host, port) - android.firestoreSettings = FirebaseFirestoreSettings.Builder() + android.firestoreSettings = com.google.firebase.firestore.FirebaseFirestoreSettings.Builder() .setPersistenceEnabled(false) .build() } + + actual fun setSettings(persistenceEnabled: Boolean?, sslEnabled: Boolean?, host: String?, cacheSizeBytes: Long?) { + android.firestoreSettings = com.google.firebase.firestore.FirebaseFirestoreSettings.Builder().also { builder -> + persistenceEnabled?.let { builder.setPersistenceEnabled(it) } + sslEnabled?.let { builder.isSslEnabled = it } + host?.let { builder.host = it } + cacheSizeBytes?.let { builder.cacheSizeBytes = it } + }.build() + } + + actual suspend fun disableNetwork() = + android.disableNetwork().await().run { } + + actual suspend fun enableNetwork() = + android.enableNetwork().await().run { } + } actual class WriteBatch(val android: com.google.firebase.firestore.WriteBatch) { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 3b224fcb1..714d931c0 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -19,7 +19,6 @@ expect val Firebase.firestore: FirebaseFirestore expect fun Firebase.firestore(app: FirebaseApp): FirebaseFirestore expect class FirebaseFirestore { -// var settings: FirebaseFirestoreSettings fun collection(collectionPath: String): CollectionReference fun document(documentPath: String): DocumentReference fun batch(): WriteBatch @@ -27,6 +26,9 @@ expect class FirebaseFirestore { suspend fun clearPersistence() suspend fun runTransaction(func: suspend Transaction.() -> T): T fun useEmulator(host: String, port: Int) + fun setSettings(persistenceEnabled: Boolean? = null, sslEnabled: Boolean? = null, host: String? = null, cacheSizeBytes: Long? = null) + suspend fun disableNetwork() + suspend fun enableNetwork() } expect class Transaction { @@ -49,10 +51,6 @@ expect class Transaction { suspend fun get(documentRef: DocumentReference): DocumentSnapshot } -//data class FirebaseFirestoreSettings( -// val persistenceEnabled: Boolean = true -//) - expect open class Query { fun limit(limit: Number): Query val snapshots: Flow diff --git a/firebase-firestore/src/iosMain/c_interop/Cartfile b/firebase-firestore/src/iosMain/c_interop/Cartfile index 7e6df3ae2..62e581bdf 100644 --- a/firebase-firestore/src/iosMain/c_interop/Cartfile +++ b/firebase-firestore/src/iosMain/c_interop/Cartfile @@ -1 +1 @@ -binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json" == 7.3.0 \ No newline at end of file +binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json" == 7.4.0 \ No newline at end of file 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 0efbb528a..9f4353525 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 @@ -50,7 +50,7 @@ actual class FirebaseFirestore(val ios: FIRFirestore) { FIRFirestore.enableLogging(loggingEnabled) actual suspend fun runTransaction(func: suspend Transaction.() -> T) = - awaitResult { ios.runTransactionWithBlock({ transaction, error -> runBlocking { Transaction(transaction!!).func() } }, it) } as T + awaitResult { ios.runTransactionWithBlock({ transaction, _ -> runBlocking { Transaction(transaction!!).func() } }, it) } as T actual suspend fun clearPersistence() = await { ios.clearPersistenceWithCompletion(it) } @@ -62,6 +62,23 @@ actual class FirebaseFirestore(val ios: FIRFirestore) { sslEnabled = false } } + + actual fun setSettings(persistenceEnabled: Boolean?, sslEnabled: Boolean?, host: String?, cacheSizeBytes: Long?) { + ios.settings = FIRFirestoreSettings().also { settings -> + persistenceEnabled?.let { settings.persistenceEnabled = it } + sslEnabled?.let { settings.sslEnabled = it } + host?.let { settings.host = it } + cacheSizeBytes?.let { settings.cacheSizeBytes = it } + } + } + + actual suspend fun disableNetwork() { + await { ios.disableNetworkWithCompletion(it) } + } + + actual suspend fun enableNetwork() { + await { ios.enableNetworkWithCompletion(it) } + } } @Suppress("UNCHECKED_CAST") 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 581b07a0d..87b08a342 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 @@ -3,6 +3,7 @@ */ package dev.gitlive.firebase.firestore + import dev.gitlive.firebase.* import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.await @@ -35,12 +36,6 @@ actual fun Firebase.firestore(app: FirebaseApp) = actual class FirebaseFirestore(val js: firebase.firestore.Firestore) { -// actual var settings: FirebaseFirestoreSettings -// get() = js.settings().run { FirebaseFirestoreSettings(js.isPersistenceEnabled) } -// set(value) { -// js.settings() = value.run { Builder().setPersistenceEnabled(persistenceEnabled).build() } -// } - actual fun collection(collectionPath: String) = rethrow { CollectionReference(js.collection(collectionPath)) } actual fun document(documentPath: String) = rethrow { DocumentReference(js.doc(documentPath)) } @@ -57,6 +52,24 @@ actual class FirebaseFirestore(val js: firebase.firestore.Firestore) { rethrow { js.clearPersistence().await() } actual fun useEmulator(host: String, port: Int) = rethrow { js.useEmulator(host, port) } + + actual fun setSettings(persistenceEnabled: Boolean?, sslEnabled: Boolean?, host: String?, cacheSizeBytes: Long?) { + if(persistenceEnabled == true) js.enablePersistence() + + js.settings(json().apply { + sslEnabled?.let { set("ssl", it) } + host?.let { set("host", it) } + cacheSizeBytes?.let { set("cacheSizeBytes", it) } + }) + } + + actual suspend fun disableNetwork() { + rethrow { js.disableNetwork().await() } + } + + actual suspend fun enableNetwork() { + rethrow { js.enableNetwork().await() } + } } actual class WriteBatch(val js: firebase.firestore.WriteBatch) { diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index aa58f140c..2e6032981 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -70,7 +70,7 @@ kotlin { } val androidMain by getting { dependencies { - api("com.google.firebase:firebase-functions:19.1.0") + api("com.google.firebase:firebase-functions:19.2.0") } } val iosMain by getting {} diff --git a/firebase-functions/package.json b/firebase-functions/package.json index 0b61d1d0a..fa16acdab 100644 --- a/firebase-functions/package.json +++ b/firebase-functions/package.json @@ -23,8 +23,8 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.1.0", - "firebase": "8.2.0", + "@gitlive/firebase-app": "1.2.0", + "firebase": "8.2.3", "kotlin": "1.4.21", "kotlinx-coroutines-core": "1.4.2" } diff --git a/firebase-functions/src/iosMain/c_interop/Cartfile b/firebase-functions/src/iosMain/c_interop/Cartfile index 608708a77..877c9ec1c 100644 --- a/firebase-functions/src/iosMain/c_interop/Cartfile +++ b/firebase-functions/src/iosMain/c_interop/Cartfile @@ -1 +1 @@ -binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json" == 7.3.0 \ No newline at end of file +binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json" == 7.4.0 \ No newline at end of file