playball 3.0.0 → 3.1.0
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/.eslintrc.json +1 -1
- package/README.md +62 -0
- package/bin/playball.js +1 -1
- package/package.json +10 -6
- package/src/cli.js +46 -0
- package/src/components/AllPlays.jsx +14 -13
- package/src/components/App.jsx +6 -6
- package/src/components/AtBat.jsx +1 -1
- package/src/components/Bases.jsx +3 -2
- package/src/components/Count.jsx +5 -4
- package/src/components/FinishedGame.jsx +2 -2
- package/src/components/Game.jsx +5 -5
- package/src/components/GameList.jsx +8 -5
- package/src/components/Grid.jsx +1 -1
- package/src/components/HelpBar.jsx +1 -1
- package/src/components/InningDisplay.jsx +1 -1
- package/src/components/LineScore.jsx +1 -1
- package/src/components/LiveGame.jsx +7 -7
- package/src/components/LoadingSpinner.jsx +2 -2
- package/src/components/Matchup.jsx +1 -1
- package/src/components/PreviewGame.jsx +1 -1
- package/src/components/Standings.jsx +6 -3
- package/src/config.js +167 -0
- package/src/features/games.js +2 -1
- package/src/features/keys.js +5 -4
- package/src/features/schedule.js +2 -1
- package/src/features/standings.js +2 -1
- package/src/hooks/useKey.js +1 -1
- package/src/logger.js +4 -1
- package/src/main.js +19 -15
- package/src/package.js +7 -0
- package/src/screen.js +18 -10
- package/src/store/index.js +6 -5
- package/src/utils.js +10 -0
- package/dist/components/AllPlays.js +0 -133
- package/dist/components/App.js +0 -68
- package/dist/components/AtBat.js +0 -67
- package/dist/components/Bases.js +0 -38
- package/dist/components/Count.js +0 -36
- package/dist/components/FinishedGame.js +0 -124
- package/dist/components/Game.js +0 -82
- package/dist/components/GameList.js +0 -222
- package/dist/components/Grid.js +0 -115
- package/dist/components/HelpBar.js +0 -30
- package/dist/components/InningDisplay.js +0 -26
- package/dist/components/LineScore.js +0 -60
- package/dist/components/LiveGame.js +0 -70
- package/dist/components/LoadingSpinner.js +0 -55
- package/dist/components/Matchup.js +0 -58
- package/dist/components/PreviewGame.js +0 -76
- package/dist/components/Standings.js +0 -91
- package/dist/features/games.js +0 -135
- package/dist/features/keys.js +0 -63
- package/dist/features/schedule.js +0 -58
- package/dist/features/standings.js +0 -57
- package/dist/hooks/useKey.js +0 -23
- package/dist/logger.js +0 -22
- package/dist/main.js +0 -28
- package/dist/screen.js +0 -22
- package/dist/store/index.js +0 -32
- package/dist/style/index.js +0 -22
package/src/config.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import pkg from './package.js';
|
|
2
|
+
|
|
3
|
+
import Conf from 'conf';
|
|
4
|
+
|
|
5
|
+
const colorPattern = '^(((light-|bright-)?(black|red|green|yellow|blue|magenta|cyan|white|grey))|default|#([0-9a-fA-F]{3}){1,2})$';
|
|
6
|
+
|
|
7
|
+
const schema = {
|
|
8
|
+
color: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
ball: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
default: 'green',
|
|
14
|
+
pattern: colorPattern,
|
|
15
|
+
},
|
|
16
|
+
strike: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
default: 'red',
|
|
19
|
+
pattern: colorPattern,
|
|
20
|
+
},
|
|
21
|
+
out: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
default: 'red',
|
|
24
|
+
pattern: colorPattern,
|
|
25
|
+
},
|
|
26
|
+
'on-base': {
|
|
27
|
+
type: 'string',
|
|
28
|
+
default: 'yellow',
|
|
29
|
+
pattern: colorPattern,
|
|
30
|
+
},
|
|
31
|
+
'strike-out': {
|
|
32
|
+
type: 'string',
|
|
33
|
+
default: 'red',
|
|
34
|
+
pattern: colorPattern,
|
|
35
|
+
},
|
|
36
|
+
'walk': {
|
|
37
|
+
type: 'string',
|
|
38
|
+
default: 'green',
|
|
39
|
+
pattern: colorPattern,
|
|
40
|
+
},
|
|
41
|
+
'other-event': {
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: 'white',
|
|
44
|
+
pattern: colorPattern,
|
|
45
|
+
},
|
|
46
|
+
'in-play-no-out': {
|
|
47
|
+
type: 'string',
|
|
48
|
+
default: 'blue',
|
|
49
|
+
pattern: colorPattern,
|
|
50
|
+
},
|
|
51
|
+
'in-play-out': {
|
|
52
|
+
type: 'string',
|
|
53
|
+
default: 'white',
|
|
54
|
+
pattern: colorPattern,
|
|
55
|
+
},
|
|
56
|
+
'in-play-runs-bg': {
|
|
57
|
+
type: 'string',
|
|
58
|
+
default: 'white',
|
|
59
|
+
pattern: colorPattern,
|
|
60
|
+
},
|
|
61
|
+
'in-play-runs-fg': {
|
|
62
|
+
type: 'string',
|
|
63
|
+
default: 'black',
|
|
64
|
+
pattern: colorPattern,
|
|
65
|
+
},
|
|
66
|
+
'favorite-star': {
|
|
67
|
+
type: 'string',
|
|
68
|
+
default: 'yellow',
|
|
69
|
+
pattern: colorPattern,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
default: {}
|
|
73
|
+
},
|
|
74
|
+
favorites: {
|
|
75
|
+
type: 'array',
|
|
76
|
+
items: {
|
|
77
|
+
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
|
+
],
|
|
110
|
+
},
|
|
111
|
+
default: []
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const config = new Conf({
|
|
116
|
+
projectName: pkg.name,
|
|
117
|
+
schema,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
function serialize(value) {
|
|
121
|
+
if (value && Array.isArray(value)) {
|
|
122
|
+
return value.join(',');
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function deserialize(key, value) {
|
|
128
|
+
if (value && schema[key]?.type === 'array') {
|
|
129
|
+
return value.split(/\s*,\s*/);
|
|
130
|
+
}
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function get(key) {
|
|
135
|
+
return serialize(config.get(key));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function set(key, value) {
|
|
139
|
+
return config.set(key, deserialize(key, value));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function unset(key) {
|
|
143
|
+
if (key) {
|
|
144
|
+
return config.delete(key);
|
|
145
|
+
} else {
|
|
146
|
+
return config.clear();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function flatten(obj) {
|
|
151
|
+
const result = {};
|
|
152
|
+
for (const [key, value] of Object.entries(obj).sort()) {
|
|
153
|
+
if (value != null && typeof value === 'object' && !Array.isArray(value)) {
|
|
154
|
+
const sub = flatten(value);
|
|
155
|
+
for (const [subkey, subvalue] of Object.entries(sub)) {
|
|
156
|
+
result[key + '.' + subkey] = subvalue;
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
result[key] = serialize(value);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function getAll() {
|
|
166
|
+
return flatten(config.store);
|
|
167
|
+
}
|
package/src/features/games.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import
|
|
2
|
+
import reduxjsToolkit from '@reduxjs/toolkit';
|
|
3
|
+
const { createAsyncThunk, createSlice, createSelector } = reduxjsToolkit;
|
|
3
4
|
import jsonpatch from 'json-patch';
|
|
4
5
|
|
|
5
6
|
const initialState = {
|
package/src/features/keys.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import reduxjsToolkit from '@reduxjs/toolkit';
|
|
2
|
+
const { createSlice } = reduxjsToolkit;
|
|
3
|
+
import screen from '../screen.js';
|
|
3
4
|
|
|
4
5
|
export const keysSlice = createSlice({
|
|
5
6
|
name: 'keys',
|
|
@@ -12,7 +13,7 @@ export const keysSlice = createSlice({
|
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
prepare: (key, listener, help) => {
|
|
15
|
-
screen.key(key, listener);
|
|
16
|
+
screen().key(key, listener);
|
|
16
17
|
return { payload: help };
|
|
17
18
|
}
|
|
18
19
|
},
|
|
@@ -26,7 +27,7 @@ export const keysSlice = createSlice({
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
prepare: (key, listener, help) => {
|
|
29
|
-
screen.unkey(key, listener);
|
|
30
|
+
screen().unkey(key, listener);
|
|
30
31
|
return { payload: help };
|
|
31
32
|
}
|
|
32
33
|
}
|
package/src/features/schedule.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import
|
|
2
|
+
import reduxjsToolkit from '@reduxjs/toolkit';
|
|
3
|
+
const { createAsyncThunk, createSlice, createSelector } = reduxjsToolkit;
|
|
3
4
|
import { format } from 'date-fns';
|
|
4
5
|
|
|
5
6
|
const initialState = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import
|
|
2
|
+
import reduxjsToolkit from '@reduxjs/toolkit';
|
|
3
|
+
const { createAsyncThunk, createSlice, createSelector } = reduxjsToolkit;
|
|
3
4
|
|
|
4
5
|
const initialState = {
|
|
5
6
|
loading: false,
|
package/src/hooks/useKey.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useDispatch } from 'react-redux';
|
|
3
|
-
import { addKeyListener, removeKeyListener } from '../features/keys';
|
|
3
|
+
import { addKeyListener, removeKeyListener } from '../features/keys.js';
|
|
4
4
|
|
|
5
5
|
function useKey(key, handler, help) {
|
|
6
6
|
const dispatch = useDispatch();
|
package/src/logger.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {fileURLToPath} from 'node:url';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
import winston from 'winston';
|
|
3
4
|
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
4
7
|
winston.configure({
|
|
5
8
|
transports: [
|
|
6
9
|
new winston.transports.File({
|
package/src/main.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from 'react-blessed';
|
|
3
2
|
import { Provider } from 'react-redux';
|
|
4
3
|
import raf from 'raf';
|
|
5
4
|
|
|
6
|
-
import screen from './screen';
|
|
7
|
-
import store from './store';
|
|
8
|
-
import log from './logger';
|
|
5
|
+
import screen from './screen.js';
|
|
6
|
+
import store from './store/index.js';
|
|
7
|
+
import log from './logger.js';
|
|
9
8
|
|
|
10
|
-
import App from './components/App';
|
|
9
|
+
import App from './components/App.js';
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
export default async function startInterface() {
|
|
12
|
+
raf.polyfill();
|
|
13
13
|
|
|
14
|
-
process.on('uncaughtException', function(error) {
|
|
15
|
-
|
|
16
|
-
});
|
|
14
|
+
process.on('uncaughtException', function(error) {
|
|
15
|
+
log.error('UNCAUGHT EXCEPTION\n' + JSON.stringify(error) + '\n' + error.stack);
|
|
16
|
+
});
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
// Must be imported dynamically because the import seems to have
|
|
19
|
+
// side effects that block other CLI commands from exiting
|
|
20
|
+
const reactBlessed = await import('react-blessed');
|
|
21
|
+
reactBlessed.render(
|
|
22
|
+
<Provider store={store}>
|
|
23
|
+
<App />
|
|
24
|
+
</Provider>,
|
|
25
|
+
screen()
|
|
26
|
+
);
|
|
27
|
+
}
|
package/src/package.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {fileURLToPath} from 'node:url';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
|
|
5
|
+
const packagePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../package.json');
|
|
6
|
+
|
|
7
|
+
export default JSON.parse(await fs.readFile(packagePath));
|
package/src/screen.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
|
|
2
1
|
import blessed from 'blessed';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
let screen;
|
|
4
|
+
|
|
5
|
+
function getScreen() {
|
|
6
|
+
if (screen === undefined) {
|
|
7
|
+
screen = blessed.screen({
|
|
8
|
+
autoPadding: true,
|
|
9
|
+
debug: true,
|
|
10
|
+
smartCSR: true,
|
|
11
|
+
title: 'Playball!',
|
|
12
|
+
handleUncaughtExceptions: false,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return screen;
|
|
19
|
+
}
|
|
11
20
|
|
|
12
|
-
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
13
21
|
|
|
14
|
-
export default
|
|
22
|
+
export default getScreen;
|
package/src/store/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import reduxjsToolkit from '@reduxjs/toolkit';
|
|
2
|
+
const { configureStore } = reduxjsToolkit;
|
|
2
3
|
|
|
3
|
-
import schedule from '../features/schedule';
|
|
4
|
-
import games from '../features/games';
|
|
5
|
-
import keys from '../features/keys';
|
|
6
|
-
import standings from '../features/standings';
|
|
4
|
+
import schedule from '../features/schedule.js';
|
|
5
|
+
import games from '../features/games.js';
|
|
6
|
+
import keys from '../features/keys.js';
|
|
7
|
+
import standings from '../features/standings.js';
|
|
7
8
|
|
|
8
9
|
export default configureStore({
|
|
9
10
|
reducer: {
|
package/src/utils.js
ADDED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
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
|
-
var _style = _interopRequireDefault(require("../style"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function getPlayResultColor(play) {
|
|
19
|
-
var _play$playEvents;
|
|
20
|
-
|
|
21
|
-
const lastPlay = (_play$playEvents = play.playEvents[play.playEvents.length - 1]) === null || _play$playEvents === void 0 ? void 0 : _play$playEvents.details;
|
|
22
|
-
|
|
23
|
-
if (!lastPlay) {
|
|
24
|
-
return 'white';
|
|
25
|
-
} else if (lastPlay.isBall) {
|
|
26
|
-
return 'green';
|
|
27
|
-
} else if (lastPlay.isStrike) {
|
|
28
|
-
return 'red';
|
|
29
|
-
} else if (lastPlay.isInPlay && !play.about.hasOut) {
|
|
30
|
-
return 'blue';
|
|
31
|
-
} else {
|
|
32
|
-
return 'white';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function formatOut(out) {
|
|
37
|
-
return ` {bold}${out} out{/bold}`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function AllPlays() {
|
|
41
|
-
const plays = (0, _alternateRenderers.useSelector)(_games.selectAllPlays);
|
|
42
|
-
const teams = (0, _alternateRenderers.useSelector)(_games.selectTeams);
|
|
43
|
-
|
|
44
|
-
const formatScoreDetail = scoreObj => ' {bold}{white-bg}{black-fg} ' + `${teams.away.abbreviation} ${scoreObj.awayScore} - ` + `${teams.home.abbreviation} ${scoreObj.homeScore}` + ' {/black-fg}{/white-bg}{/bold}';
|
|
45
|
-
|
|
46
|
-
let inning = '';
|
|
47
|
-
const lines = [];
|
|
48
|
-
plays && plays.slice().reverse().forEach((play, playIdx, plays) => {
|
|
49
|
-
let lastPlay;
|
|
50
|
-
|
|
51
|
-
if (playIdx < plays.length - 1) {
|
|
52
|
-
lastPlay = plays[playIdx + 1];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const playInning = play.about.halfInning + ' ' + play.about.inning;
|
|
56
|
-
|
|
57
|
-
if (playInning !== inning) {
|
|
58
|
-
inning = playInning;
|
|
59
|
-
|
|
60
|
-
if (lines.length > 0) {
|
|
61
|
-
lines.push('');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
lines.push(`{bold}[${inning.toUpperCase()}]{/bold}`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (play.about.isComplete) {
|
|
68
|
-
const color = getPlayResultColor(play);
|
|
69
|
-
let line = `{${color}-fg}[${play.result.event}]{/${color}-fg} ${play.result.description}`;
|
|
70
|
-
|
|
71
|
-
if (play.about.hasOut) {
|
|
72
|
-
const lastOut = play.playEvents[play.playEvents.length - 1].count.outs;
|
|
73
|
-
|
|
74
|
-
if (lastOut !== play.count.outs) {
|
|
75
|
-
line += formatOut(play.count.outs);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (play.about.isScoringPlay) {
|
|
80
|
-
line += formatScoreDetail(play.result);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
lines.push(line);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
play.playEvents && play.playEvents.slice().reverse().forEach((event, eventIdx, events) => {
|
|
87
|
-
if (event.type === 'action') {
|
|
88
|
-
var _event$count;
|
|
89
|
-
|
|
90
|
-
let line = '';
|
|
91
|
-
|
|
92
|
-
if (event.details.event) {
|
|
93
|
-
line += `[${event.details.event}] `;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
line += event.details.description;
|
|
97
|
-
|
|
98
|
-
if (event.isScoringPlay || event.details.isScoringPlay) {
|
|
99
|
-
line += formatScoreDetail(event.details);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const currentOut = (_event$count = event.count) === null || _event$count === void 0 ? void 0 : _event$count.outs;
|
|
103
|
-
let prevOut = lastPlay ? lastPlay.count.outs : 0;
|
|
104
|
-
|
|
105
|
-
if (eventIdx < events.length - 1) {
|
|
106
|
-
var _events$count;
|
|
107
|
-
|
|
108
|
-
prevOut = (_events$count = events[eventIdx + 1].count) === null || _events$count === void 0 ? void 0 : _events$count.outs;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (currentOut > prevOut) {
|
|
112
|
-
line += formatOut(currentOut);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
lines.push(line);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
return /*#__PURE__*/_react.default.createElement("box", {
|
|
120
|
-
content: lines.join('\n'),
|
|
121
|
-
focused: true,
|
|
122
|
-
mouse: true,
|
|
123
|
-
keys: true,
|
|
124
|
-
vi: true,
|
|
125
|
-
scrollable: true,
|
|
126
|
-
scrollbar: _style.default.scrollbar,
|
|
127
|
-
alwaysScroll: true,
|
|
128
|
-
tags: true
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
var _default = AllPlays;
|
|
133
|
-
exports.default = _default;
|
package/dist/components/App.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
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 _GameList = _interopRequireDefault(require("./GameList"));
|
|
13
|
-
|
|
14
|
-
var _HelpBar = _interopRequireDefault(require("./HelpBar"));
|
|
15
|
-
|
|
16
|
-
var _games = require("../features/games");
|
|
17
|
-
|
|
18
|
-
var _Game = _interopRequireDefault(require("./Game"));
|
|
19
|
-
|
|
20
|
-
var _useKey = _interopRequireDefault(require("../hooks/useKey"));
|
|
21
|
-
|
|
22
|
-
var _Standings = _interopRequireDefault(require("./Standings"));
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
|
-
const SCHEDULE = 'schedule';
|
|
31
|
-
const STANDINGS = 'standings';
|
|
32
|
-
const GAME = 'game';
|
|
33
|
-
|
|
34
|
-
function App() {
|
|
35
|
-
const [view, setView] = (0, _react.useState)(SCHEDULE);
|
|
36
|
-
const dispatch = (0, _alternateRenderers.useDispatch)();
|
|
37
|
-
(0, _useKey.default)('c', () => {
|
|
38
|
-
setView(SCHEDULE);
|
|
39
|
-
dispatch((0, _games.setSelectedId)(null));
|
|
40
|
-
}, {
|
|
41
|
-
key: 'C',
|
|
42
|
-
label: 'Schedule'
|
|
43
|
-
});
|
|
44
|
-
(0, _useKey.default)('s', () => setView(STANDINGS), {
|
|
45
|
-
key: 'S',
|
|
46
|
-
label: 'Standings'
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const handleGameSelect = game => {
|
|
50
|
-
dispatch((0, _games.setSelectedId)(game.gamePk));
|
|
51
|
-
setView(GAME);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return /*#__PURE__*/_react.default.createElement("element", null, /*#__PURE__*/_react.default.createElement("element", {
|
|
55
|
-
top: 0,
|
|
56
|
-
left: 0,
|
|
57
|
-
height: "100%-1"
|
|
58
|
-
}, view === STANDINGS && /*#__PURE__*/_react.default.createElement(_Standings.default, null), view === SCHEDULE && /*#__PURE__*/_react.default.createElement(_GameList.default, {
|
|
59
|
-
onGameSelect: handleGameSelect
|
|
60
|
-
}), view === GAME && /*#__PURE__*/_react.default.createElement(_Game.default, null)), /*#__PURE__*/_react.default.createElement("element", {
|
|
61
|
-
top: "100%-1",
|
|
62
|
-
left: 0,
|
|
63
|
-
height: 1
|
|
64
|
-
}, /*#__PURE__*/_react.default.createElement(_HelpBar.default, null)));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
var _default = App;
|
|
68
|
-
exports.default = _default;
|
package/dist/components/AtBat.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
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
|
-
|
|
16
|
-
function AtBat() {
|
|
17
|
-
const currentPlay = (0, _alternateRenderers.useSelector)(_games.selectCurrentPlay);
|
|
18
|
-
const playEvents = currentPlay.playEvents;
|
|
19
|
-
const playResult = currentPlay.about.isComplete ? currentPlay.result.description : '';
|
|
20
|
-
let content = '';
|
|
21
|
-
|
|
22
|
-
if (playResult) {
|
|
23
|
-
content += `${playResult}\n\n`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (playEvents && playEvents.length) {
|
|
27
|
-
content += playEvents.slice().reverse().map(event => {
|
|
28
|
-
let line = '';
|
|
29
|
-
|
|
30
|
-
if (event.isPitch) {
|
|
31
|
-
var _event$pitchData, _event$details, _event$details$type, _event$details2;
|
|
32
|
-
|
|
33
|
-
line = `[${event.details.description}] `;
|
|
34
|
-
|
|
35
|
-
if ((_event$pitchData = event.pitchData) !== null && _event$pitchData !== void 0 && _event$pitchData.startSpeed) {
|
|
36
|
-
line += `${event.pitchData.startSpeed} MPH `;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if ((_event$details = event.details) !== null && _event$details !== void 0 && (_event$details$type = _event$details.type) !== null && _event$details$type !== void 0 && _event$details$type.description) {
|
|
40
|
-
line += event.details.type.description;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!((_event$details2 = event.details) !== null && _event$details2 !== void 0 && _event$details2.isInPlay)) {
|
|
44
|
-
line += `{|} ${event.count.balls}-${event.count.strikes}`;
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
var _event$details3;
|
|
48
|
-
|
|
49
|
-
if ((_event$details3 = event.details) !== null && _event$details3 !== void 0 && _event$details3.event) {
|
|
50
|
-
line += `[${event.details.event}] `;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
line += event.details.description;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return line;
|
|
57
|
-
}).join('\n');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return /*#__PURE__*/_react.default.createElement("box", {
|
|
61
|
-
content: content,
|
|
62
|
-
tags: true
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var _default = AtBat;
|
|
67
|
-
exports.default = _default;
|
package/dist/components/Bases.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
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 _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _games = require("../features/games");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const formatBase = (offense, base) => base in offense ? '{yellow-fg}◆{/yellow-fg}' : '◇';
|
|
19
|
-
|
|
20
|
-
function Bases({
|
|
21
|
-
align
|
|
22
|
-
}) {
|
|
23
|
-
const {
|
|
24
|
-
offense
|
|
25
|
-
} = (0, _alternateRenderers.useSelector)(_games.selectLineScore);
|
|
26
|
-
const content = ` ${formatBase(offense, 'second')}\n` + `${formatBase(offense, 'third')} ${formatBase(offense, 'first')}`;
|
|
27
|
-
return /*#__PURE__*/_react.default.createElement("box", {
|
|
28
|
-
align: align,
|
|
29
|
-
content: content,
|
|
30
|
-
tags: true
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Bases.propTypes = {
|
|
35
|
-
align: _propTypes.default.oneOf(['left', 'center', 'right'])
|
|
36
|
-
};
|
|
37
|
-
var _default = Bases;
|
|
38
|
-
exports.default = _default;
|