-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from splendo/fix-on-disconnect
Fix OnDisconnect failing to updateChildren
- Loading branch information
Showing
118 changed files
with
2,639 additions
and
1,538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree | ||
|
||
/* | ||
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
version = project.property("firebase-common-internal.version") as String | ||
|
||
plugins { | ||
id("com.android.library") | ||
kotlin("multiplatform") | ||
kotlin("plugin.serialization") | ||
} | ||
|
||
android { | ||
val minSdkVersion: Int by project | ||
val compileSdkVersion: Int by project | ||
|
||
compileSdk = compileSdkVersion | ||
namespace = "dev.gitlive.firebase.common.internal" | ||
defaultConfig { | ||
minSdk = minSdkVersion | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
testOptions { | ||
unitTests.apply { | ||
isIncludeAndroidResources = true | ||
} | ||
} | ||
|
||
packaging { | ||
resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") | ||
resources.pickFirsts.add("META-INF/AL2.0") | ||
resources.pickFirsts.add("META-INF/LGPL2.1") | ||
} | ||
lint { | ||
abortOnError = false | ||
} | ||
} | ||
|
||
kotlin { | ||
|
||
targets.configureEach { | ||
compilations.configureEach { | ||
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" | ||
} | ||
} | ||
|
||
@Suppress("OPT_IN_USAGE") | ||
androidTarget { | ||
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) | ||
unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) | ||
publishAllLibraryVariants() | ||
compilations.configureEach { | ||
kotlinOptions { | ||
jvmTarget = "11" | ||
} | ||
} | ||
} | ||
|
||
jvm { | ||
compilations.getByName("main") { | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
compilations.getByName("test") { | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
} | ||
|
||
val supportIosTarget = project.property("skipIosTarget") != "true" | ||
|
||
if (supportIosTarget) { | ||
iosArm64() | ||
iosX64() | ||
iosSimulatorArm64() | ||
} | ||
|
||
js(IR) { | ||
useCommonJs() | ||
nodejs { | ||
testTask( | ||
Action { | ||
useKarma { | ||
useChromeHeadless() | ||
} | ||
} | ||
) | ||
} | ||
browser { | ||
testTask( | ||
Action { | ||
useKarma { | ||
useChromeHeadless() | ||
} | ||
} | ||
) | ||
} | ||
} | ||
|
||
sourceSets { | ||
all { | ||
languageSettings.apply { | ||
val apiVersion: String by project | ||
val languageVersion: String by project | ||
this.apiVersion = apiVersion | ||
this.languageVersion = languageVersion | ||
progressiveMode = true | ||
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") | ||
optIn("kotlinx.serialization.ExperimentalSerializationApi") | ||
optIn("kotlinx.serialization.InternalSerializationApi") | ||
} | ||
} | ||
|
||
getByName("commonMain") { | ||
val serializationVersion: String by project | ||
|
||
dependencies { | ||
implementation(project(":firebase-common")) | ||
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion") | ||
} | ||
} | ||
|
||
getByName("commonTest") { | ||
dependencies { | ||
implementation(project(":test-utils")) | ||
} | ||
} | ||
|
||
getByName("androidMain") { | ||
dependencies { | ||
api("com.google.firebase:firebase-common-ktx") | ||
} | ||
} | ||
|
||
getByName("jsMain") { | ||
dependencies { | ||
api(npm("firebase", "10.6.0")) | ||
} | ||
} | ||
|
||
getByName("jvmMain") { | ||
kotlin.srcDir("src/androidMain/kotlin") | ||
} | ||
|
||
getByName("jvmTest") { | ||
dependencies { | ||
implementation(kotlin("test-junit")) | ||
} | ||
kotlin.srcDir("src/androidAndroidTest/kotlin") | ||
} | ||
} | ||
} | ||
|
||
if (project.property("firebase-common.skipIosTests") == "true") { | ||
tasks.forEach { | ||
if (it.name.contains("ios", true) && it.name.contains("test", true)) { it.enabled = false } | ||
} | ||
} | ||
|
||
if (project.property("firebase-common.skipJsTests") == "true") { | ||
tasks.forEach { | ||
if (it.name.contains("js", true) && it.name.contains("test", true)) { it.enabled = false } | ||
} | ||
} | ||
|
||
signing { | ||
val signingKey: String? by project | ||
val signingPassword: String? by project | ||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
sign(publishing.publications) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@gitlive/firebase-common-internal", | ||
"version": "1.12.0", | ||
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", | ||
"main": "firebase-common-internal.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/GitLiveApp/firebase-kotlin-sdk.git" | ||
}, | ||
"keywords": [ | ||
"kotlin", | ||
"multiplatform", | ||
"kotlin-js", | ||
"firebase" | ||
], | ||
"author": "dev.gitlive", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/GitLiveApp/firebase-kotlin-multiplatform-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-multiplatform-sdk", | ||
"dependencies": { | ||
"@gitlive/firebase-common": "1.12.0", | ||
"firebase": "9.19.1", | ||
"kotlin": "1.8.20", | ||
"kotlinx-coroutines-core": "1.6.4", | ||
"kotlinx-serialization-kotlinx-serialization-runtime": "1.3.2" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ase-common-internal/src/androidMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@file:JvmName("AndroidEncodedObject") | ||
package dev.gitlive.firebase.internal | ||
|
||
val EncodedObject.android: Map<String, Any?> get() = getRaw() | ||
|
||
@PublishedApi | ||
internal actual fun Any.asNativeMap(): Map<*, *>? = this as? Map<*, *> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...mmon-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodeDecodeSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package dev.gitlive.firebase.internal | ||
|
||
import dev.gitlive.firebase.DecodeSettings | ||
import dev.gitlive.firebase.EncodeDecodeSettingsBuilder | ||
import dev.gitlive.firebase.EncodeSettings | ||
import kotlinx.serialization.modules.EmptySerializersModule | ||
import kotlinx.serialization.modules.SerializersModule | ||
|
||
@PublishedApi | ||
internal data class EncodeSettingsImpl internal constructor( | ||
override val encodeDefaults: Boolean, | ||
override val serializersModule: SerializersModule, | ||
) : EncodeSettings { | ||
|
||
@PublishedApi | ||
internal class Builder : EncodeSettings.Builder { | ||
override var encodeDefaults: Boolean = true | ||
override var serializersModule: SerializersModule = EmptySerializersModule() | ||
} | ||
} | ||
|
||
@PublishedApi | ||
internal class DecodeSettingsImpl internal constructor( | ||
override val serializersModule: SerializersModule = EmptySerializersModule(), | ||
) : DecodeSettings { | ||
|
||
@PublishedApi | ||
internal class Builder : DecodeSettings.Builder { | ||
override var serializersModule: SerializersModule = EmptySerializersModule() | ||
} | ||
} | ||
|
||
@PublishedApi | ||
internal class EncodeDecodeSettingsBuilderImpl : EncodeDecodeSettingsBuilder { | ||
|
||
override var encodeDefaults: Boolean = true | ||
override var serializersModule: SerializersModule = EmptySerializersModule() | ||
} | ||
|
||
@PublishedApi | ||
internal fun EncodeSettings.Builder.buildEncodeSettings(): EncodeSettings = EncodeSettingsImpl(encodeDefaults, serializersModule) | ||
@PublishedApi | ||
internal fun DecodeSettings.Builder.buildDecodeSettings(): DecodeSettings = DecodeSettingsImpl(serializersModule) |
29 changes: 29 additions & 0 deletions
29
...base-common-internal/src/commonMain/kotlin/dev/gitlive/firebase/internal/EncodedObject.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.gitlive.firebase.internal | ||
|
||
import kotlin.jvm.JvmInline | ||
|
||
/** | ||
* Platform specific object for storing encoded data that can be used for methods that explicitly require an object. | ||
* This is essentially a [Map] of [String] and [Any]? (as represented by [raw]) but since [encode] gives a platform specific value, this method wraps that. | ||
*/ | ||
sealed interface EncodedObject | ||
|
||
internal fun EncodedObject.getRaw(): Map<String, Any?> = when (this) { | ||
is EncodedObjectImpl -> raw | ||
} | ||
|
||
@JvmInline | ||
@PublishedApi | ||
internal value class EncodedObjectImpl(val raw: Map<String, Any?>) : EncodedObject | ||
|
||
@PublishedApi | ||
internal expect fun Any.asNativeMap(): Map<*, *>? | ||
|
||
@PublishedApi | ||
internal fun Map<*, *>.asEncodedObject(): EncodedObject = map { (key, value) -> | ||
if (key is String) { | ||
key to value | ||
} else { | ||
throw IllegalArgumentException("Expected a String key but received $key") | ||
} | ||
}.toMap().let(::EncodedObjectImpl) |
3 changes: 2 additions & 1 deletion
3
...otlin/dev/gitlive/firebase/Polymorphic.kt → .../gitlive/firebase/internal/Polymorphic.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.