\n default:\n return <>>\n }\n }\n\n return (\n \n );\n}\n\nexport default Sidebar;","import React from 'react';\nimport './Account.scss';\n\nconst Account = () => {\n return ( \n \n );\n}\n\nexport default Account;","import config from '../../config';\n\nconst apiAddress = config.apiAddress;\nconst gamesAddress = `${apiAddress}/games`\n\nvar headers = new Headers();\nheaders.append('Content-Type', 'application/json');\nheaders.append('Accept', 'application/json');\nheaders.append('Sec-Fetch-Site', 'cross-site')\n\nconst getGameService = async (gameIndex) => {\n const response = await fetch(`${gamesAddress}/${gameIndex}`, \n {method: 'GET', credentials: 'include', headers: headers}\n )\n .then(res => res.text())\n .then(text => JSON.parse(text))\n .then(obj => {\n // Reformat from SQL coluumn name convention to JS\n delete Object.assign(obj.game, {applicationVersion: obj.game.application_version }).application_version;\n delete Object.assign(obj.game, {boardSize: obj.game.board_size }).board_size;\n delete Object.assign(obj.game, {playerBlack: obj.game.player_black }).player_black;\n delete Object.assign(obj.game, {playerBlackRank: obj.game.player_black_rank }).player_black_rank;\n delete Object.assign(obj.game, {playerWhite: obj.game.player_white }).player_white;\n delete Object.assign(obj.game, {playerWhiteRank: obj.game.player_white_rank }).player_white_rank;\n delete Object.assign(obj.game, {capturesWhite: obj.game.captures_white }).captures_white;\n delete Object.assign(obj.game, {capturesBlack: obj.game.captures_black }).captures_black;\n delete Object.assign(obj.game, {mainTime: obj.game.main_time }).main_time;\n delete Object.assign(obj.game, {timePeriod: obj.game.time_period }).time_period;\n delete Object.assign(obj.game, {periodLength: obj.game.period_length }).period_length;\n delete Object.assign(obj.game, {overtimePeriod: obj.game.overtime_period }).overtime_period;\n delete Object.assign(obj.game, {overtimeLength: obj.game.overtime_length }).overtime_length;\n delete Object.assign(obj.game, {winType: obj.game.win_type }).win_type;\n\n return obj;\n })\n .catch(err => err);\n\n return response;\n}\n \nexport default {\n getGameService\n}","import React from 'react';\nimport './Point.scss';\n\nconst Point = (props) => {\n const { posX, posY, user, game, dispatch, pointData } = props;\n const turn = game.turn > 0 ? 'black' : 'white';\n \n const stone = () => {\n if (pointData === 1) return 'black'\n if (pointData === -1) return 'white'\n return 'none'\n }\n\n const dot = () => {\n if (pointData === 'l') return game.turn;\n }\n\n const xFlag = () => {\n if ( posX === 1 ) return `board__point--top`\n if ( posX === game.boardSize ) return `board__point--bottom`\n return '';\n }\n const yFlag = () => {\n if ( posY === 1 ) return `board__point--left`\n if ( posY === game.boardSize ) return `board__point--right`\n return '';\n }\n const clickHandle = (e) => {\n const action = {\n type: 'SOCKET',\n message: 'MAKE_MOVE',\n body: {\n user,\n game,\n room: game.room,\n board: {},\n move: { player: turn, pos: { x: posX, y: posY } }\n }\n }\n dispatch(action);\n }\n\n return (\n clickHandle(e)}\n >\n
\n\n
\n );\n}\n\nexport default Point;","import React from 'react';\nimport './Board.scss';\nimport Point from '../Point/Point';\n\nconst Board = (props) => {\n const { game, user, dispatch, board } = props;\n const sizeFlag = `Game__board--size-${ game.boardSize }`\n\n const renderPoints = boardSize => {\n let i = 0, boardPoints = [];\n while (i < boardSize * boardSize) {\n const posX = Math.floor(i/boardSize) + 1;\n const posY = i % boardSize + 1;\n console.log(board[`${posX}-${posY}`])\n boardPoints.push(\n \n ); i++;\n }\n return boardPoints;\n }\n\n return ( \n \n { game.id ? renderPoints(game.boardSize) : <>> }\n
\n );\n}\n\nexport default Board;","import React from 'react';\nimport './PlayerArea.scss';\n\nconst PlayerArea = (props) => {\n // const { user } = props\n const user = {\n stones: 'black',\n username: 'Name',\n captures: 0\n }\n\n return (\n \n
\n
\n
{user ? user.username : 'Waiting for player' }
\n\n
\n
Resign?
\n\n
{user ? user.captures : 'Captures go here'}
\n\n
\n\n
\n\n
\n );\n}\n\nexport default PlayerArea;","import React, { useEffect } from 'react';\nimport { useParams } from 'react-router-dom';\nimport gamesServices from '../../services/api/gamesServices';\nimport './Game.scss';\nimport Logo from '../../components/Display/Logo/Logo';\nimport Board from '../../components/GameUI/Board/Board';\nimport PlayerArea from '../../components/GameUI/PlayerArea/PlayerArea';\n\nconst Game = (props) => {\n const { state, dispatch } = props;\n const gameId = parseInt(useParams().id) || 0;\n\n \n useEffect(() => {\n const fetchGameAPI = async () => {\n const response = await gamesServices.getGameService(gameId);\n if (response) {\n const action = {\n type: 'GAMES',\n message: 'SET_ACTIVE',\n body: response\n }\n return dispatch(action);\n }\n }\n fetchGameAPI();\n }, [ gameId, dispatch ])\n\n \n useEffect(() => {\n const roomSocketConnect = () => {\n const game = state.active.game;\n const user = state.user;\n const action = {\n type: 'SOCKET',\n message: 'CONNECT_GAME',\n body: { game, user, dispatch }\n }\n return dispatch(action);\n }\n roomSocketConnect();\n }, [ state.active , dispatch, state.user ] )\n\n return ( \n \n
\n
{state.socket ? '✓' : ' ⃠'}\n
\n
Timer
\n
? Game Tree
\n
\n\n
\n\n
\n
Messages
\n
Message Form
\n
\n
\n );\n}\n\nexport default Game;","import config from '../../config';\n\nconst apiAddress = config.apiAddress;\nconst roomsAddress = `${apiAddress}/rooms`\n\nvar headers = new Headers();\nheaders.append('Content-Type', 'application/json');\nheaders.append('Accept', 'application/json');\nheaders.append('Sec-Fetch-Site', 'cross-site')\n\nconst indexService = async () => {\n const response = await fetch(roomsAddress, \n {method: 'GET', credentials: 'include', headers: headers}\n )\n .then(res => res.text())\n .then(text => JSON.parse(text))\n .catch(err => err);\n \n return response;\n}\n\nconst getRoomService = async (roomIndex) => {\n const response = await fetch(`${roomsAddress}/${roomIndex}`, \n {method: 'GET', credentials: 'include', headers: headers}\n )\n .then(res => res.text())\n .then(text => JSON.parse(text))\n \n .then(obj => {\n obj.games = obj.roomGames.map(game => {\n delete Object.assign(game, {boardSize: game.board_size }).board_size;\n delete Object.assign(game, {playerBlack: game.player_black }).player_black;\n delete Object.assign(game, {playerBlackRank: game.player_black_rank }).player_black_rank;\n delete Object.assign(game, {playerWhite: game.player_white }).player_white;\n delete Object.assign(game, {playerWhiteRank: game.player_white_rank }).player_white_rank;\n delete Object.assign(game, {winType: game.win_type }).win_type;\n\n return game;\n })\n return obj;\n })\n .catch(err => err);\n\n return response;\n}\n \nexport default {\n indexService,\n getRoomService\n}","import React from 'react';\nimport { Link } from 'react-router-dom';\nimport './Room.scss';\n\nconst RoomButton = (props) => {\n const roomData = props.room;\n return (\n \n
{roomData.name}
\n Join Room\n \n );\n}\n\nexport default RoomButton;","import React from 'react';\nimport './Loading.scss';\n\nconst Loading = () => {\n return ( \n \n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n );\n}\n\nexport default Loading;","import React, { useEffect } from 'react';\nimport './Home.scss';\nimport roomsServices from '../../services/api/roomsServices';\nimport RoomButton from '../../components/Button/Room/Room';\n\nimport Loading from '../../components/Display/Loading/Loading';\n\nconst Home = props => {\n const state = props.state || {};\n const dispatch = props.dispatch;\n \n const renderRooms = () => {\n const rooms = state.rooms || [];\n if (rooms.length) {\n return rooms.map(roomData => (\n \n ))\n }\n // TODO stub loader\n return \n }\n\n \n useEffect(() => {\n const fetchRoomsAPI = async () => {\n const response = await roomsServices.indexService();\n if (response) {\n const action = {\n type: 'ROOMS',\n message: 'SET_ROOMS',\n body: response.rooms\n }\n return dispatch(action)\n }\n }\n fetchRoomsAPI();\n }, [ dispatch ])\n\n return ( \n \n {renderRooms()}\n
\n );\n}\n\nexport default Home;","import React from 'react';\nimport './News.scss';\n\nconst News = () => {\n return ( \n \n );\n}\n\nexport default News;","import React from 'react';\nimport { Link } from 'react-router-dom';\nimport './Game.scss';\n\nconst GameButton = (props) => {\n const { game, dispatch, user } = props;\n\n const requestJoinGame = () => {\n console.log(`request to Join Game ${game.id}!`)\n const requestAction = {\n type: 'GAMES',\n message: 'JOIN_REQUEST',\n body: {id: game.id}\n }\n dispatch(requestAction);\n }\n\n const renderOpenGame = () => {\n return (\n <>\n requestJoinGame()} >Request to Join Game
\n\n \n {game.playerBlack}\n {game.playerBlackRank}\n
\n >\n )\n }\n\n const renderInProgressGame = () => {\n const gameLinkText = game.winType ? 'Study Game' \n : user ? 'Rejoin Game' : 'Watch Game' \n return (\n <>\n \n\n
\n \n \n
\n
\n {game.playerBlack}\n {game.playerBlackRank}\n
\n \n
{gameLinkText}\n\n
\n {game.playerWhite}\n {game.playerWhiteRank}\n
\n
\n\n
\n
\n\n \n\n
\n\n >\n )\n }\n\n return (\n \n {game.open ? renderOpenGame() : renderInProgressGame()}\n
\n );\n}\n\nexport default GameButton;","import React from 'react';\nimport './Message.scss';\n\nconst Message = (props) => {\n const messageData = props.message;\n return (\n \n
{messageData.content}
\n
{messageData.username}
\n
{messageData.admin ? 'admin' : <>>}
\n
\n );\n}\n\nexport default Message;","import React from 'react';\nimport './ActionError.scss';\n\nconst ActionError = (props) => {\n const errorMessage = props.error;\n return (\n \n {errorMessage}\n \n );\n}\n\nexport default ActionError;","import React from 'react';\n\nconst Development = () => {\n return (<>\n This Feature is in Development :)
\n >);\n}\n\nexport default Development;","import React, { useEffect } from 'react';\nimport { useParams } from 'react-router-dom';\nimport './Room.scss';\nimport roomsServices from '../../services/api/roomsServices';\nimport GameButton from '../../components/Button/Game/Game';\nimport Message from '../../components/Display/Message/Message';\nimport ActionError from '../../components/Error/ActionError/ActionError';\n\nimport Development from '../../components/Display/Development/Development';\nimport Loading from '../../components/Display/Loading/Loading';\n\nconst Room = (props) => {\n const { state, dispatch } = props;\n const roomId = parseInt(useParams().id) || 0;\n\n \n useEffect(() => {\n const fetchRoomAPI = async () => {\n const response = await roomsServices.getRoomService(roomId);\n if (response) {\n const action = {\n type: 'ROOMS',\n message: 'JOIN_ROOM',\n body: response\n }\n return dispatch(action);\n }\n }\n fetchRoomAPI();\n }, [ roomId, dispatch ])\n\n useEffect(() => {\n const roomSocketConnect = () => {\n const action = {\n type: 'SOCKET',\n message: 'CONNECT_ROOM',\n body: {user: state.user, room: roomId, dispatch}\n }\n dispatch(action)\n }\n roomSocketConnect();\n }, [ roomId, state.user, dispatch ])\n\n const renderGames = () => {\n const games = state.games || [];\n if (games.length) {\n return games.map(gameData => (\n \n ))\n }\n return \n }\n\n const renderMessages = () => {\n const messages = state.messages || [];\n if (messages.length) {\n return messages.map((messageData, idx) => (\n \n ))\n }\n return \n }\n\n\n return ( \n \n \n
\n {state.errors.joinGame ?
: <>>}\n \n\n
\n {renderGames()}\n
\n\n
\n {renderMessages()}\n \n
\n\n
\n );\n}\n\nexport default Room;","import React from 'react';\nimport './MainWrapper.scss';\n\nimport NavBar from '../NavBar/NavBar';\nimport Sidebar from '../Sidebar/Sidebar';\nimport Account from '../../Account/Account';\nimport Game from '../../Game/Game';\nimport Home from '../../Home/Home';\nimport News from '../../News/News';\nimport Room from '../../Room/Room';\n\nconst MainWrapper = (props) => {\n const { state, page, dispatch } = props;\n\n const setWrapperWithSidebarAndPage = () => {\n if (page === 'game') return selectPage()\n return (\n \n
\n \n \n \n {selectPage()}\n \n
\n \n )\n }\n\n const selectPage = () =>{\n switch (page) {\n case 'account':\n return \n case 'game':\n return \n case 'home':\n return \n case 'news':\n return \n case 'room':\n return \n default:\n return <>>\n }\n }\n\n return (\n <>\n { setWrapperWithSidebarAndPage() }\n >\n );\n}\n\nexport default MainWrapper;","export const initState = () => {\n return {\n active: {\n game: {\n id: 0, room: 0, \n mainTime: '', timePeriod: 0, periodLength: 0, overtime: '', overtimePeriod: 0, overtimeLength: 0,\n application: '', applicationVersion: '', open: false, description: null,\n event: null, round: null, name: null, \n winType: null, capturesBlack: null, capturesWhite: null, score: null,\n boardSize: 0, komi: 0.0, handicap: 0,\n playerBlack: '', playerBlackRank: '', playerWhite: '', playerWhiteRank: '',\n },\n record: []\n },\n\n board: {},\n \n connect: { location: '', type: '' },\n \n currentRoom: { \n description: '', id: 0, language: '', name: '' \n },\n \n errors: {},\n \n games: [ { \n boardSize: 0, handicap: 0, id: 0, komi: 0.0, open: false, \n playerBlack: '', playerBlackRank: '', playerWhite: '',\n playerWhiteRank: '', winType: null\n } ],\n \n joinGame: {},\n \n messages: [ { \n admin: false, content: '', username: ''\n } ],\n \n socket: {\n connected: false,\n nsp: ''\n },\n \n user: { username: '', email: '', id: 0 }\n };\n}","export const authReducer = (state, action) => {\n switch (action.message) {\n case 'LOGIN':\n return loginReducer(state, action);\n \n case 'SIGNUP':\n return loginReducer(state, action);\n\n case 'LOGOUT':\n return state;\n\n default:\n return state;\n } \n}\n\nfunction loginReducer(state, action) {\n const newUser = action.body;\n return {...state, user: newUser }; \n}","export const errorReducer = (state, action) => {\n switch (action.message) {\n case 'AUTH_ERROR':\n return authErrorReducer(state, action);\n\n case 'JOIN_ROOM_ERROR':\n return joinRoomErrorReducer(state, action);\n \n case 'JOIN_GAME_ERROR':\n return joinGameErrorReducer(state, action);\n\n default:\n return state;\n } \n}\n\nfunction authErrorReducer(state, action) {\n const auth = action.body.authError;\n return {...state, errors: {auth} };\n}\n\nfunction joinRoomErrorReducer(state, action) {\n const joinRoom = action.body.joinRoomError;\n return { ...state, errors: {joinRoom} }\n}\n\nfunction joinGameErrorReducer(state, action) {\n const joinGame = action.body.joinGameError;\n return { ...state, errors: {joinGame} }\n}","export const indexReducer = (state, action) => {\n switch(action.message) {\n\n case 'SET_USER':\n const user = action.body;\n return {...state, user};\n \n default: \n return state;\n }\n}","import { stateReducer } from '../reducer';\n\nexport const roomsReducer = (state, action) => {\n switch(action.message) {\n\n case 'SET_ROOMS':\n const rooms = action.body;\n return {...state, rooms};\n\n case 'SET_CURRENT':\n const currentRoom = action.body;\n return {...state, currentRoom};\n\n case 'JOIN_ROOM': {\n const stateWithRoom = setCurrentRoom(state, action);\n const stateWithMessages = setMessages(stateWithRoom, action);\n if (!action.body.roomGames) {\n return setJoinRoomError(state);\n }\n const stateWithGames = setGames(stateWithMessages, action);\n\n return stateWithGames;\n }\n\n case 'NEW_USER': {\n if (!action.data) {\n return state;\n }\n return state;\n }\n \n default:\n return state;\n }\n}\n\nfunction setMessages(state, action) {\n if(action.body.messages.length) {\n const messages = action.body.messages;\n const messageAction = {\n type: 'MESSAGES',\n message: 'SET_MESSAGES',\n body: messages\n }\n return stateReducer(state, messageAction);\n }\n return state;\n}\n\nfunction setJoinRoomError(state, body) {\n const errorAction = {\n type: 'ERR',\n message: 'JOIN_ROOM_ERROR',\n body: { joinRoomError: 'Game room has no games' }\n }\n return stateReducer(state, errorAction);\n}\n\nfunction setCurrentRoom(state, action) {\n const currentRoom = action.body.currentRoom;\n const roomAction = {\n type: 'ROOMS',\n message: 'SET_CURRENT',\n body: currentRoom\n }\n return stateReducer(state, roomAction);\n}\n\nfunction setGames(state, action) {\n if (action.body.roomGames.length) {\n const games = action.body.roomGames;\n const gamesAction = {\n type: 'GAMES',\n message: 'SET_GAMES',\n body: games\n }\n return stateReducer(state, gamesAction);\n }\n return state;\n}","import { stateReducer } from '../reducer';\n\nexport const messagesReducer = (state, action) => {\n switch(action.message) {\n\n case 'SET_MESSAGES':\n const messages = action.body;\n return {...state, messages};\n\n \n default:\n return state;\n }\n}","import { stateReducer } from '../reducer';\n\nexport const gamesReducer = (state, action) => {\n switch(action.message) {\n\n case 'SET_GAMES':\n const games = formatGames(action);;\n return {...state, games};\n \n case 'JOIN_REQUEST':\n if (!Object.entries(state.user).length) {\n const errAction = {\n type: 'ERR',\n message: 'JOIN_GAME_ERROR',\n body: {joinGameError: 'user not logged in'}\n }\n return stateReducer(state, errAction)\n }\n const id = action.body;\n return {...state, joinGame: id};\n\n case 'UPDATE_BOARD':\n console.log(action.body)\n return {...state, board: action.body};\n\n case 'SET_ACTIVE':\n return {...state, active: action.body};\n \n default:\n return state;\n }\n}\n\nfunction parseRank(rank) {\n switch(rank[0]) {\n case 'D':\n return `${rank.slice(1)}${rank[0].toLowerCase()}`\n case 'K':\n return `${rank.slice(1)}${rank[0].toLowerCase()}`\n case 'U':\n return '?'\n }\n}\n\nfunction formatGames(action) {\n const games = [...action.body].map(game => {\n\n if (game.playerBlackRank) {\n game.playerBlackRank = parseRank(game.playerBlackRank)\n }\n\n if (game.playerWhiteRank) {\n game.playerWhiteRank = parseRank(game.playerWhiteRank)\n }\n\n return game;\n })\n\n return games;\n}","import { stateReducer } from '../reducer';\nconst io = require('../../io');\n\nexport const socketReducer = (state, action) => {\n switch(action.message) {\n\n case 'CONNECTED':\n console.log(action.body.nsp)\n return {...state, connect: { type: 'home', location: action.body.nsp } }\n\n case 'LAUNCH': {\n const {nsp, dispatch} = action.body;\n const launchedSocket = io.launch(nsp, dispatch);\n return {...state, socket: launchedSocket};\n }\n\n case 'CONNECT_ROOM': {\n const {user, room, dispatch} = action.body;\n let priorSocket = state.socket;\n if (!priorSocket.nsp) {\n priorSocket = io.launch('', dispatch)\n }\n if (priorSocket.nsp !== `/${room}`) {\n priorSocket.emit('connect_room', {user, room});\n priorSocket.close();\n }\n const socket = io.launch(room, dispatch);\n return {...state, socket}\n }\n\n case 'CONNECT_GAME': {\n return connectGame(state, action);\n }\n\n case 'MAKE_MOVE': {\n return makeMove(state, action);\n }\n\n default:\n return state;\n }\n}\n\nfunction connectGame (state, action) {\n const { user, game, dispatch } = action.body;\n const priorSocket = state.socket;\n let updatedState;\n if ( !priorSocket.nsp || priorSocket.nsp !== `/${game.room}` ) {\n const connectRoomAction = {\n type: 'SOCKET',\n message: 'CONNECT_ROOM',\n body: { user, room: game.room, dispatch}\n }\n updatedState = stateReducer(state, connectRoomAction);\n \n }\n if (!updatedState) updatedState = {...state};\n const socket = updatedState.socket;\n socket.emit('connect_game', {user, game});\n return {...updatedState};\n}\n\nfunction makeMove (state, action) {\n const { user, game, room, board, move } = action.body;\n const socket = state.socket;\n console.log(action)\n socket.emit('make_move', {...action.body});\n return state;\n}","import { initState } from './init/reducer.init';\nimport { authReducer } from './auth/reducer.auth';\nimport { errorReducer } from './err/reducer.err';\nimport { indexReducer } from './index/reducer.index';\nimport { roomsReducer } from './rooms/reducer.rooms';\nimport { messagesReducer } from './messages/reducer.messages';\nimport { gamesReducer } from './games/reducer.games';\nimport { socketReducer } from './socket/reducer.socket';\n\n\nexport const stateReducer = (state, action) => {\n const errorStrippedState = stripErrors({...state});\n \n switch (action.type) {\n case 'INIT': return initState();\n \n case 'AUTH':\n return authReducer(errorStrippedState, action);\n\n case 'GAMES':\n return gamesReducer(errorStrippedState, action);\n\n case 'INDEX':\n return indexReducer(errorStrippedState, action);\n\n case 'MESSAGES':\n return messagesReducer(errorStrippedState, action);\n\n case 'ROOMS':\n return roomsReducer(errorStrippedState, action);\n\n case 'SOCKET':\n return socketReducer(errorStrippedState, action);\n\n case 'ERR':\n return errorReducer(errorStrippedState, action);\n\n default: return state;\n }\n}\n\nfunction stripErrors(state) {\n return {...state, errors: {}}\n}","import config from '../../config';\n\nconst apiAddress = config.apiAddress;\n\nvar headers = new Headers();\nheaders.append('Content-Type', 'application/json');\nheaders.append('Accept', 'application/json');\nheaders.append('Sec-Fetch-Site', 'cross-site')\n\nconst indexService = async () => {\n const response = await fetch(apiAddress, \n {method: 'GET', credentials: 'include', headers: headers}\n )\n .then(res => res.text())\n .then(text => JSON.parse(text))\n .catch(err => {\n return err;\n });\n return response;\n}\n\nexport default {\n indexService\n}","import React, { useEffect, useReducer } from 'react';\nimport { Switch, Route, BrowserRouter as Router } from 'react-router-dom';\nimport MainWrapper from './pages/Layout/MainWrapper/MainWrapper';\nimport { stateReducer } from './reducers/reducer';\nimport { initState } from './reducers/init/reducer.init';\nimport indexServices from './services/api/indexServices';\nimport './App.scss';\n\n\nfunction App() {\n const [ state, dispatch ] = useReducer(\n stateReducer,\n {},\n initState\n );\n \n useEffect(() => {\n const fetchIndexAPI = async () => {\n const response = await indexServices.indexService();\n if (response) {\n const action = {\n type: 'INDEX',\n message: 'SET_USER',\n body: response\n }\n dispatch(action)\n }\n }\n fetchIndexAPI();\n }, [ ])\n\n \n useEffect(() => {\n const socketConnect = () => {\n if (state.connect.type) return;\n dispatch({type:'SOCKET', message: 'LAUNCH', body:{nsp:'', dispatch}});\n }\n socketConnect();\n }, [ state.connect ])\n\n return (\n \n \n \n
\n\n \n \n \n\n \n \n \n\n \n \n \n \n \n \n \n\n \n \n \n \n \n {state.user.username \n ? \n : }\n \n\n \n
{state.connect.type ? '✓' : ' ⃠'}
\n
\n \n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' }\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.scss';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(\n \n , document.getElementById('root')\n);\n\nserviceWorker.unregister();\n"],"sourceRoot":""}
\ No newline at end of file
diff --git a/packages/play-node-go/build/static/js/runtime-main.7289240f.js b/packages/play-node-go/build/static/js/runtime-main.7289240f.js
new file mode 100644
index 0000000..f000760
--- /dev/null
+++ b/packages/play-node-go/build/static/js/runtime-main.7289240f.js
@@ -0,0 +1,2 @@
+!function(e){function r(r){for(var n,l,a=r[0],i=r[1],p=r[2],c=0,s=[];c {
+export const authReducer = (state, action) => {
switch (action.message) {
case 'LOGIN':
return loginReducer(state, action);
@@ -17,7 +14,7 @@ export const authReducer = (state: state, action: action):state => {
}
}
-function loginReducer(state: state, action: action): state {
+function loginReducer(state, action) {
const newUser = action.body;
return {...state, user: newUser };
}
\ No newline at end of file
diff --git a/packages/play-node-go/src/reducers/err/reducer.err.js b/packages/play-node-go/src/reducers/err/reducer.err.js
index ead71e1..02681e5 100644
--- a/packages/play-node-go/src/reducers/err/reducer.err.js
+++ b/packages/play-node-go/src/reducers/err/reducer.err.js
@@ -1,7 +1,4 @@
-// @flow
-import type { state, action } from '../reducer';
-
-export const errorReducer = (state: state, action: action):state => {
+export const errorReducer = (state, action) => {
switch (action.message) {
case 'AUTH_ERROR':
return authErrorReducer(state, action);
@@ -17,17 +14,17 @@ export const errorReducer = (state: state, action: action):state => {
}
}
-function authErrorReducer(state: state, action: action): state {
+function authErrorReducer(state, action) {
const auth = action.body.authError;
return {...state, errors: {auth} };
}
-function joinRoomErrorReducer(state: state, action: action): state {
+function joinRoomErrorReducer(state, action) {
const joinRoom = action.body.joinRoomError;
return { ...state, errors: {joinRoom} }
}
-function joinGameErrorReducer(state: state, action: action): state {
+function joinGameErrorReducer(state, action) {
const joinGame = action.body.joinGameError;
return { ...state, errors: {joinGame} }
}
\ No newline at end of file
diff --git a/packages/play-node-go/src/reducers/games/reducer.games.js b/packages/play-node-go/src/reducers/games/reducer.games.js
index 41cea6b..77600dc 100644
--- a/packages/play-node-go/src/reducers/games/reducer.games.js
+++ b/packages/play-node-go/src/reducers/games/reducer.games.js
@@ -1,8 +1,6 @@
-// @flow
-import type { state, action } from '../reducer';
import { stateReducer } from '../reducer';
-export const gamesReducer = (state: state, action: action):state => {
+export const gamesReducer = (state, action) => {
switch(action.message) {
case 'SET_GAMES':
@@ -33,7 +31,7 @@ export const gamesReducer = (state: state, action: action):state => {
}
}
-function parseRank(rank: string): string {
+function parseRank(rank) {
switch(rank[0]) {
case 'D':
return `${rank.slice(1)}${rank[0].toLowerCase()}`
@@ -44,7 +42,7 @@ function parseRank(rank: string): string {
}
}
-function formatGames(action: action): Array<{}> {
+function formatGames(action) {
const games = [...action.body].map(game => {
if (game.playerBlackRank) {
diff --git a/packages/play-node-go/src/reducers/index/reducer.index.js b/packages/play-node-go/src/reducers/index/reducer.index.js
index 2bd32b7..e01c48b 100644
--- a/packages/play-node-go/src/reducers/index/reducer.index.js
+++ b/packages/play-node-go/src/reducers/index/reducer.index.js
@@ -1,7 +1,4 @@
-// @flow
-import type { state, action } from '../reducer';
-
-export const indexReducer = (state: state, action: action):state => {
+export const indexReducer = (state, action) => {
switch(action.message) {
case 'SET_USER':
diff --git a/packages/play-node-go/src/reducers/init/reducer.init.js b/packages/play-node-go/src/reducers/init/reducer.init.js
index 03dcb45..2d00e71 100644
--- a/packages/play-node-go/src/reducers/init/reducer.init.js
+++ b/packages/play-node-go/src/reducers/init/reducer.init.js
@@ -1,8 +1,4 @@
-//@ flow
-
-import type { state } from '../reducer';
-
-export const initState = (): state => {
+export const initState = () => {
return {
active: {
game: {
diff --git a/packages/play-node-go/src/reducers/messages/reducer.messages.js b/packages/play-node-go/src/reducers/messages/reducer.messages.js
index 82552a6..0ca92cd 100644
--- a/packages/play-node-go/src/reducers/messages/reducer.messages.js
+++ b/packages/play-node-go/src/reducers/messages/reducer.messages.js
@@ -1,8 +1,6 @@
-// @flow
-import type { state, action } from '../reducer';
import { stateReducer } from '../reducer';
-export const messagesReducer = (state: state, action: action):state => {
+export const messagesReducer = (state, action) => {
switch(action.message) {
case 'SET_MESSAGES':
diff --git a/packages/play-node-go/src/reducers/reducer.js b/packages/play-node-go/src/reducers/reducer.js
index e0d967b..8a6e4b0 100644
--- a/packages/play-node-go/src/reducers/reducer.js
+++ b/packages/play-node-go/src/reducers/reducer.js
@@ -1,4 +1,3 @@
-// @flow
import { initState } from './init/reducer.init';
import { authReducer } from './auth/reducer.auth';
import { errorReducer } from './err/reducer.err';
@@ -8,20 +7,8 @@ import { messagesReducer } from './messages/reducer.messages';
import { gamesReducer } from './games/reducer.games';
import { socketReducer } from './socket/reducer.socket';
-export type state = {
- user: {},
- errors: {},
- messages: [],
- state: {}
-}
-export type action = {
- type: string,
- message: ?string,
- body: {} | Array<{}>,
-}
-
-export const stateReducer = (state: state, action: action): state => {
+export const stateReducer = (state, action) => {
const errorStrippedState = stripErrors({...state});
switch (action.type) {
@@ -52,6 +39,6 @@ export const stateReducer = (state: state, action: action): state => {
}
}
-function stripErrors(state: state): state {
+function stripErrors(state) {
return {...state, errors: {}}
}
\ No newline at end of file
diff --git a/packages/play-node-go/src/reducers/reducer.test.js b/packages/play-node-go/src/reducers/reducer.test.js
index f8ae574..01bd154 100644
--- a/packages/play-node-go/src/reducers/reducer.test.js
+++ b/packages/play-node-go/src/reducers/reducer.test.js
@@ -1,4 +1,4 @@
-import {stateReducer} from './reducer';
+import { stateReducer } from './reducer';
it('default returns state unaltered', () => {
const state = {data: 'example'};
diff --git a/packages/play-node-go/src/reducers/rooms/reducer.rooms.js b/packages/play-node-go/src/reducers/rooms/reducer.rooms.js
index ebd1cd1..e502b21 100644
--- a/packages/play-node-go/src/reducers/rooms/reducer.rooms.js
+++ b/packages/play-node-go/src/reducers/rooms/reducer.rooms.js
@@ -1,8 +1,6 @@
-// @flow
-import type { state, action } from '../reducer';
import { stateReducer } from '../reducer';
-export const roomsReducer = (state: state, action: action):state => {
+export const roomsReducer = (state, action) => {
switch(action.message) {
case 'SET_ROOMS':
diff --git a/packages/play-node-go/src/reducers/socket/reducer.socket.js b/packages/play-node-go/src/reducers/socket/reducer.socket.js
index e7625e8..329a4e9 100644
--- a/packages/play-node-go/src/reducers/socket/reducer.socket.js
+++ b/packages/play-node-go/src/reducers/socket/reducer.socket.js
@@ -1,9 +1,7 @@
-// @flow
-import type { state, action } from '../reducer';
import { stateReducer } from '../reducer';
const io = require('../../io');
-export const socketReducer = (state: state, action: action):state => {
+export const socketReducer = (state, action) => {
switch(action.message) {
case 'CONNECTED':