playball 3.1.0 → 3.1.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 (57) hide show
  1. package/dist/cli.js +31 -0
  2. package/{src/components/AllPlays.jsx → dist/components/AllPlays.js} +22 -37
  3. package/dist/components/App.js +42 -0
  4. package/dist/components/AtBat.js +42 -0
  5. package/dist/components/Bases.js +23 -0
  6. package/dist/components/Count.js +21 -0
  7. package/dist/components/FinishedGame.js +90 -0
  8. package/dist/components/Game.js +50 -0
  9. package/dist/components/GameList.js +171 -0
  10. package/{src/components/Grid.jsx → dist/components/Grid.js} +30 -33
  11. package/dist/components/HelpBar.js +16 -0
  12. package/dist/components/InningDisplay.js +12 -0
  13. package/dist/components/LineScore.js +39 -0
  14. package/dist/components/LiveGame.js +51 -0
  15. package/{src/components/LoadingSpinner.jsx → dist/components/LoadingSpinner.js} +8 -24
  16. package/dist/components/Matchup.js +40 -0
  17. package/dist/components/PreviewGame.js +54 -0
  18. package/dist/components/Standings.js +70 -0
  19. package/{src → dist}/config.js +21 -62
  20. package/dist/features/games.js +100 -0
  21. package/{src → dist}/features/keys.js +19 -10
  22. package/dist/features/schedule.js +43 -0
  23. package/dist/features/standings.js +43 -0
  24. package/{src → dist}/hooks/useKey.js +3 -5
  25. package/dist/logger.js +11 -0
  26. package/dist/main.js +20 -0
  27. package/{src → dist}/package.js +2 -4
  28. package/{src → dist}/screen.js +2 -8
  29. package/dist/store/index.js +19 -0
  30. package/{src → dist}/style/index.js +2 -2
  31. package/{src → dist}/utils.js +4 -5
  32. package/package.json +5 -1
  33. package/.eslintrc.json +0 -33
  34. package/CODE_OF_CONDUCT.md +0 -76
  35. package/demo.cast +0 -95
  36. package/demo.gif +0 -0
  37. package/src/cli.js +0 -46
  38. package/src/components/App.jsx +0 -43
  39. package/src/components/AtBat.jsx +0 -41
  40. package/src/components/Bases.jsx +0 -23
  41. package/src/components/Count.jsx +0 -25
  42. package/src/components/FinishedGame.jsx +0 -76
  43. package/src/components/Game.jsx +0 -60
  44. package/src/components/GameList.jsx +0 -169
  45. package/src/components/HelpBar.jsx +0 -19
  46. package/src/components/InningDisplay.jsx +0 -19
  47. package/src/components/LineScore.jsx +0 -52
  48. package/src/components/LiveGame.jsx +0 -47
  49. package/src/components/Matchup.jsx +0 -41
  50. package/src/components/PreviewGame.jsx +0 -54
  51. package/src/components/Standings.jsx +0 -81
  52. package/src/features/games.js +0 -166
  53. package/src/features/schedule.js +0 -60
  54. package/src/features/standings.js +0 -61
  55. package/src/logger.js +0 -19
  56. package/src/main.js +0 -27
  57. package/src/store/index.js +0 -19
@@ -1,14 +1,21 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
2
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
3
  import PropTypes from 'prop-types';
