playball 2.2.2 → 3.0.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.
Files changed (74) hide show
  1. package/.eslintrc.json +2 -2
  2. package/README.md +18 -4
  3. package/demo.cast +95 -0
  4. package/demo.gif +0 -0
  5. package/dist/components/AllPlays.js +94 -93
  6. package/dist/components/App.js +45 -117
  7. package/dist/components/AtBat.js +44 -43
  8. package/dist/components/Bases.js +17 -26
  9. package/dist/components/Count.js +15 -26
  10. package/dist/components/FinishedGame.js +51 -66
  11. package/dist/components/Game.js +51 -114
  12. package/dist/components/GameList.js +161 -135
  13. package/dist/components/Grid.js +115 -0
  14. package/dist/components/HelpBar.js +13 -6
  15. package/dist/components/InningDisplay.js +26 -0
  16. package/dist/components/LineScore.js +32 -90
  17. package/dist/components/LiveGame.js +24 -19
  18. package/dist/components/LoadingSpinner.js +34 -125
  19. package/dist/components/Matchup.js +38 -59
  20. package/dist/components/PreviewGame.js +34 -55
  21. package/dist/components/Standings.js +91 -0
  22. package/dist/features/games.js +135 -0
  23. package/dist/features/keys.js +63 -0
  24. package/dist/features/schedule.js +58 -0
  25. package/dist/features/standings.js +57 -0
  26. package/dist/hooks/useKey.js +23 -0
  27. package/dist/logger.js +8 -10
  28. package/dist/main.js +13 -23
  29. package/dist/screen.js +22 -0
  30. package/dist/store/index.js +21 -7
  31. package/dist/style/index.js +3 -3
  32. package/package.json +44 -26
  33. package/src/components/AllPlays.jsx +95 -63
  34. package/src/components/App.jsx +38 -66
  35. package/src/components/AtBat.jsx +34 -36
  36. package/src/components/Bases.jsx +8 -13
  37. package/src/components/Count.jsx +10 -15
  38. package/src/components/FinishedGame.jsx +29 -40
  39. package/src/components/Game.jsx +48 -65
  40. package/src/components/GameList.jsx +125 -81
  41. package/src/components/Grid.jsx +91 -0
  42. package/src/components/HelpBar.jsx +14 -9
  43. package/src/components/InningDisplay.jsx +19 -0
  44. package/src/components/LineScore.jsx +27 -33
  45. package/src/components/LiveGame.jsx +7 -3
  46. package/src/components/LoadingSpinner.jsx +26 -60
  47. package/src/components/Matchup.jsx +26 -39
  48. package/src/components/PreviewGame.jsx +22 -37
  49. package/src/components/Standings.jsx +78 -0
  50. package/src/features/games.js +165 -0
  51. package/src/features/keys.js +38 -0
  52. package/src/features/schedule.js +59 -0
  53. package/src/features/standings.js +60 -0
  54. package/src/hooks/useKey.js +13 -0
  55. package/src/main.js +7 -14
  56. package/src/screen.js +14 -0
  57. package/src/store/index.js +16 -7
  58. package/src/style/index.js +1 -1
  59. package/dist/actions/game.js +0 -36
  60. package/dist/actions/schedule.js +0 -33
  61. package/dist/actions/types.js +0 -16
  62. package/dist/reducers/game.js +0 -70
  63. package/dist/reducers/index.js +0 -21
  64. package/dist/reducers/schedule.js +0 -35
  65. package/dist/selectors/game.js +0 -82
  66. package/dist/selectors/schedule.js +0 -25
  67. package/src/actions/game.js +0 -25
  68. package/src/actions/schedule.js +0 -21
  69. package/src/actions/types.js +0 -5
  70. package/src/reducers/game.js +0 -56
  71. package/src/reducers/index.js +0 -9
  72. package/src/reducers/schedule.js +0 -28
  73. package/src/selectors/game.js +0 -93
  74. package/src/selectors/schedule.js +0 -18
package/.eslintrc.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ecmaFeatures": {
12
12
  "jsx": true
13
13
  },
14
- "ecmaVersion": 2018,
14
+ "ecmaVersion": 2020,
15
15
  "sourceType": "module"
16
16
  },
17
17
  "plugins": [
@@ -27,7 +27,7 @@
27
27
  "settings": {
28
28
  "react": {
29
29
  "pragma": "React",
30
- "version": "16.5.0"
30
+ "version": "17.0.2"
31
31
  }
32
32
  }
33
33
  }
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ## Playball!
2
2
  Watch MLB games from the comfort of your own terminal
3
3
 
