@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,63 +1,67 @@
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 __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.RemoteGameLoader = void 0;
19
- var jsx_runtime_1 = require("react/jsx-runtime");
20
- var client_1 = require("@apollo/client");
21
- var react_1 = require("react");
22
- var react_redux_1 = require("react-redux");
23
- var Actions_1 = require("../../Actions");
24
- var GameClientAPI_1 = require("./GameClientAPI");
25
- var GameNotificationsListener_1 = require("./GameNotificationsListener");
26
- var GET_GAME = (0, client_1.gql)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query Game($id: String!) {\n time\n gameNotifications(gameId: $id, start: 0) { ...Notifications }\n game(id: $id) {\n id\n players {\n id userId name avatar {...AvatarInfo} quit quitReason gamePointsDelta tournamentPoints ...PlayerTime\n }\n options {\n speed maxSpareTime maxExceedTime\n }\n notificationsChannel mode setup state myPlayerId endDate\n tournament {\n number signedUp\n }\n version\n }\n } ", " ", " ", "\n"], ["\n query Game($id: String!) {\n time\n gameNotifications(gameId: $id, start: 0) { ...Notifications }\n game(id: $id) {\n id\n players {\n id userId name avatar {...AvatarInfo} quit quitReason gamePointsDelta tournamentPoints ...PlayerTime\n }\n options {\n speed maxSpareTime maxExceedTime\n }\n notificationsChannel mode setup state myPlayerId endDate\n tournament {\n number signedUp\n }\n version\n }\n } ", " ", " ", "\n"])), GameClientAPI_1.PLAYERS_TIME, GameClientAPI_1.AVATAR_INFO, GameClientAPI_1.NOTIFICATIONS);
27
- function RemoteGameLoader(_a) {
28
- var _b, _c;
29
- var gameId = _a.gameId, _d = _a.version, version = _d === void 0 ? 1 : _d;
30
- var dispatch = (0, react_redux_1.useDispatch)();
31
- var isOver = (0, react_redux_1.useSelector)(function (state) { return state.gameOver; });
32
- var _e = (0, react_1.useState)(isOver), isOverForLongEnough = _e[0], setIsOverForLongEnough = _e[1];
33
- (0, react_1.useEffect)(function () {
34
- if (isOver) {
35
- setTimeout(function () { return setIsOverForLongEnough(isOver); }, 10000);
36
- }
37
- }, [isOver]);
38
- var _f = (0, client_1.useLazyQuery)(GET_GAME), getGame = _f[0], data = _f[1].data;
39
- (0, react_1.useEffect)(function () {
40
- getGame({ variables: { id: gameId } }).then(function (result) {
41
- if (result.data) {
42
- var _a = result.data, game = _a.game, time = _a.time, gameNotifications = _a.gameNotifications;
43
- var remoteVersion = game.version;
44
- if (remoteVersion && remoteVersion !== version) {
45
- var url = new URL(window.location.href);
46
- var path = url.hostname.split('.');
47
- url.hostname = "".concat(path[0], ".v").concat(remoteVersion, ".").concat(path[path.length - 2], ".").concat(path[path.length - 1]);
48
- window.location.href = url.href;
49
- }
50
- else {
51
- dispatch((0, Actions_1.gameStateLoaded)(__assign(__assign({}, game), { notifications: gameNotifications }), time));
52
- }
53
- }
54
- });
55
- }, []);
56
- if (!data || data.game.endDate || isOverForLongEnough)
57
- return null;
58
- else
59
- return (0, jsx_runtime_1.jsx)(GameNotificationsListener_1.GameNotificationsListener, { channelName: (_c = (_b = data === null || data === void 0 ? void 0 : data.game) === null || _b === void 0 ? void 0 : _b.notificationsChannel) !== null && _c !== void 0 ? _c : "game=".concat(gameId), gameId: gameId, notificationsCount: data.gameNotifications.length });
60
- }
61
- exports.RemoteGameLoader = RemoteGameLoader;
62
- var templateObject_1;
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { gql } from '@apollo/client';
3
+ import { useLazyQuery } from '@apollo/client/react';
4
+ import { useEffect, useState } from 'react';
5
+ import { loadGameState } from '../../Actions/loadGameState';
6
+ import { useGameDispatch, useGameSelector } from '../../Store';
7
+ import { AVATAR_INFO, NOTIFICATIONS, PLAYERS_TIME } from './GameClientAPI';
8
+ import { GameNotificationsListener } from './GameNotificationsListener';
9
+ const GET_GAME = gql `
10
+ query Game($id: String!) {
11
+ time
12
+ gameNotifications(gameId: $id, start: 0) { ...Notifications }
13
+ game(id: $id) {
14
+ id
15
+ players {
16
+ id userId name avatar {...AvatarInfo} quit quitReason gamePointsDelta tournamentPoints ...PlayerTime
17
+ }
18
+ options {
19
+ speed maxSpareTime maxExceedTime
20
+ }
21
+ notificationsChannel mode setup state myPlayerId endDate
22
+ tournament {
23
+ number signedUp
24
+ }
25
+ version
26
+ }
27
+ } ${PLAYERS_TIME} ${AVATAR_INFO} ${NOTIFICATIONS}
28
+ `;
29
+ export function RemoteGameLoader({ gameId, version = 1 }) {
30
+ const dispatch = useGameDispatch();
31
+ const isOver = useGameSelector(state => state.gameOver);
32
+ const [isOverForLongEnough, setIsOverForLongEnough] = useState(isOver);
33
+ useEffect(() => {
34
+ if (isOver) {
35
+ setTimeout(() => setIsOverForLongEnough(isOver), 10000);
36
+ }
37
+ }, [isOver]);
38
+ const [getGame, { data }] = useLazyQuery(GET_GAME);
39
+ useEffect(() => {
40
+ getGame({ variables: { id: gameId } }).then(result => {
41
+ if (result.data) {
42
+ const { game, time, gameNotifications } = result.data;
43
+ const remoteVersion = game.version;
44
+ if (remoteVersion && remoteVersion !== version) {
45
+ const url = new URL(window.location.href);
46
+ const path = url.hostname.split('.');
47
+ url.hostname = `${path[0]}.v${remoteVersion}.${path[path.length - 2]}.${path[path.length - 1]}`;
48
+ window.location.href = url.href;
49
+ }
50
+ else {
51
+ dispatch(loadGameState({
52
+ ...({ ...game, notifications: gameNotifications }),
53
+ playerId: { ...game, notifications: gameNotifications }.myPlayerId ?? undefined,
54
+ serverTime: time,
55
+ endDate: { ...game, notifications: gameNotifications }.endDate ?? undefined,
56
+ tournament: { ...game, notifications: gameNotifications }.tournament ?? undefined
57
+ }));
58
+ }
59
+ }
60
+ });
61
+ }, []);
62
+ if (!data || data.game.endDate || isOverForLongEnough)
63
+ return null;
64
+ else
65
+ return _jsx(GameNotificationsListener, { channelName: data?.game?.notificationsChannel ?? `game=${gameId}`, gameId: gameId, notificationsCount: data.gameNotifications.length });
66
+ }
63
67
  //# sourceMappingURL=RemoteGameLoader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteGameLoader.js","sourceRoot":"","sources":["../../../src/api/Client/RemoteGameLoader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,yCAAkD;AAClD,+BAA2C;AAC3C,2CAAsD;AACtD,yCAA+C;AAG/C,iDAA0E;AAC1E,yEAAuE;AAEvE,IAAM,QAAQ,OAAG,YAAG,8jBAAA,0eAkBd,EAAY,GAAI,EAAW,GAAI,EAAa,IACjD,KADK,4BAAY,EAAI,2BAAW,EAAI,6BAAa,CACjD,CAAA;AAED,SAAgB,gBAAgB,CAAC,EAA6D;;QAA3D,MAAM,YAAA,EAAE,eAAW,EAAX,OAAO,mBAAG,CAAC,KAAA;IACpD,IAAM,QAAQ,GAAG,IAAA,yBAAW,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AI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAA;oBAC/F,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;gBACjC,CAAC;qBAAM,CAAC;oBACN,QAAQ,CAAC,aAAa,CAAC;wBACrB,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;wBAClD,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC,UAAU,IAAI,SAAS;wBAC/E,UAAU,EAAE,IAAI;wBAChB,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC,OAAO,IAAI,SAAS;wBAC3E,UAAU,EAAE,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC,UAAU,IAAI,SAAS;qBAClF,CAAC,CAAC,CAAA;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,mBAAmB;QAAE,OAAO,IAAI,CAAA;;QAC7D,OAAO,KAAC,yBAAyB,IAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,IAAI,QAAQ,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EACjF,kBAAkB,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAA;AAC7F,CAAC"}
