@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.
Files changed (317) hide show
  1. package/dist/Actions/ActionFailed.d.ts +6 -6
  2. package/dist/Actions/ActionFailed.js +4 -8
  3. package/dist/Actions/ActionFailed.js.map +1 -1
  4. package/dist/Actions/AnimationComplete.d.ts +6 -6
  5. package/dist/Actions/AnimationComplete.js +4 -8
  6. package/dist/Actions/AnimationComplete.js.map +1 -1
  7. package/dist/Actions/AnimationPaused.d.ts +6 -6
  8. package/dist/Actions/AnimationPaused.js +4 -8
  9. package/dist/Actions/AnimationPaused.js.map +1 -1
  10. package/dist/Actions/AnimationStart.d.ts +5 -5
  11. package/dist/Actions/AnimationStart.js +1 -4
  12. package/dist/Actions/AnimationStart.js.map +1 -1
  13. package/dist/Actions/ClearFailures.d.ts +1 -5
  14. package/dist/Actions/ClearFailures.js +3 -9
  15. package/dist/Actions/ClearFailures.js.map +1 -1
  16. package/dist/Actions/GameNotificationsReceived.d.ts +8 -10
  17. package/dist/Actions/GameNotificationsReceived.js +2 -9
  18. package/dist/Actions/GameNotificationsReceived.js.map +1 -1
  19. package/dist/Actions/GameOver.d.ts +16 -16
  20. package/dist/Actions/GameOver.js +4 -8
  21. package/dist/Actions/GameOver.js.map +1 -1
  22. package/dist/Actions/GameStateLoaded.d.ts +16 -16
  23. package/dist/Actions/GameStateLoaded.js +7 -20
  24. package/dist/Actions/GameStateLoaded.js.map +1 -1
  25. package/dist/Actions/MovePlayed.d.ts +11 -11
  26. package/dist/Actions/MovePlayed.js +3 -2
  27. package/dist/Actions/MovePlayed.js.map +1 -1
  28. package/dist/Actions/MoveUndone.d.ts +7 -7
  29. package/dist/Actions/MoveUndone.js +4 -9
  30. package/dist/Actions/MoveUndone.js.map +1 -1
  31. package/dist/Actions/PlayerQuit.d.ts +5 -11
  32. package/dist/Actions/PlayerQuit.js +2 -19
  33. package/dist/Actions/PlayerQuit.js.map +1 -1
  34. package/dist/Actions/SetAnimationsSpeed.d.ts +1 -6
  35. package/dist/Actions/SetAnimationsSpeed.js +3 -9
  36. package/dist/Actions/SetAnimationsSpeed.js.map +1 -1
  37. package/dist/Actions/giveUp.d.ts +1 -0
  38. package/dist/Actions/giveUp.js +3 -0
  39. package/dist/Actions/giveUp.js.map +1 -0
  40. package/dist/Actions/index.d.ts +7 -12
  41. package/dist/Actions/index.js +7 -28
  42. package/dist/Actions/index.js.map +1 -1
  43. package/dist/Actions/loadGameState.d.ts +14 -0
  44. package/dist/Actions/loadGameState.js +3 -0
  45. package/dist/Actions/loadGameState.js.map +1 -0
  46. package/dist/Actions/playMove.d.ts +10 -0
  47. package/dist/Actions/playMove.js +3 -0
  48. package/dist/Actions/playMove.js.map +1 -0
  49. package/dist/Actions/receiveNotifications.d.ts +8 -0
  50. package/dist/Actions/receiveNotifications.js +3 -0
  51. package/dist/Actions/receiveNotifications.js.map +1 -0
  52. package/dist/Actions/removePlayer.d.ts +5 -0
  53. package/dist/Actions/removePlayer.js +3 -0
  54. package/dist/Actions/removePlayer.js.map +1 -0
  55. package/dist/Actions/reportFailure.d.ts +1 -0
  56. package/dist/Actions/reportFailure.js +3 -0
  57. package/dist/Actions/reportFailure.js.map +1 -0
  58. package/dist/Actions/setGameOver.d.ts +2 -0
  59. package/dist/Actions/setGameOver.js +3 -0
  60. package/dist/Actions/setGameOver.js.map +1 -0
  61. package/dist/Actions/startAnimation.d.ts +1 -0
  62. package/dist/Actions/startAnimation.js +3 -0
  63. package/dist/Actions/startAnimation.js.map +1 -0
  64. package/dist/Actions/undoMove.d.ts +5 -0
  65. package/dist/Actions/undoMove.js +4 -0
  66. package/dist/Actions/undoMove.js.map +1 -0
  67. package/dist/Chat/ChatChannel.d.ts +5 -5
  68. package/dist/Chat/ChatChannel.js +1 -2
  69. package/dist/Chat/Message.d.ts +6 -6
  70. package/dist/Chat/Message.js +1 -2
  71. package/dist/Chat/index.d.ts +2 -2
  72. package/dist/Chat/index.js +2 -18
  73. package/dist/Chat/index.js.map +1 -1
  74. package/dist/Deckbuilding/Deck.d.ts +5 -5
  75. package/dist/Deckbuilding/Deck.js +1 -2
  76. package/dist/Deckbuilding/index.d.ts +4 -4
  77. package/dist/Deckbuilding/index.js +4 -24
  78. package/dist/Deckbuilding/index.js.map +1 -1
  79. package/dist/Deckbuilding/useDeleteDeck.d.ts +5 -2
  80. package/dist/Deckbuilding/useDeleteDeck.js +9 -15
  81. package/dist/Deckbuilding/useDeleteDeck.js.map +1 -1
  82. package/dist/Deckbuilding/useMyDecks.d.ts +3 -2
  83. package/dist/Deckbuilding/useMyDecks.js +8 -14
  84. package/dist/Deckbuilding/useMyDecks.js.map +1 -1
  85. package/dist/Deckbuilding/useSaveDeck.d.ts +5 -2
  86. package/dist/Deckbuilding/useSaveDeck.js +9 -15
  87. package/dist/Deckbuilding/useSaveDeck.js.map +1 -1
  88. package/dist/EjectPlayer/EjectPlayer.d.ts +1 -6
  89. package/dist/EjectPlayer/EjectPlayer.js +2 -8
  90. package/dist/EjectPlayer/EjectPlayer.js.map +1 -1
  91. package/dist/EjectPlayer/index.d.ts +1 -1
  92. package/dist/EjectPlayer/index.js +1 -17
  93. package/dist/EjectPlayer/index.js.map +1 -1
  94. package/dist/Failure/Failure.d.ts +6 -6
  95. package/dist/Failure/Failure.js +6 -9
  96. package/dist/Failure/Failure.js.map +1 -1
  97. package/dist/Failure/index.d.ts +1 -1
  98. package/dist/Failure/index.js +1 -17
  99. package/dist/Failure/index.js.map +1 -1
  100. package/dist/GiveUp/GiveUp.d.ts +7 -7
  101. package/dist/GiveUp/GiveUp.js +2 -5
  102. package/dist/GiveUp/GiveUp.js.map +1 -1
  103. package/dist/GiveUp/index.d.ts +1 -1
  104. package/dist/GiveUp/index.js +1 -17
  105. package/dist/GiveUp/index.js.map +1 -1
  106. package/dist/Hooks/index.d.ts +5 -5
  107. package/dist/Hooks/index.js +5 -21
  108. package/dist/Hooks/index.js.map +1 -1
  109. package/dist/Hooks/useChatMessages.d.ts +7 -12
  110. package/dist/Hooks/useChatMessages.js +44 -51
  111. package/dist/Hooks/useChatMessages.js.map +1 -1
  112. package/dist/Hooks/useMessageAuthor.d.ts +4 -4
  113. package/dist/Hooks/useMessageAuthor.js +13 -18
  114. package/dist/Hooks/useMessageAuthor.js.map +1 -1
  115. package/dist/Hooks/useOptions.d.ts +2 -2
  116. package/dist/Hooks/useOptions.js +4 -8
  117. package/dist/Hooks/useOptions.js.map +1 -1
  118. package/dist/Hooks/useRematch.d.ts +7 -7
  119. package/dist/Hooks/useRematch.js +18 -19
  120. package/dist/Hooks/useRematch.js.map +1 -1
  121. package/dist/Hooks/useSendMessage.d.ts +4 -1
  122. package/dist/Hooks/useSendMessage.js +6 -14
  123. package/dist/Hooks/useSendMessage.js.map +1 -1
  124. package/dist/Log/StartLiveLog.d.ts +1 -4
  125. package/dist/Log/StartLiveLog.js +3 -5
  126. package/dist/Log/StartLiveLog.js.map +1 -1
  127. package/dist/Log/StopLiveLog.d.ts +2 -5
  128. package/dist/Log/StopLiveLog.js +6 -9
  129. package/dist/Log/StopLiveLog.js.map +1 -1
  130. package/dist/Log/index.d.ts +4 -4
  131. package/dist/Log/index.js +4 -20
  132. package/dist/Log/index.js.map +1 -1
  133. package/dist/Log/useLogControls.d.ts +7 -7
  134. package/dist/Log/useLogControls.js +18 -22
  135. package/dist/Log/useLogControls.js.map +1 -1
  136. package/dist/PlayerTime/PlayerTime.d.ts +11 -11
  137. package/dist/PlayerTime/PlayerTime.js +1 -2
  138. package/dist/PlayerTime/index.d.ts +1 -1
  139. package/dist/PlayerTime/index.js +1 -17
  140. package/dist/PlayerTime/index.js.map +1 -1
  141. package/dist/Rematch/RematchQueries.d.ts +19 -19
  142. package/dist/Rematch/RematchQueries.js +23 -13
  143. package/dist/Rematch/RematchQueries.js.map +1 -1
  144. package/dist/Rematch/index.d.ts +1 -1
  145. package/dist/Rematch/index.js +1 -17
  146. package/dist/Rematch/index.js.map +1 -1
  147. package/dist/Sound/MuteSounds.d.ts +2 -5
  148. package/dist/Sound/MuteSounds.js +7 -10
  149. package/dist/Sound/MuteSounds.js.map +1 -1
  150. package/dist/Sound/UnmuteSounds.d.ts +1 -4
  151. package/dist/Sound/UnmuteSounds.js +3 -5
  152. package/dist/Sound/UnmuteSounds.js.map +1 -1
  153. package/dist/Sound/index.d.ts +3 -3
  154. package/dist/Sound/index.js +3 -19
  155. package/dist/Sound/index.js.map +1 -1
  156. package/dist/Sound/useSoundControls.d.ts +7 -7
  157. package/dist/Sound/useSoundControls.js +18 -22
  158. package/dist/Sound/useSoundControls.js.map +1 -1
  159. package/dist/Store/DisplayedAction.d.ts +15 -15
  160. package/dist/Store/DisplayedAction.js +12 -19
  161. package/dist/Store/DisplayedAction.js.map +1 -1
  162. package/dist/Store/GamePageState.d.ts +27 -28
  163. package/dist/Store/GamePageState.js +1 -2
  164. package/dist/Store/PlayedMove.d.ts +5 -5
  165. package/dist/Store/PlayedMove.js +1 -2
  166. package/dist/Store/endAnimation.d.ts +1 -0
  167. package/dist/Store/endAnimation.js +3 -0
  168. package/dist/Store/endAnimation.js.map +1 -0
  169. package/dist/Store/gameMiddleware.d.ts +4 -4
  170. package/dist/Store/gameMiddleware.js +34 -41
  171. package/dist/Store/gameMiddleware.js.map +1 -1
  172. package/dist/Store/gameReducer.d.ts +14 -20
  173. package/dist/Store/gameReducer.js +462 -525
  174. package/dist/Store/gameReducer.js.map +1 -1
  175. package/dist/Store/index.d.ts +4 -3
  176. package/dist/Store/index.js +4 -19
  177. package/dist/Store/index.js.map +1 -1
  178. package/dist/Store/localMovePreviewMiddleware.d.ts +4 -4
  179. package/dist/Store/localMovePreviewMiddleware.js +19 -18
  180. package/dist/Store/localMovePreviewMiddleware.js.map +1 -1
  181. package/dist/Store/store.d.ts +13 -0
  182. package/dist/Store/store.js +27 -0
  183. package/dist/Store/store.js.map +1 -0
  184. package/dist/Tutorial/PlayTutorialMoves.d.ts +1 -9
  185. package/dist/Tutorial/PlayTutorialMoves.js +2 -6
  186. package/dist/Tutorial/PlayTutorialMoves.js.map +1 -1
  187. package/dist/Tutorial/Tutorial.d.ts +5 -5
  188. package/dist/Tutorial/Tutorial.js +1 -2
  189. package/dist/Tutorial/TutorialDescription.d.ts +7 -7
  190. package/dist/Tutorial/TutorialDescription.js +1 -2
  191. package/dist/Tutorial/index.d.ts +4 -4
  192. package/dist/Tutorial/index.js +4 -20
  193. package/dist/Tutorial/index.js.map +1 -1
  194. package/dist/Tutorial/useTutorial.d.ts +2 -2
  195. package/dist/Tutorial/useTutorial.js +12 -22
  196. package/dist/Tutorial/useTutorial.js.map +1 -1
  197. package/dist/Types/GameAI.d.ts +1 -1
  198. package/dist/Types/GameAI.js +1 -2
  199. package/dist/Types/GameData.d.ts +18 -18
  200. package/dist/Types/GameData.js +1 -2
  201. package/dist/Types/GameMessage.d.ts +8 -8
  202. package/dist/Types/GameMessage.js +1 -2
  203. package/dist/Types/GameMode.d.ts +6 -6
  204. package/dist/Types/GameMode.js +7 -10
  205. package/dist/Types/GameMode.js.map +1 -1
  206. package/dist/Types/GameNotification.d.ts +6 -6
  207. package/dist/Types/GameNotification.js +1 -2
  208. package/dist/Types/GameOptions.d.ts +9 -9
  209. package/dist/Types/GameOptions.js +5 -8
  210. package/dist/Types/GameOptions.js.map +1 -1
  211. package/dist/Types/MovePlayedNotification.d.ts +9 -9
  212. package/dist/Types/MovePlayedNotification.js +6 -12
  213. package/dist/Types/MovePlayedNotification.js.map +1 -1
  214. package/dist/Types/MoveUndoneNotification.d.ts +8 -8
  215. package/dist/Types/MoveUndoneNotification.js +6 -12
  216. package/dist/Types/MoveUndoneNotification.js.map +1 -1
  217. package/dist/Types/Player.d.ts +13 -13
  218. package/dist/Types/Player.js +1 -2
  219. package/dist/Types/PlayerQuitReason.d.ts +4 -4
  220. package/dist/Types/PlayerQuitReason.js +5 -8
  221. package/dist/Types/PlayerQuitReason.js.map +1 -1
  222. package/dist/Types/ProxyGameData.d.ts +13 -13
  223. package/dist/Types/ProxyGameData.js +1 -2
  224. package/dist/Types/Tournament.d.ts +4 -4
  225. package/dist/Types/Tournament.js +1 -2
  226. package/dist/Types/index.d.ts +12 -12
  227. package/dist/Types/index.js +12 -28
  228. package/dist/Types/index.js.map +1 -1
  229. package/dist/User/User.d.ts +6 -6
  230. package/dist/User/User.js +1 -2
  231. package/dist/User/index.d.ts +2 -2
  232. package/dist/User/index.js +2 -18
  233. package/dist/User/index.js.map +1 -1
  234. package/dist/User/useMe.d.ts +4 -4
  235. package/dist/User/useMe.js +10 -21
  236. package/dist/User/useMe.js.map +1 -1
  237. package/dist/animations/Animation.d.ts +6 -6
  238. package/dist/animations/Animation.js +1 -2
  239. package/dist/animations/AnimationContext.d.ts +8 -8
  240. package/dist/animations/AnimationContext.js +1 -2
  241. package/dist/animations/AnimationState.d.ts +6 -6
  242. package/dist/animations/AnimationState.js +1 -2
  243. package/dist/animations/AnimationStep.d.ts +6 -6
  244. package/dist/animations/AnimationStep.js +7 -10
  245. package/dist/animations/AnimationStep.js.map +1 -1
  246. package/dist/animations/Animations.d.ts +8 -8
  247. package/dist/animations/Animations.js +15 -22
  248. package/dist/animations/Animations.js.map +1 -1
  249. package/dist/animations/AnimationsListener.d.ts +6 -0
  250. package/dist/animations/AnimationsListener.js +54 -0
  251. package/dist/animations/AnimationsListener.js.map +1 -0
  252. package/dist/animations/AnimationsListenerCreator.d.ts +2 -4
  253. package/dist/animations/AnimationsListenerCreator.js +40 -50
  254. package/dist/animations/AnimationsListenerCreator.js.map +1 -1
  255. package/dist/animations/animationMiddleware.d.ts +4 -0
  256. package/dist/animations/animationMiddleware.js +50 -0
  257. package/dist/animations/animationMiddleware.js.map +1 -0
  258. package/dist/animations/index.d.ts +5 -6
  259. package/dist/animations/index.js +5 -22
  260. package/dist/animations/index.js.map +1 -1
  261. package/dist/api/Client/GameClientAPI.d.ts +24 -24
  262. package/dist/api/Client/GameClientAPI.js +116 -165
  263. package/dist/api/Client/GameClientAPI.js.map +1 -1
  264. package/dist/api/Client/GameNotificationsListener.d.ts +5 -5
  265. package/dist/api/Client/GameNotificationsListener.js +62 -113
  266. package/dist/api/Client/GameNotificationsListener.js.map +1 -1
  267. package/dist/api/Client/RemoteGameLoader.d.ts +4 -5
  268. package/dist/api/Client/RemoteGameLoader.js +66 -62
  269. package/dist/api/Client/RemoteGameLoader.js.map +1 -1
  270. package/dist/api/Client/RemoteGameProvider.d.ts +7 -7
  271. package/dist/api/Client/RemoteGameProvider.js +19 -70
  272. package/dist/api/Client/RemoteGameProvider.js.map +1 -1
  273. package/dist/api/Client/apollo-client.d.ts +2 -2
  274. package/dist/api/Client/apollo-client.js +40 -58
  275. package/dist/api/Client/apollo-client.js.map +1 -1
  276. package/dist/api/Client/index.d.ts +4 -3
  277. package/dist/api/Client/index.js +4 -19
  278. package/dist/api/Client/index.js.map +1 -1
  279. package/dist/api/Client/pusher.d.ts +2 -0
  280. package/dist/api/Client/pusher.js +9 -0
  281. package/dist/api/Client/pusher.js.map +1 -0
  282. package/dist/api/GameAPI.d.ts +10 -10
  283. package/dist/api/GameAPI.js +1 -2
  284. package/dist/api/Local/ConsoleTools.d.ts +25 -25
  285. package/dist/api/Local/ConsoleTools.js +78 -86
  286. package/dist/api/Local/ConsoleTools.js.map +1 -1
  287. package/dist/api/Local/GameLocalAPI.d.ts +44 -44
  288. package/dist/api/Local/GameLocalAPI.js +442 -540
  289. package/dist/api/Local/GameLocalAPI.js.map +1 -1
  290. package/dist/api/Local/LocalGameProvider.d.ts +15 -15
  291. package/dist/api/Local/LocalGameProvider.js +18 -58
  292. package/dist/api/Local/LocalGameProvider.js.map +1 -1
  293. package/dist/api/Local/index.d.ts +1 -1
  294. package/dist/api/Local/index.js +1 -17
  295. package/dist/api/Local/index.js.map +1 -1
  296. package/dist/api/index.d.ts +2 -2
  297. package/dist/api/index.js +2 -18
  298. package/dist/api/index.js.map +1 -1
  299. package/dist/index.d.ts +16 -18
  300. package/dist/index.js +16 -36
  301. package/dist/index.js.map +1 -1
  302. package/dist/util/ArrayUtil.d.ts +2 -2
  303. package/dist/util/ArrayUtil.js +16 -21
  304. package/dist/util/ArrayUtil.js.map +1 -1
  305. package/package.json +66 -65
  306. package/dist/Actions/ActionType.d.ts +0 -3
  307. package/dist/Actions/ActionType.js +0 -8
  308. package/dist/Actions/ActionType.js.map +0 -1
  309. package/dist/Scoring/ScoringDescription.d.ts +0 -8
  310. package/dist/Scoring/ScoringDescription.js +0 -3
  311. package/dist/Scoring/ScoringDescription.js.map +0 -1
  312. package/dist/Scoring/index.d.ts +0 -1
  313. package/dist/Scoring/index.js +0 -18
  314. package/dist/Scoring/index.js.map +0 -1
  315. package/dist/util/TimeUtil.d.ts +0 -2
  316. package/dist/util/TimeUtil.js +0 -27
  317. package/dist/util/TimeUtil.js.map +0 -1
