mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 08:37:12 +00:00
potentially complete events generator
This commit is contained in:
parent
6824f2c992
commit
4343d6d161
@ -24,6 +24,7 @@
|
||||
* folders: Folders-templates
|
||||
* -s, --skip: Skip variables setup
|
||||
* -a, --args: Pass several for several args. Use with syntax `--args a=b` or `-a a=b` to set variable with key `a` to value `b`
|
||||
* -v, --verbose: Show more verbose output
|
||||
*/
|
||||
import java.io.File
|
||||
|
||||
@ -36,6 +37,11 @@ var extensions: List<String>? = null
|
||||
var skipPrompts: Boolean = false
|
||||
val commandLineArgs = mutableMapOf<String, String>()
|
||||
val globalEnvs = System.getenv().toMutableMap()
|
||||
var verboseMode: Boolean = false
|
||||
|
||||
if (args.any { it == "-v" || it == "--verbose" }) {
|
||||
println(args.joinToString("\n"))
|
||||
}
|
||||
|
||||
fun String.replaceWithVariables(envs: Map<String, String>): String {
|
||||
var currentString = this
|
||||
@ -133,12 +139,19 @@ fun readParameters() {
|
||||
i++
|
||||
outputFolder = File(realArgs[i])
|
||||
}
|
||||
"--verbose",
|
||||
"-v" -> {
|
||||
verboseMode = true
|
||||
}
|
||||
"--args",
|
||||
"-a" -> {
|
||||
i++
|
||||
val subarg = realArgs[i]
|
||||
val key = subarg.takeWhile { it != '=' }
|
||||
val value = subarg.dropWhile { it != '=' }.removePrefix("=")
|
||||
if (verboseMode) {
|
||||
println("Argument $key=$value")
|
||||
}
|
||||
commandLineArgs[key] = value
|
||||
}
|
||||
"--help",
|
||||
|
@ -7,8 +7,8 @@ typealias {{$callback_typealias_name}} = WebApp.({{$callback_args}}) -> Unit
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.{{$event_name_uppercase}}, eventHandler: {{$callback_typealias_name}}) = { it: {{$callback_typealias_name}} ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
fun WebApp.onEvent(type: EventType.{{$event_name_uppercase}}, eventHandler: {{$callback_typealias_name}}) = { {{$callback_args_definitions}} ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), {{$callback_args_names}})
|
||||
}.also {
|
||||
on{{$event_name_uppercase}}(
|
||||
type.typeName,
|
||||
|
@ -1,17 +1,48 @@
|
||||
package dev.inmo.tgbotapi.webapps
|
||||
|
||||
sealed class EventType(val typeName: String) {
|
||||
data object EmojiStatusAccessRequested : EventType("emojiStatusAccessRequested")
|
||||
data object AccelerometerChanged : EventType("accelerometerChanged")
|
||||
data object DeviceOrientationStarted : EventType("deviceOrientationStarted")
|
||||
data object EmojiStatusFailed : EventType("emojiStatusFailed")
|
||||
data object Activated : EventType("activated")
|
||||
data object ShareMessageSent : EventType("shareMessageSent")
|
||||
data object LocationManagerUpdated : EventType("locationManagerUpdated")
|
||||
data object BiometricTokenUpdated : EventType("biometricTokenUpdated")
|
||||
data object DeviceOrientationFailed : EventType("deviceOrientationFailed")
|
||||
data object SafeAreaChanged : EventType("safeAreaChanged")
|
||||
data object WriteAccessRequested : EventType("writeAccessRequested")
|
||||
data object ContentSafeAreaChanged : EventType("contentSafeAreaChanged")
|
||||
data object AccelerometerStarted : EventType("accelerometerStarted")
|
||||
data object AccelerometerStopped : EventType("accelerometerStopped")
|
||||
data object PopupClosed : EventType("popupClosed")
|
||||
data object GyroscopeStopped : EventType("gyroscopeStopped")
|
||||
data object BackButtonClicked : EventType("backButtonClicked")
|
||||
data object HomeScreenAdded : EventType("homeScreenAdded")
|
||||
data object ShareMessageFailed : EventType("shareMessageFailed")
|
||||
data object ThemeChanged : EventType("themeChanged")
|
||||
data object BiometricManagerUpdated : EventType("biometricManagerUpdated")
|
||||
data object ScanQrPopupClosed : EventType("scanQrPopupClosed")
|
||||
data object BiometricAuthRequested : EventType("biometricAuthRequested")
|
||||
data object HomeScreenChecked : EventType("homeScreenChecked")
|
||||
data object LocationRequested : EventType("locationRequested")
|
||||
data object SecondaryButtonClicked : EventType("secondaryButtonClicked")
|
||||
data object QrTextReceived : EventType("qrTextReceived")
|
||||
data object EmojiStatusSet : EventType("emojiStatusSet")
|
||||
data object FullscreenFailed : EventType("fullscreenFailed")
|
||||
data object GyroscopeFailed : EventType("gyroscopeFailed")
|
||||
data object SettingsButtonClicked : EventType("settingsButtonClicked")
|
||||
data object Deactivated : EventType("deactivated")
|
||||
data object DeviceOrientationStopped : EventType("deviceOrientationStopped")
|
||||
data object FullscreenChanged : EventType("fullscreenChanged")
|
||||
data object ViewportChanged : EventType("viewportChanged")
|
||||
data object MainButtonClicked : EventType("mainButtonClicked")
|
||||
data object SecondaryButtonClicked : EventType("secondaryButtonClicked")
|
||||
data object BackButtonClicked : EventType("backButtonClicked")
|
||||
data object SettingsButtonClicked : EventType("settingsButtonClicked")
|
||||
data object InvoiceClosed : EventType("invoiceClosed")
|
||||
data object PopupClosed : EventType("popupClosed")
|
||||
data object QRTextReceived : EventType("qrTextReceived")
|
||||
data object AccelerometerFailed : EventType("accelerometerFailed")
|
||||
data object ClipboardTextReceived : EventType("clipboardTextReceived")
|
||||
data object WriteAccessRequested : EventType("writeAccessRequested")
|
||||
data object FileDownloadRequested : EventType("fileDownloadRequested")
|
||||
data object ContactRequested : EventType("contactRequested")
|
||||
data object ScanQRPopupClosed : EventType("scanQrPopupClosed")
|
||||
data object InvoiceClosed : EventType("invoiceClosed")
|
||||
data object GyroscopeStarted : EventType("gyroscopeStarted")
|
||||
data object GyroscopeChanged : EventType("gyroscopeChanged")
|
||||
data object DeviceOrientationChanged : EventType("deviceOrientationChanged")
|
||||
}
|
@ -105,24 +105,6 @@ external class WebApp {
|
||||
val settingsButton: SettingsButton
|
||||
|
||||
internal fun onEvent(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithViewportChangedData(type: String, callback: (ViewportChangedData) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithInvoiceClosedInfo(type: String, callback: (InvoiceClosedInfo) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithPopupClosedInfo(type: String, callback: (String?) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithQRTextInfo(type: String, callback: (String) -> Boolean)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithTextInfo(type: String, callback: (String) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithWriteAccessRequested(type: String, callback: (RequestStatus) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithContactRequested(type: String, callback: (RequestStatus) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithSettingsButtonClicked(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEventWithScanQRPopupClosed(type: String, callback: () -> Unit)
|
||||
|
||||
fun offEvent(type: String, callback: () -> Unit)
|
||||
@JsName("offEvent")
|
||||
@ -152,6 +134,99 @@ external class WebApp {
|
||||
|
||||
fun requestWriteAccess(callback: ((Boolean) -> Unit)? = definedExternally)
|
||||
fun requestContact(callback: ((Boolean) -> Unit)? = definedExternally)
|
||||
|
||||
// Start of generated part
|
||||
|
||||
@JsName("onEvent")
|
||||
internal fun onEmojiStatusAccessRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onAccelerometerChanged(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onDeviceOrientationStarted(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEmojiStatusFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onActivated(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onShareMessageSent(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onLocationManagerUpdated(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onBiometricTokenUpdated(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgIsUpdatedObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onDeviceOrientationFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onSafeAreaChanged(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onWriteAccessRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onContentSafeAreaChanged(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onAccelerometerStarted(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onAccelerometerStopped(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onPopupClosed(type: String, callback: (dev.inmo.tgbotapi.webapps.popup.PopupClosedEventArg) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onGyroscopeStopped(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onBackButtonClicked(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onHomeScreenAdded(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onShareMessageFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onThemeChanged(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onBiometricManagerUpdated(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onScanQrPopupClosed(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onBiometricAuthRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgBiometricAuthRequested) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onHomeScreenChecked(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onLocationRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgLocationDataObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onSecondaryButtonClicked(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onQrTextReceived(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgDataObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onEmojiStatusSet(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onFullscreenFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onGyroscopeFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onSettingsButtonClicked(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onDeactivated(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onDeviceOrientationStopped(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onFullscreenChanged(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onViewportChanged(type: String, callback: (Boolean) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onMainButtonClicked(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onAccelerometerFailed(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onClipboardTextReceived(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgDataNullableObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onFileDownloadRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onContactRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onInvoiceClosed(type: String, callback: (String, dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onGyroscopeStarted(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onGyroscopeChanged(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onDeviceOrientationChanged(type: String, callback: () -> Unit)
|
||||
|
||||
// End of generated part
|
||||
}
|
||||
|
||||
val WebApp.colorScheme: ColorScheme
|
||||
@ -161,178 +236,178 @@ val WebApp.colorScheme: ColorScheme
|
||||
else -> ColorScheme.LIGHT
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = {
|
||||
eventHandler(js("this").unsafeCast<WebApp>())
|
||||
}.also {
|
||||
onEvent(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: ViewportChangedData ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
onEventWithViewportChangedData(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { it: InvoiceClosedInfo ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
onEventWithInvoiceClosedInfo(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHandler) = { it: String? ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
onEventWithPopupClosedInfo(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.QRTextReceived, eventHandler: QRTextReceivedEventHandler) = { it: String ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
onEventWithQRTextInfo(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: TextReceivedEventHandler) = { it: String ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
onEventWithTextInfo(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedHandler) = { it: RequestStatus ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it.isAllowed)
|
||||
}.also {
|
||||
onEventWithWriteAccessRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedHandler) = { it: RequestStatus ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it.isSent)
|
||||
}.also {
|
||||
onEventWithContactRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = {
|
||||
eventHandler(js("this").unsafeCast<WebApp>())
|
||||
}.also {
|
||||
onEventWithSettingsButtonClicked(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ScanQRPopupClosed, eventHandler: EventHandler) = {
|
||||
eventHandler(js("this").unsafeCast<WebApp>())
|
||||
}.also {
|
||||
onEventWithScanQRPopupClosed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onThemeChanged(eventHandler: EventHandler) = onEvent(EventType.ThemeChanged, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onMainButtonClicked(eventHandler: EventHandler) = onEvent(EventType.MainButtonClicked, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onSecondaryButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SecondaryButtonClicked, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onViewportChanged(eventHandler: ViewportChangedEventHandler) = onEvent(EventType.ViewportChanged, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onBackButtonClicked(eventHandler: EventHandler) = onEvent(EventType.BackButtonClicked, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onSettingsButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SettingsButtonClicked, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(EventType.InvoiceClosed, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onPopupClosed(eventHandler: PopupClosedEventHandler) = onEvent(EventType.PopupClosed, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onQRTextReceived(eventHandler: QRTextReceivedEventHandler) = onEvent(EventType.QRTextReceived, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onClipboardTextReceived(eventHandler: TextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onWriteAccessRequested(eventHandler: WriteAccessRequestedHandler) = onEvent(EventType.WriteAccessRequested, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onContactRequested(eventHandler: ContactRequestedHandler) = onEvent(EventType.ContactRequested, eventHandler)
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onScanQRPopupClosed(eventHandler: onScanQRPopupClosedHandler) = onEvent(EventType.ScanQRPopupClosed, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = {
|
||||
// eventHandler(js("this").unsafeCast<WebApp>())
|
||||
//}.also {
|
||||
// onEvent(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: ViewportChangedData ->
|
||||
// eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
//}.also {
|
||||
// onEventWithViewportChangedData(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { it: InvoiceClosedInfo ->
|
||||
// eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
//}.also {
|
||||
// onEventWithInvoiceClosedInfo(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHandler) = { it: String? ->
|
||||
// eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
//}.also {
|
||||
// onEventWithPopupClosedInfo(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.QRTextReceived, eventHandler: QRTextReceivedEventHandler) = { it: String ->
|
||||
// eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
//}.also {
|
||||
// onEventWithQRTextInfo(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: TextReceivedEventHandler) = { it: String ->
|
||||
// eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
//}.also {
|
||||
// onEventWithTextInfo(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedHandler) = { it: RequestStatus ->
|
||||
// eventHandler(js("this").unsafeCast<WebApp>(), it.isAllowed)
|
||||
//}.also {
|
||||
// onEventWithWriteAccessRequested(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedHandler) = { it: RequestStatus ->
|
||||
// eventHandler(js("this").unsafeCast<WebApp>(), it.isSent)
|
||||
//}.also {
|
||||
// onEventWithContactRequested(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: EventHandler) = {
|
||||
// eventHandler(js("this").unsafeCast<WebApp>())
|
||||
//}.also {
|
||||
// onEventWithSettingsButtonClicked(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onEvent(type: EventType.ScanQRPopupClosed, eventHandler: EventHandler) = {
|
||||
// eventHandler(js("this").unsafeCast<WebApp>())
|
||||
//}.also {
|
||||
// onEventWithScanQRPopupClosed(
|
||||
// type.typeName,
|
||||
// callback = it
|
||||
// )
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onThemeChanged(eventHandler: EventHandler) = onEvent(EventType.ThemeChanged, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onMainButtonClicked(eventHandler: EventHandler) = onEvent(EventType.MainButtonClicked, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onSecondaryButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SecondaryButtonClicked, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onViewportChanged(eventHandler: ViewportChangedEventHandler) = onEvent(EventType.ViewportChanged, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onBackButtonClicked(eventHandler: EventHandler) = onEvent(EventType.BackButtonClicked, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onSettingsButtonClicked(eventHandler: EventHandler) = onEvent(EventType.SettingsButtonClicked, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(EventType.InvoiceClosed, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onPopupClosed(eventHandler: PopupClosedEventHandler) = onEvent(EventType.PopupClosed, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onQRTextReceived(eventHandler: QRTextReceivedEventHandler) = onEvent(EventType.QRTextReceived, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onClipboardTextReceived(eventHandler: TextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onWriteAccessRequested(eventHandler: WriteAccessRequestedHandler) = onEvent(EventType.WriteAccessRequested, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onContactRequested(eventHandler: ContactRequestedHandler) = onEvent(EventType.ContactRequested, eventHandler)
|
||||
///**
|
||||
// * @return The callback which should be used in case you want to turn off events handling
|
||||
// */
|
||||
//fun WebApp.onScanQRPopupClosed(eventHandler: onScanQRPopupClosedHandler) = onEvent(EventType.ScanQRPopupClosed, eventHandler)
|
||||
|
||||
fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData(
|
||||
initData,
|
||||
|
@ -0,0 +1,973 @@
|
||||
package dev.inmo.tgbotapi.webapps.events
|
||||
|
||||
import dev.inmo.tgbotapi.webapps.EventType
|
||||
import dev.inmo.tgbotapi.webapps.WebApp
|
||||
|
||||
// Part for callback typealias
|
||||
|
||||
typealias EmojiStatusAccessRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.EmojiStatusAccessRequested, eventHandler: EmojiStatusAccessRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onEmojiStatusAccessRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEmojiStatusAccessRequested(eventHandler: EmojiStatusAccessRequestedEventHandler) = onEvent(EventType.EmojiStatusAccessRequested, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias AccelerometerChangedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.AccelerometerChanged, eventHandler: AccelerometerChangedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onAccelerometerChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onAccelerometerChanged(eventHandler: AccelerometerChangedEventHandler) = onEvent(EventType.AccelerometerChanged, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias DeviceOrientationStartedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.DeviceOrientationStarted, eventHandler: DeviceOrientationStartedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onDeviceOrientationStarted(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onDeviceOrientationStarted(eventHandler: DeviceOrientationStartedEventHandler) = onEvent(EventType.DeviceOrientationStarted, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias EmojiStatusFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.EmojiStatusFailed, eventHandler: EmojiStatusFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onEmojiStatusFailed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEmojiStatusFailed(eventHandler: EmojiStatusFailedEventHandler) = onEvent(EventType.EmojiStatusFailed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ActivatedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.Activated, eventHandler: ActivatedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onActivated(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onActivated(eventHandler: ActivatedEventHandler) = onEvent(EventType.Activated, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ShareMessageSentEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ShareMessageSent, eventHandler: ShareMessageSentEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onShareMessageSent(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onShareMessageSent(eventHandler: ShareMessageSentEventHandler) = onEvent(EventType.ShareMessageSent, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias LocationManagerUpdatedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.LocationManagerUpdated, eventHandler: LocationManagerUpdatedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onLocationManagerUpdated(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onLocationManagerUpdated(eventHandler: LocationManagerUpdatedEventHandler) = onEvent(EventType.LocationManagerUpdated, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias BiometricTokenUpdatedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgIsUpdatedObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.BiometricTokenUpdated, eventHandler: BiometricTokenUpdatedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgIsUpdatedObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onBiometricTokenUpdated(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onBiometricTokenUpdated(eventHandler: BiometricTokenUpdatedEventHandler) = onEvent(EventType.BiometricTokenUpdated, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias DeviceOrientationFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.DeviceOrientationFailed, eventHandler: DeviceOrientationFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onDeviceOrientationFailed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onDeviceOrientationFailed(eventHandler: DeviceOrientationFailedEventHandler) = onEvent(EventType.DeviceOrientationFailed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias SafeAreaChangedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.SafeAreaChanged, eventHandler: SafeAreaChangedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onSafeAreaChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onSafeAreaChanged(eventHandler: SafeAreaChangedEventHandler) = onEvent(EventType.SafeAreaChanged, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias WriteAccessRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.WriteAccessRequested, eventHandler: WriteAccessRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onWriteAccessRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onWriteAccessRequested(eventHandler: WriteAccessRequestedEventHandler) = onEvent(EventType.WriteAccessRequested, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ContentSafeAreaChangedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ContentSafeAreaChanged, eventHandler: ContentSafeAreaChangedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onContentSafeAreaChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onContentSafeAreaChanged(eventHandler: ContentSafeAreaChangedEventHandler) = onEvent(EventType.ContentSafeAreaChanged, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias AccelerometerStartedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.AccelerometerStarted, eventHandler: AccelerometerStartedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onAccelerometerStarted(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onAccelerometerStarted(eventHandler: AccelerometerStartedEventHandler) = onEvent(EventType.AccelerometerStarted, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias AccelerometerStoppedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.AccelerometerStopped, eventHandler: AccelerometerStoppedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onAccelerometerStopped(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onAccelerometerStopped(eventHandler: AccelerometerStoppedEventHandler) = onEvent(EventType.AccelerometerStopped, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias PopupClosedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.popup.PopupClosedEventArg) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.popup.PopupClosedEventArg ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onPopupClosed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onPopupClosed(eventHandler: PopupClosedEventHandler) = onEvent(EventType.PopupClosed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias GyroscopeStoppedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.GyroscopeStopped, eventHandler: GyroscopeStoppedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onGyroscopeStopped(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onGyroscopeStopped(eventHandler: GyroscopeStoppedEventHandler) = onEvent(EventType.GyroscopeStopped, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias BackButtonClickedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.BackButtonClicked, eventHandler: BackButtonClickedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onBackButtonClicked(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onBackButtonClicked(eventHandler: BackButtonClickedEventHandler) = onEvent(EventType.BackButtonClicked, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias HomeScreenAddedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.HomeScreenAdded, eventHandler: HomeScreenAddedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onHomeScreenAdded(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onHomeScreenAdded(eventHandler: HomeScreenAddedEventHandler) = onEvent(EventType.HomeScreenAdded, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ShareMessageFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ShareMessageFailed, eventHandler: ShareMessageFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onShareMessageFailed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onShareMessageFailed(eventHandler: ShareMessageFailedEventHandler) = onEvent(EventType.ShareMessageFailed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ThemeChangedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ThemeChanged, eventHandler: ThemeChangedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onThemeChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onThemeChanged(eventHandler: ThemeChangedEventHandler) = onEvent(EventType.ThemeChanged, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias BiometricManagerUpdatedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.BiometricManagerUpdated, eventHandler: BiometricManagerUpdatedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onBiometricManagerUpdated(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onBiometricManagerUpdated(eventHandler: BiometricManagerUpdatedEventHandler) = onEvent(EventType.BiometricManagerUpdated, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ScanQrPopupClosedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ScanQrPopupClosed, eventHandler: ScanQrPopupClosedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onScanQrPopupClosed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onScanQrPopupClosed(eventHandler: ScanQrPopupClosedEventHandler) = onEvent(EventType.ScanQrPopupClosed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias BiometricAuthRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgBiometricAuthRequested) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.BiometricAuthRequested, eventHandler: BiometricAuthRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgBiometricAuthRequested ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onBiometricAuthRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onBiometricAuthRequested(eventHandler: BiometricAuthRequestedEventHandler) = onEvent(EventType.BiometricAuthRequested, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias HomeScreenCheckedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.HomeScreenChecked, eventHandler: HomeScreenCheckedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onHomeScreenChecked(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onHomeScreenChecked(eventHandler: HomeScreenCheckedEventHandler) = onEvent(EventType.HomeScreenChecked, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias LocationRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgLocationDataObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.LocationRequested, eventHandler: LocationRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgLocationDataObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onLocationRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onLocationRequested(eventHandler: LocationRequestedEventHandler) = onEvent(EventType.LocationRequested, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias SecondaryButtonClickedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.SecondaryButtonClicked, eventHandler: SecondaryButtonClickedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onSecondaryButtonClicked(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onSecondaryButtonClicked(eventHandler: SecondaryButtonClickedEventHandler) = onEvent(EventType.SecondaryButtonClicked, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias QrTextReceivedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgDataObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.QrTextReceived, eventHandler: QrTextReceivedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgDataObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onQrTextReceived(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onQrTextReceived(eventHandler: QrTextReceivedEventHandler) = onEvent(EventType.QrTextReceived, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias EmojiStatusSetEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.EmojiStatusSet, eventHandler: EmojiStatusSetEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onEmojiStatusSet(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEmojiStatusSet(eventHandler: EmojiStatusSetEventHandler) = onEvent(EventType.EmojiStatusSet, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias FullscreenFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.FullscreenFailed, eventHandler: FullscreenFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onFullscreenFailed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onFullscreenFailed(eventHandler: FullscreenFailedEventHandler) = onEvent(EventType.FullscreenFailed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias GyroscopeFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.GyroscopeFailed, eventHandler: GyroscopeFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onGyroscopeFailed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onGyroscopeFailed(eventHandler: GyroscopeFailedEventHandler) = onEvent(EventType.GyroscopeFailed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias SettingsButtonClickedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.SettingsButtonClicked, eventHandler: SettingsButtonClickedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onSettingsButtonClicked(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onSettingsButtonClicked(eventHandler: SettingsButtonClickedEventHandler) = onEvent(EventType.SettingsButtonClicked, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias DeactivatedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.Deactivated, eventHandler: DeactivatedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onDeactivated(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onDeactivated(eventHandler: DeactivatedEventHandler) = onEvent(EventType.Deactivated, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias DeviceOrientationStoppedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.DeviceOrientationStopped, eventHandler: DeviceOrientationStoppedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onDeviceOrientationStopped(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onDeviceOrientationStopped(eventHandler: DeviceOrientationStoppedEventHandler) = onEvent(EventType.DeviceOrientationStopped, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias FullscreenChangedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.FullscreenChanged, eventHandler: FullscreenChangedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onFullscreenChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onFullscreenChanged(eventHandler: FullscreenChangedEventHandler) = onEvent(EventType.FullscreenChanged, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ViewportChangedEventHandler = WebApp.(Boolean) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { p0: Boolean ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onViewportChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onViewportChanged(eventHandler: ViewportChangedEventHandler) = onEvent(EventType.ViewportChanged, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias MainButtonClickedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.MainButtonClicked, eventHandler: MainButtonClickedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onMainButtonClicked(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onMainButtonClicked(eventHandler: MainButtonClickedEventHandler) = onEvent(EventType.MainButtonClicked, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias AccelerometerFailedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgErrorObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.AccelerometerFailed, eventHandler: AccelerometerFailedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgErrorObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onAccelerometerFailed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onAccelerometerFailed(eventHandler: AccelerometerFailedEventHandler) = onEvent(EventType.AccelerometerFailed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ClipboardTextReceivedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgDataNullableObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: ClipboardTextReceivedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgDataNullableObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onClipboardTextReceived(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onClipboardTextReceived(eventHandler: ClipboardTextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias FileDownloadRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.FileDownloadRequested, eventHandler: FileDownloadRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onFileDownloadRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onFileDownloadRequested(eventHandler: FileDownloadRequestedEventHandler) = onEvent(EventType.FileDownloadRequested, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias ContactRequestedEventHandler = WebApp.(dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactRequestedEventHandler) = { p0: dev.inmo.tgbotapi.webapps.args.ArgStatusObject ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0)
|
||||
}.also {
|
||||
onContactRequested(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onContactRequested(eventHandler: ContactRequestedEventHandler) = onEvent(EventType.ContactRequested, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias InvoiceClosedEventHandler = WebApp.(String, dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { p0: String, p1: dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0, p1)
|
||||
}.also {
|
||||
onInvoiceClosed(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(EventType.InvoiceClosed, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias GyroscopeStartedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.GyroscopeStarted, eventHandler: GyroscopeStartedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onGyroscopeStarted(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onGyroscopeStarted(eventHandler: GyroscopeStartedEventHandler) = onEvent(EventType.GyroscopeStarted, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias GyroscopeChangedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.GyroscopeChanged, eventHandler: GyroscopeChangedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onGyroscopeChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onGyroscopeChanged(eventHandler: GyroscopeChangedEventHandler) = onEvent(EventType.GyroscopeChanged, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias DeviceOrientationChangedEventHandler = WebApp.() -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.DeviceOrientationChanged, eventHandler: DeviceOrientationChangedEventHandler) = { ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), )
|
||||
}.also {
|
||||
onDeviceOrientationChanged(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onDeviceOrientationChanged(eventHandler: DeviceOrientationChangedEventHandler) = onEvent(EventType.DeviceOrientationChanged, eventHandler)
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env kotlin
|
||||
// This script will read Event
|
||||
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
|
||||
|
||||
import kotlinx.serialization.json.*
|
||||
@ -37,12 +38,46 @@ fun readParameters() {
|
||||
}
|
||||
}
|
||||
|
||||
fun generateEvent(eventName: String, callbacks: String) {
|
||||
readParameters()
|
||||
|
||||
fun generateEvent(eventName: String, callbackArgs: String) {
|
||||
println("Start generating $eventName (callbacks: $callbackArgs)")
|
||||
val uppercaseEventName = eventName.take(1).uppercase() + eventName.drop(1)
|
||||
val subpackage = eventName.map { if (it.isUpperCase()) "_${it.lowercase()}" else it }.joinToString("")
|
||||
val command = "${rfAbsolutePath}/.templates/generator.kts -s -a \"subpackage=$subpackage\" -a \"event_name=$eventName\" -a \"event_name_uppercase=$uppercaseEventName\" -a \"callback_args=$callbacks\" -a \"callback_typealias_name=${uppercaseEventName}EventHandler\" -o \"$cfAbsolutePath\" -ex \"kt\" \"${rfAbsolutePath}/.templates/{{\$subpackage}}\""
|
||||
var callbackNumber: Int = -1
|
||||
val splittedCallbacks = callbackArgs.split(Regex(" ?, ?")).filter { !it.isBlank() }
|
||||
val callback_args_names = splittedCallbacks.joinToString(", ") {
|
||||
callbackNumber++
|
||||
"p$callbackNumber"
|
||||
}
|
||||
callbackNumber = -1
|
||||
val callback_args_definitions = splittedCallbacks.joinToString(", ") {
|
||||
callbackNumber++
|
||||
"p$callbackNumber: $it"
|
||||
}
|
||||
val verboseFlag = if (verboseMode) "-v" else ""
|
||||
|
||||
val process = Runtime.getRuntime().exec(command)
|
||||
val commandParts = arrayOf(
|
||||
"${rfAbsolutePath}/.templates/generator.kts",
|
||||
verboseFlag,
|
||||
"-s",
|
||||
"-a", "subpackage=$subpackage",
|
||||
"-a", "event_name=$eventName",
|
||||
"-a", "callback_args_names=$callback_args_names",
|
||||
"-a", "event_name_uppercase=$uppercaseEventName",
|
||||
"-a", "callback_args_definitions=$callback_args_definitions",
|
||||
"-a", "callback_args=$callbackArgs",
|
||||
"-a", "callback_typealias_name=${uppercaseEventName}EventHandler",
|
||||
"-o", cfAbsolutePath,
|
||||
"-ex", "kt",
|
||||
"${rfAbsolutePath}/.templates/{{\$subpackage}}"
|
||||
)
|
||||
val command = commandParts.joinToString(" ") { "\"$it\"" }
|
||||
if (verboseMode) {
|
||||
println(command)
|
||||
}
|
||||
|
||||
val process = Runtime.getRuntime().exec(commandParts)
|
||||
val inputStream: InputStream = process.getInputStream()
|
||||
val errorStream: InputStream = process.getErrorStream()
|
||||
|
||||
@ -61,6 +96,7 @@ fun generateEvent(eventName: String, callbacks: String) {
|
||||
}
|
||||
Runtime.getRuntime().exit(exitCode)
|
||||
}
|
||||
println("Complete generating $eventName")
|
||||
}
|
||||
|
||||
val eventsList: JsonArray = Json.parseToJsonElement(File("EventsList.json").readText()).jsonArray
|
||||
@ -68,7 +104,7 @@ val eventsList: JsonArray = Json.parseToJsonElement(File("EventsList.json").read
|
||||
eventsList.forEach {
|
||||
generateEvent(
|
||||
it.jsonObject["event_name"]!!.jsonPrimitive.content,
|
||||
it.jsonObject["callback"] ?.jsonPrimitive ?.content ?: ""
|
||||
it.jsonObject["callback_args"] ?.jsonPrimitive ?.content ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
@ -96,8 +132,10 @@ currentFolder.listFiles() ?.forEach { generatedFolder: File ->
|
||||
|
||||
val eventTypePartsString = eventTypeParts.joinToString("\n") { " $it" }
|
||||
eventTypeParts.clear()
|
||||
val eventTypeFileContent = "package dev.inmo.tgbotapi.webapps\n\nsealed class EventType(val typeName: String) {\n${eventTypePartsString}\n}\n"
|
||||
println(eventTypeFileContent)
|
||||
val eventTypeFileContent = "package dev.inmo.tgbotapi.webapps\n\nimport dev.inmo.tgbotapi.webapps.EventType\nimport dev.inmo.tgbotapi.webapps.WebApp\n\nsealed class EventType(val typeName: String) {\n${eventTypePartsString}\n}\n"
|
||||
if (verboseMode) {
|
||||
println(eventTypeFileContent)
|
||||
}
|
||||
|
||||
val eventTypeOutputFile = File(currentFolder, "../EventType.kt")
|
||||
eventTypeOutputFile.writeText(
|
||||
@ -106,18 +144,22 @@ eventTypeOutputFile.writeText(
|
||||
|
||||
val webAppPartsString = webAppParts.joinToString("\n")
|
||||
webAppParts.clear()
|
||||
val eventTypeFileContent = webAppPartsString
|
||||
println(eventTypeFileContent)
|
||||
val webAppPartsFileContent = webAppPartsString
|
||||
if (verboseMode) {
|
||||
println(webAppPartsFileContent)
|
||||
}
|
||||
|
||||
val webAppOutputFile = File(currentFolder, "ToPutInWebApp!!!!!.kt")
|
||||
webAppOutputFile.writeText(
|
||||
webAppPartsString
|
||||
webAppPartsFileContent
|
||||
)
|
||||
|
||||
val extensionsPartsString = extensionsParts.joinToString("\n")
|
||||
extensionsParts.clear()
|
||||
val extensionsPartsFileContent = "package dev.inmo.tgbotapi.webapps.events\n\n${extensionsPartsString}\n"
|
||||
println(extensionsPartsFileContent)
|
||||
if (verboseMode) {
|
||||
println(extensionsPartsFileContent)
|
||||
}
|
||||
|
||||
val extensionsPartsOutputFile = File(currentFolder, "Extensions.kt")
|
||||
extensionsPartsOutputFile.writeText(
|
||||
@ -126,7 +168,7 @@ extensionsPartsOutputFile.writeText(
|
||||
|
||||
|
||||
currentFolder.listFiles() ?.toList() ?.forEach { generatedFolder: File ->
|
||||
if (it.isDirectory) {
|
||||
it.deleteRecursively()
|
||||
if (generatedFolder.isDirectory) {
|
||||
generatedFolder.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user