File tree Expand file tree Collapse file tree 4 files changed +33
-60
lines changed
firebase-common/src/jsMain/kotlin/dev/gitlive/firebase
firebase-installations/src/jsMain/kotlin/dev/gitlive/firebase/installations Expand file tree Collapse file tree 4 files changed +33
-60
lines changed Original file line number Diff line number Diff line change 2
2
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
- @file:JsModule(" firebase/compat/app" )
6
-
7
5
package dev.gitlive.firebase
8
6
9
- import kotlin.js.Json
7
+ import dev.gitlive.firebase.externals.database.DataSnapshot
8
+ import dev.gitlive.firebase.externals.functions.HttpsCallable
9
+ import dev.gitlive.firebase.externals.functions.HttpsCallableResult
10
10
import kotlin.js.Promise
11
11
12
- @JsName(" default" )
13
- external object firebase {
14
-
15
- open class App {
16
- }
17
-
18
- interface FirebaseError {
19
- var code: String
20
- var message: String
21
- var name: String
22
- }
23
-
24
- fun installations (app : App ? = definedExternally): installations.Installations
12
+ typealias ChangeSnapshotCallback = (data: DataSnapshot , previousChildName: String? ) -> Unit
13
+ typealias ValueSnapshotCallback = (data: DataSnapshot ) -> Unit
14
+ typealias CancelCallback = (error: Throwable ) -> Unit
15
+ typealias Unsubscribe = () -> Unit
25
16
26
- object installations {
27
- interface Installations {
28
- fun delete (): Promise <Unit >
29
- fun getId (): Promise <String >
30
- fun getToken (forceRefresh : Boolean ): Promise <String >
31
- }
32
- }
33
- }
17
+ operator fun HttpsCallable.invoke () = asDynamic()() as Promise <HttpsCallableResult >
18
+ operator fun HttpsCallable.invoke (data : Any? ) = asDynamic()(data) as Promise <HttpsCallableResult >
Original file line number Diff line number Diff line change
1
+ @file:JsModule(" firebase/installations" )
2
+ @file:JsNonModule
3
+
4
+ package dev.gitlive.firebase.externals.installations
5
+
6
+ import dev.gitlive.firebase.externals.app.FirebaseApp
7
+ import kotlin.js.Promise
8
+
9
+ external fun delete (installations : Installations ): Promise <Unit >
10
+
11
+ external fun getId (installations : Installations ): Promise <String >
12
+
13
+ external fun getInstallations (app : FirebaseApp ? = definedExternally): Installations
14
+
15
+ external fun getToken (installations : Installations , forceRefresh : Boolean ): Promise <String >
16
+
17
+ external interface Installations
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
package dev.gitlive.firebase.installations
2
2
3
3
import dev.gitlive.firebase.*
4
+ import dev.gitlive.firebase.externals.installations.*
4
5
import kotlinx.coroutines.await
5
6
6
7
actual val Firebase .installations
7
- get() = rethrow {
8
- dev.gitlive.firebase.installations
9
- FirebaseInstallations (firebase.installations())
10
- }
8
+ get() = rethrow { FirebaseInstallations (getInstallations()) }
11
9
12
10
actual fun Firebase.installations (app : FirebaseApp ) =
13
- rethrow {
14
- dev.gitlive.firebase.installations
15
- FirebaseInstallations (firebase.installations(app.js))
16
- }
11
+ rethrow { FirebaseInstallations (getInstallations(app.js)) }
17
12
18
- actual class FirebaseInstallations internal constructor(val js : firebase.installations. Installations ) {
13
+ actual class FirebaseInstallations internal constructor(val js : Installations ) {
19
14
20
- actual suspend fun delete () = rethrow { js. delete().await() }
15
+ actual suspend fun delete () = rethrow { delete(js ).await() }
21
16
22
- actual suspend fun getId (): String = rethrow { js. getId().await() }
17
+ actual suspend fun getId (): String = rethrow { getId(js ).await() }
23
18
24
19
actual suspend fun getToken (forceRefresh : Boolean ): String =
25
- rethrow { js. getToken(forceRefresh).await() }
20
+ rethrow { getToken(js, forceRefresh).await() }
26
21
}
27
22
28
23
actual open class FirebaseInstallationsException (code : String? , cause : Throwable ): FirebaseException(code, cause)
You can’t perform that action at this time.
0 commit comments