playball 3.0.0 → 3.1.1
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.
- package/README.md +62 -0
- package/bin/playball.js +1 -1
- package/dist/cli.js +31 -0
- package/dist/components/AllPlays.js +20 -60
- package/dist/components/App.js +19 -45
- package/dist/components/AtBat.js +8 -33
- package/dist/components/Bases.js +10 -25
- package/dist/components/Count.js +10 -25
- package/dist/components/FinishedGame.js +26 -60
- package/dist/components/Game.js +25 -57
- package/dist/components/GameList.js +32 -83
- package/dist/components/Grid.js +20 -47
- package/dist/components/HelpBar.js +6 -20
- package/dist/components/InningDisplay.js +6 -20
- package/dist/components/LineScore.js +10 -31
- package/dist/components/LiveGame.js +22 -41
- package/dist/components/LoadingSpinner.js +12 -34
- package/dist/components/Matchup.js +11 -29
- package/dist/components/PreviewGame.js +18 -40
- package/dist/components/Standings.js +23 -45
- package/dist/config.js +126 -0
- package/dist/features/games.js +32 -67
- package/dist/features/keys.js +10 -25
- package/dist/features/schedule.js +16 -31
- package/dist/features/standings.js +14 -28
- package/dist/hooks/useKey.js +8 -20
- package/dist/logger.js +9 -20
- package/dist/main.js +20 -28
- package/dist/package.js +5 -0
- package/dist/screen.js +16 -22
- package/dist/store/index.js +14 -27
- package/dist/style/index.js +2 -9
- package/dist/utils.js +8 -0
- package/package.json +14 -6
- package/.eslintrc.json +0 -33
- package/CODE_OF_CONDUCT.md +0 -76
- package/demo.cast +0 -95
- package/demo.gif +0 -0
- package/src/components/AllPlays.jsx +0 -107
- package/src/components/App.jsx +0 -43
- package/src/components/AtBat.jsx +0 -41
- package/src/components/Bases.jsx +0 -22
- package/src/components/Count.jsx +0 -24
- package/src/components/FinishedGame.jsx +0 -76
- package/src/components/Game.jsx +0 -60
- package/src/components/GameList.jsx +0 -166
- package/src/components/Grid.jsx +0 -91
- package/src/components/HelpBar.jsx +0 -19
- package/src/components/InningDisplay.jsx +0 -19
- package/src/components/LineScore.jsx +0 -52
- package/src/components/LiveGame.jsx +0 -47
- package/src/components/LoadingSpinner.jsx +0 -49
- package/src/components/Matchup.jsx +0 -41
- package/src/components/PreviewGame.jsx +0 -54
- package/src/components/Standings.jsx +0 -78
- package/src/features/games.js +0 -165
- package/src/features/keys.js +0 -38
- package/src/features/schedule.js +0 -59
- package/src/features/standings.js +0 -60
- package/src/hooks/useKey.js +0 -13
- package/src/logger.js +0 -16
- package/src/main.js +0 -23
- package/src/screen.js +0 -14
- package/src/store/index.js +0 -18
- package/src/style/index.js +0 -15
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
11
|
-
|
|
12
|
-
var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSelector } from "react-redux/lib/alternate-renderers.js";
|
|
3
|
+
import LoadingSpinner from "./LoadingSpinner.js";
|
|
16
4
|
const HelpBar = () => {
|
|
17
|
-
const keys =
|
|
5
|
+
const keys = useSelector(state => state.keys);
|
|
18
6
|
const content = keys.map(({
|
|
19
7
|
key,
|
|
20
8
|
label
|
|
21
9
|
}) => `{inverse}${key}{/inverse}:${label}`).join(' ');
|
|
22
|
-
return /*#__PURE__*/
|
|
10
|
+
return /*#__PURE__*/React.createElement("element", null, /*#__PURE__*/React.createElement(LoadingSpinner, null), /*#__PURE__*/React.createElement("box", {
|
|
23
11
|
left: 3,
|
|
24
12
|
content: content,
|
|
25
13
|
tags: true
|
|
26
14
|
}));
|
|
27
15
|
};
|
|
28
|
-
|
|
29
|
-
var _default = HelpBar;
|
|
30
|
-
exports.default = _default;
|
|
16
|
+
export default HelpBar;
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
11
|
-
|
|
12
|
-
var _games = require("../features/games");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSelector } from "react-redux/lib/alternate-renderers.js";
|
|
3
|
+
import { selectLineScore } from "../features/games.js";
|
|
16
4
|
function InningDisplay() {
|
|
17
|
-
const linescore =
|
|
5
|
+
const linescore = useSelector(selectLineScore);
|
|
18
6
|
const content = [linescore.isTopInning ? '▲' : '', linescore.currentInning, linescore.isTopInning ? '' : '▼'].join('\n');
|
|
19
|
-
return /*#__PURE__*/
|
|
7
|
+
return /*#__PURE__*/React.createElement("box", {
|
|
20
8
|
content: content,
|
|
21
9
|
align: "right"
|
|
22
10
|
});
|
|
23
11
|
}
|
|
24
|
-
|
|
25
|
-
var _default = InningDisplay;
|
|
26
|
-
exports.default = _default;
|
|
12
|
+
export default InningDisplay;
|
|
@@ -1,60 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
13
|
-
|
|
14
|
-
var _games = require("../features/games");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
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";
|
|
18
5
|
const getRuns = (inning, homeAway, isFinal) => {
|
|
19
6
|
const runs = inning[homeAway].runs;
|
|
20
|
-
|
|
21
7
|
if (runs !== undefined) {
|
|
22
8
|
return runs;
|
|
23
9
|
}
|
|
24
|
-
|
|
25
10
|
return isFinal ? 'X' : '';
|
|
26
11
|
};
|
|
27
|
-
|
|
28
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);
|
|
29
|
-
|
|
30
13
|
function LineScore({
|
|
31
14
|
align,
|
|
32
15
|
final
|
|
33
16
|
}) {
|
|
34
|
-
const linescore =
|
|
35
|
-
const teams =
|
|
17
|
+
const linescore = useSelector(selectLineScore);
|
|
18
|
+
const teams = useSelector(selectTeams);
|
|
36
19
|
const currentInning = linescore.currentInning;
|
|
37
|
-
|
|
38
20
|
if (!currentInning) {
|
|
39
21
|
return '';
|
|
40
22
|
}
|
|
41
|
-
|
|
42
23
|
const totalInnings = Math.max(currentInning, 9);
|
|
43
24
|
const home = teams.home.abbreviation;
|
|
44
25
|
const away = teams.away.abbreviation;
|
|
45
26
|
const teamNameLength = 3;
|
|
46
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);
|
|
47
|
-
return /*#__PURE__*/
|
|
28
|
+
return /*#__PURE__*/React.createElement("box", {
|
|
48
29
|
align: align,
|
|
49
30
|
content: str,
|
|
50
31
|
tags: true,
|
|
51
32
|
wrap: false
|
|
52
33
|
});
|
|
53
34
|
}
|
|
54
|
-
|
|
55
35
|
LineScore.propTypes = {
|
|
56
|
-
align:
|
|
57
|
-
final:
|
|
36
|
+
align: PropTypes.oneOf(['left', 'center', 'right']),
|
|
37
|
+
final: PropTypes.bool
|
|
58
38
|
};
|
|
59
|
-
|
|
60
|
-
exports.default = _default;
|
|
39
|
+
export default LineScore;
|
|
@@ -1,70 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _Count = _interopRequireDefault(require("./Count"));
|
|
11
|
-
|
|
12
|
-
var _Bases = _interopRequireDefault(require("./Bases"));
|
|
13
|
-
|
|
14
|
-
var _LineScore = _interopRequireDefault(require("./LineScore"));
|
|
15
|
-
|
|
16
|
-
var _Matchup = _interopRequireDefault(require("./Matchup"));
|
|
17
|
-
|
|
18
|
-
var _AtBat = _interopRequireDefault(require("./AtBat"));
|
|
19
|
-
|
|
20
|
-
var _AllPlays = _interopRequireDefault(require("./AllPlays"));
|
|
21
|
-
|
|
22
|
-
var _InningDisplay = _interopRequireDefault(require("./InningDisplay"));
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
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";
|
|
26
9
|
function LiveGame() {
|
|
27
|
-
return /*#__PURE__*/
|
|
10
|
+
return /*#__PURE__*/React.createElement("element", null, /*#__PURE__*/React.createElement("element", {
|
|
28
11
|
top: 0,
|
|
29
12
|
left: 1,
|
|
30
13
|
width: "100%-1",
|
|
31
14
|
height: 3
|
|
32
|
-
}, /*#__PURE__*/
|
|
15
|
+
}, /*#__PURE__*/React.createElement("element", {
|
|
33
16
|
left: 0,
|
|
34
17
|
width: 2
|
|
35
|
-
}, /*#__PURE__*/
|
|
18
|
+
}, /*#__PURE__*/React.createElement(InningDisplay, null)), /*#__PURE__*/React.createElement("element", {
|
|
36
19
|
left: 5,
|
|
37
20
|
width: "25%-5"
|
|
38
|
-
}, /*#__PURE__*/
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Count, null)), /*#__PURE__*/React.createElement("element", {
|
|
39
22
|
left: "25%+1",
|
|
40
23
|
width: "25%"
|
|
41
|
-
}, /*#__PURE__*/
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Bases, null)), /*#__PURE__*/React.createElement("element", {
|
|
42
25
|
left: "50%+2",
|
|
43
26
|
width: "50%-2"
|
|
44
|
-
}, /*#__PURE__*/
|
|
27
|
+
}, /*#__PURE__*/React.createElement(LineScore, null))), /*#__PURE__*/React.createElement("line", {
|
|
45
28
|
orientation: "horizontal",
|
|
46
29
|
type: "line",
|
|
47
30
|
top: 3,
|
|
48
31
|
width: "100%"
|
|
49
|
-
}), /*#__PURE__*/
|
|
32
|
+
}), /*#__PURE__*/React.createElement("element", {
|
|
50
33
|
top: 4,
|
|
51
34
|
left: 1
|
|
52
|
-
}, /*#__PURE__*/
|
|
35
|
+
}, /*#__PURE__*/React.createElement("element", {
|
|
53
36
|
width: "50%-1"
|
|
54
|
-
}, /*#__PURE__*/
|
|
37
|
+
}, /*#__PURE__*/React.createElement("element", {
|
|
55
38
|
top: 0,
|
|
56
39
|
height: 2
|
|
57
|
-
}, /*#__PURE__*/
|
|
40
|
+
}, /*#__PURE__*/React.createElement(Matchup, null)), /*#__PURE__*/React.createElement("element", {
|
|
58
41
|
top: 3
|
|
59
|
-
}, /*#__PURE__*/
|
|
42
|
+
}, /*#__PURE__*/React.createElement(AtBat, null))), /*#__PURE__*/React.createElement("line", {
|
|
60
43
|
orientation: "vertical",
|
|
61
44
|
type: "line",
|
|
62
45
|
left: "50%"
|
|
63
|
-
}), /*#__PURE__*/
|
|
46
|
+
}), /*#__PURE__*/React.createElement("element", {
|
|
64
47
|
left: "50%+2",
|
|
65
48
|
width: "50%-2"
|
|
66
|
-
}, /*#__PURE__*/
|
|
49
|
+
}, /*#__PURE__*/React.createElement(AllPlays, null))));
|
|
67
50
|
}
|
|
68
|
-
|
|
69
|
-
var _default = LiveGame;
|
|
70
|
-
exports.default = _default;
|
|
51
|
+
export default LiveGame;
|
|
@@ -1,55 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
11
|
-
|
|
12
|
-
var _schedule = require("../features/schedule");
|
|
13
|
-
|
|
14
|
-
var _games = require("../features/games");
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
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";
|
|
20
5
|
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
21
|
-
|
|
22
6
|
function LoadingSpinner() {
|
|
23
|
-
const [frame, setFrame] =
|
|
24
|
-
const [animating, setAnimating] =
|
|
25
|
-
const timerRef =
|
|
26
|
-
const scheduleLoading =
|
|
27
|
-
const gameLoading =
|
|
28
|
-
|
|
7
|
+
const [frame, setFrame] = useState(0);
|
|
8
|
+
const [animating, setAnimating] = useState(false);
|
|
9
|
+
const timerRef = useRef(null);
|
|
10
|
+
const scheduleLoading = useSelector(selectScheduleLoading);
|
|
11
|
+
const gameLoading = useSelector(gamesLoading);
|
|
29
12
|
const increment = () => {
|
|
30
13
|
setFrame(prevFrame => (prevFrame + 1) % frames.length);
|
|
31
14
|
};
|
|
32
|
-
|
|
33
15
|
const doUpdate = () => {
|
|
34
16
|
if (!animating && (gameLoading || scheduleLoading)) {
|
|
35
17
|
setAnimating(true);
|
|
36
18
|
increment();
|
|
37
19
|
timerRef.current = setInterval(increment, 50);
|
|
38
20
|
}
|
|
39
|
-
|
|
40
21
|
if (!gameLoading && !scheduleLoading && frame === 0) {
|
|
41
22
|
setAnimating(false);
|
|
42
23
|
clearInterval(timerRef.current);
|
|
43
24
|
}
|
|
44
25
|
};
|
|
45
|
-
|
|
46
|
-
(0, _react.useEffect)(() => {
|
|
26
|
+
useEffect(() => {
|
|
47
27
|
doUpdate();
|
|
48
28
|
}, [gameLoading, scheduleLoading, frame]);
|
|
49
|
-
return /*#__PURE__*/
|
|
29
|
+
return /*#__PURE__*/React.createElement("box", {
|
|
50
30
|
content: animating ? frames[frame] : ' '
|
|
51
31
|
});
|
|
52
32
|
}
|
|
53
|
-
|
|
54
|
-
var _default = LoadingSpinner;
|
|
55
|
-
exports.default = _default;
|
|
33
|
+
export default LoadingSpinner;
|
|
@@ -1,43 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
11
|
-
|
|
12
|
-
var _games = require("../features/games");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSelector } from "react-redux/lib/alternate-renderers.js";
|
|
3
|
+
import { selectCurrentPlay, selectBoxscore, selectTeams } from "../features/games.js";
|
|
16
4
|
const getPlayerStats = (boxscore, teams, id) => {
|
|
17
5
|
const key = 'ID' + id;
|
|
18
6
|
const homePlayers = boxscore.home.players;
|
|
19
|
-
|
|
20
7
|
if (homePlayers[key]) {
|
|
21
8
|
return {
|
|
22
9
|
team: teams.home,
|
|
23
10
|
player: homePlayers[key]
|
|
24
11
|
};
|
|
25
12
|
}
|
|
26
|
-
|
|
27
13
|
return {
|
|
28
14
|
team: teams.away,
|
|
29
15
|
player: boxscore.away.players[key]
|
|
30
16
|
};
|
|
31
17
|
};
|
|
32
|
-
|
|
33
18
|
function Matchup() {
|
|
34
|
-
var _currentPlay$matchup, _currentPlay$
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const batterId = (_currentPlay$matchup2 = currentPlay.matchup) === null || _currentPlay$matchup2 === void 0 ? void 0 : (_currentPlay$matchup3 = _currentPlay$matchup2.batter) === null || _currentPlay$matchup3 === void 0 ? void 0 : _currentPlay$matchup3.id;
|
|
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;
|
|
41
25
|
const {
|
|
42
26
|
team: pitchTeam,
|
|
43
27
|
player: pitcher
|
|
@@ -47,12 +31,10 @@ function Matchup() {
|
|
|
47
31
|
player: batter
|
|
48
32
|
} = getPlayerStats(boxscore, teams, batterId);
|
|
49
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`;
|
|
50
|
-
return /*#__PURE__*/
|
|
34
|
+
return /*#__PURE__*/React.createElement("box", {
|
|
51
35
|
tags: true,
|
|
52
36
|
content: display,
|
|
53
37
|
wrap: false
|
|
54
38
|
});
|
|
55
39
|
}
|
|
56
|
-
|
|
57
|
-
var _default = Matchup;
|
|
58
|
-
exports.default = _default;
|
|
40
|
+
export default Matchup;
|
|
@@ -1,69 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
11
|
-
|
|
12
|
-
var _dateFns = require("date-fns");
|
|
13
|
-
|
|
14
|
-
var _games = require("../features/games");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
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";
|
|
18
5
|
const formatPitcherName = pitcher => {
|
|
19
6
|
let display = pitcher.person.fullName;
|
|
20
7
|
const number = pitcher.jerseyNumber;
|
|
21
|
-
|
|
22
8
|
if (number) {
|
|
23
9
|
display += `, #${number}`;
|
|
24
10
|
}
|
|
25
|
-
|
|
26
11
|
return display;
|
|
27
12
|
};
|
|
28
|
-
|
|
29
13
|
const formatTeam = (teams, probables, boxscore, homeAway) => {
|
|
30
14
|
const pitcherId = probables[homeAway].id;
|
|
31
15
|
const pitcher = boxscore[homeAway].players['ID' + pitcherId];
|
|
32
16
|
let lines = [teams[homeAway].teamName, `(${teams[homeAway].record.wins}-${teams[homeAway].record.losses})`];
|
|
33
|
-
|
|
34
17
|
if (pitcher) {
|
|
35
|
-
var _pitcher$seasonStats, _pitcher$
|
|
36
|
-
|
|
37
|
-
lines = lines.concat(['', formatPitcherName(pitcher), `${(_pitcher$seasonStats = pitcher.seasonStats) === null || _pitcher$seasonStats === void 0 ? 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 ? void 0 : (_pitcher$seasonStats3 = _pitcher$seasonStats2.pitching) === null || _pitcher$seasonStats3 === void 0 ? void 0 : _pitcher$seasonStats3.losses}`, `${(_pitcher$seasonStats4 = pitcher.seasonStats) === null || _pitcher$seasonStats4 === void 0 ? void 0 : (_pitcher$seasonStats5 = _pitcher$seasonStats4.pitching) === null || _pitcher$seasonStats5 === void 0 ? void 0 : _pitcher$seasonStats5.era} ERA ${(_pitcher$seasonStats6 = pitcher.seasonStats) === null || _pitcher$seasonStats6 === void 0 ? void 0 : (_pitcher$seasonStats7 = _pitcher$seasonStats6.pitching) === null || _pitcher$seasonStats7 === void 0 ? void 0 : _pitcher$seasonStats7.strikeOuts} K`]);
|
|
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`]);
|
|
38
20
|
}
|
|
39
|
-
|
|
40
21
|
return lines;
|
|
41
22
|
};
|
|
42
|
-
|
|
43
23
|
function PreviewGame() {
|
|
44
|
-
const boxscore =
|
|
45
|
-
const probables =
|
|
46
|
-
const startTime =
|
|
47
|
-
const status =
|
|
48
|
-
const teams =
|
|
49
|
-
const venue =
|
|
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);
|
|
50
30
|
const away = formatTeam(teams, probables, boxscore, 'away');
|
|
51
31
|
const home = formatTeam(teams, probables, boxscore, 'home');
|
|
52
|
-
const formattedStart = status.startTimeTBD ? 'Start time TBD' :
|
|
53
|
-
return /*#__PURE__*/
|
|
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", {
|
|
54
34
|
height: "60%"
|
|
55
|
-
}, /*#__PURE__*/
|
|
35
|
+
}, /*#__PURE__*/React.createElement("box", {
|
|
56
36
|
content: away.join('\n'),
|
|
57
37
|
width: "33%-1",
|
|
58
38
|
top: "50%",
|
|
59
39
|
align: "center"
|
|
60
|
-
}), /*#__PURE__*/
|
|
40
|
+
}), /*#__PURE__*/React.createElement("box", {
|
|
61
41
|
content: `\nvs.\n\n${formattedStart}\n${venue.name}\n${venue.location.city}, ${venue.location.stateAbbrev}`,
|
|
62
42
|
width: "33%-1",
|
|
63
43
|
left: "33%",
|
|
64
44
|
top: "50%",
|
|
65
45
|
align: "center"
|
|
66
|
-
}), /*#__PURE__*/
|
|
46
|
+
}), /*#__PURE__*/React.createElement("box", {
|
|
67
47
|
content: home.join('\n'),
|
|
68
48
|
width: "34%",
|
|
69
49
|
top: "50%",
|
|
@@ -71,6 +51,4 @@ function PreviewGame() {
|
|
|
71
51
|
align: "center"
|
|
72
52
|
})));
|
|
73
53
|
}
|
|
74
|
-
|
|
75
|
-
var _default = PreviewGame;
|
|
76
|
-
exports.default = _default;
|
|
54
|
+
export default PreviewGame;
|
|
@@ -1,45 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
13
|
-
|
|
14
|
-
var _standings = require("../features/standings");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
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";
|
|
22
6
|
function formatHeaderRow(record) {
|
|
23
7
|
return record.division.nameShort.padEnd(15) + ' W' + ' L' + ' PCT' + ' GB' + ' WCGB' + ' L10' + ' STRK';
|
|
24
8
|
}
|
|
25
|
-
|
|
26
9
|
function formatTeamRow(record) {
|
|
27
10
|
const lastTen = record.records.splitRecords.find(o => o.type === 'lastTen');
|
|
28
|
-
|
|
11
|
+
const star = teamFavoriteStar(record.team);
|
|
12
|
+
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.streakCode.padStart(5);
|
|
29
13
|
}
|
|
30
|
-
|
|
31
14
|
function Division({
|
|
32
15
|
record,
|
|
33
16
|
top,
|
|
34
17
|
left,
|
|
35
18
|
width
|
|
36
19
|
}) {
|
|
37
|
-
return /*#__PURE__*/
|
|
20
|
+
return /*#__PURE__*/React.createElement("box", {
|
|
38
21
|
top: top,
|
|
39
22
|
left: left,
|
|
40
23
|
height: 6,
|
|
41
24
|
width: width
|
|
42
|
-
}, /*#__PURE__*/
|
|
25
|
+
}, /*#__PURE__*/React.createElement("box", {
|
|
43
26
|
top: 0,
|
|
44
27
|
left: 0,
|
|
45
28
|
height: 1,
|
|
@@ -47,38 +30,35 @@ function Division({
|
|
|
47
30
|
bg: "white",
|
|
48
31
|
content: formatHeaderRow(record),
|
|
49
32
|
wrap: false
|
|
50
|
-
}), /*#__PURE__*/
|
|
33
|
+
}), /*#__PURE__*/React.createElement("box", {
|
|
51
34
|
top: 1,
|
|
52
35
|
left: 0,
|
|
53
36
|
height: 5,
|
|
54
37
|
content: record.teamRecords.map(formatTeamRow).join('\n'),
|
|
55
|
-
wrap: false
|
|
38
|
+
wrap: false,
|
|
39
|
+
tags: true
|
|
56
40
|
}));
|
|
57
41
|
}
|
|
58
|
-
|
|
59
42
|
Division.propTypes = {
|
|
60
|
-
record:
|
|
61
|
-
top:
|
|
62
|
-
left:
|
|
63
|
-
width:
|
|
43
|
+
record: PropTypes.object,
|
|
44
|
+
top: PropTypes.number,
|
|
45
|
+
left: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
46
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
64
47
|
};
|
|
65
|
-
|
|
66
48
|
function Standings() {
|
|
67
|
-
const dispatch =
|
|
68
|
-
const standings =
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
const dispatch = useDispatch();
|
|
50
|
+
const standings = useSelector(selectData);
|
|
51
|
+
useEffect(() => dispatch(fetchStandings()), []);
|
|
71
52
|
if (!standings) {
|
|
72
|
-
return /*#__PURE__*/
|
|
53
|
+
return /*#__PURE__*/React.createElement("element", null);
|
|
73
54
|
}
|
|
74
|
-
|
|
75
|
-
return /*#__PURE__*/_react.default.createElement("element", null, standings.records.filter(record => record.league.id === 103).map((record, idx) => /*#__PURE__*/_react.default.createElement(Division, {
|
|
55
|
+
return /*#__PURE__*/React.createElement("element", null, standings.records.filter(record => record.league.id === 103).map((record, idx) => /*#__PURE__*/React.createElement(Division, {
|
|
76
56
|
top: idx * 7,
|
|
77
57
|
left: 0,
|
|
78
58
|
width: "50%-1",
|
|
79
59
|
key: record.division.id,
|
|
80
60
|
record: record
|
|
81
|
-
})), standings.records.filter(record => record.league.id === 104).map((record, idx) => /*#__PURE__*/
|
|
61
|
+
})), standings.records.filter(record => record.league.id === 104).map((record, idx) => /*#__PURE__*/React.createElement(Division, {
|
|
82
62
|
top: idx * 7,
|
|
83
63
|
left: "50%+1",
|
|
84
64
|
width: "50%-1",
|
|
@@ -86,6 +66,4 @@ function Standings() {
|
|
|
86
66
|
record: record
|
|
87
67
|
})));
|
|
88
68
|
}
|
|
89
|
-
|
|
90
|
-
var _default = Standings;
|
|
91
|
-
exports.default = _default;
|
|
69
|
+
export default Standings;
|