4
- ![screenshot](https://i.imgur.com/SdA4fWR.gif)
4
+ ![screenshot](./demo.gif)
5
5
 
6
6
  ### Why?
7
7
  [MLB Gameday](http://www.mlb.com/mlb/gameday/#) and [MLB.tv](http://mlb.tv) are
@@ -25,12 +25,26 @@ $ playball
25
25
  ```
26
26
 
27
27
  ### Keys
28
+ #### Global
28
29
  key | action
29
30
  ----|--------
30
31
  <kbd>q</kbd> | quit
31
- <kbd>&darr;</kbd> / <kbd>j</kbd>, <kbd>&uarr;</kbd> / <kbd>k</kbd> | change highlighted game in list; scroll list of plays in game
32
- <kbd>enter</kbd> | view highlighted game in list
33
- <kbd>l</kbd> | return to list of games
32
+ <kbd>c</kbd> | go to schedule view
33
+ <kbd>s</kbd> | go to standings view
34
+
35
+ #### Schedule View
36
+ key | action
37
+ ----|--------
38
+ <kbd>&darr;</kbd>/<kbd>j</kbd>, <kbd>&uarr;</kbd>/<kbd>k</kbd>, <kbd>&larr;</kbd>/<kbd>h</kbd>, <kbd>&rarr;</kbd>/<kbd>l</kbd> | change highlighted game
39
+ <kbd>enter</kbd> | view highlighted game
40
+ <kbd>p</kbd> | show previous day's schedule/results
41
+ <kbd>n</kbd> | show next day's schedule
42
+ <kbd>t</kbd> | return to today's schedule
43
+
44
+ #### Game View
45
+ key | action
46
+ ----|--------
47
+ <kbd>&darr;</kbd>/<kbd>j</kbd>, <kbd>&uarr;</kbd>/<kbd>k</kbd> | scroll list of all plays
34
48
 
35
49
  ### Development
36
50
  ```
package/demo.cast ADDED
@@ -0,0 +1,95 @@
1
+ {"version": 2, "width": 118, "height": 36, "timestamp": 1654987630, "idle_time_limit": 2.0, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}}
2
+ [0.159133, "o", "$ "]
3
+ [1.331166, "o", "p"]
4
+ [1.412778, "o", "l"]
5
+ [1.564842, "o", "a"]
6
+ [1.772299, "o", "y"]
7
+ [2.035449, "o", "b"]
8
+ [2.160659, "o", "a"]
9
+ [2.261186, "o", "l"]
10
+ [2.413437, "o", "l"]
11
+ [2.627466, "o", "\r\n"]
12
+ [3.043377, "o", "\u001b]0;Playball!\u0007\u001b[?1049h\u001b[?1h\u001b=\u001b[1;36r\u001b[?25l\u001b[1;1H\u001b[H\u001b[2J\u001b[?1002h\u001b[?1003h\u001b[?1006h"]
13
+ [3.068237, "o", "\u001b7\u001b[1;1H\u001b[47;30m Saturday, June 11th, 2022 \u001b[m\u001b[19;1H\u001b[54CLoading...\u001b[36;1H\u001b[36;1H⠙\u001b[2C\u001b[7mQ\u001b[m:Quit\u001b[2C\u001b[7mC\u001b[m:Schedule\u001b[2C\u001b[7mS\u001b[m:Standings\u001b[2C\u001b[7mP\u001b[m:Prev\u001b[1CDay\u001b[2C\u001b[7mN\u001b[m:Next\u001b[1CDay\u001b[2C\u001b[7mT\u001b[m:Today\u001b8"]
14
+ [3.117385, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠹\u001b8"]
15
+ [3.167954, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠸\u001b8"]
16
+ [3.215288, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠼\u001b8"]
17
+ [3.297623, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠴\u001b8"]
18
+ [3.31866, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠦\u001b8"]
19
+ [3.40441, "o", "\u001b7\u001b[3;1H\u001b[3;1H\u001b(0lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk\u001b[4;1H\u001b[4;1Hx\u001b[1C\u001b(BTop\u001b[1C9th\u001b[14CH\u001b[2CR\u001b[2CE\u001b[8C\u001b(0x\u001b[2C\u001b(BTop\u001b[1C9th\u001b[14CH\u001b[2CR\u001b[2CE\u001b[11CBottom\u001b[1C8th\u001b[11CH\u001b[2CR\u001b[2CE\u001b[5;1H\u001b[5;1H\u001b(0x\u001b[1C\u001b(BRockies\u001b[1C(25-33)\u001b[6C1\u001b[2C8\u001b[2C0\u001b[8C\u001b(0x\u001b[2C\u001b(BPirates\u001b[1C(24-32)\u001b[6C4\u001b[2C6\u001b[2C2\u001b[11CD-backs\u001b[1C(28-32)\u001b[6C0\u001b[2C4\u001b[2C1\u001b[6;1H\u001b[6;1H\u001b(0x\u001b[1C\u001b(BPadres\u001b[1C(36-22)\u001b[7C1\u001b[2C3\u001b[2C0\u001b[8C\u001b(0x\u001b[2C\u001b(BBraves\u001b[1C(32-27)\u001b[6C10\u001b[2C8\u001b[2C0\u001b[11CPhillies\u001b[1C(29-29)\u001b[5C4\u001b[2C9\u001b[2C0\u001b[7;1H\u001b[7;1H\u001b(0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj\u001b[9;1H\u001b[9;3H\u001b(BTop\u001b[1C8th\u001b[14CH\u001b[2CR\u001b[2CE\u001b[11CBottom\u001b[1C8th\u001b[11CH\u001b[2CR\u001b[2CE\u001b[11CTop\u001b[1C8th\u001b[14CH\u001b[2CR\u001b[2CE\u001b[10;1H\u001b[10;3HBrewers\u001b[1C(33-27)\u001b[6C4\u001b[2C9\u001b[2C1\u001b[11COrioles\u001b[1C(24-35)\u001b[6C6\u001b[1C10\u001b[2C0\u001b[11CAthletics\u001b[1C(20-40)\u001b[4C8\u001b[1C11\u001b[2C1\u001b[11;1H\u001b[11;3HNationals\u001b[1C(22-38)\u001b[4C8\u001b[2C9\u001b[2C1\u001b[11CRoyals\u001b[1C(20-37)\u001b[7C3\u001b[2C6\u001b[2C1\u001b[11CGuardians\u001b[1C(28-26)\u001b[4C5\u001b[2C8\u001b[2C1\u001b[14;1H\u001b[14;3HBottom\u001b[1C8th\u001b[11CH\u001b[2CR\u001b[2CE\u001b[11CTop\u001b[1C8th\u001b[14CH\u001b[2CR\u001b[2CE\u001b[11C7:10\u001b[1CPM\u001b[15;1H\u001b[15;3HBlue\u001b[1CJays\u001b[1C(34-23)\u001b[4C0\u001b[2C7\u001b[2C1\u001b[11CMarl"]
20
+ [3.404479, "o", "ins\u001b[1C(26-30)\u001b[6C4\u001b[2C4\u001b[2C2\u001b[11CRockies\u001b[1C(25-33)\u001b[16;1H\u001b[16;3HTigers\u001b[1C(23-34)\u001b[7C3\u001b[2C8\u001b[2C1\u001b[11CAstros\u001b[1C(36-22)\u001b[7C1\u001b[2C7\u001b[2C1\u001b[11CPadres\u001b[1C(36-22)\u001b[19;1H\u001b[19;3H4:15\u001b[1CPM\u001b[32C4:15\u001b[1CPM\u001b[6C \u001b[16C7:07\u001b[1CPM\u001b[20;1H\u001b[20;3HDodgers\u001b[1C(37-21)\u001b[24CCubs\u001b[1C(23-34)\u001b[27CMets\u001b[1C(39-21)\u001b[21;1H\u001b[21;3HGiants\u001b[1C(31-26)\u001b[25CYankees\u001b[1C(42-16)\u001b[24CAngels\u001b[1C(28-32)\u001b[24;1H\u001b[24;3H7:10\u001b[1CPM\u001b[32CFinal\u001b[16CH\u001b[2CR\u001b[2CE\u001b[11CFinal/10\u001b[13CH\u001b[2CR\u001b[2CE\u001b[25;1H\u001b[25;3HRed\u001b[1CSox\u001b[1C(31-28)\u001b[24CRays\u001b[1C(34-25)\u001b[9C5\u001b[1C13\u001b[2C0\u001b[11C\u001b[1mRangers (27-31) 11 15 1\u001b[m\u001b[26;1H\u001b[26;3HMariners\u001b[1C(26-32)\u001b[23C\u001b[1mTwins (35-26) 6 11 2\u001b[11C\u001b[mWhite\u001b[1CSox\u001b[1C(27-30)\u001b[4C9\u001b[1C15\u001b[2C2\u001b[29;1H\u001b[29;3HFinal\u001b[16CH\u001b[2CR\u001b[2CE\u001b[30;1H\u001b[30;3HReds\u001b[1C(20-39)\u001b[9C4\u001b[1C12\u001b[2C2\u001b[31;1H\u001b[31;3H\u001b[1mCardinals (34-26) 5 7 0\u001b[m\u001b[36;1H\u001b[36;1H⠧\u001b8"]
21
+ [3.441761, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠇\u001b8"]
22
+ [3.513144, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠏\u001b8"]
23
+ [3.545197, "o", "\u001b7\u001b[36;1H\u001b[36;1H \u001b8"]
24
+ [5.677285, "o", "\u001b7\u001b[3;1H\u001b[3;1H \u001b(0lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk\u001b[4;1H\u001b[4;1H\u001b(B \u001b[37C \u001b(0x\u001b[37Cx\u001b[5;1H\u001b[5;1H\u001b(B \u001b[37C \u001b(0x\u001b[37Cx\u001b[6;1H\u001b[6;1H\u001b(B \u001b[37C \u001b(0x\u001b[37Cx\u001b[7;1H\u001b[7;1H\u001b(B \u001b(0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj\u001b(B\u001b8"]
25
+ [5.845659, "o", "\u001b7\u001b[3;1H\u001b[3;40H \u001b(0lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk\u001b[4;1H\u001b[4;40H\u001b(B \u001b[37C \u001b(0x\u001b[37Cx\u001b[5;1H\u001b[5;40H\u001b(B \u001b[37C \u001b(0x\u001b[37Cx\u001b[6;1H\u001b[6;40H\u001b(B \u001b[37C \u001b(0x\u001b[37Cx\u001b[7;1H\u001b[7;40H\u001b(B \u001b(0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj\u001b(B\u001b8"]
26
+ [7.016135, "o", "\u001b7\u001b[1;1H \u001b[3;1H\u001b[78C \u001b[4;1H\u001b[4;3H \u001b[1C \u001b[14C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[14C \u001b[2C \u001b[2C \u001b[9C \u001b[1C \u001b[1C \u001b[11C \u001b[2C \u001b[2C \u001b[8C \u001b[5;1H\u001b[5;3H \u001b[1C \u001b[6C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[6C \u001b[2C \u001b[2C \u001b[9C \u001b[1C \u001b[1C \u001b[6C \u001b[2C \u001b[2C \u001b[8C \u001b[6;1H\u001b[6;3H \u001b[1C \u001b[7C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[6C \u001b[2C \u001b[2C \u001b[9C \u001b[1C \u001b[1C \u001b[5C \u001b[2C \u001b[2C \u001b[8C \u001b[7;1H\u001b[7;79H \u001b[9;1H\u001b[9;3H \u001b[1C \u001b[14C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[11C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[14C \u001b[2C \u001b[2C \u001b[10;1H\u001b[10;3H \u001b[1C \u001b[6C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[6C \u001b[1C \u001b[2C \u001b[11C \u001b[1C \u001b[4C \u001b[1C \u001b[2C \u001b[11;1H\u001b[11;3H \u001b[1C \u001b[4C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[7C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[4C \u001b[2C \u001b[2C \u001b[14;1H\u001b[14;3H \u001b[1C \u001b[11C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[14C \u001b[2C"]
27
+ [7.016312, "o", " \u001b[2C \u001b[11C \u001b[1C \u001b[15;1H\u001b[15;3H \u001b[1C \u001b[1C \u001b[4C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[6C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[16;1H\u001b[16;3H \u001b[1C \u001b[7C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[7C \u001b[2C \u001b[2C \u001b[11C \u001b[1C \u001b[19;1H\u001b[19;3H \u001b[1C \u001b[32C \u001b[1C \u001b[32C \u001b[1C \u001b[20;1H\u001b[20;3H \u001b[1C \u001b[24C \u001b[1C \u001b[27C \u001b[1C \u001b[21;1H\u001b[21;3H \u001b[1C \u001b[25C \u001b[1C \u001b[24C \u001b[1C \u001b[24;1H\u001b[24;3H \u001b[1C \u001b[32C \u001b[16C \u001b[2C \u001b[2C \u001b[11C \u001b[13C \u001b[2C \u001b[2C \u001b[25;1H\u001b[25;3H \u001b[1C \u001b[1C \u001b[24C \u001b[1C \u001b[9C \u001b[1C \u001b[2C \u001b[11C \u001b[26;1H\u001b[26;3H \u001b[1C \u001b[23C \u001b[11C \u001b[1C \u001b[1C \u001b[4C \u001b[1C \u001b[2C \u001b[29;1H\u001b[29;3H \u001b[16C \u001b[2C \u001b[2C \u001b[30;1H\u001b[30;3H \u001b[1C \u001b[9C \u001b[1C \u001b[2C \u001b[31;1H\u001b[31;3H \u001b[36;1H\u001b[36;1H⠙\u001b[35C \u001b[1C \u001b[2C \u001b[1C \u001b[2C \u001b8"]
28
+ [7.069271, "o", "\u001b7\u001b[36;1H⠹\u001b8"]
29
+ [7.120474, "o", "\u001b7\u001b[36;1H⠸\u001b8"]
30
+ [7.169237, "o", "\u001b7\u001b[36;1H⠼\u001b8"]
31
+ [7.220735, "o", "\u001b7\u001b[36;1H⠴\u001b8"]
32
+ [7.270481, "o", "\u001b7\u001b[36;1H⠦\u001b8"]
33
+ [7.320113, "o", "\u001b7\u001b[36;1H⠧\u001b8"]
34
+ [7.370402, "o", "\u001b7\u001b[36;1H⠇\u001b8"]
35
+ [7.419372, "o", "\u001b7\u001b[36;1H⠏\u001b8"]
36
+ [7.469781, "o", "\u001b7\u001b[36;1H⠋\u001b8"]
37
+ [7.520863, "o", "\u001b7\u001b[36;1H⠙\u001b8"]
38
+ [7.571275, "o", "\u001b7\u001b[36;1H⠹\u001b8"]
39
+ [7.626738, "o", "\u001b7\u001b[36;1H⠸\u001b8"]
40
+ [7.669718, "o", "\u001b7\u001b[36;1H⠼\u001b8"]
41
+ [7.721801, "o", "\u001b7\u001b[36;1H⠴\u001b8"]
42
+ [7.7709, "o", "\u001b7\u001b[36;1H⠦\u001b8"]
43
+ [7.821713, "o", "\u001b7\u001b[36;1H⠧\u001b8"]
44
+ [7.873451, "o", "\u001b7\u001b[36;1H⠇\u001b8"]
45
+ [7.922679, "o", "\u001b7\u001b[36;1H⠏\u001b8"]
46
+ [7.972914, "o", "\u001b7\u001b[36;1H⠋\u001b8"]
47
+ [8.022984, "o", "\u001b7\u001b[36;1H⠙\u001b8"]
48
+ [8.072782, "o", "\u001b7\u001b[36;1H⠹\u001b8"]
49
+ [8.122838, "o", "\u001b7\u001b[36;1H⠸\u001b8"]
50
+ [8.17296, "o", "\u001b7\u001b[36;1H⠼\u001b8"]
51
+ [8.222793, "o", "\u001b7\u001b[36;1H⠴\u001b8"]
52
+ [8.272494, "o", "\u001b7\u001b[36;1H⠦\u001b8"]
53
+ [8.324117, "o", "\u001b7\u001b[36;1H⠧\u001b8"]
54
+ [8.375222, "o", "\u001b7\u001b[36;1H⠇\u001b8"]
55
+ [8.423489, "o", "\u001b7\u001b[36;1H⠏\u001b8"]
56
+ [8.471642, "o", "\u001b7\u001b[36;1H⠋\u001b8"]
57
+ [8.522495, "o", "\u001b7\u001b[36;1H⠙\u001b8"]
58
+ [8.572956, "o", "\u001b7\u001b[36;1H⠹\u001b8"]
59
+ [8.62592, "o", "\u001b7\u001b[36;1H⠸\u001b8"]
60
+ [8.675946, "o", "\u001b7\u001b[36;1H⠼\u001b8"]
61
+ [8.726318, "o", "\u001b7\u001b[36;1H⠴\u001b8"]
62
+ [8.863595, "o", "\u001b7\u001b[1;1H\u001b[6CB:\u001b[1C\u001b[32m● ○ ○ ○ \u001b[16C\u001b[m\u001b[33m\u001b(0`\u001b[31C\u001b[m\u001b(B1\u001b[2C2\u001b[2C3\u001b[2C4\u001b[2C5\u001b[2C6\u001b[2C7\u001b[2C8\u001b[2C9\u001b[3C\u001b[1mR\u001b[2C\u001b[mH\u001b[2CE\u001b[2;1H\u001b[2;3H8\u001b[3CS:\u001b[1C\u001b[31m● ○ ○ \u001b[16C\u001b[m◇\u001b[3C◇\u001b[25CARI\u001b[1C0\u001b[2C0\u001b[2C0\u001b[2C0\u001b[2C0\u001b[2C0\u001b[2C0\u001b[2C0\u001b[4C\u001b[1m 0\u001b[2C\u001b[m4\u001b[2C1\u001b[3;1H\u001b[3;3H▼\u001b[3CO:\u001b[1C\u001b[31m○ ○ ○ \u001b[46C\u001b[mPHI\u001b[1C1\u001b[2C2\u001b[2C0\u001b[2C0\u001b[2C0\u001b[2C0\u001b[2C0\u001b[2C1\u001b[4C\u001b[1m 4\u001b[2C\u001b[m9\u001b[2C0\u001b[4;1H\u001b[4;1H\u001b(0qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\u001b[5;1H\u001b[1C\u001b(BARI\u001b[1CPitching:\u001b[1C\u001b[1mCaleb Smith\u001b[1C\u001b[m1.0\u001b[1CIP,\u001b[1C17\u001b[1CP,\u001b[1C5.81\u001b[1CERA\u001b[10C\u001b(0x\u001b[1C\u001b[1m\u001b(B[BOTTOM 8]\u001b[45C\u001b[m\u001b[7;37m \u001b[m\u001b[6;1H\u001b[6;2HPHI\u001b[1CAt\u001b[1CBat:\u001b[3C\u001b[1mJ.T. Realmuto\u001b[1C\u001b[m0-2,\u001b[1C.239\u001b[1CAVG,\u001b[1C3\u001b[1CHR\u001b[11C\u001b(0x\u001b[1C\u001b[34m\u001b(B[Double]\u001b[1C\u001b[mNick\u001b[1CCastellanos\u001b[1Cdoubles\u001b[1C(14)\u001b[1Con\u001b[1Ca\u001b[1Cline\u001b[1Cdrive\u001b[7;1H\u001b[7;60H\u001b(0x\u001b[1C\u001b(Bto\u001b[1Cright\u001b[1Cfielder\u001b[1CJordan\u001b[1CLuplow.\u001b[3CBryce\u001b[1CHarper\u001b[1Cscores.\u001b[8;1H\u001b[8;2H[Ball]\u001b[1C92.3\u001b[1CMPH\u001b[1CFour-Seam\u001b[1CFastball\u001b[20C1-1\u001b[1C\u001b(0x\u001b[1C\u001b[1;47;3"]
63
+ [8.863739, "o", "0m\u001b(B ARI 0 - PHI 4 \u001b[m\u001b[9;1H\u001b[9;2H[Swinging\u001b[1CStrike]\u001b[1C82.9\u001b[1CMPH\u001b[1CChangeup\u001b[19C0-1\u001b[1C\u001b(0x\u001b[1C\u001b[34m\u001b(B[Single]\u001b[1C\u001b[mBryce\u001b[1CHarper\u001b[1Csingles\u001b[1Con\u001b[1Ca\u001b[1Cground\u001b[1Cball\u001b[1Cto\u001b[10;1H\u001b[10;60H\u001b(0x\u001b[1C\u001b(Bcenter\u001b[1Cfielder\u001b[1CAlek\u001b[1CThomas.\u001b[11;1H\u001b[11;60H\u001b(0x\u001b[1C\u001b(B[Defensive\u001b[1CSwitch]\u001b[1CCarson\u001b[1CKelly\u001b[1Cremains\u001b[1Cin\u001b[1Cthe\u001b[1Cgame\u001b[1Cas\u001b[12;1H\u001b[12;60H\u001b(0x\u001b[1C\u001b(Bthe\u001b[1Ccatcher.\u001b[13;1H\u001b[13;60H\u001b(0x\u001b[1C\u001b(B[Defensive\u001b[1CSwitch]\u001b[1CJordan\u001b[1CLuplow\u001b[1Cremains\u001b[1Cin\u001b[1Cthe\u001b[1Cgame\u001b[14;1H\u001b[14;60H\u001b(0x\u001b[1C\u001b(Bas\u001b[1Cthe\u001b[1Cright\u001b[1Cfielder.\u001b[15;1H\u001b[15;60H\u001b(0x\u001b[16;1H\u001b[16;60Hx\u001b[1C\u001b[1m\u001b(B[TOP 8]\u001b[m\u001b[17;1H\u001b[17;60H\u001b(0x\u001b[1C\u001b[37m\u001b(B[Pop Out]\u001b[1C\u001b[mJordan\u001b[1CLuplow\u001b[1Cpops\u001b[1Cout\u001b[1Cto\u001b[1Ccatcher\u001b[1CJ.\u001b[2CT.\u001b[18;1H\u001b[18;60H\u001b(0x\u001b[1C\u001b(BRealmuto\u001b[1Cin\u001b[1Cfoul\u001b[1Cterritory.\u001b[1C\u001b[1m3 out\u001b[m\u001b[19;1H\u001b[19;60H\u001b(0x\u001b[1C\u001b(B[Offensive\u001b[1CSubstitution]\u001b[1COffensive\u001b[1CSubstitution:\u001b[20;1H\u001b[20;60H\u001b(0x\u001b[1C\u001b(BPinch-hitter\u001b[1CJordan\u001b[1CLuplow\u001b[1Creplaces\u001b[1CPavin\u001b[1CSmith.\u001b[21;1H\u001b[21;60H\u001b(0x\u001b[1C\u001b[31m\u001b(B[Strikeout]\u001b[1C\u001b[mDaulton\u001b[1CVar"]
64
+ [8.863817, "o", "sho\u001b[1Ccalled\u001b[1Cout\u001b[1Con\u001b[1Cstrikes.\u001b[1C\u001b[1m2 \u001b[m\u001b[22;1H\u001b[22;60H\u001b(0x\u001b[1C\u001b[1m\u001b(Bout\u001b[m\u001b[23;1H\u001b[23;60H\u001b(0x\u001b[1C\u001b[37m\u001b(B[Flyout]\u001b[1C\u001b[mCarson\u001b[1CKelly\u001b[1Cflies\u001b[1Cout\u001b[1Cto\u001b[1Cright\u001b[1Cfielder\u001b[1CNick\u001b[24;1H\u001b[24;60H\u001b(0x\u001b[1C\u001b(BCastellanos.\u001b[1C\u001b[1m1 out\u001b[m\u001b[25;1H\u001b[25;60H\u001b(0x\u001b[1C\u001b(B[Offensive\u001b[1CSubstitution]\u001b[1COffensive\u001b[1CSubstitution:\u001b[26;1H\u001b[26;60H\u001b(0x\u001b[1C\u001b(BPinch-hitter\u001b[1CCarson\u001b[1CKelly\u001b[1Creplaces\u001b[1CJose\u001b[1CHerrera.\u001b[27;1H\u001b[27;60H\u001b(0x\u001b[1C\u001b(B[Pitching\u001b[1CSubstitution]\u001b[1CPitching\u001b[1CChange:\u001b[1CBrad\u001b[1CHand\u001b[28;1H\u001b[28;60H\u001b(0x\u001b[1C\u001b(Breplaces\u001b[1CAndrew\u001b[1CBellatti.\u001b[29;1H\u001b[29;60H\u001b(0x\u001b[30;1H\u001b[30;60Hx\u001b[1C\u001b[1m\u001b(B[BOTTOM 7]\u001b[m\u001b[31;1H\u001b[31;60H\u001b(0x\u001b[1C\u001b[37m\u001b(B[Flyout]\u001b[1C\u001b[mRhys\u001b[1CHoskins\u001b[1Cflies\u001b[1Cout\u001b[1Cto\u001b[1Cleft\u001b[1Cfielder\u001b[1CDavid\u001b[32;1H\u001b[32;60H\u001b(0x\u001b[1C\u001b(BPeralta.\u001b[1C\u001b[1m3 out\u001b[m\u001b[33;1H\u001b[33;60H\u001b(0x\u001b[1C\u001b[37m\u001b(B[Flyout]\u001b[1C\u001b[mKyle\u001b[1CSchwarber\u001b[1Cflies\u001b[1Cout\u001b[1Cto\u001b[1Cleft\u001b[1Cfielder\u001b[34;1H\u001b[34;60H\u001b(0x\u001b[1C\u001b(BDavid\u001b[1CPeralta.\u001b[1C\u001b[1m2 out\u001b[m\u001b[35;1H\u001b[35;60H\u001b(0x\u001b[1C\u001b[37m\u001b(B[Flyout]\u001b[1C\u001b[mBryson\u001b[1CStott\u001b[1C"]
65
+ [8.863918, "o", "flies\u001b[1Cout\u001b[1Cto\u001b[1Cleft\u001b[1Cfielder\u001b[1CDavid\u001b[36;1H\u001b[36;1H⠧\u001b8"]
66
+ [8.924124, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠇\u001b8"]
67
+ [8.9612, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠏\u001b8"]
68
+ [9.007753, "o", "\u001b7\u001b[36;1H\u001b[36;1H \u001b8"]
69
+ [12.88646, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠙\u001b8"]
70
+ [12.926627, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠹\u001b8"]
71
+ [12.963286, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠸\u001b8"]
72
+ [13.012915, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠼\u001b8"]
73
+ [13.067279, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠴\u001b8"]
74
+ [13.120957, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠦\u001b8"]
75
+ [13.166379, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠧\u001b8"]
76
+ [13.218225, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠇\u001b8"]
77
+ [13.26743, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠏\u001b8"]
78
+ [13.315387, "o", "\u001b7\u001b[36;1H\u001b[36;1H \u001b8"]
79
+ [15.120313, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠙\u001b8"]
80
+ [15.166934, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠹\u001b8"]
81
+ [15.219901, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠸\u001b8"]
82
+ [15.28849, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠼\u001b8"]
83
+ [15.319905, "o", "\u001b7\u001b[2;1H\u001b[2;12H\u001b[31m●\u001b[m\u001b[5;1H\u001b[5;37H8\u001b[8;1H\u001b[8;3HFou\u001b[3C83\u001b[1C8\u001b[5CChangeup \u001b[1C \u001b[22C2\u001b[9;1H\u001b[9;3HBall] 92.3 MPH Four-Seam Fastball \u001b[19C1\u001b[10;1H\u001b[10;2H[Swinging\u001b[1CStrike]\u001b[1C82.9\u001b[1CMPH\u001b[1CChangeup\u001b[19C0-1\u001b[36;1H\u001b[36;1H⠴\u001b8"]
84
+ [15.366276, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠦\u001b8"]
85
+ [15.410643, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠧\u001b8"]
86
+ [15.468101, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠇\u001b8"]
87
+ [15.52299, "o", "\u001b7\u001b[36;1H\u001b[36;1H⠏\u001b8"]
88
+ [15.568221, "o", "\u001b7\u001b[36;1H\u001b[36;1H \u001b8"]
89
+ [19.074182, "o", "\u001b[?1l\u001b>"]
90
+ [19.074493, "o", "\u001b[?12l\u001b[?25h"]
91
+ [19.078092, "o", "\u001b[H\u001b[2J"]
92
+ [19.078282, "o", "\u001b[?1002l\u001b[?1003l\u001b[?1006l"]
93
+ [19.078387, "o", "\u001b[?1049l"]
94
+ [19.093955, "o", "$ "]
95
+ [19.677325, "o", "exit\r\n"]
package/demo.gif ADDED
Binary file
@@ -3,130 +3,131 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _alternateRenderers = require("react-redux/lib/alternate-renderers");
11
11
 
12
- var _reactRedux = require("react-redux");
13
-
14
- var _game = require("../selectors/game");
12
+ var _games = require("../features/games");
15
13
 
16
14
  var _style = _interopRequireDefault(require("../style"));
17
15
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
17
 
22
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
+ function getPlayResultColor(play) {
19
+ var _play$playEvents;
23
20
 
24
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
21
+ const lastPlay = (_play$playEvents = play.playEvents[play.playEvents.length - 1]) === null || _play$playEvents === void 0 ? void 0 : _play$playEvents.details;
25
22
 
26
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
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
+ }
27
35
 
28
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
36
+ function formatOut(out) {
37
+ return ` {bold}${out} out{/bold}`;
38
+ }
29
39
 
30
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
40
+ function AllPlays() {
41
+ const plays = (0, _alternateRenderers.useSelector)(_games.selectAllPlays);
42
+ const teams = (0, _alternateRenderers.useSelector)(_games.selectTeams);
31
43
 
32
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
44
+ const formatScoreDetail = scoreObj => ' {bold}{white-bg}{black-fg} ' + `${teams.away.abbreviation} ${scoreObj.awayScore} - ` + `${teams.home.abbreviation} ${scoreObj.homeScore}` + ' {/black-fg}{/white-bg}{/bold}';
33
45
 
34
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
46
+ let inning = '';
47
+ const lines = [];
48
+ plays && plays.slice().reverse().forEach((play, playIdx, plays) => {
49
+ let lastPlay;
35
50
 
36
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
51
+ if (playIdx < plays.length - 1) {
52
+ lastPlay = plays[playIdx + 1];
53
+ }
37
54
 
38
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
55
+ const playInning = play.about.halfInning + ' ' + play.about.inning;
39
56
 
40
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
57
+ if (playInning !== inning) {
58
+ inning = playInning;
41
59
 
42
- var AllPlays = /*#__PURE__*/function (_React$Component) {
43
- _inherits(AllPlays, _React$Component);
60
+ if (lines.length > 0) {
61
+ lines.push('');
62
+ }
44
63
 
45
- var _super = _createSuper(AllPlays);
64
+ lines.push(`{bold}[${inning.toUpperCase()}]{/bold}`);
65
+ }
46
66
 
47
- function AllPlays() {
48
- _classCallCheck(this, AllPlays);
67
+ if (play.about.isComplete) {
68
+ const color = getPlayResultColor(play);
69
+ let line = `{${color}-fg}[${play.result.event}]{/${color}-fg} ${play.result.description}`;
49
70
 
50
- return _super.apply(this, arguments);
51
- }
71
+ if (play.about.hasOut) {
72
+ const lastOut = play.playEvents[play.playEvents.length - 1].count.outs;
52
73
 
53
- _createClass(AllPlays, [{
54
- key: "render",
55
- value: function render() {
56
- var _this$props = this.props,
57
- plays = _this$props.plays,
58
- teams = _this$props.teams;
59
- var inning = '';
60
- var lines = [];
61
- plays && plays.reverse().forEach(function (play) {
62
- var playInning = play.getIn(['about', 'halfInning']) + ' ' + play.getIn(['about', 'inning']);
63
-
64
- if (playInning !== inning) {
65
- inning = playInning;
66
- lines.push("{yellow-fg}[".concat(inning.toUpperCase(), "]{/yellow-fg}"));
74
+ if (lastOut !== play.count.outs) {
75
+ line += formatOut(play.count.outs);
67
76
  }
77
+ }
68
78
 
69
- if (play.getIn(['about', 'isComplete'])) {
70
- var line = "[".concat(play.getIn(['result', 'event']), "] ").concat(play.getIn(['result', 'description']));
79
+ if (play.about.isScoringPlay) {
80
+ line += formatScoreDetail(play.result);
81
+ }
71
82
 
72
- if (play.getIn(['about', 'hasOut'])) {
73
- line += "{bold}".concat(play.getIn(['count', 'outs']), " out{/bold}");
74
- }
83
+ lines.push(line);
84
+ }
75
85
 
76
- if (play.getIn(['about', 'isScoringPlay'])) {
77
- line += '{bold}{white-bg}{black-fg} ' + "".concat(teams.getIn(['away', 'abbreviation']), " ").concat(play.getIn(['result', 'awayScore']), " - ") + "".concat(teams.getIn(['home', 'abbreviation']), " ").concat(play.getIn(['result', 'homeScore'])) + ' {/black-fg}{/white-bg}{/bold}';
78
- }
86
+ play.playEvents && play.playEvents.slice().reverse().forEach((event, eventIdx, events) => {
87
+ if (event.type === 'action') {
88
+ var _event$count;
79
89
 
80
- lines.push(line);
90
+ let line = '';
91
+
92
+ if (event.details.event) {
93
+ line += `[${event.details.event}] `;
81
94
  }
82
95
 
83
- play.get('playEvents') && play.get('playEvents').reverse().forEach(function (event) {
84
- if (event.get('type') === 'action') {
85
- var _line = '';
86
-
87
- if (event.getIn(['details', 'event'])) {
88
- _line += "[".concat(event.getIn(['details', 'event']), "] ");
89
- }
90
-
91
- _line += event.getIn(['details', 'description']);
92
-
93
- if (event.get('isScoringPlay')) {
94
- _line += '{white-bg}{black-fg}{bold}' + "".concat(teams.getIn(['away', 'abbreviation']), " ").concat(event.getIn(['details', 'awayScore']), " - ") + "".concat(teams.getIn(['home', 'abbreviation']), " ").concat(event.getIn(['details', 'homeScore'])) + '{/bold}{/black-fg}{/white-bg}';
95
- }
96
-
97
- lines.push(_line);
98
- }
99
- });
100
- });
101
- return /*#__PURE__*/_react["default"].createElement("box", {
102
- content: lines.join('\n'),
103
- focused: true,
104
- mouse: true,
105
- keys: true,
106
- vi: true,
107
- scrollable: true,
108
- scrollbar: _style["default"].scrollbar,
109
- alwaysScroll: true,
110
- tags: true
111
- });
112
- }
113
- }]);
96
+ line += event.details.description;
97
+
98
+ if (event.isScoringPlay || event.details.isScoringPlay) {
99
+ line += formatScoreDetail(event.details);
100
+ }
114
101
 
115
- return AllPlays;
116
- }(_react["default"].Component);
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;
117
104
 
118
- AllPlays.propTypes = {
119
- plays: _propTypes["default"].object,
120
- teams: _propTypes["default"].object
121
- };
105
+ if (eventIdx < events.length - 1) {
106
+ var _events$count;
122
107
 
123
- var mapStateToProps = function mapStateToProps(state) {
124
- return {
125
- plays: (0, _game.selectAllPlays)(state),
126
- teams: (0, _game.selectTeams)(state)
127
- };
128
- };
108
+ prevOut = (_events$count = events[eventIdx + 1].count) === null || _events$count === void 0 ? void 0 : _events$count.outs;
109
+ }
129
110
 
130
- var _default = (0, _reactRedux.connect)(mapStateToProps)(AllPlays);
111
+ if (currentOut > prevOut) {
112
+ line += formatOut(currentOut);
113
+ }
131
114
 
132
- exports["default"] = _default;
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;
@@ -3,138 +3,66 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _reactRedux = require("react-redux");
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _alternateRenderers = require("react-redux/lib/alternate-renderers");
13
11
 
14
12
  var _GameList = _interopRequireDefault(require("./GameList"));
15
13
 
16
- var _Game = _interopRequireDefault(require("./Game"));
17
-
18
14
  var _HelpBar = _interopRequireDefault(require("./HelpBar"));
19
15
 
20
- var _fs = _interopRequireDefault(require("fs"));
21
-
22
- var _game = require("../actions/game");
23
-
24
- var _game2 = require("../selectors/game");
25
-
26
- var _winston = _interopRequireDefault(require("winston"));
27
-
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
-
30
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
31
-
32
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
-
34
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
35
-
36
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16
+ var _games = require("../features/games");
37
17
 
38
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
-
40
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
-
42
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
43
-
44
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
45
-
46
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
-
48
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
49
-
50
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
51
-
52
- var App = /*#__PURE__*/function (_React$Component) {
53
- _inherits(App, _React$Component);
18
+ var _Game = _interopRequireDefault(require("./Game"));
54
19
 
55
- var _super = _createSuper(App);
20
+ var _useKey = _interopRequireDefault(require("../hooks/useKey"));
56
21
 
57
- function App() {
58
- _classCallCheck(this, App);
22
+ var _Standings = _interopRequireDefault(require("./Standings"));
59
23
 
60
- return _super.apply(this, arguments);
61
- }
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
62
25
 
63
- _createClass(App, [{
64
- key: "componentDidMount",
65
- value: function componentDidMount() {
66
- var _this = this;
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); }
67
27
 
68
- var _this$props = this.props,
69
- onKeyPress = _this$props.onKeyPress,
70
- setSelectedGame = _this$props.setSelectedGame;
71
- onKeyPress(['l'], function () {
72
- return setSelectedGame(null);
73
- });
74
- onKeyPress(['C-d'], function () {
75
- var _this$props2 = _this.props,
76
- selectedGame = _this$props2.selectedGame,
77
- game = _this$props2.game;
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; }
78
29
 
79
- _fs["default"].writeFileSync(selectedGame + '_' + Date.now() + '.json', JSON.stringify(game, null, 2));
80
- });
81
- }
82
- }, {
83
- key: "componentDidCatch",
84
- value: function componentDidCatch(error, info) {
85
- _winston["default"].error(error);
30
+ const SCHEDULE = 'schedule';
31
+ const STANDINGS = 'standings';
32
+ const GAME = 'game';
86
33
 
87
- _winston["default"].error(JSON.stringify(info, null, 2));
88
- }
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));
89
40
  }, {
90
- key: "render",
91
- value: function render() {
92
- var _this$props3 = this.props,
93
- selectedGame = _this$props3.selectedGame,
94
- setSelectedGame = _this$props3.setSelectedGame;
95
-
96
- try {
97
- return /*#__PURE__*/_react["default"].createElement("element", null, /*#__PURE__*/_react["default"].createElement("element", {
98
- top: 0,
99
- left: 0,
100
- height: "100%-1"
101
- }, selectedGame ? /*#__PURE__*/_react["default"].createElement(_Game["default"], null) : /*#__PURE__*/_react["default"].createElement(_GameList["default"], {
102
- onGameSelect: function onGameSelect(game) {
103
- return setSelectedGame(game.gamePk);
104
- }
105
- })), /*#__PURE__*/_react["default"].createElement("element", {
106
- top: "100%-1",
107
- left: 0,
108
- height: 1
109
- }, /*#__PURE__*/_react["default"].createElement(_HelpBar["default"], null)));
110
- } catch (error) {
111
- this.props.debug(error);
112
- }
113
- }
114
- }]);
115
-
116
- return App;
117
- }(_react["default"].Component);
118
-
119
- App.propTypes = {
120
- debug: _propTypes["default"].func,
121
- onKeyPress: _propTypes["default"].func,
122
- selectedGame: _propTypes["default"].number,
123
- setSelectedGame: _propTypes["default"].func,
124
- game: _propTypes["default"].object
125
- };
126
-
127
- var mapStateToProps = function mapStateToProps(state) {
128
- return {
129
- selectedGame: (0, _game2.selectSelectedId)(state),
130
- game: (0, _game2.selectGame)(state)
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);
131
52
  };
132
- };
133
-
134
- var mapDispatchToProps = {
135
- setSelectedGame: _game.setSelectedGame
136
- };
137
-
138
- var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(App);
139
53
 
140
- exports["default"] = _default;
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;