@@ -1,7 +1,7 @@
1
- import { PropsWithChildren } from 'react';
2
- import { GameReducerContext } from '../../Store/gameReducer';
3
- type RemoveGameProviderProps<Game = any, Move = any, PlayerId = any> = {
4
- gameId: string;
5
- } & GameReducerContext<Game, Move, PlayerId>;
6
- export declare function RemoteGameProvider<Game = any, Move = any, PlayerId = any>({ gameId, children, ...context }: PropsWithChildren<RemoveGameProviderProps<Game, Move, PlayerId>>): JSX.Element;
7
- export {};
1
+ import { PropsWithChildren } from 'react';
2
+ import { GameReducerContext } from '../../Store/gameReducer';
3
+ type RemoveGameProviderProps<Game = any, Move = any, PlayerId = any> = {
4
+ gameId: string;
5
+ } & GameReducerContext<Game, Move, PlayerId>;
6
+ export declare function RemoteGameProvider<Game = any, Move = any, PlayerId = any>({ gameId, children, ...context }: PropsWithChildren<RemoveGameProviderProps<Game, Move, PlayerId>>): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -1,71 +1,20 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
- var _a, _b, _c;
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.RemoteGameProvider = void 0;
30
- var jsx_runtime_1 = require("react/jsx-runtime");
31
- var use_pusher_1 = require("@harelpls/use-pusher");
32
- var pusher_js_1 = __importDefault(require("pusher-js"));
33
- var react_1 = require("react");
34
- var react_redux_1 = require("react-redux");
35
- var redux_1 = require("redux");
36
- var rules_api_1 = require("../../../../rules-api");
37
- var animations_1 = require("../../animations");
38
- var index_1 = require("../../index");
39
- var gameMiddleware_1 = require("../../Store/gameMiddleware");
40
- var gameReducer_1 = require("../../Store/gameReducer");
41
- var localMovePreviewMiddleware_1 = require("../../Store/localMovePreviewMiddleware");
42
- var GameClientAPI_1 = require("./GameClientAPI");
43
- var RemoteGameLoader_1 = require("./RemoteGameLoader");
44
- pusher_js_1.default.logToConsole = true;
45
- pusher_js_1.default.Runtime.createXHR = function () {
46
- var xhr = new XMLHttpRequest();
47
- xhr.withCredentials = true;
48
- return xhr;
49
- };
50
- var authEndpoint = index_1.PLATFORM_URI + ((_a = process.env.REACT_APP_PUSHER_ENDPOINT) !== null && _a !== void 0 ? _a : '/api/pusher/auth');
51
- var clientKey = (_b = process.env.REACT_APP_PUSHER_KEY) !== null && _b !== void 0 ? _b : '747557f1e8edf7fc2816';
52
- var cluster = (_c = process.env.REACT_APP_PUSHER_CLUSTER) !== null && _c !== void 0 ? _c : 'eu';
53
- function RemoteGameProvider(_a) {
54
- var gameId = _a.gameId, children = _a.children, context = __rest(_a, ["gameId", "children"]);
55
- var store = (0, react_1.useMemo)(function () { return createRemoteApiStore(gameId, context); }, []);
56
- return ((0, jsx_runtime_1.jsx)(use_pusher_1.PusherProvider, __assign({ authEndpoint: authEndpoint, clientKey: clientKey, cluster: cluster }, { children: (0, jsx_runtime_1.jsxs)(react_redux_1.Provider, __assign({ store: store }, { children: [(0, jsx_runtime_1.jsx)(RemoteGameLoader_1.RemoteGameLoader, { gameId: gameId, version: context.version }), children] })) })));
57
- }
58
- exports.RemoteGameProvider = RemoteGameProvider;
59
- function createRemoteApiStore(gameId, context) {
60
- var api = new GameClientAPI_1.GameClientAPI(gameId);
61
- var reducer = (0, gameReducer_1.gameReducer)(context);
62
- var middlewares = [(0, gameMiddleware_1.gameMiddleware)(api)];
63
- if ((0, rules_api_1.hasLocalMovePreview)(new context.Rules({}))) {
64
- middlewares.unshift((0, localMovePreviewMiddleware_1.localMovePreviewMiddleware)(context));
65
- }
66
- var store = (0, redux_1.createStore)(reducer, redux_1.applyMiddleware.apply(void 0, middlewares));
67
- store.subscribe((0, animations_1.createAnimationsListener)(store, context.Rules));
68
- api.init(store.dispatch);
69
- return store;
70
- }
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Pusher from 'pusher-js';
3
+ import { useEffect } from 'react';
4
+ import { Provider } from 'react-redux';
5
+ import { initStore, store } from '../../Store';
6
+ import { GameClientAPI } from './GameClientAPI';
7
+ import { RemoteGameLoader } from './RemoteGameLoader';
8
+ Pusher.logToConsole = true;
9
+ Pusher.Runtime.createXHR = function () {
10
+ const xhr = new XMLHttpRequest();
11
+ xhr.withCredentials = true;
12
+ return xhr;
13
+ };
14
+ export function RemoteGameProvider({ gameId, children, ...context }) {
15
+ useEffect(() => {
16
+ initStore(context, () => new GameClientAPI(gameId));
17
+ }, []);
18
+ return (_jsxs(Provider, { store: store, children: [_jsx(RemoteGameLoader, { gameId: gameId, version: context.version }), children] }));
19
+ }
71
20
  //# sourceMappingURL=RemoteGameProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteGameProvider.js","sourceRoot":"","sources":["../../../src/api/Client/RemoteGameProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAqD;AACrD,wDAA8B;AAE9B,+BAAkD;AAClD,2CAAsC;AACtC,+BAAoD;AACpD,mDAA2D;AAC3D,+CAA2D;AAC3D,qCAA0C;AAC1C,6DAA2D;AAC3D,uDAAyE;AACzE,qFAAmF;AACnF,iDAA+C;AAC/C,uDAAqD;AAErD,mBAAM,CAAC,YAAY,GAAG,IAAI,CAAA;AAE1B,mBAAM,CAAC,OAAO,CAAC,SAAS,GAAG;IACzB,IAAM,GAAG,GAAG,IAAI,cAAc,EAAU,CAAA;IACxC,GAAG,CAAC,eAAe,GAAG,IAAI,CAAA;IAC1B,OAAO,GAA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gB,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,EAC5D,QAAQ,IACA,CACZ,CAAA;AACH,CAAC"}
