@gamepark/react-client 6.38.5 → 7.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions/ActionFailed.d.ts +6 -6
- package/dist/Actions/ActionFailed.js +4 -8
- package/dist/Actions/ActionFailed.js.map +1 -1
- package/dist/Actions/AnimationComplete.d.ts +6 -6
- package/dist/Actions/AnimationComplete.js +4 -8
- package/dist/Actions/AnimationComplete.js.map +1 -1
- package/dist/Actions/AnimationPaused.d.ts +6 -6
- package/dist/Actions/AnimationPaused.js +4 -8
- package/dist/Actions/AnimationPaused.js.map +1 -1
- package/dist/Actions/AnimationStart.d.ts +5 -5
- package/dist/Actions/AnimationStart.js +1 -4
- package/dist/Actions/AnimationStart.js.map +1 -1
- package/dist/Actions/ClearFailures.d.ts +1 -5
- package/dist/Actions/ClearFailures.js +3 -9
- package/dist/Actions/ClearFailures.js.map +1 -1
- package/dist/Actions/GameNotificationsReceived.d.ts +8 -10
- package/dist/Actions/GameNotificationsReceived.js +2 -9
- package/dist/Actions/GameNotificationsReceived.js.map +1 -1
- package/dist/Actions/GameOver.d.ts +16 -16
- package/dist/Actions/GameOver.js +4 -8
- package/dist/Actions/GameOver.js.map +1 -1
- package/dist/Actions/GameStateLoaded.d.ts +16 -16
- package/dist/Actions/GameStateLoaded.js +7 -20
- package/dist/Actions/GameStateLoaded.js.map +1 -1
- package/dist/Actions/MovePlayed.d.ts +11 -11
- package/dist/Actions/MovePlayed.js +3 -2
- package/dist/Actions/MovePlayed.js.map +1 -1
- package/dist/Actions/MoveUndone.d.ts +7 -7
- package/dist/Actions/MoveUndone.js +4 -9
- package/dist/Actions/MoveUndone.js.map +1 -1
- package/dist/Actions/PlayerQuit.d.ts +5 -11
- package/dist/Actions/PlayerQuit.js +2 -19
- package/dist/Actions/PlayerQuit.js.map +1 -1
- package/dist/Actions/SetAnimationsSpeed.d.ts +1 -6
- package/dist/Actions/SetAnimationsSpeed.js +3 -9
- package/dist/Actions/SetAnimationsSpeed.js.map +1 -1
- package/dist/Actions/giveUp.d.ts +1 -0
- package/dist/Actions/giveUp.js +3 -0
- package/dist/Actions/giveUp.js.map +1 -0
- package/dist/Actions/index.d.ts +7 -12
- package/dist/Actions/index.js +7 -28
- package/dist/Actions/index.js.map +1 -1
- package/dist/Actions/loadGameState.d.ts +14 -0
- package/dist/Actions/loadGameState.js +3 -0
- package/dist/Actions/loadGameState.js.map +1 -0
- package/dist/Actions/playMove.d.ts +10 -0
- package/dist/Actions/playMove.js +3 -0
- package/dist/Actions/playMove.js.map +1 -0
- package/dist/Actions/receiveNotifications.d.ts +8 -0
- package/dist/Actions/receiveNotifications.js +3 -0
- package/dist/Actions/receiveNotifications.js.map +1 -0
- package/dist/Actions/removePlayer.d.ts +5 -0
- package/dist/Actions/removePlayer.js +3 -0
- package/dist/Actions/removePlayer.js.map +1 -0
- package/dist/Actions/reportFailure.d.ts +1 -0
- package/dist/Actions/reportFailure.js +3 -0
- package/dist/Actions/reportFailure.js.map +1 -0
- package/dist/Actions/setGameOver.d.ts +2 -0
- package/dist/Actions/setGameOver.js +3 -0
- package/dist/Actions/setGameOver.js.map +1 -0
- package/dist/Actions/startAnimation.d.ts +1 -0
- package/dist/Actions/startAnimation.js +3 -0
- package/dist/Actions/startAnimation.js.map +1 -0
- package/dist/Actions/undoMove.d.ts +5 -0
- package/dist/Actions/undoMove.js +4 -0
- package/dist/Actions/undoMove.js.map +1 -0
- package/dist/Chat/ChatChannel.d.ts +5 -5
- package/dist/Chat/ChatChannel.js +1 -2
- package/dist/Chat/Message.d.ts +6 -6
- package/dist/Chat/Message.js +1 -2
- package/dist/Chat/index.d.ts +2 -2
- package/dist/Chat/index.js +2 -18
- package/dist/Chat/index.js.map +1 -1
- package/dist/Deckbuilding/Deck.d.ts +5 -5
- package/dist/Deckbuilding/Deck.js +1 -2
- package/dist/Deckbuilding/index.d.ts +4 -4
- package/dist/Deckbuilding/index.js +4 -24
- package/dist/Deckbuilding/index.js.map +1 -1
- package/dist/Deckbuilding/useDeleteDeck.d.ts +5 -2
- package/dist/Deckbuilding/useDeleteDeck.js +9 -15
- package/dist/Deckbuilding/useDeleteDeck.js.map +1 -1
- package/dist/Deckbuilding/useMyDecks.d.ts +3 -2
- package/dist/Deckbuilding/useMyDecks.js +8 -14
- package/dist/Deckbuilding/useMyDecks.js.map +1 -1
- package/dist/Deckbuilding/useSaveDeck.d.ts +5 -2
- package/dist/Deckbuilding/useSaveDeck.js +9 -15
- package/dist/Deckbuilding/useSaveDeck.js.map +1 -1
- package/dist/EjectPlayer/EjectPlayer.d.ts +1 -6
- package/dist/EjectPlayer/EjectPlayer.js +2 -8
- package/dist/EjectPlayer/EjectPlayer.js.map +1 -1
- package/dist/EjectPlayer/index.d.ts +1 -1
- package/dist/EjectPlayer/index.js +1 -17
- package/dist/EjectPlayer/index.js.map +1 -1
- package/dist/Failure/Failure.d.ts +6 -6
- package/dist/Failure/Failure.js +6 -9
- package/dist/Failure/Failure.js.map +1 -1
- package/dist/Failure/index.d.ts +1 -1
- package/dist/Failure/index.js +1 -17
- package/dist/Failure/index.js.map +1 -1
- package/dist/GiveUp/GiveUp.d.ts +7 -7
- package/dist/GiveUp/GiveUp.js +2 -5
- package/dist/GiveUp/GiveUp.js.map +1 -1
- package/dist/GiveUp/index.d.ts +1 -1
- package/dist/GiveUp/index.js +1 -17
- package/dist/GiveUp/index.js.map +1 -1
- package/dist/Hooks/index.d.ts +5 -5
- package/dist/Hooks/index.js +5 -21
- package/dist/Hooks/index.js.map +1 -1
- package/dist/Hooks/useChatMessages.d.ts +7 -12
- package/dist/Hooks/useChatMessages.js +44 -51
- package/dist/Hooks/useChatMessages.js.map +1 -1
- package/dist/Hooks/useMessageAuthor.d.ts +4 -4
- package/dist/Hooks/useMessageAuthor.js +13 -18
- package/dist/Hooks/useMessageAuthor.js.map +1 -1
- package/dist/Hooks/useOptions.d.ts +2 -2
- package/dist/Hooks/useOptions.js +4 -8
- package/dist/Hooks/useOptions.js.map +1 -1
- package/dist/Hooks/useRematch.d.ts +7 -7
- package/dist/Hooks/useRematch.js +18 -19
- package/dist/Hooks/useRematch.js.map +1 -1
- package/dist/Hooks/useSendMessage.d.ts +4 -1
- package/dist/Hooks/useSendMessage.js +6 -14
- package/dist/Hooks/useSendMessage.js.map +1 -1
- package/dist/Log/StartLiveLog.d.ts +1 -4
- package/dist/Log/StartLiveLog.js +3 -5
- package/dist/Log/StartLiveLog.js.map +1 -1
- package/dist/Log/StopLiveLog.d.ts +2 -5
- package/dist/Log/StopLiveLog.js +6 -9
- package/dist/Log/StopLiveLog.js.map +1 -1
- package/dist/Log/index.d.ts +4 -4
- package/dist/Log/index.js +4 -20
- package/dist/Log/index.js.map +1 -1
- package/dist/Log/useLogControls.d.ts +7 -7
- package/dist/Log/useLogControls.js +18 -22
- package/dist/Log/useLogControls.js.map +1 -1
- package/dist/PlayerTime/PlayerTime.d.ts +11 -11
- package/dist/PlayerTime/PlayerTime.js +1 -2
- package/dist/PlayerTime/index.d.ts +1 -1
- package/dist/PlayerTime/index.js +1 -17
- package/dist/PlayerTime/index.js.map +1 -1
- package/dist/Rematch/RematchQueries.d.ts +19 -19
- package/dist/Rematch/RematchQueries.js +23 -13
- package/dist/Rematch/RematchQueries.js.map +1 -1
- package/dist/Rematch/index.d.ts +1 -1
- package/dist/Rematch/index.js +1 -17
- package/dist/Rematch/index.js.map +1 -1
- package/dist/Sound/MuteSounds.d.ts +2 -5
- package/dist/Sound/MuteSounds.js +7 -10
- package/dist/Sound/MuteSounds.js.map +1 -1
- package/dist/Sound/UnmuteSounds.d.ts +1 -4
- package/dist/Sound/UnmuteSounds.js +3 -5
- package/dist/Sound/UnmuteSounds.js.map +1 -1
- package/dist/Sound/index.d.ts +3 -3
- package/dist/Sound/index.js +3 -19
- package/dist/Sound/index.js.map +1 -1
- package/dist/Sound/useSoundControls.d.ts +7 -7
- package/dist/Sound/useSoundControls.js +18 -22
- package/dist/Sound/useSoundControls.js.map +1 -1
- package/dist/Store/DisplayedAction.d.ts +15 -15
- package/dist/Store/DisplayedAction.js +12 -19
- package/dist/Store/DisplayedAction.js.map +1 -1
- package/dist/Store/GamePageState.d.ts +27 -28
- package/dist/Store/GamePageState.js +1 -2
- package/dist/Store/PlayedMove.d.ts +5 -5
- package/dist/Store/PlayedMove.js +1 -2
- package/dist/Store/endAnimation.d.ts +1 -0
- package/dist/Store/endAnimation.js +3 -0
- package/dist/Store/endAnimation.js.map +1 -0
- package/dist/Store/gameMiddleware.d.ts +4 -4
- package/dist/Store/gameMiddleware.js +34 -41
- package/dist/Store/gameMiddleware.js.map +1 -1
- package/dist/Store/gameReducer.d.ts +14 -20
- package/dist/Store/gameReducer.js +462 -525
- package/dist/Store/gameReducer.js.map +1 -1
- package/dist/Store/index.d.ts +4 -3
- package/dist/Store/index.js +4 -19
- package/dist/Store/index.js.map +1 -1
- package/dist/Store/localMovePreviewMiddleware.d.ts +4 -4
- package/dist/Store/localMovePreviewMiddleware.js +19 -18
- package/dist/Store/localMovePreviewMiddleware.js.map +1 -1
- package/dist/Store/store.d.ts +13 -0
- package/dist/Store/store.js +27 -0
- package/dist/Store/store.js.map +1 -0
- package/dist/Tutorial/PlayTutorialMoves.d.ts +1 -9
- package/dist/Tutorial/PlayTutorialMoves.js +2 -6
- package/dist/Tutorial/PlayTutorialMoves.js.map +1 -1
- package/dist/Tutorial/Tutorial.d.ts +5 -5
- package/dist/Tutorial/Tutorial.js +1 -2
- package/dist/Tutorial/TutorialDescription.d.ts +7 -7
- package/dist/Tutorial/TutorialDescription.js +1 -2
- package/dist/Tutorial/index.d.ts +4 -4
- package/dist/Tutorial/index.js +4 -20
- package/dist/Tutorial/index.js.map +1 -1
- package/dist/Tutorial/useTutorial.d.ts +2 -2
- package/dist/Tutorial/useTutorial.js +12 -22
- package/dist/Tutorial/useTutorial.js.map +1 -1
- package/dist/Types/GameAI.d.ts +1 -1
- package/dist/Types/GameAI.js +1 -2
- package/dist/Types/GameData.d.ts +18 -18
- package/dist/Types/GameData.js +1 -2
- package/dist/Types/GameMessage.d.ts +8 -8
- package/dist/Types/GameMessage.js +1 -2
- package/dist/Types/GameMode.d.ts +6 -6
- package/dist/Types/GameMode.js +7 -10
- package/dist/Types/GameMode.js.map +1 -1
- package/dist/Types/GameNotification.d.ts +6 -6
- package/dist/Types/GameNotification.js +1 -2
- package/dist/Types/GameOptions.d.ts +9 -9
- package/dist/Types/GameOptions.js +5 -8
- package/dist/Types/GameOptions.js.map +1 -1
- package/dist/Types/MovePlayedNotification.d.ts +9 -9
- package/dist/Types/MovePlayedNotification.js +6 -12
- package/dist/Types/MovePlayedNotification.js.map +1 -1
- package/dist/Types/MoveUndoneNotification.d.ts +8 -8
- package/dist/Types/MoveUndoneNotification.js +6 -12
- package/dist/Types/MoveUndoneNotification.js.map +1 -1
- package/dist/Types/Player.d.ts +13 -13
- package/dist/Types/Player.js +1 -2
- package/dist/Types/PlayerQuitReason.d.ts +4 -4
- package/dist/Types/PlayerQuitReason.js +5 -8
- package/dist/Types/PlayerQuitReason.js.map +1 -1
- package/dist/Types/ProxyGameData.d.ts +13 -13
- package/dist/Types/ProxyGameData.js +1 -2
- package/dist/Types/Tournament.d.ts +4 -4
- package/dist/Types/Tournament.js +1 -2
- package/dist/Types/index.d.ts +12 -12
- package/dist/Types/index.js +12 -28
- package/dist/Types/index.js.map +1 -1
- package/dist/User/User.d.ts +6 -6
- package/dist/User/User.js +1 -2
- package/dist/User/index.d.ts +2 -2
- package/dist/User/index.js +2 -18
- package/dist/User/index.js.map +1 -1
- package/dist/User/useMe.d.ts +4 -4
- package/dist/User/useMe.js +10 -21
- package/dist/User/useMe.js.map +1 -1
- package/dist/animations/Animation.d.ts +6 -6
- package/dist/animations/Animation.js +1 -2
- package/dist/animations/AnimationContext.d.ts +8 -8
- package/dist/animations/AnimationContext.js +1 -2
- package/dist/animations/AnimationState.d.ts +6 -6
- package/dist/animations/AnimationState.js +1 -2
- package/dist/animations/AnimationStep.d.ts +6 -6
- package/dist/animations/AnimationStep.js +7 -10
- package/dist/animations/AnimationStep.js.map +1 -1
- package/dist/animations/Animations.d.ts +8 -8
- package/dist/animations/Animations.js +15 -22
- package/dist/animations/Animations.js.map +1 -1
- package/dist/animations/AnimationsListener.d.ts +6 -0
- package/dist/animations/AnimationsListener.js +54 -0
- package/dist/animations/AnimationsListener.js.map +1 -0
- package/dist/animations/AnimationsListenerCreator.d.ts +2 -4
- package/dist/animations/AnimationsListenerCreator.js +40 -50
- package/dist/animations/AnimationsListenerCreator.js.map +1 -1
- package/dist/animations/animationMiddleware.d.ts +4 -0
- package/dist/animations/animationMiddleware.js +50 -0
- package/dist/animations/animationMiddleware.js.map +1 -0
- package/dist/animations/index.d.ts +5 -6
- package/dist/animations/index.js +5 -22
- package/dist/animations/index.js.map +1 -1
- package/dist/api/Client/GameClientAPI.d.ts +24 -24
- package/dist/api/Client/GameClientAPI.js +116 -165
- package/dist/api/Client/GameClientAPI.js.map +1 -1
- package/dist/api/Client/GameNotificationsListener.d.ts +5 -5
- package/dist/api/Client/GameNotificationsListener.js +62 -113
- package/dist/api/Client/GameNotificationsListener.js.map +1 -1
- package/dist/api/Client/RemoteGameLoader.d.ts +4 -5
- package/dist/api/Client/RemoteGameLoader.js +66 -62
- package/dist/api/Client/RemoteGameLoader.js.map +1 -1
- package/dist/api/Client/RemoteGameProvider.d.ts +7 -7
- package/dist/api/Client/RemoteGameProvider.js +19 -70
- package/dist/api/Client/RemoteGameProvider.js.map +1 -1
- package/dist/api/Client/apollo-client.d.ts +2 -2
- package/dist/api/Client/apollo-client.js +40 -58
- package/dist/api/Client/apollo-client.js.map +1 -1
- package/dist/api/Client/index.d.ts +4 -3
- package/dist/api/Client/index.js +4 -19
- package/dist/api/Client/index.js.map +1 -1
- package/dist/api/Client/pusher.d.ts +2 -0
- package/dist/api/Client/pusher.js +9 -0
- package/dist/api/Client/pusher.js.map +1 -0
- package/dist/api/GameAPI.d.ts +10 -10
- package/dist/api/GameAPI.js +1 -2
- package/dist/api/Local/ConsoleTools.d.ts +25 -25
- package/dist/api/Local/ConsoleTools.js +78 -86
- package/dist/api/Local/ConsoleTools.js.map +1 -1
- package/dist/api/Local/GameLocalAPI.d.ts +44 -44
- package/dist/api/Local/GameLocalAPI.js +442 -540
- package/dist/api/Local/GameLocalAPI.js.map +1 -1
- package/dist/api/Local/LocalGameProvider.d.ts +15 -15
- package/dist/api/Local/LocalGameProvider.js +18 -58
- package/dist/api/Local/LocalGameProvider.js.map +1 -1
- package/dist/api/Local/index.d.ts +1 -1
- package/dist/api/Local/index.js +1 -17
- package/dist/api/Local/index.js.map +1 -1
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +2 -18
- package/dist/api/index.js.map +1 -1
- package/dist/index.d.ts +16 -18
- package/dist/index.js +16 -36
- package/dist/index.js.map +1 -1
- package/dist/util/ArrayUtil.d.ts +2 -2
- package/dist/util/ArrayUtil.js +16 -21
- package/dist/util/ArrayUtil.js.map +1 -1
- package/package.json +66 -65
- package/dist/Actions/ActionType.d.ts +0 -3
- package/dist/Actions/ActionType.js +0 -8
- package/dist/Actions/ActionType.js.map +0 -1
- package/dist/Scoring/ScoringDescription.d.ts +0 -8
- package/dist/Scoring/ScoringDescription.js +0 -3
- package/dist/Scoring/ScoringDescription.js.map +0 -1
- package/dist/Scoring/index.d.ts +0 -1
- package/dist/Scoring/index.js +0 -18
- package/dist/Scoring/index.js.map +0 -1
- package/dist/util/TimeUtil.d.ts +0 -2
- package/dist/util/TimeUtil.js +0 -27
- package/dist/util/TimeUtil.js.map +0 -1
|
@@ -1,167 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function step(op) {
|
|
20
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
-
switch (op[0]) {
|
|
25
|
-
case 0: case 1: t = op; break;
|
|
26
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
-
default:
|
|
30
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
-
if (t[2]) _.ops.pop();
|
|
35
|
-
_.trys.pop(); continue;
|
|
36
|
-
}
|
|
37
|
-
op = body.call(thisArg, _);
|
|
38
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1
|
+
import { CombinedGraphQLErrors, gql } from '@apollo/client';
|
|
2
|
+
import { receiveNotifications } from '../../Actions';
|
|
3
|
+
import { reportFailure } from '../../Actions/reportFailure';
|
|
4
|
+
import { Failure } from '../../Failure';
|
|
5
|
+
import { getApolloClient } from './apollo-client';
|
|
6
|
+
export const PLATFORM_URI = process.env.PLATFORM_URI ?? 'https://game-park.com';
|
|
7
|
+
export const AVATAR_INFO = gql `fragment AvatarInfo on Avataaar {accessoriesType clotheColor clotheType eyeType eyebrowType facialHairType facialHairColor graphicType hairColor mouthType skinColor topType}`;
|
|
8
|
+
export const PLAYERS_TIME = gql `fragment PlayerTime on Player { time { availableTime cumulatedDownTime cumulatedPlayTime cumulatedWaitForMeTime highestDownTime highestPlayTime lastChange playing weightedWaitForMeTime } }`;
|
|
9
|
+
export const NOTIFICATIONS = gql `fragment Notifications on GameNotification { playerId ... on MovePlayedNotification { actionId moveView consequences } ... on MoveUndoneNotification { actionId moveUndone } }`;
|
|
10
|
+
const PLAY = gql `mutation PlayMoves($gameId: String!, $moves: [JSON!]!) { playMoves(gameId: $gameId, moves: $moves) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ${NOTIFICATIONS} ${PLAYERS_TIME}`;
|
|
11
|
+
const UNDO = gql `mutation UndoMoves($gameId: String!, $actions: [String!]!) { undoMoves(gameId: $gameId, actions: $actions) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ${NOTIFICATIONS} ${PLAYERS_TIME}`;
|
|
12
|
+
const EJECT_PLAYER = gql `mutation EjectPlayer($gameId: String!, $playerId: JSON!) { ejectPlayer(gameId: $gameId, playerId: $playerId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ${NOTIFICATIONS} ${PLAYERS_TIME}`;
|
|
13
|
+
const GIVE_UP = gql `mutation GiveUp($gameId: String!) { giveUp(gameId: $gameId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ${NOTIFICATIONS} ${PLAYERS_TIME}`;
|
|
14
|
+
const CLAIM_VICTORY = gql `mutation ClaimVictory($gameId: String!) { claimVictory(gameId: $gameId) { id endDate } }`;
|
|
15
|
+
export const GET_MESSAGE_AUTHOR = gql `
|
|
16
|
+
query GetMessageAuthor($id: String!) {
|
|
17
|
+
user(id: $id) {
|
|
18
|
+
id name avatar {...AvatarInfo}
|
|
40
19
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (this.pendingActions.length
|
|
92
|
-
this.pendingActions.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
var _this = this;
|
|
140
|
-
(0, apollo_client_1.getApolloClient)().mutate({ mutation: GIVE_UP, variables: { gameId: this.gameId } })
|
|
141
|
-
.then(function (result) { return result.data && _this.handleGameMessageResult(result.data.giveUp); });
|
|
142
|
-
};
|
|
143
|
-
GameClientAPI.prototype.onError = function (_a) {
|
|
144
|
-
var _this = this;
|
|
145
|
-
var graphQLErrors = _a.graphQLErrors, networkError = _a.networkError;
|
|
146
|
-
if (graphQLErrors) {
|
|
147
|
-
graphQLErrors.map(function (_a) {
|
|
148
|
-
var message = _a.message;
|
|
149
|
-
return _this.dispatch((0, Actions_1.actionFailed)(message));
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
if (networkError) {
|
|
153
|
-
console.error(networkError);
|
|
154
|
-
this.dispatch((0, Actions_1.actionFailed)(Failure_1.Failure.NETWORK));
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
GameClientAPI.prototype.playTutorialMoves = function () {
|
|
158
|
-
console.error('Tutorial should only be played with local API');
|
|
159
|
-
};
|
|
160
|
-
GameClientAPI.prototype.claimVictory = function () {
|
|
161
|
-
return (0, apollo_client_1.getApolloClient)().mutate({ mutation: CLAIM_VICTORY, variables: { gameId: this.gameId } });
|
|
162
|
-
};
|
|
163
|
-
return GameClientAPI;
|
|
164
|
-
}());
|
|
165
|
-
exports.GameClientAPI = GameClientAPI;
|
|
166
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
20
|
+
} ${AVATAR_INFO}
|
|
21
|
+
`;
|
|
22
|
+
export class GameClientAPI {
|
|
23
|
+
dispatch;
|
|
24
|
+
gameId;
|
|
25
|
+
ongoingAction;
|
|
26
|
+
pendingActions = [];
|
|
27
|
+
constructor(gameId) {
|
|
28
|
+
this.gameId = gameId;
|
|
29
|
+
}
|
|
30
|
+
async init(dispatch) {
|
|
31
|
+
this.dispatch = dispatch;
|
|
32
|
+
}
|
|
33
|
+
play(move) {
|
|
34
|
+
if (this.pendingActions.length === 0) {
|
|
35
|
+
this.pendingActions.push({ type: 'PLAY', moves: [move] });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const lastPendingAction = this.pendingActions[this.pendingActions.length - 1];
|
|
39
|
+
if (lastPendingAction.type === 'PLAY') {
|
|
40
|
+
lastPendingAction.moves.push(move);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.pendingActions.push({ type: 'PLAY', moves: [move] });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!this.ongoingAction) {
|
|
47
|
+
this.ongoingAction = new Promise(resolve => setTimeout(resolve, 50)).then(() => this.executePendingActions());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
undo(action) {
|
|
51
|
+
if (typeof action === 'number')
|
|
52
|
+
return console.error('GameClientAPI can no longer undo without an action ID');
|
|
53
|
+
if (this.pendingActions.length === 0) {
|
|
54
|
+
this.pendingActions.push({ type: 'UNDO', actions: [action] });
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const lastPendingAction = this.pendingActions[this.pendingActions.length - 1];
|
|
58
|
+
if (lastPendingAction.type === 'UNDO') {
|
|
59
|
+
lastPendingAction.actions.push(action);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.pendingActions.push({ type: 'UNDO', actions: [action] });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!this.ongoingAction) {
|
|
66
|
+
this.executePendingActions();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
executePendingActions() {
|
|
70
|
+
if (this.pendingActions.length > 0) {
|
|
71
|
+
const pendingAction = this.pendingActions.shift();
|
|
72
|
+
if (pendingAction.type == 'PLAY') {
|
|
73
|
+
this.ongoingAction = getApolloClient().mutate({
|
|
74
|
+
mutation: PLAY, variables: { gameId: this.gameId, moves: pendingAction.moves }
|
|
75
|
+
}).then(result => result.data && this.handleGameMessageResult(result.data.playMoves));
|
|
76
|
+
}
|
|
77
|
+
else if (pendingAction.type === 'UNDO') {
|
|
78
|
+
this.ongoingAction = getApolloClient().mutate({
|
|
79
|
+
mutation: UNDO, variables: { gameId: this.gameId, actions: pendingAction.actions }
|
|
80
|
+
}).then(result => result.data && this.handleGameMessageResult(result.data.undoMoves));
|
|
81
|
+
}
|
|
82
|
+
if (this.ongoingAction) {
|
|
83
|
+
this.ongoingAction = this.ongoingAction.catch(error => this.onError(error)).finally(() => this.executePendingActions());
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
delete this.ongoingAction;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
handleGameMessageResult({ date, index, notifications, players }) {
|
|
91
|
+
this.dispatch(receiveNotifications({ notifications, notificationsIndex: index, players, serverTime: Date.parse(date) }));
|
|
92
|
+
}
|
|
93
|
+
eject(playerId) {
|
|
94
|
+
getApolloClient().mutate({ mutation: EJECT_PLAYER, variables: { gameId: this.gameId, playerId } })
|
|
95
|
+
.then(result => result.data && this.handleGameMessageResult(result.data.ejectPlayer));
|
|
96
|
+
}
|
|
97
|
+
giveUp() {
|
|
98
|
+
getApolloClient().mutate({ mutation: GIVE_UP, variables: { gameId: this.gameId } })
|
|
99
|
+
.then(result => result.data && this.handleGameMessageResult(result.data.giveUp));
|
|
100
|
+
}
|
|
101
|
+
onError(error) {
|
|
102
|
+
if (CombinedGraphQLErrors.is(error)) {
|
|
103
|
+
for (const graphqlFormattedError of error.errors) {
|
|
104
|
+
this.dispatch(reportFailure(graphqlFormattedError.message));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.dispatch(reportFailure(Failure.NETWORK));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
playTutorialMoves() {
|
|
112
|
+
console.error('Tutorial should only be played with local API');
|
|
113
|
+
}
|
|
114
|
+
claimVictory() {
|
|
115
|
+
return getApolloClient().mutate({ mutation: CLAIM_VICTORY, variables: { gameId: this.gameId } });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
167
118
|
//# sourceMappingURL=GameClientAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameClientAPI.js","sourceRoot":"","sources":["../../../src/api/Client/GameClientAPI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GameClientAPI.js","sourceRoot":"","sources":["../../../src/api/Client/GameClientAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB,CAAA;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA,+KAA+K,CAAA;AAC7M,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA,8LAA8L,CAAA;AAC7N,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA,gLAAgL,CAAA;AAChN,MAAM,IAAI,GAAG,GAAG,CAAA,uLAAuL,aAAa,IAAI,YAAY,EAAE,CAAA;AACtO,MAAM,IAAI,GAAG,GAAG,CAAA,+LAA+L,aAAa,IAAI,YAAY,EAAE,CAAA;AAC9O,MAAM,YAAY,GAAG,GAAG,CAAA,iMAAiM,aAAa,IAAI,YAAY,EAAE,CAAA;AACxP,MAAM,OAAO,GAAG,GAAG,CAAA,gJAAgJ,aAAa,IAAI,YAAY,EAAE,CAAA;AAClM,MAAM,aAAa,GAAG,GAAG,CAAA,0FAA0F,CAAA;AACnH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;;;;;MAK/B,WAAW;CAChB,CAAA;AAED,MAAM,OAAO,aAAa;IAChB,QAAQ,CAAW;IACV,MAAM,CAAQ;IACvB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AAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;IACzF,CAAC;IAED,MAAM;QACJ,eAAe,EAAE,CAAC,MAAM,CAAoC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;aACnH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACpF,CAAC;IAED,OAAO,CAAC,KAAc;QACpB,IAAI,qBAAqB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,KAAK,MAAM,qBAAqB,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBACjD,IAAI,CAAC,QAAS,CAAC,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAA;YAC9D,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAS,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAED,iBAAiB;QACf,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAChE,CAAC;IAED,YAAY;QACV,OAAO,eAAe,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAClG,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function GameNotificationsListener({ gameId, channelName, notificationsCount }: {
|
|
2
|
-
gameId: string;
|
|
3
|
-
channelName: string;
|
|
4
|
-
notificationsCount: number;
|
|
5
|
-
}): null;
|
|
1
|
+
export declare function GameNotificationsListener({ gameId, channelName, notificationsCount }: {
|
|
2
|
+
gameId: string;
|
|
3
|
+
channelName: string;
|
|
4
|
+
notificationsCount: number;
|
|
5
|
+
}): null;
|
|
@@ -1,115 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
|
-
function step(op) {
|
|
20
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
21
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
22
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
23
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
24
|
-
switch (op[0]) {
|
|
25
|
-
case 0: case 1: t = op; break;
|
|
26
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
27
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
28
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
29
|
-
default:
|
|
30
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
31
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
32
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
33
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
34
|
-
if (t[2]) _.ops.pop();
|
|
35
|
-
_.trys.pop(); continue;
|
|
36
|
-
}
|
|
37
|
-
op = body.call(thisArg, _);
|
|
38
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
39
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
import { useApolloClient } from '@apollo/client/react';
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { receiveNotifications, setGameOver } from '../../Actions';
|
|
5
|
+
import { removePlayer } from '../../Actions/removePlayer';
|
|
6
|
+
import { useGameDispatch } from '../../Store';
|
|
7
|
+
import { NOTIFICATIONS, PLAYERS_TIME } from './GameClientAPI';
|
|
8
|
+
import { pusherClient } from './pusher';
|
|
9
|
+
const GET_NOTIFICATIONS = gql `
|
|
10
|
+
query GameNotifications($gameId: String!, $start: Int) {
|
|
11
|
+
time
|
|
12
|
+
gameNotifications(gameId: $gameId, start: $start) { ...Notifications }
|
|
13
|
+
game(id: $gameId) {
|
|
14
|
+
id players { id ...PlayerTime }
|
|
40
15
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
dispatch((0, Actions_1.gameNotificationsReceived)(notifications, index, players, Date.parse(date)));
|
|
90
|
-
if (!notifications.length) return [3, 1];
|
|
91
|
-
notificationsCountRef.current = Math.max(notificationsCountRef.current, index + notifications.length);
|
|
92
|
-
return [3, 3];
|
|
93
|
-
case 1: return [4, getNotifications(index)];
|
|
94
|
-
case 2:
|
|
95
|
-
_a.sent();
|
|
96
|
-
_a.label = 3;
|
|
97
|
-
case 3: return [2];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}); });
|
|
101
|
-
(0, use_pusher_1.useEvent)(channel, 'game-over', function (players) {
|
|
102
|
-
if (players) {
|
|
103
|
-
dispatch((0, Actions_1.gameOver)(players));
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
(0, use_pusher_1.useEvent)(channel, 'player-quit', function (data) {
|
|
107
|
-
if (data) {
|
|
108
|
-
dispatch((0, PlayerQuit_1.playerQuit)(data));
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
exports.GameNotificationsListener = GameNotificationsListener;
|
|
114
|
-
var templateObject_1;
|
|
16
|
+
} ${NOTIFICATIONS} ${PLAYERS_TIME}
|
|
17
|
+
`;
|
|
18
|
+
export function GameNotificationsListener({ gameId, channelName, notificationsCount }) {
|
|
19
|
+
const client = useApolloClient();
|
|
20
|
+
const dispatch = useGameDispatch();
|
|
21
|
+
const notificationsCountRef = useRef(notificationsCount);
|
|
22
|
+
const getNotifications = async (start) => {
|
|
23
|
+
const { data } = await client.query({
|
|
24
|
+
query: GET_NOTIFICATIONS,
|
|
25
|
+
variables: { gameId, start }
|
|
26
|
+
});
|
|
27
|
+
if (!data)
|
|
28
|
+
return console.error('Failed to collect game data');
|
|
29
|
+
dispatch(receiveNotifications({ notifications: data.gameNotifications, notificationsIndex: start, players: data.game.players, serverTime: data.time }));
|
|
30
|
+
if (data.gameNotifications.length > 0) {
|
|
31
|
+
notificationsCountRef.current = Math.max(notificationsCountRef.current, start + data.gameNotifications.length);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const channel = pusherClient.subscribe(channelName);
|
|
36
|
+
channel.bind('pusher:subscription_error', (error) => console.error('pusher subscription failed', error));
|
|
37
|
+
channel.bind('pusher:subscription_succeeded', () => getNotifications(notificationsCountRef.current));
|
|
38
|
+
channel.bind('moves-played', async (message) => {
|
|
39
|
+
if (!message)
|
|
40
|
+
return;
|
|
41
|
+
const { index, notifications, players, date } = message;
|
|
42
|
+
dispatch(receiveNotifications({ notifications, notificationsIndex: index, players, serverTime: Date.parse(date) }));
|
|
43
|
+
if (notifications.length) {
|
|
44
|
+
notificationsCountRef.current = Math.max(notificationsCountRef.current, index + notifications.length);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
await getNotifications(index);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
channel.bind('game-over', (players) => {
|
|
51
|
+
if (players) {
|
|
52
|
+
dispatch(setGameOver(players));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
channel.bind('player-quit', (data) => {
|
|
56
|
+
if (data) {
|
|
57
|
+
dispatch(removePlayer(data));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return () => pusherClient.unsubscribe(channelName);
|
|
61
|
+
}, []);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
115
64
|
//# sourceMappingURL=GameNotificationsListener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameNotificationsListener.js","sourceRoot":"","sources":["../../../src/api/Client/GameNotificationsListener.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GameNotificationsListener.js","sourceRoot":"","s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AK,CAAC,CAAA;YAC/B,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAA2E,EAAE,EAAE;YACxG,IAAI,OAAO,EAAE,CAAC;gBACZ,QAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;YACjC,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAiD,EAAE,EAAE;YAChF,IAAI,IAAI,EAAE,CAAC;gBACT,QAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/B,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;IACpD,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}): JSX.Element | null;
|
|
1
|
+
export declare function RemoteGameLoader({ gameId, version }: {
|
|
2
|
+
gameId: string;
|
|
3
|
+
version?: number;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|