forked from Minecraft/Stonks
1 line
16 KiB
Plaintext
1 line
16 KiB
Plaintext
{"version":3,"sources":["Search.js","Player.js","Statistic.js","App.js","index.js"],"names":["Search","statistics","players","useState","searchTerm","setSearchTerm","searchEngine","useMemo","fullList","map","s","type","value","name","concat","p","Fuse","minMatchCharLength","ignoreLocation","shouldSort","keys","searchResults","search","renderRow","index","style","isScrolling","isVisible","key","parent","x","to","item","id","size","leftIcon","as","FaUserCircle","FaArrowAltCircleRight","transform","variant","my","display","textAlign","width","height","onChildScroll","scrollTop","registerChild","placeholder","onChange","event","target","ref","disableHeight","autoHeight","onScroll","rowCount","length","rowHeight","rowRenderer","Player","playerId","playerStats","useQuery","a","axios","get","data","sort","b","rank","placeholderData","playerName","find","mt","fontWeight","mb","src","replaceAll","mr","isNumeric","i","Statistic","ranking","playerDict","Object","assign","App","path","render","routeProps","match","params","queryClient","QueryClient","theme","extendTheme","initialColorMode","useSystemColorMode","ReactDOM","StrictMode","config","QueryClientProvider","client","resetCSS","document","getElementById"],"mappings":"4WA6HeA,EArHA,SAAC,GAA6B,IAA3BC,EAA0B,EAA1BA,WAAYC,EAAc,EAAdA,QAC5B,EAAoCC,mBAAS,IAA7C,mBAAOC,EAAP,KAAmBC,EAAnB,KAEMC,EAAeC,mBAAQ,WAC3B,IAAMC,EAAWP,EACdQ,KAAI,SAACC,GACJ,MAAO,CACLC,KAAM,YACNC,MAAOF,EACPN,WAAW,GAAD,OAAKM,EAAEC,KAAP,YAAeD,EAAEG,UAG9BC,OACCZ,EAAQO,KAAI,SAACM,GACX,MAAO,CACLJ,KAAM,SACNC,MAAOG,EACPX,WAAYW,EAAEF,UAKtB,OAAO,IAAIG,IAAKR,EAAU,CACxBS,mBAAoB,EACpBC,gBAAgB,EAChBC,YAAY,EACZC,KAAM,CAAC,kBAER,CAACnB,EAAYC,IAEVmB,EAAgBd,mBAAQ,WAC5B,OAAOD,EAAagB,OAAb,aAAyBlB,EAAzB,UACN,CAACE,EAAcF,IAEZmB,EA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AC,IAAD,CAAgBW,UAAU,EAAMT,MAAOA,EAAvC,SACE,cAAC,EAAD,WAINU,SAASC,eAAe,W","file":"static/js/main.63dbb61b.chunk.js","sourcesContent":["import React, { useMemo, useState } from \"react\";\r\nimport Fuse from \"fuse.js\";\r\n\r\nimport { Button, Center, Heading, Icon, Input } from \"@chakra-ui/react\";\r\nimport { FaUserCircle, FaArrowAltCircleRight } from \"react-icons/fa\";\r\nimport { Link } from \"react-router-dom\";\r\nimport { AutoSizer, WindowScroller, List } from \"react-virtualized\";\r\n\r\nconst Search = ({ statistics, players }) => {\r\n const [searchTerm, setSearchTerm] = useState(\"\");\r\n\r\n const searchEngine = useMemo(() => {\r\n const fullList = statistics\r\n .map((s) => {\r\n return {\r\n type: \"statistic\",\r\n value: s,\r\n searchTerm: `${s.type} ${s.name}`,\r\n };\r\n })\r\n .concat(\r\n players.map((p) => {\r\n return {\r\n type: \"player\",\r\n value: p,\r\n searchTerm: p.name,\r\n };\r\n })\r\n );\r\n\r\n return new Fuse(fullList, {\r\n minMatchCharLength: 3,\r\n ignoreLocation: true,\r\n shouldSort: true,\r\n keys: [\"searchTerm\"],\r\n });\r\n }, [statistics, players]);\r\n\r\n const searchResults = useMemo(() => {\r\n return searchEngine.search(`'\"${searchTerm}\"'`);\r\n }, [searchEngine, searchTerm]);\r\n\r\n const renderRow = ({\r\n index, // Index of row\r\n isScrolling, // The List is currently being scrolled\r\n isVisible, // This row is visible within the List (eg it is not an overscanned row)\r\n key, // Unique key within array of rendered rows\r\n parent, // Reference to the parent List (instance)\r\n style, // Style object to be applied to row (to position it);\r\n // This must be passed through to the rendered row element.\r\n }) => {\r\n const x = searchResults[index];\r\n\r\n return (\r\n <Link\r\n key={\r\n x.item.type === \"player\"\r\n ? `/${x.item.type}/${x.item.value.id}`\r\n : `/${x.item.type}/${x.item.value.type}/${x.item.value.name}`\r\n }\r\n to={\r\n x.item.type === \"player\"\r\n ? `/${x.item.type}/${x.item.value.id}`\r\n : `/${x.item.type}/${x.item.value.type}/${x.item.value.name}`\r\n }\r\n style={style}\r\n >\r\n <Button\r\n size=\"sm\"\r\n leftIcon={\r\n x.item.type === \"player\" ? (\r\n <Icon as={FaUserCircle} />\r\n ) : (\r\n <Icon as={FaArrowAltCircleRight} transform=\"rotate(-45deg)\" />\r\n )\r\n }\r\n variant=\"ghost\"\r\n my=\"0.5\"\r\n display=\"block\"\r\n textAlign=\"left\"\r\n width=\"100%\"\r\n >\r\n {x.item.searchTerm}\r\n </Button>\r\n </Link>\r\n );\r\n };\r\n\r\n return (\r\n <WindowScroller>\r\n {({ height, isScrolling, onChildScroll, scrollTop, registerChild }) => (\r\n <>\r\n <Heading as=\"h1\" size=\"4xl\" my=\"8\">\r\n <Center>📈</Center>\r\n </Heading>\r\n <Input\r\n placeholder=\"Find statistics or players\"\r\n size=\"lg\"\r\n variant=\"filled\"\r\n value={searchTerm}\r\n onChange={(event) => setSearchTerm(event.target.value)}\r\n />\r\n <div ref={registerChild}>\r\n <AutoSizer disableHeight>\r\n {({ width }) => (\r\n <List\r\n autoHeight\r\n height={height}\r\n isScrolling={isScrolling}\r\n onScroll={onChildScroll}\r\n scrollTop={scrollTop}\r\n rowCount={searchResults.length}\r\n rowHeight={36}\r\n rowRenderer={renderRow}\r\n width={width}\r\n />\r\n )}\r\n </AutoSizer>\r\n </div>\r\n </>\r\n )}\r\n </WindowScroller>\r\n );\r\n};\r\n\r\nexport default Search;\r\n","import React from \"react\";\r\nimport { useQuery } from \"react-query\";\r\nimport axios from \"axios\";\r\nimport {\r\n Center,\r\n Heading,\r\n Image,\r\n Table,\r\n Thead,\r\n Tbody,\r\n Tr,\r\n Th,\r\n Td,\r\n} from \"@chakra-ui/react\";\r\nimport { Link } from \"react-router-dom\";\r\n\r\nconst Player = ({ playerId, players }) => {\r\n const playerStats = useQuery(\r\n `player ${playerId}`,\r\n async () => {\r\n const { data } = await axios.get(`/api/players/${playerId}`);\r\n data.sort((a, b) => a.rank - b.rank);\r\n return data;\r\n },\r\n {\r\n placeholderData: [],\r\n }\r\n );\r\n\r\n const playerName = players.data.find((x) => x.id === playerId).name;\r\n\r\n return (\r\n <>\r\n <Heading as=\"h2\" size=\"4xl\" my=\"8\">\r\n <Link to=\"/\">\r\n <Center>📈</Center>\r\n </Link>\r\n </Heading>\r\n <Heading as=\"h3\" size=\"sm\" mt=\"8\" fontWeight=\"normal\">\r\n Stonks for\r\n </Heading>\r\n <Heading as=\"h1\" size=\"xl\" mb=\"8\">\r\n <Image\r\n display=\"inline\"\r\n width=\"48px\"\r\n height=\"48px\"\r\n src={`https://minotar.net/avatar/${playerId.replaceAll(\"-\", \"\")}/48`}\r\n mr=\"4\"\r\n />\r\n {playerName}\r\n </Heading>\r\n <Table size=\"sm\" variant=\"striped\">\r\n <Thead>\r\n <Tr>\r\n <Th>Statistic</Th>\r\n <Th isNumeric>Rank</Th>\r\n <Th isNumeric>Value</Th>\r\n </Tr>\r\n </Thead>\r\n <Tbody>\r\n {playerStats.data.map((x, i) => {\r\n return (\r\n <Tr key={i}>\r\n <Td>\r\n <Link to={`/statistic/${x.type}/${x.name}`}>\r\n {x.type} {x.name}\r\n </Link>\r\n </Td>\r\n <Td isNumeric>{x.rank}</Td>\r\n <Td isNumeric>{x.value}</Td>\r\n </Tr>\r\n );\r\n })}\r\n </Tbody>\r\n </Table>\r\n </>\r\n );\r\n};\r\n\r\nexport default Player;\r\n","import React, { useMemo } from \"react\";\r\nimport { useQuery } from \"react-query\";\r\nimport axios from \"axios\";\r\nimport {\r\n Center,\r\n Heading,\r\n Table,\r\n Thead,\r\n Tbody,\r\n Tr,\r\n Th,\r\n Td,\r\n} from \"@chakra-ui/react\";\r\nimport { Link } from \"react-router-dom\";\r\n\r\nconst Statistic = ({ type, name, players }) => {\r\n const ranking = useQuery(\r\n `statistic ${type} ${name}`,\r\n async () => {\r\n const { data } = await axios.get(`/api/statistics/${type}/${name}`);\r\n return data;\r\n },\r\n {\r\n placeholderData: [],\r\n }\r\n );\r\n\r\n const playerDict = useMemo(() => {\r\n return Object.assign({}, ...players.data.map((x) => ({ [x.id]: x.name })));\r\n }, [players]);\r\n\r\n return (\r\n <>\r\n <Heading as=\"h1\" size=\"4xl\" my=\"8\">\r\n <Link to=\"/\">\r\n <Center>📈</Center>\r\n </Link>\r\n </Heading>\r\n <Heading as=\"h3\" size=\"sm\" mt=\"8\" fontWeight=\"normal\">\r\n Stonks for\r\n </Heading>\r\n <Heading as=\"h1\" size=\"xl\" mb=\"8\">\r\n {type} {name}\r\n </Heading>\r\n <Table size=\"sm\" variant=\"striped\">\r\n <Thead>\r\n <Tr>\r\n <Th>Player</Th>\r\n <Th isNumeric>Rank</Th>\r\n <Th isNumeric>Value</Th>\r\n </Tr>\r\n </Thead>\r\n <Tbody>\r\n {ranking.data.map((x, i) => {\r\n return (\r\n <Tr key={i}>\r\n <Td>\r\n <Link to={`/player/${x.playerId}`}>\r\n {playerDict[x.playerId]}\r\n </Link>\r\n </Td>\r\n <Td isNumeric>{x.rank}</Td>\r\n <Td isNumeric>{x.value}</Td>\r\n </Tr>\r\n );\r\n })}\r\n </Tbody>\r\n </Table>\r\n </>\r\n );\r\n};\r\n\r\nexport default Statistic;\r\n","import React from \"react\";\r\nimport { useQuery } from \"react-query\";\r\nimport axios from \"axios\";\r\nimport { BrowserRouter, Switch, Route } from \"react-router-dom\";\r\nimport { Container } from \"@chakra-ui/react\";\r\n\r\nimport Search from \"./Search\";\r\nimport Player from \"./Player\";\r\nimport Statistic from \"./Statistic\";\r\n\r\nconst App = () => {\r\n const statistics = useQuery(\r\n \"statistics\",\r\n async () => {\r\n const { data } = await axios.get(\"/api/statistics\");\r\n return data;\r\n },\r\n {\r\n placeholderData: [],\r\n }\r\n );\r\n\r\n const players = useQuery(\r\n \"players\",\r\n async () => {\r\n const { data } = await axios.get(\"/api/players\");\r\n return data;\r\n },\r\n {\r\n placeholderData: [],\r\n }\r\n );\r\n\r\n return (\r\n <Container>\r\n <BrowserRouter>\r\n <Switch>\r\n <Route\r\n path=\"/statistic/:type/:name\"\r\n render={(routeProps) => (\r\n <Statistic\r\n type={routeProps.match.params.type}\r\n name={routeProps.match.params.name}\r\n players={players}\r\n />\r\n )}\r\n />\r\n <Route\r\n path=\"/player/:id\"\r\n render={(routeProps) => (\r\n <Player playerId={routeProps.match.params.id} players={players} />\r\n )}\r\n />\r\n <Route>\r\n <Search statistics={statistics.data} players={players.data} />\r\n </Route>\r\n </Switch>\r\n </BrowserRouter>\r\n </Container>\r\n );\r\n};\r\n\r\nexport default App;\r\n","import { ChakraProvider, ColorModeScript, extendTheme } from \"@chakra-ui/react\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { QueryClient, QueryClientProvider } from \"react-query\";\n\nimport App from \"./App.js\";\n\nimport \"./index.css\";\nimport \"react-virtualized/styles.css\";\n\nconst queryClient = new QueryClient();\n\nconst config = {\n initialColorMode: \"light\",\n useSystemColorMode: false,\n};\nconst theme = extendTheme(config);\n\nReactDOM.render(\n <React.StrictMode>\n <ColorModeScript initialColorMode={theme.config.initialColorMode} />\n <QueryClientProvider client={queryClient}>\n <ChakraProvider resetCSS={true} theme={theme}>\n <App />\n </ChakraProvider>\n </QueryClientProvider>\n </React.StrictMode>,\n document.getElementById(\"root\")\n);\n"],"sourceRoot":""} |