3
- import useKey from '../hooks/useKey.js';
4
-
5
- function Grid({ items, itemHeight, itemMinWidth, onSelect }) {
4
+ import useKey from "../hooks/useKey.js";
5
+ function Grid({
6
+ items,
7
+ itemHeight,
8
+ itemMinWidth,
9
+ onSelect
10
+ }) {
6
11
  const containerRef = useRef();
7
12
  const [size, setSize] = useState([0, 0]);
8
13
  const [selectedIndex, setSelectedIndex] = useState(0);
9
- const updateSize = () => setSize([containerRef.current?.width, containerRef.current?.height]);
14
+ const updateSize = () => {
15
+ var _containerRef$current, _containerRef$current2;
16
+ return setSize([(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.width, (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.height]);
17
+ };
10
18
  useEffect(updateSize, []);
11
-
12
19
  const pos = [];
13
20
  let row = 0;
14
21
  let col = 0;
@@ -19,7 +26,7 @@ function Grid({ items, itemHeight, itemMinWidth, onSelect }) {
19
26
  top: row,
20
27
  left: col,
21
28
  width: colWidth,
22
- height: itemHeight,
29
+ height: itemHeight
23
30
  });
24
31
  col += colWidth;
25
32
  if (col > size[0] - colWidth) {
@@ -27,14 +34,12 @@ function Grid({ items, itemHeight, itemMinWidth, onSelect }) {
27
34
  row += itemHeight;
28
35
  }
29
36
  }
30
-
31
37
  useEffect(() => {
32
38
  const curr = pos[selectedIndex].top;
33
39
  const total = pos[pos.length - 1].top;
34
40
  const perc = Math.round(curr / total * 100);
35
41
  containerRef.current.setScrollPerc(perc);
36
42
  }, [pos, selectedIndex]);
37
-
38
43
  useKey(['right', 'l'], useCallback(() => setSelectedIndex(prev => Math.min(prev + 1, items.length - 1)), [items.length]));
39
44
  useKey(['left', 'h'], useCallback(() => setSelectedIndex(prev => Math.max(prev - 1, 0)), []));
40
45
  useKey(['down', 'j'], useCallback(() => {
@@ -58,34 +63,26 @@ function Grid({ items, itemHeight, itemMinWidth, onSelect }) {
58
63
  });
59
64
  }, [numCols]));
60
65
  useKey('enter', () => onSelect(selectedIndex));
61
-
62
- return (
63
- <box
64
- ref={containerRef}
65
- onResize={updateSize}
66
- width='100%'
67
- height='100%'
68
- scrollable={true}
69
- >
70
- {pos.map((p, idx) => (
71
- <box
72
- {...p}
73
- border={{type: selectedIndex === idx ? 'line' : 'bg'}}
74
- key={items[idx]}
75
- tags
76
- content={items[idx]}
77
- wrap={false}
78
- />
79
- ))}
80
- </box>
81
- );
66
+ return /*#__PURE__*/React.createElement("box", {
67
+ ref: containerRef,
68
+ onResize: updateSize,
69
+ width: "100%",
70
+ height: "100%",
71
+ scrollable: true
72
+ }, pos.map((p, idx) => /*#__PURE__*/React.createElement("box", _extends({}, p, {
73
+ border: {
74
+ type: selectedIndex === idx ? 'line' : 'bg'
75
+ },
76
+ key: items[idx],
77
+ tags: true,
78
+ content: items[idx],
79
+ wrap: false
80
+ }))));
82
81
  }
83
-
84
82
  Grid.propTypes = {
85
83
  items: PropTypes.arrayOf(PropTypes.string),
86
84
  itemHeight: PropTypes.number,
87
85
  itemMinWidth: PropTypes.number,
88
- onSelect: PropTypes.func,
86
+ onSelect: PropTypes.func
89
87
  };
90
-
91
- export default Grid;
88
+ export default Grid;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { useSelector } from "react-redux/lib/alternate-renderers.js";
3
+ import LoadingSpinner from "./LoadingSpinner.js";
4
+ const HelpBar = () => {
5
+ const keys = useSelector(state => state.keys);
6
+ const content = keys.map(({
7
+ key,
8
+ label
9
+ }) => `{inverse}${key}{/inverse}:${label}`).join(' ');
10
+ return /*#__PURE__*/React.createElement("element", null, /*#__PURE__*/React.createElement(LoadingSpinner, null), /*#__PURE__*/React.createElement("box", {
11
+ left: 3,
12
+ content: content,
13
+ tags: true
14
+ }));
15
+ };
16
+ export default HelpBar;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { useSelector } from "react-redux/lib/alternate-renderers.js";
3
+ import { selectLineScore } from "../features/games.js";
4
+ function InningDisplay() {
5
+ const linescore = useSelector(selectLineScore);
6
+ const content = [linescore.isTopInning ? '▲' : '', linescore.currentInning, linescore.isTopInning ? '' : '▼'].join('\n');
7
+ return /*#__PURE__*/React.createElement("box", {
8
+ content: content,
9
+ align: "right"
10
+ });
11
+ }
12
+ export default InningDisplay;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useSelector } from "react-redux/lib/alternate-renderers.js";
4
+ import { selectLineScore, selectTeams } from "../features/games.js";
5
+ const getRuns = (inning, homeAway, isFinal) => {
6
+ const runs = inning[homeAway].runs;
7
+ if (runs !== undefined) {
8
+ return runs;
9
+ }
10
+ return isFinal ? 'X' : '';
11
+ };
12
+ const getTeamLine = (linescore, totalInnings, homeAway, final) => linescore.innings.map(inning => getRuns(inning, homeAway, final)).map(r => r.toString().padStart(2)).join(' ').padEnd(totalInnings * 3) + '{bold}' + linescore.teams[homeAway].runs.toString().padStart(3) + '{/bold}' + linescore.teams[homeAway].hits.toString().padStart(3) + linescore.teams[homeAway].errors.toString().padStart(3);
13
+ function LineScore({
14
+ align,
15
+ final
16
+ }) {
17
+ const linescore = useSelector(selectLineScore);
18
+ const teams = useSelector(selectTeams);
19
+ const currentInning = linescore.currentInning;
20
+ if (!currentInning) {
21
+ return '';
22
+ }
23
+ const totalInnings = Math.max(currentInning, 9);
24
+ const home = teams.home.abbreviation;
25
+ const away = teams.away.abbreviation;
26
+ const teamNameLength = 3;
27
+ let str = ''.padEnd(teamNameLength) + Array.from(Array(totalInnings).keys()).map(i => (i + 1).toString().padStart(2)).join(' ') + ' {bold}R{/bold} H E\n' + away.padEnd(teamNameLength) + getTeamLine(linescore, totalInnings, 'away', final) + '\n' + home.padEnd(teamNameLength) + getTeamLine(linescore, totalInnings, 'home', final);
28
+ return /*#__PURE__*/React.createElement("box", {
29
+ align: align,
30
+ content: str,
31
+ tags: true,
32
+ wrap: false
33
+ });
34
+ }
35
+ LineScore.propTypes = {
36
+ align: PropTypes.oneOf(['left', 'center', 'right']),
37
+ final: PropTypes.bool
38
+ };
39
+ export default LineScore;
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import Count from "./Count.js";
3
+ import Bases from "./Bases.js";
4
+ import LineScore from "./LineScore.js";
5
+ import Matchup from "./Matchup.js";
6
+ import AtBat from "./AtBat.js";
7
+ import AllPlays from "./AllPlays.js";
8
+ import InningDisplay from "./InningDisplay.js";
9
+ function LiveGame() {
10
+ return /*#__PURE__*/React.createElement("element", null, /*#__PURE__*/React.createElement("element", {
11
+ top: 0,
12
+ left: 1,
13
+ width: "100%-1",
14
+ height: 3
15
+ }, /*#__PURE__*/React.createElement("element", {
16
+ left: 0,
17
+ width: 2
18
+ }, /*#__PURE__*/React.createElement(InningDisplay, null)), /*#__PURE__*/React.createElement("element", {
19
+ left: 5,
20
+ width: "25%-5"
21
+ }, /*#__PURE__*/React.createElement(Count, null)), /*#__PURE__*/React.createElement("element", {
22
+ left: "25%+1",
23
+ width: "25%"
24
+ }, /*#__PURE__*/React.createElement(Bases, null)), /*#__PURE__*/React.createElement("element", {
25
+ left: "50%+2",
26
+ width: "50%-2"
27
+ }, /*#__PURE__*/React.createElement(LineScore, null))), /*#__PURE__*/React.createElement("line", {
28
+ orientation: "horizontal",
29
+ type: "line",
30
+ top: 3,
31
+ width: "100%"
32
+ }), /*#__PURE__*/React.createElement("element", {
33
+ top: 4,
34
+ left: 1
35
+ }, /*#__PURE__*/React.createElement("element", {
36
+ width: "50%-1"
37
+ }, /*#__PURE__*/React.createElement("element", {
38
+ top: 0,
39
+ height: 2
40
+ }, /*#__PURE__*/React.createElement(Matchup, null)), /*#__PURE__*/React.createElement("element", {
41
+ top: 3
42
+ }, /*#__PURE__*/React.createElement(AtBat, null))), /*#__PURE__*/React.createElement("line", {
43
+ orientation: "vertical",
44
+ type: "line",
45
+ left: "50%"
46
+ }), /*#__PURE__*/React.createElement("element", {
47
+ left: "50%+2",
48
+ width: "50%-2"
49
+ }, /*#__PURE__*/React.createElement(AllPlays, null))));
50
+ }
51
+ export default LiveGame;
@@ -1,32 +1,17 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
- import { useSelector } from 'react-redux';
3
- import { selectLoading as selectScheduleLoading } from '../features/schedule.js';
4
- import { selectLoading as gamesLoading } from '../features/games.js';
5
-
6
- const frames = [
7
- '⠋',
8
- '⠙',
9
- '⠹',
10
- '⠸',
11
- '⠼',
12
- '⠴',
13
- '⠦',
14
- '⠧',
15
- '⠇',
16
- '⠏'
17
- ];
18
-
19
- function LoadingSpinner() {
2
+ import { useSelector } from "react-redux/lib/alternate-renderers.js";
3
+ import { selectLoading as selectScheduleLoading } from "../features/schedule.js";
4
+ import { selectLoading as gamesLoading } from "../features/games.js";
5
+ const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
6
+ function LoadingSpinner() {
20
7
  const [frame, setFrame] = useState(0);
21
8
  const [animating, setAnimating] = useState(false);
22
9
  const timerRef = useRef(null);
23
10
  const scheduleLoading = useSelector(selectScheduleLoading);
24
11
  const gameLoading = useSelector(gamesLoading);
25
-
26
12
  const increment = () => {
27
13
  setFrame(prevFrame => (prevFrame + 1) % frames.length);
28
14
  };
29
-
30
15
  const doUpdate = () => {
31
16
  if (!animating && (gameLoading || scheduleLoading)) {
32
17
  setAnimating(true);
@@ -38,12 +23,11 @@ function LoadingSpinner() {
38
23
  clearInterval(timerRef.current);
39
24
  }
40
25
  };
41
-
42
26
  useEffect(() => {
43
27
  doUpdate();
44
28
  }, [gameLoading, scheduleLoading, frame]);
45
-
46
- return <box content={animating ? frames[frame] : ' '} />;
29
+ return /*#__PURE__*/React.createElement("box", {
30
+ content: animating ? frames[frame] : ' '
31
+ });
47
32
  }
48
-
49
33
  export default LoadingSpinner;
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { useSelector } from "react-redux/lib/alternate-renderers.js";
3
+ import { selectCurrentPlay, selectBoxscore, selectTeams } from "../features/games.js";
4
+ const getPlayerStats = (boxscore, teams, id) => {
5
+ const key = 'ID' + id;
6
+ const homePlayers = boxscore.home.players;
7
+ if (homePlayers[key]) {
8
+ return {
9
+ team: teams.home,
10
+ player: homePlayers[key]
11
+ };
12
+ }
13
+ return {
14
+ team: teams.away,
15
+ player: boxscore.away.players[key]
16
+ };
17
+ };
18
+ function Matchup() {
19
+ var _currentPlay$matchup, _currentPlay$matchup2;
20
+ const boxscore = useSelector(selectBoxscore);
21
+ const currentPlay = useSelector(selectCurrentPlay);
22
+ const teams = useSelector(selectTeams);
23
+ const pitcherId = (_currentPlay$matchup = currentPlay.matchup) === null || _currentPlay$matchup === void 0 || (_currentPlay$matchup = _currentPlay$matchup.pitcher) === null || _currentPlay$matchup === void 0 ? void 0 : _currentPlay$matchup.id;
24
+ const batterId = (_currentPlay$matchup2 = currentPlay.matchup) === null || _currentPlay$matchup2 === void 0 || (_currentPlay$matchup2 = _currentPlay$matchup2.batter) === null || _currentPlay$matchup2 === void 0 ? void 0 : _currentPlay$matchup2.id;
25
+ const {
26
+ team: pitchTeam,
27
+ player: pitcher
28
+ } = getPlayerStats(boxscore, teams, pitcherId);
29
+ const {
30
+ team: batTeam,
31
+ player: batter
32
+ } = getPlayerStats(boxscore, teams, batterId);
33
+ const display = `${pitchTeam.abbreviation} Pitching: ` + `{bold}${pitcher.person.fullName}{/bold} ${pitcher.stats.pitching.inningsPitched} IP, ${pitcher.stats.pitching.pitchesThrown || 0} P, ${pitcher.seasonStats.pitching.era} ERA\n` + `${batTeam.abbreviation} At Bat: ` + `{bold}${batter.person.fullName}{/bold} ${batter.stats.batting.hits}-${batter.stats.batting.atBats}, ${batter.seasonStats.batting.avg} AVG, ${batter.seasonStats.batting.homeRuns} HR`;
34
+ return /*#__PURE__*/React.createElement("box", {
35
+ tags: true,
36
+ content: display,
37
+ wrap: false
38
+ });
39
+ }
40
+ export default Matchup;
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { useSelector } from "react-redux/lib/alternate-renderers.js";
3
+ import { format } from 'date-fns';
4
+ import { selectTeams, selectVenue, selectStartTime, selectBoxscore, selectProbablePitchers, selectGameStatus } from "../features/games.js";
5
+ const formatPitcherName = pitcher => {
6
+ let display = pitcher.person.fullName;
7
+ const number = pitcher.jerseyNumber;
8
+ if (number) {
9
+ display += `, #${number}`;
10
+ }
11
+ return display;
12
+ };
13
+ const formatTeam = (teams, probables, boxscore, homeAway) => {
14
+ const pitcherId = probables[homeAway].id;
15
+ const pitcher = boxscore[homeAway].players['ID' + pitcherId];
16
+ let lines = [teams[homeAway].teamName, `(${teams[homeAway].record.wins}-${teams[homeAway].record.losses})`];
17
+ if (pitcher) {
18
+ var _pitcher$seasonStats, _pitcher$seasonStats2, _pitcher$seasonStats3, _pitcher$seasonStats4;
19
+ lines = lines.concat(['', formatPitcherName(pitcher), `${(_pitcher$seasonStats = pitcher.seasonStats) === null || _pitcher$seasonStats === void 0 || (_pitcher$seasonStats = _pitcher$seasonStats.pitching) === null || _pitcher$seasonStats === void 0 ? void 0 : _pitcher$seasonStats.wins}-${(_pitcher$seasonStats2 = pitcher.seasonStats) === null || _pitcher$seasonStats2 === void 0 || (_pitcher$seasonStats2 = _pitcher$seasonStats2.pitching) === null || _pitcher$seasonStats2 === void 0 ? void 0 : _pitcher$seasonStats2.losses}`, `${(_pitcher$seasonStats3 = pitcher.seasonStats) === null || _pitcher$seasonStats3 === void 0 || (_pitcher$seasonStats3 = _pitcher$seasonStats3.pitching) === null || _pitcher$seasonStats3 === void 0 ? void 0 : _pitcher$seasonStats3.era} ERA ${(_pitcher$seasonStats4 = pitcher.seasonStats) === null || _pitcher$seasonStats4 === void 0 || (_pitcher$seasonStats4 = _pitcher$seasonStats4.pitching) === null || _pitcher$seasonStats4 === void 0 ? void 0 : _pitcher$seasonStats4.strikeOuts} K`]);
20
+ }
21
+ return lines;
22
+ };
23
+ function PreviewGame() {
24
+ const boxscore = useSelector(selectBoxscore);
25
+ const probables = useSelector(selectProbablePitchers);
26
+ const startTime = useSelector(selectStartTime);
27
+ const status = useSelector(selectGameStatus);
28
+ const teams = useSelector(selectTeams);
29
+ const venue = useSelector(selectVenue);
30
+ const away = formatTeam(teams, probables, boxscore, 'away');
31
+ const home = formatTeam(teams, probables, boxscore, 'home');
32
+ const formattedStart = status.startTimeTBD ? 'Start time TBD' : format(new Date(startTime), 'MMMM d, yyy p');
33
+ return /*#__PURE__*/React.createElement("element", null, /*#__PURE__*/React.createElement("element", {
34
+ height: "60%"
35
+ }, /*#__PURE__*/React.createElement("box", {
36
+ content: away.join('\n'),
37
+ width: "33%-1",
38
+ top: "50%",
39
+ align: "center"
40
+ }), /*#__PURE__*/React.createElement("box", {
41
+ content: `\nvs.\n\n${formattedStart}\n${venue.name}\n${venue.location.city}, ${venue.location.stateAbbrev}`,
42
+ width: "33%-1",
43
+ left: "33%",
44
+ top: "50%",
45
+ align: "center"
46
+ }), /*#__PURE__*/React.createElement("box", {
47
+ content: home.join('\n'),
48
+ width: "34%",
49
+ top: "50%",
50
+ left: "66%",
51
+ align: "center"
52
+ })));
53
+ }
54
+ export default PreviewGame;
@@ -0,0 +1,70 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useDispatch, useSelector } from "react-redux/lib/alternate-renderers.js";
4
+ import { fetchStandings, selectData } from "../features/standings.js";
5
+ import { teamFavoriteStar } from "../utils.js";
6
+ function formatHeaderRow(record) {
7
+ return record.division.nameShort.padEnd(15) + ' W' + ' L' + ' PCT' + ' GB' + ' WCGB' + ' L10' + ' STRK';
8
+ }
9
+ function formatTeamRow(record) {
10
+ var _record$streak;
11
+ const lastTen = record.records.splitRecords.find(o => o.type === 'lastTen');
12
+ const star = teamFavoriteStar(record.team);
13
+ return star + record.team.teamName.padEnd(star ? 13 : 15) + record.wins.toString().padStart(5) + record.losses.toString().padStart(5) + record.winningPercentage.padStart(7) + record.gamesBack.padStart(6) + record.wildCardGamesBack.padStart(6) + `${lastTen.wins}-${lastTen.losses}`.padStart(6) + (((_record$streak = record.streak) === null || _record$streak === void 0 ? void 0 : _record$streak.streakCode) || '').padStart(5);
14
+ }
15
+ function Division({
16
+ record,
17
+ top,
18
+ left,
19
+ width
20
+ }) {
21
+ return /*#__PURE__*/React.createElement("box", {
22
+ top: top,
23
+ left: left,
24
+ height: 6,
25
+ width: width
26
+ }, /*#__PURE__*/React.createElement("box", {
27
+ top: 0,
28
+ left: 0,
29
+ height: 1,
30
+ fg: "black",
31
+ bg: "white",
32
+ content: formatHeaderRow(record),
33
+ wrap: false
34
+ }), /*#__PURE__*/React.createElement("box", {
35
+ top: 1,
36
+ left: 0,
37
+ height: 5,
38
+ content: record.teamRecords.map(formatTeamRow).join('\n'),
39
+ wrap: false,
40
+ tags: true
41
+ }));
42
+ }
43
+ Division.propTypes = {
44
+ record: PropTypes.object,
45
+ top: PropTypes.number,
46
+ left: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
47
+ width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
48
+ };
49
+ function Standings() {
50
+ const dispatch = useDispatch();
51
+ const standings = useSelector(selectData);
52
+ useEffect(() => dispatch(fetchStandings()), []);
53
+ if (!standings) {
54
+ return /*#__PURE__*/React.createElement("element", null);
55
+ }
56
+ return /*#__PURE__*/React.createElement("element", null, standings.records.filter(record => record.league.id === 103).map((record, idx) => /*#__PURE__*/React.createElement(Division, {
57
+ top: idx * 7,
58
+ left: 0,
59
+ width: "50%-1",
60
+ key: record.division.id,
61
+ record: record
62
+ })), standings.records.filter(record => record.league.id === 104).map((record, idx) => /*#__PURE__*/React.createElement(Division, {
63
+ top: idx * 7,
64
+ left: "50%+1",
65
+ width: "50%-1",
66
+ key: record.division.id,
67
+ record: record
68
+ })));
69
+ }
70
+ export default Standings;
@@ -1,9 +1,6 @@
1
- import pkg from './package.js';
2
-
1
+ import pkg from "./package.js";
3
2
  import Conf from 'conf';
4
-
5
3
  const colorPattern = '^(((light-|bright-)?(black|red|green|yellow|blue|magenta|cyan|white|grey))|default|#([0-9a-fA-F]{3}){1,2})$';
6
-
7
4
  const schema = {
8
5
  color: {
9
6
  type: 'object',
@@ -11,63 +8,63 @@ const schema = {
11
8
  ball: {
12
9
  type: 'string',
13
10
  default: 'green',
14
- pattern: colorPattern,
11
+ pattern: colorPattern
15
12
  },
16
13
  strike: {
17
14
  type: 'string',
18
15
  default: 'red',
19
- pattern: colorPattern,
16
+ pattern: colorPattern
20
17
  },
21
18
  out: {
22
19
  type: 'string',
23
20
  default: 'red',
24
- pattern: colorPattern,
21
+ pattern: colorPattern
25
22
  },
26
23
  'on-base': {
27
24
  type: 'string',
28
25
  default: 'yellow',
29
- pattern: colorPattern,
26
+ pattern: colorPattern
30
27
  },
31
28
  'strike-out': {
32
29
  type: 'string',
33
30
  default: 'red',
34
- pattern: colorPattern,
31
+ pattern: colorPattern
35
32
  },
36
33
  'walk': {
37
34
  type: 'string',
38
35
  default: 'green',
39
- pattern: colorPattern,
36
+ pattern: colorPattern
40
37
  },
41
38
  'other-event': {
42
39
  type: 'string',
43
40
  default: 'white',
44
- pattern: colorPattern,
41
+ pattern: colorPattern
45
42
  },
46
43
  'in-play-no-out': {
47
44
  type: 'string',
48
45
  default: 'blue',
49
- pattern: colorPattern,
46
+ pattern: colorPattern
50
47
  },
51
48
  'in-play-out': {
52
49
  type: 'string',
53
50
  default: 'white',
54
- pattern: colorPattern,
51
+ pattern: colorPattern
55
52
  },
56
53
  'in-play-runs-bg': {
57
54
  type: 'string',
58
55
  default: 'white',
59
- pattern: colorPattern,
56
+ pattern: colorPattern
60
57
  },
61
58
  'in-play-runs-fg': {
62
59
  type: 'string',
63
60
  default: 'black',
64
- pattern: colorPattern,
61
+ pattern: colorPattern
65
62
  },
66
63
  'favorite-star': {
67
64
  type: 'string',
68
65
  default: 'yellow',
69
- pattern: colorPattern,
70
- },
66
+ pattern: colorPattern
67
+ }
71
68
  },
72
69
  default: {}
73
70
  },
@@ -75,70 +72,34 @@ const schema = {
75
72
  type: 'array',
76
73
  items: {
77
74
  type: 'string',
78
- enum: [
79
- 'ATL',
80
- 'AZ',
81
- 'BAL',
82
- 'BOS',
83
- 'CHC',
84
- 'CIN',
85
- 'CLE',
86
- 'COL',
87
- 'CWS',
88
- 'DET',
89
- 'HOU',
90
- 'KC',
91
- 'LAA',
92
- 'LAD',
93
- 'MIA',
94
- 'MIL',
95
- 'MIN',
96
- 'NYM',
97
- 'NYY',
98
- 'OAK',
99
- 'PHI',
100
- 'PIT',
101
- 'SD',
102
- 'SEA',
103
- 'SF',
104
- 'STL',
105
- 'TB',
106
- 'TEX',
107
- 'TOR',
108
- 'WSH'
109
- ],
75
+ enum: ['ATL', 'AZ', 'BAL', 'BOS', 'CHC', 'CIN', 'CLE', 'COL', 'CWS', 'DET', 'HOU', 'KC', 'LAA', 'LAD', 'MIA', 'MIL', 'MIN', 'NYM', 'NYY', 'OAK', 'PHI', 'PIT', 'SD', 'SEA', 'SF', 'STL', 'TB', 'TEX', 'TOR', 'WSH']
110
76
  },
111
77
  default: []
112
- },
78
+ }
113
79
  };