@@ -1,2 +1,2 @@
1
- import { ApolloClient } from '@apollo/client';
2
- export declare function getApolloClient(): ApolloClient<any>;
1
+ import { ApolloClient } from '@apollo/client';
2
+ export declare function getApolloClient(): ApolloClient;
@@ -1,59 +1,41 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getApolloClient = void 0;
16
- var client_1 = require("@apollo/client");
17
- var retry_1 = require("@apollo/client/link/retry");
18
- var dayjs_1 = __importDefault(require("dayjs"));
19
- var index_1 = require("../../index");
20
- var apolloClient;
21
- function getApolloClient() {
22
- if (!apolloClient) {
23
- apolloClient = initApolloClient();
24
- }
25
- return apolloClient;
26
- }
27
- exports.getApolloClient = getApolloClient;
28
- function initApolloClient() {
29
- var _a;
30
- var httpLink = new client_1.HttpLink({ uri: index_1.PLATFORM_URI + ((_a = process.env.REACT_APP_GRAPHQL_ENDPOINT) !== null && _a !== void 0 ? _a : '/api/graphql'), fetch: fetch, credentials: 'include' });
31
- return new client_1.ApolloClient({
32
- link: client_1.ApolloLink.from([new retry_1.RetryLink(), httpLink]),
33
- cache: new client_1.InMemoryCache({
34
- typePolicies: {
35
- ChatChannel: {
36
- keyFields: ['name'],
37
- fields: {
38
- messages: {
39
- keyArgs: false,
40
- merge: function (existing, incoming) {
41
- if (existing === void 0) { existing = []; }
42
- if (incoming === void 0) { incoming = []; }
43
- return __spreadArray(__spreadArray([], incoming, true), existing, true).sort(function (m1, m2) { return (0, dayjs_1.default)(m1.date).unix() - (0, dayjs_1.default)(m2.date).unix(); })
44
- .filter(function (message, index, messages) { return index === 0 || message.id !== messages[index - 1].id; });
45
- }
46
- }
47
- }
48
- },
49
- Message: {
50
- keyFields: false
51
- }
52
- },
53
- possibleTypes: {
54
- GameNotification: ['MovePlayedNotification', 'MoveUndoneNotification']
55
- }
56
- })
57
- });
58
- }
1
+ import { ApolloClient, ApolloLink, HttpLink, InMemoryCache } from '@apollo/client';
2
+ import { RetryLink } from '@apollo/client/link/retry';
3
+ import dayjs from 'dayjs';
4
+ import { PLATFORM_URI } from './GameClientAPI';
5
+ let apolloClient;
6
+ export function getApolloClient() {
7
+ if (!apolloClient) {
8
+ apolloClient = initApolloClient();
9
+ }
10
+ return apolloClient;
11
+ }
12
+ function initApolloClient() {
13
+ const httpLink = new HttpLink({ uri: PLATFORM_URI + (process.env.GRAPHQL_ENDPOINT ?? '/api/graphql'), fetch, credentials: 'include' });
14
+ return new ApolloClient({
15
+ link: ApolloLink.from([new RetryLink(), httpLink]),
16
+ cache: new InMemoryCache({
17
+ typePolicies: {
18
+ ChatChannel: {
19
+ keyFields: ['name'],
20
+ fields: {
21
+ messages: {
22
+ keyArgs: false,
23
+ merge(existing = [], incoming = []) {
24
+ return [...incoming, ...existing]
25
+ .sort((m1, m2) => dayjs(m2.date).unix() - dayjs(m1.date).unix())
26
+ .filter((message, index, messages) => index === 0 || message.id !== messages[index - 1].id);
27
+ }
28
+ }
29
+ }
30
+ },
31
+ Message: {
32
+ keyFields: false
33
+ }
34
+ },
35
+ possibleTypes: {
36
+ GameNotification: ['MovePlayedNotification', 'MoveUndoneNotification']
37
+ }
38
+ })
39
+ });
40
+ }
59
41
  //# sourceMappingURL=apollo-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apollo-client.js","sourceRoot":"","sources":["../../../src/api/Client/apollo-client.ts"],"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EAAE;4BACR,OAAO,EAAE,KAAK;4BACd,KAAK,CAAC,WAAsB,EAAE,EAAE,WAAsB,EAAE;gCACtD,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC;qCAC9B,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;qCAC/D,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;4BAC/F,CAAC;yBACF;qBACF;iBACF;gBACD,OAAO,EAAE;oBACP,SAAS,EAAE,KAAK;iBACjB;aACF;YACD,aAAa,EAAE;gBACb,gBAAgB,EAAE,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;aACvE;SACF,CAAC;KACH,CAAC,CAAA;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
