Skip to content

Commit 6439a1c

Browse files
authored
Merge pull request #555 from splendo/feature/make-native-classes-interna
Remove Native classes from Public API
2 parents e996b7c + bcdf8e3 commit 6439a1c

36 files changed

+263
-399
lines changed

firebase-database/api/android/firebase-database.api

+4-27
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public final class dev/gitlive/firebase/database/DataSnapshot {
3838
public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive/firebase/database/Query {
3939
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference;
4040
public final fun getKey ()Ljava/lang/String;
41-
public final fun getNativeReference ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
4241
public final fun onDisconnect ()Ldev/gitlive/firebase/database/OnDisconnect;
4342
public final fun push ()Ldev/gitlive/firebase/database/DatabaseReference;
4443
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -47,9 +46,11 @@ public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive
4746
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
4847
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
4948
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
49+
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5050
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5151
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
5252
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/DatabaseReference;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
53+
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5354
}
5455

5556
public final class dev/gitlive/firebase/database/FirebaseDatabase {
@@ -68,41 +69,17 @@ public final class dev/gitlive/firebase/database/FirebaseDatabase {
6869
public final class dev/gitlive/firebase/database/FirebaseDatabase$Companion {
6970
}
7071

71-
public final class dev/gitlive/firebase/database/NativeDatabaseReference {
72-
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/NativeDatabaseReference;
73-
public fun getAndroid ()Lcom/google/firebase/database/DatabaseReference;
74-
public synthetic fun getAndroid ()Lcom/google/firebase/database/Query;
75-
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
76-
public final fun getKey ()Ljava/lang/String;
77-
public final fun onDisconnect ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
78-
public final fun push ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
79-
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
80-
public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
81-
public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/NativeDatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
82-
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
83-
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
84-
}
85-
86-
public final class dev/gitlive/firebase/database/NativeOnDisconnect {
87-
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
88-
public final fun getAndroid ()Lcom/google/firebase/database/OnDisconnect;
89-
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
90-
public final fun getPersistenceEnabled ()Z
91-
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
92-
public final fun setValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
93-
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
94-
}
95-
9672
public final class dev/gitlive/firebase/database/OnDisconnect {
9773
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
98-
public final fun getNative ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
9974
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
75+
public final fun setEncodedValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10076
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10177
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
10278
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/OnDisconnect;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
10379
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10480
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
10581
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/OnDisconnect;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
82+
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10683
}
10784

10885
public class dev/gitlive/firebase/database/Query {

firebase-database/api/jvm/firebase-database.api

+4-27
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public final class dev/gitlive/firebase/database/DataSnapshot {
3838
public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive/firebase/database/Query {
3939
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/DatabaseReference;
4040
public final fun getKey ()Ljava/lang/String;
41-
public final fun getNativeReference ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
4241
public final fun onDisconnect ()Ldev/gitlive/firebase/database/OnDisconnect;
4342
public final fun push ()Ldev/gitlive/firebase/database/DatabaseReference;
4443
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -47,9 +46,11 @@ public final class dev/gitlive/firebase/database/DatabaseReference : dev/gitlive
4746
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
4847
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
4948
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/DatabaseReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
49+
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5050
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5151
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
5252
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/DatabaseReference;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
53+
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
5354
}
5455

5556
public final class dev/gitlive/firebase/database/FirebaseDatabase {
@@ -68,41 +69,17 @@ public final class dev/gitlive/firebase/database/FirebaseDatabase {
6869
public final class dev/gitlive/firebase/database/FirebaseDatabase$Companion {
6970
}
7071

71-
public final class dev/gitlive/firebase/database/NativeDatabaseReference {
72-
public final fun child (Ljava/lang/String;)Ldev/gitlive/firebase/database/NativeDatabaseReference;
73-
public fun getAndroid ()Lcom/google/firebase/database/DatabaseReference;
74-
public synthetic fun getAndroid ()Lcom/google/firebase/database/Query;
75-
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
76-
public final fun getKey ()Ljava/lang/String;
77-
public final fun onDisconnect ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
78-
public final fun push ()Ldev/gitlive/firebase/database/NativeDatabaseReference;
79-
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
80-
public final fun runTransaction (Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
81-
public static synthetic fun runTransaction$default (Ldev/gitlive/firebase/database/NativeDatabaseReference;Lkotlinx/serialization/KSerializer;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
82-
public final fun setValueEncoded (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
83-
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
84-
}
85-
86-
public final class dev/gitlive/firebase/database/NativeOnDisconnect {
87-
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
88-
public final fun getAndroid ()Lcom/google/firebase/database/OnDisconnect;
89-
public final fun getDatabase ()Ldev/gitlive/firebase/database/FirebaseDatabase;
90-
public final fun getPersistenceEnabled ()Z
91-
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
92-
public final fun setValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
93-
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
94-
}
95-
9672
public final class dev/gitlive/firebase/database/OnDisconnect {
9773
public final fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
98-
public final fun getNative ()Ldev/gitlive/firebase/database/NativeOnDisconnect;
9974
public final fun removeValue (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
75+
public final fun setEncodedValue (Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10076
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10177
public final fun setValue (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
10278
public static synthetic fun setValue$default (Ldev/gitlive/firebase/database/OnDisconnect;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
10379
public final fun updateChildren (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10480
public final fun updateChildren (Ljava/util/Map;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
10581
public static synthetic fun updateChildren$default (Ldev/gitlive/firebase/database/OnDisconnect;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
82+
public final fun updateEncodedChildren (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
10683
}
10784

10885
public class dev/gitlive/firebase/database/Query {

firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ public actual open class Query internal actual constructor(
202202
override fun toString(): String = android.toString()
203203
}
204204

205-
@PublishedApi
206205
internal actual class NativeDatabaseReference internal constructor(
207206
override val android: com.google.firebase.database.DatabaseReference,
208207
persistenceEnabled: Boolean,
@@ -292,7 +291,6 @@ public actual class DataSnapshot internal constructor(
292291
public actual val children: Iterable<DataSnapshot> get() = android.children.map { DataSnapshot(it, persistenceEnabled) }
293292
}
294293

295-
@PublishedApi
296294
internal actual class NativeOnDisconnect internal constructor(
297295
val android: com.google.firebase.database.OnDisconnect,
298296
val persistenceEnabled: Boolean,
@@ -309,7 +307,7 @@ internal actual class NativeOnDisconnect internal constructor(
309307
.run { if (persistenceEnabled) await() else awaitWhileOnline(database) }
310308
}
311309

312-
actual suspend fun setValue(encodedValue: Any?) {
310+
actual suspend fun setEncodedValue(encodedValue: Any?) {
313311
android.setValue(encodedValue)
314312
.run { if (persistenceEnabled) await() else awaitWhileOnline(database) }
315313
}

firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt

+28-10
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ public expect open class Query internal constructor(nativeQuery: NativeQuery) {
286286
public fun equalTo(value: Boolean, key: String? = null): Query
287287
}
288288

289-
@PublishedApi
290289
internal expect class NativeDatabaseReference : NativeQuery {
291290
val key: String?
292291
fun push(): NativeDatabaseReference
@@ -307,7 +306,7 @@ internal expect class NativeDatabaseReference : NativeQuery {
307306
* This class is the starting point for all Database operations. After you've initialized it with
308307
* a URL, you can use it to read data, write data, and to create new DatabaseReferences.
309308
*/
310-
public class DatabaseReference internal constructor(@PublishedApi internal val nativeReference: NativeDatabaseReference) : Query(nativeReference) {
309+
public class DatabaseReference internal constructor(internal val nativeReference: NativeDatabaseReference) : Query(nativeReference) {
311310
/**
312311
* @return The last token in the location pointed to by this reference or null if this reference
313312
* points to the database root
@@ -346,7 +345,7 @@ public class DatabaseReference internal constructor(@PublishedApi internal val n
346345
}
347346
}
348347
public suspend inline fun <reified T> setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
349-
nativeReference.setValueEncoded(encode(value, buildSettings))
348+
setValueEncoded(encode(value, buildSettings))
350349
}
351350

352351
@Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("setValue(strategy, value) { this.encodeDefaults = encodeDefaults }"))
@@ -356,7 +355,12 @@ public class DatabaseReference internal constructor(@PublishedApi internal val n
356355
}
357356
}
358357
public suspend inline fun <T> setValue(strategy: SerializationStrategy<T>, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
359-
nativeReference.setValueEncoded(encode(strategy, value, buildSettings))
358+
setValueEncoded(encode(strategy, value, buildSettings))
359+
}
360+
361+
@PublishedApi
362+
internal suspend fun setValueEncoded(encodedValue: Any?) {
363+
nativeReference.setValueEncoded(encodedValue)
360364
}
361365

362366
@Deprecated("Deprecated. Use builder instead", replaceWith = ReplaceWith("updateChildren(update) { this.encodeDefaults = encodeDefaults }"))
@@ -374,11 +378,16 @@ public class DatabaseReference internal constructor(@PublishedApi internal val n
374378
* @return The {@link Task} for this operation.
375379
*/
376380
public suspend inline fun updateChildren(update: Map<String, Any?>, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
377-
nativeReference.updateEncodedChildren(
381+
updateEncodedChildren(
378382
encodeAsObject(update, buildSettings),
379383
)
380384
}
381385

386+
@PublishedApi
387+
internal suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) {
388+
nativeReference.updateEncodedChildren(encodedUpdate)
389+
}
390+
382391
/**
383392
* Set the value at this location to 'null'
384393
*
@@ -478,11 +487,10 @@ public expect class DataSnapshot {
478487
*/
479488
public expect class DatabaseException(message: String?, cause: Throwable?) : RuntimeException
480489

481-
@PublishedApi
482490
internal expect class NativeOnDisconnect {
483491
suspend fun removeValue()
484492
suspend fun cancel()
485-
suspend fun setValue(encodedValue: Any?)
493+
suspend fun setEncodedValue(encodedValue: Any?)
486494
suspend fun updateEncodedChildren(encodedUpdate: EncodedObject)
487495
}
488496

@@ -494,7 +502,7 @@ internal expect class NativeOnDisconnect {
494502
* Instances of this class are obtained by calling [DatabaseReference.onDisconnect]
495503
* on a Firebase Database ref.
496504
*/
497-
public class OnDisconnect internal constructor(@PublishedApi internal val native: NativeOnDisconnect) {
505+
public class OnDisconnect internal constructor(internal val native: NativeOnDisconnect) {
498506
/**
499507
* Remove the value at this location when the client disconnects
500508
*
@@ -535,7 +543,7 @@ public class OnDisconnect internal constructor(@PublishedApi internal val native
535543
* @param value The value to be set when a disconnect occurs or null to delete the existing value
536544
*/
537545
public suspend inline fun <reified T> setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
538-
native.setValue(encode(value, buildSettings))
546+
setEncodedValue(encode(value, buildSettings))
539547
}
540548

541549
/**
@@ -565,13 +573,18 @@ public class OnDisconnect internal constructor(@PublishedApi internal val native
565573
setValue(encode(strategy, value, buildSettings))
566574
}
567575

576+
@PublishedApi
577+
internal suspend fun setEncodedValue(encodedValue: Any?) {
578+
native.setEncodedValue(encodedValue)
579+
}
580+
568581
/**
569582
* Ensure the data has the specified child values updated when the client is disconnected
570583
*
571584
* @param update The paths to update, along with their desired values
572585
*/
573586
public suspend inline fun updateChildren(update: Map<String, Any?>, buildSettings: EncodeSettings.Builder.() -> Unit = {}) {
574-
native.updateEncodedChildren(
587+
updateEncodedChildren(
575588
encodeAsObject(update, buildSettings),
576589
)
577590
}
@@ -587,4 +600,9 @@ public class OnDisconnect internal constructor(@PublishedApi internal val native
587600
this.encodeDefaults = encodeDefaults
588601
}
589602
}
603+
604+
@PublishedApi
605+
internal suspend fun updateEncodedChildren(encodedUpdate: EncodedObject) {
606+
native.updateEncodedChildren(encodedUpdate)
607+
}
590608
}

firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ public actual open class Query internal actual constructor(
165165
override fun toString(): String = ios.toString()
166166
}
167167

168-
@PublishedApi
169168
internal actual class NativeDatabaseReference internal constructor(
170169
override val ios: FIRDatabaseReference,
171170
persistenceEnabled: Boolean,
@@ -236,7 +235,6 @@ public actual class DataSnapshot internal constructor(
236235
public actual val children: Iterable<DataSnapshot> get() = ios.children.allObjects.map { DataSnapshot(it as FIRDataSnapshot, persistenceEnabled) }
237236
}
238237

239-
@PublishedApi
240238
internal actual class NativeOnDisconnect internal constructor(
241239
val ios: FIRDatabaseReference,
242240
val persistenceEnabled: Boolean,
@@ -249,7 +247,7 @@ internal actual class NativeOnDisconnect internal constructor(
249247
ios.await(persistenceEnabled) { cancelDisconnectOperationsWithCompletionBlock(it) }
250248
}
251249

252-
actual suspend fun setValue(encodedValue: Any?) {
250+
actual suspend fun setEncodedValue(encodedValue: Any?) {
253251
ios.await(persistenceEnabled) { onDisconnectSetValue(encodedValue, it) }
254252
}
255253

0 commit comments

Comments
 (0)