-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix OnDisconnect failing to updateChildren #494
Merged
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0e53ad3
Temp encoding test
Daeda88 06dd193
Adding fixes for OnDisconnect
Daeda88 194e802
EncodedObject to make encoding more robust
Daeda88 dc54714
More stable implementation of Firestore encoding
Daeda88 7941f11
Cleanup & reenable tests
Daeda88 32ac02f
Fixing some JS issues
Daeda88 5dc2e4b
Restricted access to creating an EncodedObject
Daeda88 a371444
EncodedObject as interface
Daeda88 828cd98
Merge remote-tracking branch 'GitLiveApp/master' into fix-on-disconnect
Daeda88 9f7d3cb
Move parts of the firebase-common module to new firebase-common-internal
Daeda88 a629f9a
moved EncodedData to internal
Daeda88 6ba3fa0
Merge pull request #70 from splendo/split-common-into-internals
Daeda88 83f0192
Make raw internal/Disable Android DB test
Daeda88 f615bc3
Merge remote-tracking branch 'GitLiveApp/master' into fix-on-disconnect
Daeda88 cce8b82
Moved Firestore internals to different package
Daeda88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() = raw | ||
|
||
@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) |
27 changes: 27 additions & 0 deletions
27
...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,27 @@ | ||
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 { | ||
val raw: Map<String, Any?> | ||
} | ||
|
||
@JvmInline | ||
@PublishedApi | ||
internal value class EncodedObjectImpl(override 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the purpose of still exposing this to clients?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured it would be useful. Moved to an internal get method now (cant be value due to JS weirdness)