@gamepark/react-client 7.1.0 → 7.3.0
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/Chat/ChatChannel.d.ts +1 -1
- package/dist/Chat/index.d.ts +0 -1
- package/dist/Chat/index.js +0 -1
- package/dist/Chat/index.js.map +1 -1
- package/dist/Deckbuilding/useDeleteDeck.d.ts +5 -5
- package/dist/Deckbuilding/useDeleteDeck.js +9 -8
- package/dist/Deckbuilding/useDeleteDeck.js.map +1 -1
- package/dist/Deckbuilding/useMyDecks.d.ts +5 -5
- package/dist/Deckbuilding/useMyDecks.js +3 -6
- package/dist/Deckbuilding/useMyDecks.js.map +1 -1
- package/dist/Deckbuilding/useSaveDeck.d.ts +12 -7
- package/dist/Deckbuilding/useSaveDeck.js +16 -8
- package/dist/Deckbuilding/useSaveDeck.js.map +1 -1
- package/dist/Hooks/useChatMessages.d.ts +12 -2
- package/dist/Hooks/useChatMessages.js +30 -26
- package/dist/Hooks/useChatMessages.js.map +1 -1
- package/dist/Hooks/useMessageAuthor.js +5 -6
- package/dist/Hooks/useMessageAuthor.js.map +1 -1
- package/dist/Hooks/useRematch.d.ts +59 -5
- package/dist/Hooks/useRematch.js +5 -7
- package/dist/Hooks/useRematch.js.map +1 -1
- package/dist/Hooks/useSendMessage.d.ts +2 -4
- package/dist/Hooks/useSendMessage.js +2 -4
- package/dist/Hooks/useSendMessage.js.map +1 -1
- package/dist/Rematch/RematchQueries.d.ts +4 -4
- package/dist/User/User.d.ts +1 -1
- package/dist/User/useMe.js +4 -6
- package/dist/User/useMe.js.map +1 -1
- package/dist/api/Client/GameClientAPI.d.ts +6 -7
- package/dist/api/Client/GameClientAPI.js +32 -35
- package/dist/api/Client/GameClientAPI.js.map +1 -1
- package/dist/api/Client/GameNotificationsListener.js +15 -18
- package/dist/api/Client/GameNotificationsListener.js.map +1 -1
- package/dist/api/Client/RemoteGameLoader.js +45 -45
- package/dist/api/Client/RemoteGameLoader.js.map +1 -1
- package/dist/api/Client/apollo-client.js +0 -19
- package/dist/api/Client/apollo-client.js.map +1 -1
- package/dist/api/Client/index.d.ts +0 -1
- package/dist/api/Client/index.js +0 -1
- package/dist/api/Client/index.js.map +1 -1
- package/dist/api/boardGameCredits.d.ts +17 -0
- package/dist/api/boardGameCredits.js +127 -0
- package/dist/api/boardGameCredits.js.map +1 -0
- package/dist/api/boardGameNames.d.ts +9 -0
- package/dist/api/boardGameNames.js +119 -0
- package/dist/api/boardGameNames.js.map +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/trpc/TRPCProvider.d.ts +3 -0
- package/dist/api/trpc/TRPCProvider.js +19 -0
- package/dist/api/trpc/TRPCProvider.js.map +1 -0
- package/dist/api/trpc/client.d.ts +6 -0
- package/dist/api/trpc/client.js +34 -0
- package/dist/api/trpc/client.js.map +1 -0
- package/dist/api/trpc/index.d.ts +2 -0
- package/dist/api/trpc/index.js +3 -0
- package/dist/api/trpc/index.js.map +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +69 -63
package/dist/Chat/index.d.ts
CHANGED
package/dist/Chat/index.js
CHANGED
package/dist/Chat/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Chat/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Chat/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
export declare function useDeleteDeck(boardGame: string): {
|
|
2
|
+
mutate: (id: string) => void;
|
|
3
|
+
mutateAsync: (id: string) => Promise<string>;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { trpc } from '../api';
|
|
2
|
+
export function useDeleteDeck(boardGame) {
|
|
3
|
+
const utils = trpc.useUtils();
|
|
4
|
+
const mutation = trpc.deck.deleteDeck.useMutation({
|
|
5
|
+
onSuccess: (deletedId) => {
|
|
6
|
+
utils.deck.myDecks.setData(boardGame, (oldDecks) => oldDecks?.filter((deck) => deck.id !== deletedId));
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
return { mutate: mutation.mutate, mutateAsync: mutation.mutateAsync, isLoading: mutation.isPending };
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=useDeleteDeck.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeleteDeck.js","sourceRoot":"","sources":["../../src/Deckbuilding/useDeleteDeck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useDeleteDeck.js","sourceRoot":"","sources":["../../src/Deckbuilding/useDeleteDeck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;IAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QAChD,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;YACvB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAA;QACxG,CAAC;KACF,CAAC,CAAA;IACF,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAA;AACtG,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client/react';
|
|
2
1
|
import { Deck } from './Deck';
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export declare function useMyDecks(boardGame: string): {
|
|
3
|
+
data: Deck[] | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
refetch: () => void;
|
|
6
|
+
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useQuery } from '@apollo/client/react';
|
|
3
|
-
export const MY_DECKS = gql `query MyDecks($boardGame: String!) {
|
|
4
|
-
myDecks(boardGame: $boardGame) { id name cards }
|
|
5
|
-
}`;
|
|
1
|
+
import { trpc } from '../api';
|
|
6
2
|
export function useMyDecks(boardGame) {
|
|
7
|
-
|
|
3
|
+
const query = trpc.deck.myDecks.useQuery(boardGame);
|
|
4
|
+
return { data: query.data, isLoading: query.isLoading, refetch: query.refetch };
|
|
8
5
|
}
|
|
9
6
|
//# sourceMappingURL=useMyDecks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMyDecks.js","sourceRoot":"","sources":["../../src/Deckbuilding/useMyDecks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useMyDecks.js","sourceRoot":"","sources":["../../src/Deckbuilding/useMyDecks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7B,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IACnD,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;AACjF,CAAC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { useMutation } from '@apollo/client/react';
|
|
2
1
|
import { Deck } from './Deck';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
2
|
+
type SaveDeckInput = {
|
|
3
|
+
id?: string;
|
|
4
|
+
boardGame: string;
|
|
5
|
+
name: string;
|
|
6
|
+
cards: number[];
|
|
7
|
+
};
|
|
8
|
+
export declare function useSaveDeck(boardGame: string): {
|
|
9
|
+
mutate: (input: SaveDeckInput) => void;
|
|
10
|
+
mutateAsync: (input: SaveDeckInput) => Promise<Deck>;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { trpc } from '../api';
|
|
2
|
+
export function useSaveDeck(boardGame) {
|
|
3
|
+
const utils = trpc.useUtils();
|
|
4
|
+
const mutation = trpc.deck.saveDeck.useMutation({
|
|
5
|
+
onSuccess: (savedDeck, variables) => {
|
|
6
|
+
utils.deck.myDecks.setData(boardGame, (oldDecks) => {
|
|
7
|
+
if (!oldDecks)
|
|
8
|
+
return [savedDeck];
|
|
9
|
+
if (variables.id) {
|
|
10
|
+
return oldDecks.map((deck) => (deck.id === savedDeck.id ? savedDeck : deck));
|
|
11
|
+
}
|
|
12
|
+
return [savedDeck, ...oldDecks];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return { mutate: mutation.mutate, mutateAsync: mutation.mutateAsync, isLoading: mutation.isPending };
|
|
9
17
|
}
|
|
10
18
|
//# sourceMappingURL=useSaveDeck.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSaveDeck.js","sourceRoot":"","sources":["../../src/Deckbuilding/useSaveDeck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSaveDeck.js","sourceRoot":"","sources":["../../src/Deckbuilding/useSaveDeck.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAK7B,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;IAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC9C,SAAS,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YAClC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACjD,IAAI,CAAC,QAAQ;oBAAE,OAAO,CAAC,SAAS,CAAC,CAAA;gBACjC,IAAI,SAAS,CAAC,EAAE,EAAE,CAAC;oBACjB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;gBAC9E,CAAC;gBACD,OAAO,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,CAAA;YACjC,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;IACF,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAA;AACtG,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
export type Message = {
|
|
2
|
+
id: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
text: string;
|
|
5
|
+
date: Date;
|
|
6
|
+
};
|
|
2
7
|
export declare function useChatMessages(gameId: string, onMessageReceived?: (message: Message) => void): {
|
|
3
|
-
messages:
|
|
8
|
+
messages: {
|
|
9
|
+
id: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
text: string;
|
|
12
|
+
date: Date;
|
|
13
|
+
}[];
|
|
4
14
|
hasMoreMessages: boolean;
|
|
5
15
|
loading: boolean;
|
|
6
16
|
fetchMore: () => Promise<void>;
|
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
import { gql } from '@apollo/client';
|
|
2
|
-
import { useQuery } from '@apollo/client/react';
|
|
3
1
|
import { useEffect, useState } from 'react';
|
|
4
|
-
import { pusherClient } from '../api';
|
|
5
|
-
const GET_CHAT_MESSAGES = gql `query ChatMessages($channel: String!, $limit: Int, $maxDate: DateTime) {
|
|
6
|
-
chatChannel(name: $channel) {
|
|
7
|
-
name
|
|
8
|
-
messages(limit: $limit, maxDate: $maxDate) {
|
|
9
|
-
id userId text date
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}`;
|
|
2
|
+
import { pusherClient, trpc } from '../api';
|
|
13
3
|
export function useChatMessages(gameId, onMessageReceived) {
|
|
14
4
|
const [subscribed, setSubscribed] = useState(false);
|
|
15
5
|
const [hasMoreMessages, setHasMoreMessages] = useState(true);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
const messages = (data?.chatChannel?.messages ?? []);
|
|
6
|
+
const utils = trpc.useUtils();
|
|
7
|
+
const { data: messages = [], isLoading } = trpc.chat.getMessages.useQuery({ channel: `game=${gameId}`, limit: 50 }, { enabled: subscribed });
|
|
20
8
|
useEffect(() => {
|
|
21
9
|
const channel = pusherClient.subscribe(`game=${gameId}`);
|
|
22
10
|
channel.bind('pusher:subscription_succeeded', () => setSubscribed(true));
|
|
23
|
-
channel.bind('message', (
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
data: { messages: [{ __typename: 'Message', ...message }] }
|
|
11
|
+
channel.bind('message', (pusherMessage) => {
|
|
12
|
+
if (pusherMessage) {
|
|
13
|
+
const message = { ...pusherMessage, date: new Date(pusherMessage.date) };
|
|
14
|
+
utils.chat.getMessages.setData({ channel: `game=${gameId}`, limit: 50 }, (oldData) => {
|
|
15
|
+
return [message, ...(oldData ?? [])];
|
|
29
16
|
});
|
|
30
17
|
if (onMessageReceived)
|
|
31
18
|
onMessageReceived(message);
|
|
32
19
|
}
|
|
33
20
|
});
|
|
34
21
|
return () => pusherClient.unsubscribe(`game=${gameId}`);
|
|
35
|
-
}, []);
|
|
22
|
+
}, [gameId, onMessageReceived, utils]);
|
|
23
|
+
const fetchMore = async () => {
|
|
24
|
+
if (messages.length === 0)
|
|
25
|
+
return;
|
|
26
|
+
const oldestMessage = messages[messages.length - 1];
|
|
27
|
+
const olderMessages = await utils.client.chat.getMessages.query({
|
|
28
|
+
channel: `game=${gameId}`,
|
|
29
|
+
limit: 10,
|
|
30
|
+
cursor: oldestMessage.date
|
|
31
|
+
});
|
|
32
|
+
if (olderMessages && olderMessages.length > 0) {
|
|
33
|
+
utils.chat.getMessages.setData({ channel: `game=${gameId}`, limit: 50 }, (oldData = []) => {
|
|
34
|
+
return [...oldData, ...olderMessages];
|
|
35
|
+
});
|
|
36
|
+
setHasMoreMessages(olderMessages.length === 10);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
setHasMoreMessages(false);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
36
42
|
return {
|
|
37
43
|
messages,
|
|
38
44
|
hasMoreMessages,
|
|
39
|
-
loading,
|
|
40
|
-
fetchMore
|
|
41
|
-
setHasMoreMessages(result.data !== undefined && result.data.chatChannel.messages.length === 10);
|
|
42
|
-
})
|
|
45
|
+
loading: isLoading,
|
|
46
|
+
fetchMore
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
//# sourceMappingURL=useChatMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatMessages.js","sourceRoot":"","sources":["../../src/Hooks/useChatMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useChatMessages.js","sourceRoot":"","sources":["../../src/Hooks/useChatMessages.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GET_MESSAGE_AUTHOR } from '../api';
|
|
1
|
+
import { trpc } from '../api';
|
|
3
2
|
import { useGameSelector } from '../Store';
|
|
4
3
|
const query = new URLSearchParams(window.location.search);
|
|
5
4
|
export function useMessageAuthor(author) {
|
|
6
5
|
const players = useGameSelector(state => state.players);
|
|
7
6
|
const player = players.find(p => p.userId === author);
|
|
8
|
-
const
|
|
9
|
-
const { data } = useQuery(
|
|
10
|
-
const avatar = player?.avatar ?? data?.
|
|
11
|
-
const name = player?.name ?? data?.
|
|
7
|
+
const enabled = !player && query.get('game') !== null;
|
|
8
|
+
const { data } = trpc.user.getUser.useQuery(author, { enabled });
|
|
9
|
+
const avatar = player?.avatar ?? data?.avatar;
|
|
10
|
+
const name = player?.name ?? data?.name;
|
|
12
11
|
return { avatar, name };
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=useMessageAuthor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessageAuthor.js","sourceRoot":"","sources":["../../src/Hooks/useMessageAuthor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useMessageAuthor.js","sourceRoot":"","sources":["../../src/Hooks/useMessageAuthor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAEzD,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACvD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;IACrD,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;IACrD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;IAChE,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,IAAI,EAAE,MAAM,CAAA;IAC7C,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,CAAA;IACvC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AACzB,CAAC"}
|
|
@@ -1,7 +1,61 @@
|
|
|
1
|
-
import { CanRematchData } from '../Rematch';
|
|
2
1
|
export declare function useRematch(): {
|
|
3
|
-
game:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
game: {
|
|
3
|
+
id: string;
|
|
4
|
+
canRematch: boolean;
|
|
5
|
+
rematch?: {
|
|
6
|
+
id: string;
|
|
7
|
+
players: {
|
|
8
|
+
id: any;
|
|
9
|
+
userId: string;
|
|
10
|
+
ready: boolean;
|
|
11
|
+
name?: string;
|
|
12
|
+
}[];
|
|
13
|
+
startDate?: Date;
|
|
14
|
+
};
|
|
15
|
+
} | undefined;
|
|
16
|
+
rematch: () => Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
canRematch: boolean;
|
|
19
|
+
rematch?: {
|
|
20
|
+
id: string;
|
|
21
|
+
players: {
|
|
22
|
+
id: any;
|
|
23
|
+
userId: string;
|
|
24
|
+
ready: boolean;
|
|
25
|
+
name?: string;
|
|
26
|
+
}[];
|
|
27
|
+
startDate?: Date;
|
|
28
|
+
};
|
|
29
|
+
} | import("@tanstack/query-core").QueryObserverResult<{
|
|
30
|
+
id: string;
|
|
31
|
+
canRematch: boolean;
|
|
32
|
+
rematch?: {
|
|
33
|
+
id: string;
|
|
34
|
+
players: {
|
|
35
|
+
id: any;
|
|
36
|
+
userId: string;
|
|
37
|
+
ready: boolean;
|
|
38
|
+
name?: string;
|
|
39
|
+
}[];
|
|
40
|
+
startDate?: Date;
|
|
41
|
+
};
|
|
42
|
+
}, import("@trpc/client").TRPCClientErrorLike<{
|
|
43
|
+
input: string;
|
|
44
|
+
output: {
|
|
45
|
+
id: string;
|
|
46
|
+
canRematch: boolean;
|
|
47
|
+
rematch?: {
|
|
48
|
+
id: string;
|
|
49
|
+
players: {
|
|
50
|
+
id: any;
|
|
51
|
+
userId: string;
|
|
52
|
+
ready: boolean;
|
|
53
|
+
name?: string;
|
|
54
|
+
}[];
|
|
55
|
+
startDate?: Date;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
transformer: true;
|
|
59
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
60
|
+
}>>>;
|
|
7
61
|
};
|
package/dist/Hooks/useRematch.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { useMutation, useQuery } from '@apollo/client/react';
|
|
2
1
|
import { useEffect } from 'react';
|
|
3
|
-
import { pusherClient } from '../api';
|
|
4
|
-
import { CAN_REMATCH, REMATCH } from '../Rematch';
|
|
2
|
+
import { pusherClient, trpc } from '../api';
|
|
5
3
|
export function useRematch() {
|
|
6
4
|
const query = new URLSearchParams(window.location.search);
|
|
7
5
|
const gameId = query.get('game');
|
|
8
|
-
const canRematchResult = useQuery(
|
|
9
|
-
const game = canRematchResult.data
|
|
10
|
-
const
|
|
6
|
+
const canRematchResult = trpc.rematch.canRematch.useQuery(gameId, { enabled: !!gameId });
|
|
7
|
+
const game = canRematchResult.data;
|
|
8
|
+
const rematchMutation = trpc.rematch.requestRematch.useMutation();
|
|
11
9
|
useEffect(() => {
|
|
12
10
|
const channel = pusherClient.subscribe('rematch=' + gameId);
|
|
13
11
|
channel.bind('rematch', () => canRematchResult.refetch());
|
|
14
12
|
channel.bind('pusher:subscription_succeeded', () => canRematchResult.refetch());
|
|
15
13
|
return () => pusherClient.unsubscribe('rematch=' + gameId);
|
|
16
14
|
}, []);
|
|
17
|
-
return { game, rematch: () =>
|
|
15
|
+
return { game, rematch: () => rematchMutation.mutateAsync(gameId).catch(() => canRematchResult.refetch()) };
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=useRematch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRematch.js","sourceRoot":"","sources":["../../src/Hooks/useRematch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useRematch.js","sourceRoot":"","sources":["../../src/Hooks/useRematch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE3C,MAAM,UAAU,UAAU;IACxB,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACzD,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAE,CAAA;IACjC,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;IACxF,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAA;IAClC,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,CAAA;IACjE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,CAAA;QAC3D,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAA;QACzD,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAA;QAC/E,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,UAAU,GAAG,MAAM,CAAC,CAAA;IAC5D,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,CAAA;AAC7G,CAAC"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function useSendMessage():
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
}, import("@apollo/client").ApolloCache>;
|
|
1
|
+
import { trpc } from '../api';
|
|
2
|
+
export declare function useSendMessage(): ReturnType<typeof trpc.chat.sendMessage.useMutation>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMutation } from '@apollo/client/react';
|
|
3
|
-
const SEND_MESSAGE = gql `mutation SendMessage($channel: String!, $text: String!) { sendMessage(channel: $channel, text: $text) { date } }`;
|
|
1
|
+
import { trpc } from '../api';
|
|
4
2
|
export function useSendMessage() {
|
|
5
|
-
return useMutation(
|
|
3
|
+
return trpc.chat.sendMessage.useMutation();
|
|
6
4
|
}
|
|
7
5
|
//# sourceMappingURL=useSendMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendMessage.js","sourceRoot":"","sources":["../../src/Hooks/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSendMessage.js","sourceRoot":"","sources":["../../src/Hooks/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAO7B,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAA;AAC5C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CAN_REMATCH: import("
|
|
1
|
+
export declare const CAN_REMATCH: import("graphql").DocumentNode;
|
|
2
2
|
export interface CanRematchData {
|
|
3
3
|
id: string;
|
|
4
4
|
canRematch: boolean;
|
|
@@ -14,6 +14,6 @@ export interface RematchPlayerData {
|
|
|
14
14
|
userId: string;
|
|
15
15
|
ready: boolean;
|
|
16
16
|
}
|
|
17
|
-
export declare const REMATCH: import("
|
|
18
|
-
export declare const ACCEPT_REMATCH: import("
|
|
19
|
-
export declare const REFUSE_REMATCH: import("
|
|
17
|
+
export declare const REMATCH: import("graphql").DocumentNode;
|
|
18
|
+
export declare const ACCEPT_REMATCH: import("graphql").DocumentNode;
|
|
19
|
+
export declare const REFUSE_REMATCH: import("graphql").DocumentNode;
|
package/dist/User/User.d.ts
CHANGED
package/dist/User/useMe.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { gql } from '@apollo/client';
|
|
2
|
-
import { useQuery } from '@apollo/client/react';
|
|
3
1
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
const GET_ME = gql `query Me { me { user { id name subscriptionSince avatar {...AvatarInfo} } } } ${AVATAR_INFO}`;
|
|
2
|
+
import { trpc } from '../api';
|
|
6
3
|
export function useMe() {
|
|
7
4
|
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
8
|
-
const
|
|
9
|
-
|
|
5
|
+
const enabled = useMemo(() => process.env.NODE_ENV === 'production' || !!urlSearchParams.get('game') || !!urlSearchParams.get('mode'), []);
|
|
6
|
+
const { data } = trpc.user.getMe.useQuery(undefined, { enabled });
|
|
7
|
+
return data ? { user: data } : undefined;
|
|
10
8
|
}
|
|
11
9
|
//# sourceMappingURL=useMe.js.map
|
package/dist/User/useMe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMe.js","sourceRoot":"","sources":["../../src/User/useMe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useMe.js","sourceRoot":"","sources":["../../src/User/useMe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7B,MAAM,UAAU,KAAK;IACnB,MAAM,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACnE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CACzB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,EACvG,EAAE,CAAC,CAAA;IACP,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;IACjE,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAY,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAClD,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
2
|
import { GameAPI } from '../GameAPI';
|
|
3
|
-
export declare const PLATFORM_URI:
|
|
4
|
-
export declare const AVATAR_INFO: import("@apollo/client").DocumentNode;
|
|
5
|
-
export declare const PLAYERS_TIME: import("@apollo/client").DocumentNode;
|
|
6
|
-
export declare const NOTIFICATIONS: import("@apollo/client").DocumentNode;
|
|
7
|
-
export declare const GET_MESSAGE_AUTHOR: import("@apollo/client").DocumentNode;
|
|
3
|
+
export declare const PLATFORM_URI: any;
|
|
8
4
|
export declare class GameClientAPI<Move = any, PlayerId = any> implements GameAPI<Move, PlayerId> {
|
|
9
5
|
private dispatch?;
|
|
10
6
|
private readonly gameId;
|
|
@@ -15,10 +11,13 @@ export declare class GameClientAPI<Move = any, PlayerId = any> implements GameAP
|
|
|
15
11
|
play(move: Move): void;
|
|
16
12
|
undo(action: number | string): void;
|
|
17
13
|
private executePendingActions;
|
|
18
|
-
private
|
|
14
|
+
private handleTRPCResult;
|
|
19
15
|
eject(playerId: PlayerId): void;
|
|
20
16
|
giveUp(): void;
|
|
21
17
|
onError(error: unknown): void;
|
|
22
18
|
playTutorialMoves(): void;
|
|
23
|
-
claimVictory(): Promise<
|
|
19
|
+
claimVictory(): Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
endDate?: Date;
|
|
22
|
+
}>;
|
|
24
23
|
}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TRPCClientError } from '@trpc/client';
|
|
2
2
|
import { receiveNotifications } from '../../Actions';
|
|
3
3
|
import { reportFailure } from '../../Actions/reportFailure';
|
|
4
4
|
import { Failure } from '../../Failure';
|
|
5
|
-
import {
|
|
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}
|
|
19
|
-
}
|
|
20
|
-
} ${AVATAR_INFO}
|
|
21
|
-
`;
|
|
5
|
+
import { trpcClient } from '../trpc';
|
|
6
|
+
export const PLATFORM_URI = import.meta.env?.VITE_PLATFORM_URI ?? process.env.PLATFORM_URI ?? 'https://game-park.com';
|
|
22
7
|
export class GameClientAPI {
|
|
23
8
|
dispatch;
|
|
24
9
|
gameId;
|
|
@@ -70,14 +55,16 @@ export class GameClientAPI {
|
|
|
70
55
|
if (this.pendingActions.length > 0) {
|
|
71
56
|
const pendingAction = this.pendingActions.shift();
|
|
72
57
|
if (pendingAction.type == 'PLAY') {
|
|
73
|
-
this.ongoingAction =
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
this.ongoingAction = trpcClient.game.playMoves.mutate({
|
|
59
|
+
gameId: this.gameId,
|
|
60
|
+
moves: pendingAction.moves
|
|
61
|
+
}).then(result => this.handleTRPCResult(result));
|
|
76
62
|
}
|
|
77
63
|
else if (pendingAction.type === 'UNDO') {
|
|
78
|
-
this.ongoingAction =
|
|
79
|
-
|
|
80
|
-
|
|
64
|
+
this.ongoingAction = trpcClient.game.undoMoves.mutate({
|
|
65
|
+
gameId: this.gameId,
|
|
66
|
+
actions: pendingAction.actions
|
|
67
|
+
}).then(result => this.handleTRPCResult(result));
|
|
81
68
|
}
|
|
82
69
|
if (this.ongoingAction) {
|
|
83
70
|
this.ongoingAction = this.ongoingAction.catch(error => this.onError(error)).finally(() => this.executePendingActions());
|
|
@@ -87,22 +74,32 @@ export class GameClientAPI {
|
|
|
87
74
|
delete this.ongoingAction;
|
|
88
75
|
}
|
|
89
76
|
}
|
|
90
|
-
|
|
91
|
-
this.dispatch(receiveNotifications({
|
|
77
|
+
handleTRPCResult(result) {
|
|
78
|
+
this.dispatch(receiveNotifications({
|
|
79
|
+
notifications: result.notifications,
|
|
80
|
+
notificationsIndex: result.index,
|
|
81
|
+
players: result.players.map(p => ({
|
|
82
|
+
id: p.id,
|
|
83
|
+
time: p.time ? {
|
|
84
|
+
...p.time,
|
|
85
|
+
lastChange: p.time.lastChange.toISOString(),
|
|
86
|
+
availableTime: p.time.availableTime ?? null
|
|
87
|
+
} : undefined
|
|
88
|
+
})),
|
|
89
|
+
serverTime: result.date.getTime()
|
|
90
|
+
}));
|
|
92
91
|
}
|
|
93
92
|
eject(playerId) {
|
|
94
|
-
|
|
95
|
-
.then(result =>
|
|
93
|
+
trpcClient.game.ejectPlayer.mutate({ gameId: this.gameId, playerId })
|
|
94
|
+
.then(result => this.handleTRPCResult(result));
|
|
96
95
|
}
|
|
97
96
|
giveUp() {
|
|
98
|
-
|
|
99
|
-
.then(result =>
|
|
97
|
+
trpcClient.game.giveUp.mutate({ gameId: this.gameId })
|
|
98
|
+
.then(result => this.handleTRPCResult(result));
|
|
100
99
|
}
|
|
101
100
|
onError(error) {
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
this.dispatch(reportFailure(graphqlFormattedError.message));
|
|
105
|
-
}
|
|
101
|
+
if (error instanceof TRPCClientError) {
|
|
102
|
+
this.dispatch(reportFailure(error.message));
|
|
106
103
|
}
|
|
107
104
|
else {
|
|
108
105
|
this.dispatch(reportFailure(Failure.NETWORK));
|
|
@@ -112,7 +109,7 @@ export class GameClientAPI {
|
|
|
112
109
|
console.error('Tutorial should only be played with local API');
|
|
113
110
|
}
|
|
114
111
|
claimVictory() {
|
|
115
|
-
return
|
|
112
|
+
return trpcClient.game.claimVictory.mutate({ gameId: this.gameId });
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
115
|
//# sourceMappingURL=GameClientAPI.js.map
|