@@ -1,167 +1,118 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
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 { 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
- Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.GameClientAPI = exports.GET_MESSAGE_AUTHOR = exports.NOTIFICATIONS = exports.PLAYERS_TIME = exports.AVATAR_INFO = void 0;
44
- var client_1 = require("@apollo/client");
45
- var Actions_1 = require("../../Actions");
46
- var Failure_1 = require("../../Failure");
47
- var apollo_client_1 = require("./apollo-client");
48
- exports.AVATAR_INFO = (0, client_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["fragment AvatarInfo on Avataaar {accessoriesType clotheColor clotheType eyeType eyebrowType facialHairType facialHairColor graphicType hairColor mouthType skinColor topType}"], ["fragment AvatarInfo on Avataaar {accessoriesType clotheColor clotheType eyeType eyebrowType facialHairType facialHairColor graphicType hairColor mouthType skinColor topType}"])));
49
- exports.PLAYERS_TIME = (0, client_1.gql)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["fragment PlayerTime on Player { time { availableTime cumulatedDownTime cumulatedPlayTime cumulatedWaitForMeTime highestDownTime highestPlayTime lastChange playing weightedWaitForMeTime } }"], ["fragment PlayerTime on Player { time { availableTime cumulatedDownTime cumulatedPlayTime cumulatedWaitForMeTime highestDownTime highestPlayTime lastChange playing weightedWaitForMeTime } }"])));
50
- exports.NOTIFICATIONS = (0, client_1.gql)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["fragment Notifications on GameNotification { playerId ... on MovePlayedNotification { actionId moveView consequences } ... on MoveUndoneNotification { actionId moveUndone } }"], ["fragment Notifications on GameNotification { playerId ... on MovePlayedNotification { actionId moveView consequences } ... on MoveUndoneNotification { actionId moveUndone } }"])));
51
- var PLAY = (0, client_1.gql)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["mutation PlayMoves($gameId: String!, $moves: [JSON!]!) { playMoves(gameId: $gameId, moves: $moves) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation PlayMoves($gameId: String!, $moves: [JSON!]!) { playMoves(gameId: $gameId, moves: $moves) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
52
- var UNDO = (0, client_1.gql)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["mutation UndoMoves($gameId: String!, $actions: [String!]!) { undoMoves(gameId: $gameId, actions: $actions) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation UndoMoves($gameId: String!, $actions: [String!]!) { undoMoves(gameId: $gameId, actions: $actions) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
53
- var EJECT_PLAYER = (0, client_1.gql)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["mutation EjectPlayer($gameId: String!, $playerId: JSON!) { ejectPlayer(gameId: $gameId, playerId: $playerId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation EjectPlayer($gameId: String!, $playerId: JSON!) { ejectPlayer(gameId: $gameId, playerId: $playerId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
54
- var GIVE_UP = (0, client_1.gql)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["mutation GiveUp($gameId: String!) { giveUp(gameId: $gameId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""], ["mutation GiveUp($gameId: String!) { giveUp(gameId: $gameId) { notifications { ...Notifications } index players { id ...PlayerTime } date } } ", " ", ""])), exports.NOTIFICATIONS, exports.PLAYERS_TIME);
55
- var CLAIM_VICTORY = (0, client_1.gql)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["mutation ClaimVictory($gameId: String!) { claimVictory(gameId: $gameId) { id endDate } }"], ["mutation ClaimVictory($gameId: String!) { claimVictory(gameId: $gameId) { id endDate } }"])));
56
- exports.GET_MESSAGE_AUTHOR = (0, client_1.gql)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n query GetMessageAuthor($id: String!) {\n user(id: $id) {\n id name avatar {...AvatarInfo}\n }\n } ", "\n"], ["\n query GetMessageAuthor($id: String!) {\n user(id: $id) {\n id name avatar {...AvatarInfo}\n }\n } ", "\n"])), exports.AVATAR_INFO);
57
- var GameClientAPI = (function () {
58
- function GameClientAPI(gameId) {
59
- this.pendingActions = [];
60
- this.gameId = gameId;
61
- }
62
- GameClientAPI.prototype.init = function (dispatch) {
63
- return __awaiter(this, void 0, void 0, function () {
64
- return __generator(this, function (_a) {
65
- this.dispatch = dispatch;
66
- return [2];
67
- });
68
- });
69
- };
70
- GameClientAPI.prototype.play = function (move) {
71
- var _this = this;
72
- if (this.pendingActions.length === 0) {
73
- this.pendingActions.push({ type: 'PLAY', moves: [move] });
74
- }
75
- else {
76
- var lastPendingAction = this.pendingActions[this.pendingActions.length - 1];
77
- if (lastPendingAction.type === 'PLAY') {
78
- lastPendingAction.moves.push(move);
79
- }
80
- else {
81
- this.pendingActions.push({ type: 'PLAY', moves: [move] });
82
- }
83
- }
84
- if (!this.ongoingAction) {
85
- this.ongoingAction = new Promise(function (resolve) { return setTimeout(resolve, 50); }).then(function () { return _this.executePendingActions(); });
86
- }
87
- };
88
- GameClientAPI.prototype.undo = function (action) {
89
- if (typeof action === 'number')
90
- return console.error('GameClientAPI can no longer undo without an action ID');
91
- if (this.pendingActions.length === 0) {
92
- this.pendingActions.push({ type: 'UNDO', actions: [action] });
93
- }
94
- else {
95
- var lastPendingAction = this.pendingActions[this.pendingActions.length - 1];
96
- if (lastPendingAction.type === 'UNDO') {
97
- lastPendingAction.actions.push(action);
98
- }
99
- else {
100
- this.pendingActions.push({ type: 'UNDO', actions: [action] });
101
- }
102
- }
103
- if (!this.ongoingAction) {
104
- this.executePendingActions();
105
- }
106
- };
107
- GameClientAPI.prototype.executePendingActions = function () {
108
- var _this = this;
109
- if (this.pendingActions.length > 0) {
110
- var pendingAction = this.pendingActions.shift();
111
- if (pendingAction.type == 'PLAY') {
112
- this.ongoingAction = (0, apollo_client_1.getApolloClient)().mutate({
113
- mutation: PLAY, variables: { gameId: this.gameId, moves: pendingAction.moves }
114
- }).then(function (result) { return result.data && _this.handleGameMessageResult(result.data.playMoves); });
115
- }
116
- else if (pendingAction.type === 'UNDO') {
117
- this.ongoingAction = (0, apollo_client_1.getApolloClient)().mutate({
118
- mutation: UNDO, variables: { gameId: this.gameId, actions: pendingAction.actions }
119
- }).then(function (result) { return result.data && _this.handleGameMessageResult(result.data.undoMoves); });
120
- }
121
- if (this.ongoingAction) {
122
- this.ongoingAction = this.ongoingAction.catch(function (error) { return _this.onError(error); }).finally(function () { return _this.executePendingActions(); });
123
- }
124
- }
125
- else {
126
- delete this.ongoingAction;
127
- }
128
- };
129
- GameClientAPI.prototype.handleGameMessageResult = function (_a) {
130
- var date = _a.date, index = _a.index, notifications = _a.notifications, players = _a.players;
131
- this.dispatch((0, Actions_1.gameNotificationsReceived)(notifications, index, players, Date.parse(date)));
132
- };
133
- GameClientAPI.prototype.eject = function (playerId) {
134
- var _this = this;
135
- (0, apollo_client_1.getApolloClient)().mutate({ mutation: EJECT_PLAYER, variables: { gameId: this.gameId, playerId: playerId } })
136
- .then(function (result) { return result.data && _this.handleGameMessageResult(result.data.ejectPlayer); });
137
- };
138
- GameClientAPI.prototype.giveUp = function () {
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiD;AAEjD,yCAAuE;AACvE,yCAAuC;AAGvC,iDAAiD;AAEpC,QAAA,WAAW,OAAG,YAAG,mPAAA,+KAA+K,KAAA;AAChM,QAAA,YAAY,OAAG,YAAG,kQAAA,8LAA8L,KAAA;AAChN,QAAA,aAAa,OAAG,YAAG,oPAAA,gLAAgL,KAAA;AAChN,IAAM,IAAI,OAAG,YAAG,mQAAA,sLAAuL,EAAa,GAAI,EAAY,EAAE,KAA/B,qBAAa,EAAI,oBAAY,CAAE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+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
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
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
- Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.GameNotificationsListener = void 0;
44
- var client_1 = require("@apollo/client");
45
- var use_pusher_1 = require("@harelpls/use-pusher");
46
- var react_1 = require("react");
47
- var react_redux_1 = require("react-redux");
48
- var Actions_1 = require("../../Actions");
49
- var PlayerQuit_1 = require("../../Actions/PlayerQuit");
50
- var GameClientAPI_1 = require("./GameClientAPI");
51
- var GET_NOTIFICATIONS = (0, client_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query GameNotifications($gameId: String!, $start: Int) {\n time\n gameNotifications(gameId: $gameId, start: $start) { ...Notifications }\n game(id: $gameId) {\n id players { id ...PlayerTime }\n }\n } ", " ", "\n"], ["\n query GameNotifications($gameId: String!, $start: Int) {\n time\n gameNotifications(gameId: $gameId, start: $start) { ...Notifications }\n game(id: $gameId) {\n id players { id ...PlayerTime }\n }\n } ", " ", "\n"])), GameClientAPI_1.NOTIFICATIONS, GameClientAPI_1.PLAYERS_TIME);
52
- function GameNotificationsListener(_a) {
53
- var _this = this;
54
- var gameId = _a.gameId, channelName = _a.channelName, notificationsCount = _a.notificationsCount;
55
- var channel = (0, use_pusher_1.useChannel)(channelName);
56
- var client = (0, client_1.useApolloClient)();
57
- var dispatch = (0, react_redux_1.useDispatch)();
58
- var notificationsCountRef = (0, react_1.useRef)(notificationsCount);
59
- var getNotifications = function (start) { return __awaiter(_this, void 0, void 0, function () {
60
- var data;
61
- return __generator(this, function (_a) {
62
- switch (_a.label) {
63
- case 0: return [4, client.query({
64
- query: GET_NOTIFICATIONS,
65
- variables: { gameId: gameId, start: start }
66
- })];
67
- case 1:
68
- data = (_a.sent()).data;
69
- if (!data)
70
- return [2, console.error('Failed to collect game data')];
71
- dispatch((0, Actions_1.gameNotificationsReceived)(data.gameNotifications, start, data.game.players, data.time));
72
- if (data.gameNotifications.length > 0) {
73
- notificationsCountRef.current = Math.max(notificationsCountRef.current, start + data.gameNotifications.length);
74
- }
75
- return [2];
76
- }
77
- });
78
- }); };
79
- (0, use_pusher_1.useEvent)(channel, 'pusher:subscription_error', function (error) { return console.error('pusher subscription failed', error); });
80
- (0, use_pusher_1.useEvent)(channel, 'pusher:subscription_succeeded', function () { return getNotifications(notificationsCountRef.current); });
81
- (0, use_pusher_1.useEvent)(channel, 'moves-played', function (message) { return __awaiter(_this, void 0, void 0, function () {
82
- var index, notifications, players, date;
83
- return __generator(this, function (_a) {
84
- switch (_a.label) {
85
- case 0:
86
- if (!message)
87
- return [2];
88
- index = message.index, notifications = message.notifications, players = message.players, date = message.date;
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAqD;AACrD,mDAA2D;AAC3D,+BAA8B;AAC9B,2CAAyC;AACzC,yCAAmE;AACnE,uDAAqD;AAErD,iDAA6D;AAE7D,IAAM,iBAAiB,OAAG,YAAG,gTAAA,iOAOvB,EAAa,GAAI,EAAY,IAClC,KADK,6BAAa,EAAI,4BAAY,CAClC,CAAA;AAED,SAAgB,yBAAyB,CAAC,EAAgH;IAA1J,iBA8CC;QA9C2C,MAAM,YAAA,EAAE,WAAW,iBAAA,EAAE,kBAAkB,wBAAA;IACjF,IAAM,OAAO,GAAG,IAAA,uBAAU,EAAC,WAAW,CAAC,CAAA;IACvC,IAAM,MAAM,GAAG,IAAA,wBAAe,GAAE,CAAA;IAChC,IAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAA;IAC9B,IAAM,qBAAqB,GAAG,IAAA,cAAM,EAAC,kBAAkB,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AAC,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
- /// <reference types="react" />
2
- export declare function RemoteGameLoader({ gameId, version }: {
3
- gameId: string;
4
- version?: number;
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;