- export * from './apollo-client';
2
- export * from './GameClientAPI';
3
- export * from './RemoteGameProvider';
1
+ export * from './apollo-client';
2
+ export * from './GameClientAPI';
3
+ export * from './pusher';
4
+ export * from './RemoteGameProvider';
@@ -1,20 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./apollo-client"), exports);
18
- __exportStar(require("./GameClientAPI"), exports);
19
- __exportStar(require("./RemoteGameProvider"), exports);
1
+ export * from './apollo-client';
2
+ export * from './GameClientAPI';
3
+ export * from './pusher';
4
+ export * from './RemoteGameProvider';
20
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/Client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,kDAA+B;AAC/B,uDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/Client/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,sBAAsB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import Pusher from 'pusher-js';
2
+ export declare const pusherClient: Pusher;
@@ -0,0 +1,9 @@
1
+ import Pusher from 'pusher-js';
2
+ import { PLATFORM_URI } from './GameClientAPI';
3
+ export const pusherClient = new Pusher(process.env.PUSHER_KEY ?? '747557f1e8edf7fc2816', {
4
+ cluster: process.env.PUSHER_CLUSTER ?? 'eu',
5
+ authEndpoint: PLATFORM_URI + (process.env.PUSHER_ENDPOINT ?? '/api/pusher/auth'),
6
+ forceTLS: true,
7
+ disableStats: true
8
+ });
9
+ //# sourceMappingURL=pusher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pusher.js","sourceRoot":"","sources":["../../../src/api/Client/pusher.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,sBAAsB,EAAE;IACvF,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,IAAI;IAC3C,YAAY,EAAE,YAAY,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,kBAAkB,CAAC;IAChF,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;CACnB,CAAC,CAAA"}
@@ -1,10 +1,10 @@
1
- import { Dispatch } from 'redux';
2
- export interface GameAPI<Move = string, PlayerId = number> {
3
- init(dispatch: Dispatch): void;
4
- play(move: Move): void;
5
- undo(playerActionIndex: number): void;
6
- undo(actionId: string): void;
7
- eject(playerId: PlayerId): void;
8
- giveUp(): void;
9
- playTutorialMoves(quantity: number): void;
10
- }
1
+ import { Dispatch } from 'redux';
2
+ export interface GameAPI<Move = any, PlayerId = any> {
3
+ init(dispatch: Dispatch): void;
4
+ play(move: Move): void;
5
+ undo(playerActionIndex: number): void;
6
+ undo(actionId: string): void;
7
+ eject(playerId: PlayerId): void;
8
+ giveUp(): void;
9
+ playTutorialMoves(quantity: number): void;
10
+ }
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=GameAPI.js.map
@@ -1,25 +1,25 @@
1
- import { Action } from '@gamepark/rules-api';
2
- import { Store } from 'redux';
3
- import { GamePageState } from '../../Store';
4
- import { GameLocalAPI } from './GameLocalAPI';
5
- declare global {
6
- interface Window {
7
- game: ConsoleTools;
8
- }
9
- }
10
- type ConsoleTools<Game = any, Move = any, PlayerId = any> = {
11
- state: Game;
12
- store: GamePageState<Game>;
13
- moves: Action<Move, PlayerId>[];
14
- new: (options?: any) => void;
15
- undo: (quantity?: number) => void;
16
- monkeyOpponents: (start?: boolean) => void;
17
- bot: (start?: boolean) => void;
18
- setPlayerName: (name: string, playerId?: PlayerId) => void;
19
- setAnimationsSpeed: (speed?: number) => void;
20
- tutorial: (options?: any) => void;
21
- changePlayer: (playerId?: PlayerId) => void;
22
- timer: (seconds: number, playerId?: PlayerId) => void;
23
- };
24
- export declare function consoleTools<Game, Move, PlayerId, View, MoveView>(gameServerProxy: GameLocalAPI<Game, Move, PlayerId, View, MoveView>, store: Store): ConsoleTools<Game, Move, PlayerId>;
25
- export {};
1
+ import { Action } from '@gamepark/rules-api';
2
+ import { Store } from 'redux';
3
+ import { GamePageState } from '../../Store';
4
+ import { GameLocalAPI } from './GameLocalAPI';
5
+ declare global {
6
+ interface Window {
7
+ game: ConsoleTools;
8
+ }
9
+ }
10
+ type ConsoleTools<Game = any, Move = any, PlayerId = any> = {
11
+ state: Game;
12
+ store: GamePageState<Game>;
13
+ moves: Action<Move, PlayerId>[];
14
+ new: (options?: any) => void;
15
+ undo: (quantity?: number) => void;
16
+ monkeyOpponents: (start?: boolean) => void;
17
+ bot: (start?: boolean) => void;
18
+ setPlayerName: (name: string, playerId?: PlayerId) => void;
19
+ setAnimationsSpeed: (speed?: number) => void;
20
+ tutorial: (options?: any) => void;
21
+ changePlayer: (playerId?: PlayerId) => void;
22
+ timer: (seconds: number, playerId?: PlayerId) => void;
23
+ };
24
+ export declare function consoleTools<Game, Move, PlayerId, View, MoveView>(gameServerProxy: GameLocalAPI<Game, Move, PlayerId, View, MoveView>, store: Store<GamePageState<Game, Move, PlayerId>>): ConsoleTools<Game, Move, PlayerId>;
25
+ export {};