1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 08:37:12 +00:00

add sealed workaround for webapp event type

This commit is contained in:
InsanusMokrassar 2024-12-08 10:26:53 +06:00
parent 6388d8db13
commit adcaffe115
5 changed files with 69 additions and 8 deletions

View File

@ -57,6 +57,8 @@ microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
microutils-ksp-sealed = { module = "dev.inmo:micro_utils.ksp.sealed", version.ref = "microutils" }
microutils-ksp-sealed-generator = { module = "dev.inmo:micro_utils.ksp.sealed.generator", version.ref = "microutils" }
kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }

View File

@ -2,6 +2,7 @@ plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id "org.jetbrains.dokka"
id "com.google.devtools.ksp"
}
project.description = "Web App bindings for the Telegram Web Apps API"
@ -14,7 +15,15 @@ kotlin {
commonMain {
dependencies {
api project(":tgbotapi.core")
api libs.microutils.ksp.sealed
}
}
}
}
dependencies {
add("kspJs", libs.microutils.ksp.sealed.generator)
}
ksp {}

View File

@ -3,11 +3,3 @@ package dev.inmo.tgbotapi.webapps
import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
typealias EventHandler = WebApp.() -> Unit
typealias ViewportChangedEventHandler = WebApp.(ViewportChangedData) -> Unit
typealias InvoiceClosedEventHandler = WebApp.(InvoiceClosedInfo) -> Unit
typealias PopupClosedEventHandler = WebApp.(String?) -> Unit
typealias QRTextReceivedEventHandler = WebApp.(String) -> Boolean
typealias TextReceivedEventHandler = WebApp.(String) -> Unit
typealias WriteAccessRequestedHandler = WebApp.(Boolean) -> Unit
typealias ContactRequestedHandler = WebApp.(Boolean) -> Unit
typealias onScanQRPopupClosedHandler = WebApp.() -> Unit

View File

@ -1,5 +1,8 @@
package dev.inmo.tgbotapi.webapps
import dev.inmo.micro_utils.ksp.sealed.GenerateSealedWorkaround
@GenerateSealedWorkaround
sealed class EventType(val typeName: String) {
data object EmojiStatusAccessRequested : EventType("emojiStatusAccessRequested")
data object AccelerometerChanged : EventType("accelerometerChanged")
@ -45,4 +48,6 @@ sealed class EventType(val typeName: String) {
data object GyroscopeStarted : EventType("gyroscopeStarted")
data object GyroscopeChanged : EventType("gyroscopeChanged")
data object DeviceOrientationChanged : EventType("deviceOrientationChanged")
companion object
}

View File

@ -0,0 +1,53 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: EventType.kt
package dev.inmo.tgbotapi.webapps
import kotlin.collections.Set
private val values: Set<EventType> = setOf(EventType.EmojiStatusAccessRequested,
EventType.AccelerometerChanged,
EventType.DeviceOrientationStarted,
EventType.EmojiStatusFailed,
EventType.Activated,
EventType.ShareMessageSent,
EventType.LocationManagerUpdated,
EventType.BiometricTokenUpdated,
EventType.DeviceOrientationFailed,
EventType.SafeAreaChanged,
EventType.WriteAccessRequested,
EventType.ContentSafeAreaChanged,
EventType.AccelerometerStarted,
EventType.AccelerometerStopped,
EventType.PopupClosed,
EventType.GyroscopeStopped,
EventType.BackButtonClicked,
EventType.HomeScreenAdded,
EventType.ShareMessageFailed,
EventType.ThemeChanged,
EventType.BiometricManagerUpdated,
EventType.ScanQrPopupClosed,
EventType.BiometricAuthRequested,
EventType.HomeScreenChecked,
EventType.LocationRequested,
EventType.SecondaryButtonClicked,
EventType.QrTextReceived,
EventType.EmojiStatusSet,
EventType.FullscreenFailed,
EventType.GyroscopeFailed,
EventType.SettingsButtonClicked,
EventType.Deactivated,
EventType.DeviceOrientationStopped,
EventType.FullscreenChanged,
EventType.ViewportChanged,
EventType.MainButtonClicked,
EventType.AccelerometerFailed,
EventType.ClipboardTextReceived,
EventType.FileDownloadRequested,
EventType.ContactRequested,
EventType.InvoiceClosed,
EventType.GyroscopeStarted,
EventType.GyroscopeChanged,
EventType.DeviceOrientationChanged)
public fun EventType.Companion.values(): Set<EventType> = values