114
-
115
80
  const config = new Conf({
116
81
  projectName: pkg.name,
117
- schema,
82
+ schema
118
83
  });
119
-
120
84
  function serialize(value) {
121
85
  if (value && Array.isArray(value)) {
122
86
  return value.join(',');
123
- }
87
+ }
124
88
  return value;
125
89
  }
126
-
127
90
  function deserialize(key, value) {
128
- if (value && schema[key]?.type === 'array') {
91
+ var _schema$key;
92
+ if (value && ((_schema$key = schema[key]) === null || _schema$key === void 0 ? void 0 : _schema$key.type) === 'array') {
129
93
  return value.split(/\s*,\s*/);
130
94
  }
131
95
  return value;
132
96
  }
133
-
134
97
  export function get(key) {
135
98
  return serialize(config.get(key));
136
99
  }
137
-
138
100
  export function set(key, value) {
139
101
  return config.set(key, deserialize(key, value));
140
102
  }
141
-
142
103
  export function unset(key) {
143
104
  if (key) {
144
105
  return config.delete(key);
@@ -146,7 +107,6 @@ export function unset(key) {
146
107
  return config.clear();
147
108
  }
148
109
  }
149
-
150
110
  function flatten(obj) {
151
111
  const result = {};
152
112
  for (const [key, value] of Object.entries(obj).sort()) {
@@ -161,7 +121,6 @@ function flatten(obj) {
161
121
  }
162
122
  return result;
163
123
  }
164
-
165
124
  export function getAll() {
166
125
  return flatten(config.store);
167
- }
126
+ }