From d5b7f463bc64a849de1595a5b52ab26e2038613f Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sun, 29 Jan 2023 04:36:31 +0100 Subject: Upgrade to Kotlin 1.8 and JS IR --- .../sevenwonders/ui/components/errors/ErrorDialog.kt | 6 +++--- .../sevenwonders/ui/components/game/GameScene.kt | 4 ++-- .../org/luxons/sevenwonders/ui/components/game/Hand.kt | 2 +- .../ui/components/game/PlayerPreparedCard.kt | 4 ++-- .../ui/components/game/TransactionsSelector.kt | 2 +- .../ui/components/gameBrowser/CreateGameForm.kt | 8 +++++--- .../sevenwonders/ui/components/gameBrowser/GameList.kt | 4 ++-- .../ui/components/gameBrowser/PlayerInfo.kt | 2 +- .../sevenwonders/ui/components/home/ChooseNameForm.kt | 2 +- .../luxons/sevenwonders/ui/components/lobby/Lobby.kt | 4 ++-- .../kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt | 18 +++++++++--------- 11 files changed, 29 insertions(+), 27 deletions(-) (limited to 'sw-ui/src/main/kotlin/org') diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt index 68b23ce0..38b3617a 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt @@ -14,15 +14,15 @@ import react.dom.p import styled.css import styled.styledDiv -interface ErrorDialogStateProps : PropsWithChildren { +external interface ErrorDialogStateProps : PropsWithChildren { var errorMessage: String? } -interface ErrorDialogDispatchProps : PropsWithChildren { +external interface ErrorDialogDispatchProps : PropsWithChildren { var goHome: () -> Unit } -interface ErrorDialogProps : ErrorDialogDispatchProps, ErrorDialogStateProps +external interface ErrorDialogProps : ErrorDialogDispatchProps, ErrorDialogStateProps class ErrorDialogPresenter(props: ErrorDialogProps) : RComponent(props) { override fun RBuilder.render() { diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt index f24e0bc8..e69882c4 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt @@ -25,7 +25,7 @@ import styled.css import styled.getClassName import styled.styledDiv -interface GameSceneStateProps : PropsWithChildren { +external interface GameSceneStateProps : PropsWithChildren { var currentPlayer: PlayerDTO? var players: List var game: GameState? @@ -33,7 +33,7 @@ interface GameSceneStateProps : PropsWithChildren { var preparedCard: HandCard? } -interface GameSceneDispatchProps : PropsWithChildren { +external interface GameSceneDispatchProps : PropsWithChildren { var sayReady: () -> Unit var prepareMove: (move: PlayerMove) -> Unit var unprepareMove: () -> Unit diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt index 28f3e92d..0078fbd5 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt @@ -33,7 +33,7 @@ private enum class HandAction( COPY_GUILD("Copy this guild card", MoveType.COPY_GUILD, "duplicate") } -interface HandProps : PropsWithChildren { +external interface HandProps : PropsWithChildren { var action: TurnAction var ownBoard: Board var preparedMove: PlayerMove? diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt index 9a72c43c..b42d3b81 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt @@ -13,12 +13,12 @@ import styled.css import styled.styledDiv import styled.styledImg -interface PlayerPreparedCardProps : PropsWithChildren { +external interface PlayerPreparedCardProps : PropsWithChildren { var playerDisplayName: String var cardBack: CardBack? } -interface PlayerPreparedCardContainerProps : PropsWithChildren { +external interface PlayerPreparedCardContainerProps : PropsWithChildren { var playerDisplayName: String var username: String } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt index 46f7cca7..b50f540f 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt @@ -92,7 +92,7 @@ private fun RBuilder.optionsTable( } } -private interface OptionsTableProps : PropsWithChildren { +private external interface OptionsTableProps : PropsWithChildren { var state: TransactionSelectorState var prepareMove: (PlayerMove) -> Unit } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt index e9fb467f..45bc3ae4 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt @@ -10,11 +10,13 @@ import react.* import react.dom.* import styled.* -private interface CreateGameFormProps : PropsWithChildren { +private external interface CreateGameFormProps : PropsWithChildren { var createGame: (String) -> Unit } -private data class CreateGameFormState(var gameName: String = "") : State +private external interface CreateGameFormState : State { + var gameName: String +} private class CreateGameForm(props: CreateGameFormProps) : RComponent(props) { @@ -42,7 +44,7 @@ private class CreateGameForm(props: CreateGameFormProps) : RComponent val input = e.currentTarget as HTMLInputElement - setState(transformState = { CreateGameFormState(input.value) }) + state.gameName = input.value }, rightElement = createGameButton(), ) diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt index b0976a36..466f9251 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt @@ -15,12 +15,12 @@ import react.dom.* import styled.* import react.State as RState -interface GameListStateProps : PropsWithChildren { +external interface GameListStateProps : PropsWithChildren { var connectedPlayer: ConnectedPlayer var games: List } -interface GameListDispatchProps : PropsWithChildren { +external interface GameListDispatchProps : PropsWithChildren { var joinGame: (Long) -> Unit } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt index 603b46cb..aa1033a0 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt @@ -12,7 +12,7 @@ import styled.css import styled.styledDiv import styled.styledSpan -interface PlayerInfoProps : PropsWithChildren { +external interface PlayerInfoProps : PropsWithChildren { var player: BasicPlayerInfo? var showUsername: Boolean var iconSize: Int diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt index 6a4f1059..279e94f2 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt @@ -14,7 +14,7 @@ import styled.css import styled.styledDiv import styled.styledForm -private interface ChooseNameFormProps : PropsWithChildren { +private external interface ChooseNameFormProps : PropsWithChildren { var chooseUsername: (String) -> Unit } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt index a8f59bfb..1cb4989c 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt @@ -19,12 +19,12 @@ import styled.* private val BOT_NAMES = listOf("Wall-E", "B-Max", "Sonny", "T-800", "HAL", "GLaDOS", "R2-D2", "Bender", "AWESOM-O") -interface LobbyStateProps : PropsWithChildren { +external interface LobbyStateProps : PropsWithChildren { var currentGame: LobbyDTO? var currentPlayer: PlayerDTO? } -interface LobbyDispatchProps : PropsWithChildren { +external interface LobbyDispatchProps : PropsWithChildren { var startGame: () -> Unit var addBot: (displayName: String) -> Unit var leaveLobby: () -> Unit diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt index ffd1a582..d5b3fffd 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt @@ -6,34 +6,34 @@ import redux.RAction import redux.WrapperAction import kotlin.reflect.KClass -inline fun connectDispatch( +fun connectDispatch( clazz: KClass>, - noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, + mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, ): ComponentClass { val connect = rConnect(mapDispatchToProps = mapDispatchToProps) return connect.invoke(clazz.js.unsafeCast>()) } -inline fun connectState( +fun connectState( clazz: KClass>, - noinline mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, + mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, ): ComponentClass { val connect = rConnect(mapStateToProps = mapStateToProps) return connect.invoke(clazz.js.unsafeCast>()) } -inline fun connectStateWithOwnProps( +fun connectStateWithOwnProps( clazz: KClass>, - noinline mapStateToProps: SP.(SwState, OP) -> Unit, + mapStateToProps: SP.(SwState, OP) -> Unit, ): ComponentClass { val connect = rConnect(mapStateToProps = mapStateToProps) return connect.invoke(clazz.js.unsafeCast>()) } -inline fun connectStateAndDispatch( +fun connectStateAndDispatch( clazz: KClass>, - noinline mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, - noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, + mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, + mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, ): ComponentClass { val connect = rConnect( mapStateToProps = mapStateToProps, -- cgit