@maestro_io/maestro-web-sdk 2.1.1 → 2.1.3
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/dist/MaestroEventDelegate.js +60 -0
- package/dist/components/atoms/BaseButton/BaseButton.js +11 -0
- package/dist/components/atoms/BaseButton/index.js +2 -0
- package/dist/components/atoms/Image/index.js +30 -0
- package/dist/components/atoms/Rive/index.d.ts +1 -0
- package/dist/components/atoms/Rive/index.js +53 -0
- package/dist/components/atoms/SvgIcon/BetGeneralIcon.js +9 -0
- package/dist/components/atoms/SvgIcon/BetsIcon.js +11 -0
- package/dist/components/atoms/SvgIcon/BetsWarningIcon.js +11 -0
- package/dist/components/atoms/SvgIcon/CheckmarkIcon.js +6 -0
- package/dist/components/atoms/SvgIcon/CollapseIcon.js +6 -0
- package/dist/components/atoms/SvgIcon/ExpandIcon.js +6 -0
- package/dist/components/atoms/SvgIcon/FantasyIcon.js +8 -0
- package/dist/components/atoms/SvgIcon/FlameIcon.js +11 -0
- package/dist/components/atoms/SvgIcon/Icon.js +42 -0
- package/dist/components/atoms/SvgIcon/KeyPlaysIcon.js +10 -0
- package/dist/components/atoms/SvgIcon/MobilePhoneIcon.js +11 -0
- package/dist/components/atoms/SvgIcon/PlayIcon.js +8 -0
- package/dist/components/atoms/SvgIcon/StatsIcon.js +12 -0
- package/dist/components/atoms/SvgIcon/TimesIcon.js +6 -0
- package/dist/components/atoms/SvgIcon/WarningIcon.js +8 -0
- package/dist/components/atoms/SvgIcon/index.js +2 -0
- package/dist/components/core/App/App.js +41 -0
- package/dist/components/core/App/index.js +2 -0
- package/dist/components/core/OverlayContainer.js +58 -0
- package/dist/components/core/PanelManager/PanelManager.js +80 -0
- package/dist/components/core/PanelManager/index.js +2 -0
- package/dist/components/core/ScrollableContainer/FocusableItem.js +38 -0
- package/dist/components/core/ScrollableContainer/ScrollableContainer.js +166 -0
- package/dist/components/core/ScrollableContainer/index.js +2 -0
- package/dist/components/molecules/ActionButton/ActionButton.d.ts +1 -0
- package/dist/components/molecules/ActionButton/ActionButton.js +10 -0
- package/dist/components/molecules/ActionButton/index.js +2 -0
- package/dist/components/molecules/Overlay/Overlay.js +139 -0
- package/dist/components/molecules/Overlay/index.js +2 -0
- package/dist/components/molecules/PanelNavButton/PanelNavButton.d.ts +1 -0
- package/dist/components/molecules/PanelNavButton/PanelNavButton.js +40 -0
- package/dist/components/molecules/PanelNavButton/index.js +2 -0
- package/dist/components/molecules/SegmentButton/SegmentButton.js +10 -0
- package/dist/components/molecules/SegmentButton/index.js +2 -0
- package/dist/components/molecules/WatchButton/WatchButton.js +15 -0
- package/dist/components/molecules/WatchButton/index.js +2 -0
- package/dist/components/organisms/PanelNavigation/PanelNavigation.js +71 -0
- package/dist/components/organisms/PanelNavigation/index.js +2 -0
- package/dist/components/organisms/SegmentController/SegmentController.d.ts +2 -2
- package/dist/components/organisms/SegmentController/SegmentController.js +68 -0
- package/dist/components/organisms/SegmentController/index.d.ts +1 -1
- package/dist/components/organisms/SegmentController/index.js +2 -0
- package/dist/external/AxiosNetworkClient.js +83 -0
- package/dist/external/LocalStorageCacheManager.js +213 -0
- package/dist/external/ReactRenderer.d.ts +2 -2
- package/dist/external/ReactRenderer.js +86 -0
- package/dist/external/mocks/MockExternalNetworkClient.js +161 -0
- package/dist/external/ports/cacheManager.js +1 -0
- package/dist/external/ports/networkClient.js +1 -0
- package/dist/external/ports/renderer.js +1 -0
- package/dist/external/spatial-navigation/index.d.ts +3 -4
- package/dist/external/spatial-navigation/index.js +3 -0
- package/dist/external/spatial-navigation/measureLayout.js +30 -0
- package/dist/external/spatial-navigation/spatialNavigation.d.ts +2 -4
- package/dist/external/spatial-navigation/spatialNavigation.js +864 -0
- package/dist/external/spatial-navigation/utils.js +6 -0
- package/dist/external/spatial-navigation/visualDebugger.js +76 -0
- package/dist/external/spatial-navigation/withFocusable.d.ts +1 -0
- package/dist/external/spatial-navigation/withFocusable.js +245 -0
- package/dist/helpers/Observable.js +37 -0
- package/dist/helpers/deliver-focus.js +12 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +192 -0
- package/dist/interfaces/IMaestroEvent.js +6 -0
- package/dist/interfaces/IMaestroEventDelegate.js +1 -0
- package/dist/interfaces/IMaestroManager.js +1 -0
- package/dist/maestro-web-sdk.umd.js +3 -3
- package/dist/maestro-web-sdk.umd.js.map +1 -1
- package/dist/models/IModel.js +1 -0
- package/dist/models/IPanel.js +53 -0
- package/dist/models/ITheme.js +20 -0
- package/dist/models/IWinningBet.js +1 -0
- package/dist/modules/bets/interfaces/IBets.js +1 -0
- package/dist/modules/bets/mocks.js +572 -0
- package/dist/modules/bets/view/BetsView.js +116 -0
- package/dist/modules/bets/view/HotProps/HotPropsView.d.ts +7 -6
- package/dist/modules/bets/view/HotProps/HotPropsView.js +139 -0
- package/dist/modules/bets/view/SixPack/SixPackView.d.ts +2 -2
- package/dist/modules/bets/view/SixPack/SixPackView.js +103 -0
- package/dist/modules/bets/view/TabLoadFailureView.d.ts +1 -0
- package/dist/modules/bets/view/TabLoadFailureView.js +12 -0
- package/dist/modules/bets/view/UserBets/BetResult/BetResult.js +6 -0
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.d.ts +7 -6
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +122 -0
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +34 -0
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +22 -0
- package/dist/modules/bets/view/UserBets/Boost/Boost.js +6 -0
- package/dist/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +9 -0
- package/dist/modules/bets/view/UserBets/Parlay/Parlay.js +13 -0
- package/dist/modules/bets/view/UserBets/Straight/Straight.js +6 -0
- package/dist/modules/bets/view/UserBets/Teaser/Teaser.js +13 -0
- package/dist/modules/bets/view/UserBets/UserBetsView.js +114 -0
- package/dist/modules/bets/view/components/Bet/Bet.d.ts +1 -0
- package/dist/modules/bets/view/components/Bet/Bet.js +32 -0
- package/dist/modules/bets/view/components/BetPill/BetPill.js +6 -0
- package/dist/modules/bets/view/components/BetsCard/BetsCard.js +15 -0
- package/dist/modules/bets/view/components/BetsCard/BetsCardHeader.js +20 -0
- package/dist/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +14 -0
- package/dist/modules/bets/view/components/LocationWarning/LocationWarning.js +16 -0
- package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.d.ts +2 -2
- package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +63 -0
- package/dist/modules/bets/view/components/PromoCodeBanner/index.d.ts +1 -1
- package/dist/modules/bets/view/components/PromoCodeBanner/index.js +1 -0
- package/dist/modules/bets/view-model/BetsViewModel.js +767 -0
- package/dist/modules/key-plays/constants.js +292 -0
- package/dist/modules/key-plays/interfaces/IKeyPlays.d.ts +4 -4
- package/dist/modules/key-plays/interfaces/IKeyPlays.js +14 -0
- package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.js +1 -0
- package/dist/modules/key-plays/view/KeyPlayCardScoreTagView.js +13 -0
- package/dist/modules/key-plays/view/KeyPlayCardView.d.ts +0 -4
- package/dist/modules/key-plays/view/KeyPlayCardView.js +120 -0
- package/dist/modules/key-plays/view/KeyPlayErrorStateView.js +58 -0
- package/dist/modules/key-plays/view/KeyPlaysView.js +166 -0
- package/dist/modules/key-plays/view-model/KeyPlaysViewModel.js +182 -0
- package/dist/modules/stats/interfaces/IStats.d.ts +166 -0
- package/dist/modules/stats/interfaces/IStats.js +1 -0
- package/dist/modules/stats/mocks.d.ts +82 -0
- package/dist/modules/stats/mocks.js +686 -0
- package/dist/modules/stats/utils/renderTeamStatistic.d.ts +21 -0
- package/dist/modules/stats/utils/renderTeamStatistic.js +16 -0
- package/dist/modules/stats/utils.d.ts +39 -0
- package/dist/modules/stats/utils.js +62 -0
- package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.d.ts +34 -0
- package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.js +78 -0
- package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.d.ts +5 -0
- package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.js +27 -0
- package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.d.ts +10 -0
- package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.js +15 -0
- package/dist/modules/stats/view/ActiveAthletes/index.d.ts +2 -0
- package/dist/modules/stats/view/ActiveAthletes/index.js +2 -0
- package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +8 -0
- package/dist/modules/stats/view/GameLeaders/GameLeaders.js +9 -0
- package/dist/modules/stats/view/GameLeaders/index.d.ts +2 -0
- package/dist/modules/stats/view/GameLeaders/index.js +2 -0
- package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.d.ts +17 -0
- package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +55 -0
- package/dist/modules/stats/view/MatchPredictor/DonutChart/index.d.ts +2 -0
- package/dist/modules/stats/view/MatchPredictor/DonutChart/index.js +1 -0
- package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +53 -0
- package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.js +66 -0
- package/dist/modules/stats/view/MatchPredictor/index.d.ts +3 -0
- package/dist/modules/stats/view/MatchPredictor/index.js +2 -0
- package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +63 -0
- package/dist/modules/stats/view/RecentGames/RecentGames.js +22 -0
- package/dist/modules/stats/view/RecentGames/index.d.ts +2 -0
- package/dist/modules/stats/view/RecentGames/index.js +2 -0
- package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.d.ts +52 -0
- package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.js +38 -0
- package/dist/modules/stats/view/StatsQRCode/index.d.ts +2 -0
- package/dist/modules/stats/view/StatsQRCode/index.js +1 -0
- package/dist/modules/stats/view/StatsView.d.ts +20 -0
- package/dist/modules/stats/view/StatsView.js +107 -0
- package/dist/modules/stats/view/TeamStats/TeamStatsView.d.ts +54 -0
- package/dist/modules/stats/view/TeamStats/TeamStatsView.js +69 -0
- package/dist/modules/stats/view/TeamStats/index.d.ts +2 -0
- package/dist/modules/stats/view/TeamStats/index.js +1 -0
- package/dist/modules/stats/view/Teams/StatsCarousel.d.ts +8 -0
- package/dist/modules/stats/view/Teams/StatsCarousel.js +14 -0
- package/dist/modules/stats/view/Teams/StatsProgressBar.d.ts +7 -0
- package/dist/modules/stats/view/Teams/StatsProgressBar.js +18 -0
- package/dist/modules/stats/view/Teams/Teams.d.ts +68 -0
- package/dist/modules/stats/view/Teams/Teams.js +42 -0
- package/dist/modules/stats/view/Teams/index.d.ts +2 -0
- package/dist/modules/stats/view/Teams/index.js +2 -0
- package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +63 -0
- package/dist/modules/stats/view/WinProbability/WinProbability.js +27 -0
- package/dist/modules/stats/view/WinProbability/index.d.ts +2 -0
- package/dist/modules/stats/view/WinProbability/index.js +2 -0
- package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.d.ts +67 -0
- package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +29 -0
- package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.d.ts +4 -0
- package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +12 -0
- package/dist/modules/stats/view/components/AthletesStatistics/index.d.ts +2 -0
- package/dist/modules/stats/view/components/AthletesStatistics/index.js +2 -0
- package/dist/modules/stats/view/index.d.ts +2 -0
- package/dist/modules/stats/view/index.js +2 -0
- package/dist/modules/stats/view-model/StatsViewModel.d.ts +31 -0
- package/dist/modules/stats/view-model/StatsViewModel.js +90 -0
- package/dist/services/BetsService.js +102 -0
- package/dist/services/NetworkManager/NetworkManager.js +410 -0
- package/dist/services/NetworkManager/errors.js +45 -0
- package/dist/services/StatsService.d.ts +36 -0
- package/dist/services/StatsService.js +68 -0
- package/dist/services/ThemeManager/constants.js +47 -0
- package/dist/test-polyfills.d.ts +1 -0
- package/dist/test-polyfills.js +15 -0
- package/dist/types/OverlayTypes.js +4 -0
- package/dist/view-models/MaestroEventViewModel.d.ts +9 -0
- package/dist/view-models/MaestroEventViewModel.js +168 -0
- package/dist/view-models/OverlayViewModel.js +222 -0
- package/dist/view-models/PanelManagerViewModel.js +80 -0
- package/dist/view-models/ViewModel.js +32 -0
- package/dist/view-models/index.js +59 -0
- package/package.json +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import KeyPlayCardView from './KeyPlayCardView';
|
|
3
|
+
import './KeyPlaysView.styles.css';
|
|
4
|
+
import KeyPlayErrorStateView from './KeyPlayErrorStateView';
|
|
5
|
+
import SDK from '@/index';
|
|
6
|
+
import ScrollableContainer from '@/components/core/ScrollableContainer';
|
|
7
|
+
const STICKY_HEADER_HEIGHT = 32;
|
|
8
|
+
export class KeyPlays extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
Object.defineProperty(this, "container", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: null
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "playbackProgressUnsub", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: null
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "playbackIndexUnsub", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: null
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "itemsUnsub", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: null
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "vm", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: void 0
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(this, "handlePlayClip", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: (index) => async () => {
|
|
46
|
+
await this.vm.playKeyPlay(index);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
|
|
50
|
+
const rawSections = this.vm.items.value;
|
|
51
|
+
this.state = {
|
|
52
|
+
scrollableContainer: null,
|
|
53
|
+
playbackProgress: this.vm.currentClipPlaybackProgress.value ?? null,
|
|
54
|
+
playbackIndex: this.vm.currentlyPlayingClipIndex.value ?? null,
|
|
55
|
+
items: rawSections.map((section) => ({
|
|
56
|
+
title: section.title,
|
|
57
|
+
items: section.items.map((item) => ({
|
|
58
|
+
id: item.id,
|
|
59
|
+
clipID: item.clipID,
|
|
60
|
+
awayTeamScore: item.awayTeamScore,
|
|
61
|
+
homeTeamScore: item.homeTeamScore,
|
|
62
|
+
awayTeamName: item.awayTeamName,
|
|
63
|
+
homeTeamName: item.homeTeamName,
|
|
64
|
+
description: item.description,
|
|
65
|
+
playerImageUrl: item.playerImageUrl || '',
|
|
66
|
+
teamImageUrl: item.teamImageUrl || '',
|
|
67
|
+
thumbnailImageUrl: item.thumbnailImageUrl || '',
|
|
68
|
+
})),
|
|
69
|
+
})),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
componentDidMount() {
|
|
73
|
+
this.playbackProgressUnsub = this.vm.currentClipPlaybackProgress.subscribe((value) => {
|
|
74
|
+
this.setState({ playbackProgress: value ?? null });
|
|
75
|
+
});
|
|
76
|
+
this.playbackIndexUnsub = this.vm.currentlyPlayingClipIndex.subscribe((value) => {
|
|
77
|
+
this.setState({ playbackIndex: value ?? null });
|
|
78
|
+
});
|
|
79
|
+
this.itemsUnsub = this.vm.items.subscribe((rawSections) => {
|
|
80
|
+
this.setState({
|
|
81
|
+
items: rawSections.map((section) => ({
|
|
82
|
+
title: section.title,
|
|
83
|
+
items: section.items.map((item) => ({
|
|
84
|
+
id: item.id,
|
|
85
|
+
clipID: item.clipID,
|
|
86
|
+
awayTeamScore: item.awayTeamScore,
|
|
87
|
+
homeTeamScore: item.homeTeamScore,
|
|
88
|
+
awayTeamName: item.awayTeamName,
|
|
89
|
+
homeTeamName: item.homeTeamName,
|
|
90
|
+
description: item.description,
|
|
91
|
+
playerImageUrl: item.playerImageUrl || '',
|
|
92
|
+
teamImageUrl: item.teamImageUrl || '',
|
|
93
|
+
thumbnailImageUrl: item.thumbnailImageUrl || '',
|
|
94
|
+
})),
|
|
95
|
+
})),
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
this.setState({
|
|
99
|
+
scrollableContainer: this.container,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
componentWillUnmount() {
|
|
103
|
+
this.playbackProgressUnsub && this.playbackProgressUnsub();
|
|
104
|
+
this.playbackIndexUnsub && this.playbackIndexUnsub();
|
|
105
|
+
this.itemsUnsub && this.itemsUnsub();
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
const { playbackProgress, playbackIndex, items, scrollableContainer, } = this.state;
|
|
109
|
+
return (React.createElement(ScrollableContainer, { scrollableContainerRef: scrollableContainer, containerTopOffset: STICKY_HEADER_HEIGHT },
|
|
110
|
+
React.createElement("div", { ref: (el) => {
|
|
111
|
+
this.container = el;
|
|
112
|
+
}, className: "key-plays-view" },
|
|
113
|
+
items.map((section, sectionIndex) => (React.createElement("div", { key: `section-${sectionIndex}`, className: "key-plays-section" },
|
|
114
|
+
React.createElement("h3", { className: "key-plays-section-title T10" }, section.title),
|
|
115
|
+
React.createElement("div", { className: "key-plays-section-items" }, section.items.map((item) => {
|
|
116
|
+
const absoluteIndex = this.vm.allItems.findIndex((vmItem) => vmItem.id === item.id);
|
|
117
|
+
return (React.createElement(KeyPlayCardView, { key: item.id, id: item.id, clipID: item.clipID, description: item.description, awayTeamName: item.awayTeamName, homeTeamName: item.homeTeamName, awayTeamScore: item.awayTeamScore, homeTeamScore: item.homeTeamScore, playerImageUrl: item.playerImageUrl, teamImageUrl: item.teamImageUrl, thumbnailImageUrl: item.thumbnailImageUrl, isPlaying: this.vm.isCurrentlyPlaying(absoluteIndex), isScoring: Boolean(item.awayTeamScore && item.homeTeamScore), playbackProgress: absoluteIndex === playbackIndex
|
|
118
|
+
? playbackProgress
|
|
119
|
+
: null, onEnterPress: this.handlePlayClip(absoluteIndex) }));
|
|
120
|
+
}))))),
|
|
121
|
+
React.createElement("div", { className: "key-plays-bottom-padding" }))));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export default class KeyPlaysWithErrorState extends Component {
|
|
125
|
+
constructor(props) {
|
|
126
|
+
super(props);
|
|
127
|
+
Object.defineProperty(this, "errorStateUnsub", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
configurable: true,
|
|
130
|
+
writable: true,
|
|
131
|
+
value: null
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(this, "vm", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
value: void 0
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(this, "handleRetry", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
configurable: true,
|
|
142
|
+
writable: true,
|
|
143
|
+
value: async () => {
|
|
144
|
+
await this.vm.userRequestedNewKeyPlaysData();
|
|
145
|
+
SDK.getMaestroEventViewModel().navigation.setFocus('PANEL_NAV_BUTTON_0');
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
|
|
149
|
+
this.state = { errorState: this.vm.errorState.value };
|
|
150
|
+
}
|
|
151
|
+
componentDidMount() {
|
|
152
|
+
this.errorStateUnsub = this.vm.errorState.subscribe((value) => {
|
|
153
|
+
this.setState({ errorState: value });
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
componentWillUnmount() {
|
|
157
|
+
this.errorStateUnsub && this.errorStateUnsub();
|
|
158
|
+
}
|
|
159
|
+
render() {
|
|
160
|
+
const { errorState } = this.state;
|
|
161
|
+
if (errorState) {
|
|
162
|
+
return (React.createElement(KeyPlayErrorStateView, { errorState: errorState, onRetry: this.handleRetry }));
|
|
163
|
+
}
|
|
164
|
+
return React.createElement(KeyPlays, null);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import SDK from '@/index';
|
|
2
|
+
import { Observable } from '@/helpers/Observable';
|
|
3
|
+
class KeyPlaysViewModel {
|
|
4
|
+
constructor() {
|
|
5
|
+
Object.defineProperty(this, "currentlyPlayingClipIndex", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true,
|
|
9
|
+
value: new Observable(null)
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(this, "lastPlayedClipIndex", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: new Observable(null)
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(this, "currentClipPlaybackProgress", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: new Observable(null)
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "errorState", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: new Observable('unpopulatedEvent')
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "failedClips", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: new Observable({})
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "items", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: new Observable([])
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
isCurrentlyPlaying(index) {
|
|
43
|
+
return index === this.currentlyPlayingClipIndex.value;
|
|
44
|
+
}
|
|
45
|
+
async setKeyPlays(items) {
|
|
46
|
+
if (items === null) {
|
|
47
|
+
this.errorState.value = 'tabLoadFailure';
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.items.value = this.parseNetworkResponse(items);
|
|
51
|
+
this.cleanErrors();
|
|
52
|
+
}
|
|
53
|
+
cleanErrors() {
|
|
54
|
+
if (this.errorState.value === 'tabLoadFailure') {
|
|
55
|
+
this.errorState.value = null;
|
|
56
|
+
}
|
|
57
|
+
if (this.errorState.value === 'unpopulatedEvent' && this.allItems.length) {
|
|
58
|
+
this.errorState.value = null;
|
|
59
|
+
}
|
|
60
|
+
if (!this.allItems.length) {
|
|
61
|
+
this.errorState.value = 'unpopulatedEvent';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async playKeyPlay(atIndex) {
|
|
65
|
+
const mevm = SDK.getMaestroEventViewModel();
|
|
66
|
+
mevm.delegate.playClip(atIndex);
|
|
67
|
+
}
|
|
68
|
+
parseNetworkResponse(response) {
|
|
69
|
+
const teams = Object.values(response.entities.team);
|
|
70
|
+
const athletes = Object.values(response.entities.athlete);
|
|
71
|
+
const homeTeam = teams.find((team) => team.homeAway === 'home');
|
|
72
|
+
const awayTeam = teams.find((team) => team.homeAway === 'away');
|
|
73
|
+
if (!homeTeam || !awayTeam) {
|
|
74
|
+
console.warn('Could not find home or away team');
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
const items = [];
|
|
78
|
+
const result = [];
|
|
79
|
+
for (const section of response.sections) {
|
|
80
|
+
for (const keyPlay of section.items) {
|
|
81
|
+
const playTeam = keyPlay.team
|
|
82
|
+
? teams.find((team) => team.id === keyPlay.team)
|
|
83
|
+
: undefined;
|
|
84
|
+
const athlete = keyPlay.athlete
|
|
85
|
+
? athletes.find((a) => a.id === keyPlay.athlete)
|
|
86
|
+
: undefined;
|
|
87
|
+
const teamImageUrl = playTeam ? playTeam.logoRef : undefined;
|
|
88
|
+
const playerImageUrl = athlete ? athlete.headshot : undefined;
|
|
89
|
+
const thumbnailImageUrl = keyPlay.thumbnailType !== 'headshot' ? keyPlay.thumbnail : undefined;
|
|
90
|
+
const homeScore = keyPlay.homeScore ? keyPlay.homeScore : '0';
|
|
91
|
+
const awayScore = keyPlay.awayScore ? keyPlay.awayScore : '0';
|
|
92
|
+
const homeTeamScore = keyPlay.scoringPlay
|
|
93
|
+
? parseInt(homeScore)
|
|
94
|
+
: undefined;
|
|
95
|
+
const awayTeamScore = keyPlay.scoringPlay
|
|
96
|
+
? parseInt(awayScore)
|
|
97
|
+
: undefined;
|
|
98
|
+
const randomId = Math.random().toString(36).substring(2, 15);
|
|
99
|
+
const keyPlayData = {
|
|
100
|
+
id: randomId,
|
|
101
|
+
description: keyPlay.description ? keyPlay.description : '',
|
|
102
|
+
homeTeamName: homeTeam ? homeTeam.shortName : '',
|
|
103
|
+
awayTeamName: awayTeam ? awayTeam.shortName : '',
|
|
104
|
+
homeTeamScore,
|
|
105
|
+
awayTeamScore,
|
|
106
|
+
clipID: keyPlay.clipID,
|
|
107
|
+
teamImageUrl,
|
|
108
|
+
playerImageUrl,
|
|
109
|
+
thumbnailImageUrl,
|
|
110
|
+
section: section.title,
|
|
111
|
+
};
|
|
112
|
+
items.push(keyPlayData);
|
|
113
|
+
}
|
|
114
|
+
// Only add the section if it has items
|
|
115
|
+
if (items.length) {
|
|
116
|
+
const sectionTitle = section.title;
|
|
117
|
+
const existingSection = result.find((item) => item.title === sectionTitle);
|
|
118
|
+
if (existingSection) {
|
|
119
|
+
existingSection.items.push(...items);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
result.push({
|
|
123
|
+
title: sectionTitle,
|
|
124
|
+
items: [...items],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// Reset items for the next section
|
|
128
|
+
items.length = 0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
get allItems() {
|
|
134
|
+
return this.items.value.reduce((acc, section) => {
|
|
135
|
+
return acc.concat(section.items);
|
|
136
|
+
}, []);
|
|
137
|
+
}
|
|
138
|
+
clipID(forKeyPlayAtIndex) {
|
|
139
|
+
const item = this.allItems[forKeyPlayAtIndex];
|
|
140
|
+
if (!item) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
return this.allItems[forKeyPlayAtIndex].clipID;
|
|
144
|
+
}
|
|
145
|
+
handleKeyPlayLoadFailure(forKeyPlayAtIndex) {
|
|
146
|
+
const clipID = this.clipID(forKeyPlayAtIndex);
|
|
147
|
+
if (clipID) {
|
|
148
|
+
const newFailedClips = this.failedClips.value;
|
|
149
|
+
newFailedClips[clipID] = 'recentFailure';
|
|
150
|
+
this.failedClips.value = newFailedClips;
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
if (this.loadFailureStatus(forKeyPlayAtIndex) === 'recentFailure') {
|
|
153
|
+
const newFailedClips = this.failedClips.value;
|
|
154
|
+
newFailedClips[clipID] = 'nonRecentFailure';
|
|
155
|
+
this.failedClips.value = newFailedClips;
|
|
156
|
+
}
|
|
157
|
+
}, 5000);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
loadFailureStatus(forKeyPlayAtIndex) {
|
|
161
|
+
const clipID = this.clipID(forKeyPlayAtIndex);
|
|
162
|
+
const newFailedClips = this.failedClips.value;
|
|
163
|
+
if (!newFailedClips) {
|
|
164
|
+
return 'noFailure';
|
|
165
|
+
}
|
|
166
|
+
return clipID ? this.failedClips.value[clipID] : 'noFailure';
|
|
167
|
+
}
|
|
168
|
+
clearLoadFailureStatus(forKeyPlayAtIndex) {
|
|
169
|
+
const clipID = this.clipID(forKeyPlayAtIndex);
|
|
170
|
+
if (clipID && this.failedClips) {
|
|
171
|
+
this.failedClips.value = {
|
|
172
|
+
...this.failedClips.value,
|
|
173
|
+
[clipID]: 'noFailure',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async userRequestedNewKeyPlaysData() {
|
|
178
|
+
const mevm = SDK.getMaestroEventViewModel();
|
|
179
|
+
await mevm.delegate.userRequestedNewKeyPlaysData();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export default KeyPlaysViewModel;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export interface TeamStatistic {
|
|
2
|
+
$key: string;
|
|
3
|
+
value: number;
|
|
4
|
+
displayValue: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Team {
|
|
8
|
+
id: string;
|
|
9
|
+
uid: string;
|
|
10
|
+
slug?: string;
|
|
11
|
+
location?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
abbreviation: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
shortDisplayName?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
alternateColor?: string;
|
|
18
|
+
logo: string;
|
|
19
|
+
statistics?: TeamStatistic[];
|
|
20
|
+
homeAway?: string;
|
|
21
|
+
record?: string;
|
|
22
|
+
displayOrder?: number;
|
|
23
|
+
}
|
|
24
|
+
interface AthleteLink {
|
|
25
|
+
rel: string[];
|
|
26
|
+
href: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
interface AthletePosition {
|
|
30
|
+
name?: string;
|
|
31
|
+
displayName?: string;
|
|
32
|
+
abbreviation: string;
|
|
33
|
+
}
|
|
34
|
+
export interface Athlete {
|
|
35
|
+
id: string;
|
|
36
|
+
uid: string;
|
|
37
|
+
guid: string;
|
|
38
|
+
displayName: string;
|
|
39
|
+
shortName: string;
|
|
40
|
+
jersey: string;
|
|
41
|
+
headshot: string;
|
|
42
|
+
links: AthleteLink[];
|
|
43
|
+
position?: AthletePosition;
|
|
44
|
+
statistics?: {
|
|
45
|
+
$key: string;
|
|
46
|
+
value?: number;
|
|
47
|
+
displayValue: string;
|
|
48
|
+
}[];
|
|
49
|
+
}
|
|
50
|
+
export interface EntityMap<T> {
|
|
51
|
+
[id: string]: T;
|
|
52
|
+
}
|
|
53
|
+
export interface LeaderStatistic {
|
|
54
|
+
displayValue: string;
|
|
55
|
+
abbreviation: string;
|
|
56
|
+
}
|
|
57
|
+
interface LeaderAthlete {
|
|
58
|
+
$key: string;
|
|
59
|
+
statistics?: LeaderStatistic[];
|
|
60
|
+
}
|
|
61
|
+
interface LeaderTeam {
|
|
62
|
+
team: {
|
|
63
|
+
$key: string;
|
|
64
|
+
};
|
|
65
|
+
athlete: LeaderAthlete;
|
|
66
|
+
}
|
|
67
|
+
export interface Leader {
|
|
68
|
+
displayName: string;
|
|
69
|
+
name: string;
|
|
70
|
+
home: LeaderTeam;
|
|
71
|
+
away: LeaderTeam;
|
|
72
|
+
}
|
|
73
|
+
interface LineScore {
|
|
74
|
+
displayValue: string;
|
|
75
|
+
}
|
|
76
|
+
interface HeaderTeam {
|
|
77
|
+
$key: string;
|
|
78
|
+
score?: string;
|
|
79
|
+
linescores: LineScore[];
|
|
80
|
+
}
|
|
81
|
+
export interface Header {
|
|
82
|
+
teams: HeaderTeam[];
|
|
83
|
+
linescoresHeader: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface PredictorTeam {
|
|
86
|
+
team: {
|
|
87
|
+
$key: string;
|
|
88
|
+
};
|
|
89
|
+
gameProjection: string;
|
|
90
|
+
teamChanceLoss: string;
|
|
91
|
+
}
|
|
92
|
+
export interface Predictor {
|
|
93
|
+
header: string;
|
|
94
|
+
imageUrl: string;
|
|
95
|
+
homeTeam: PredictorTeam;
|
|
96
|
+
awayTeam: PredictorTeam;
|
|
97
|
+
}
|
|
98
|
+
export interface WinProbabilityTeam {
|
|
99
|
+
team: {
|
|
100
|
+
$key: string;
|
|
101
|
+
};
|
|
102
|
+
winPercentage: string;
|
|
103
|
+
}
|
|
104
|
+
export interface WinProbability {
|
|
105
|
+
imageUrl: string;
|
|
106
|
+
homeTeam: WinProbabilityTeam;
|
|
107
|
+
awayTeam: WinProbabilityTeam;
|
|
108
|
+
}
|
|
109
|
+
interface ActiveAthletesTeam {
|
|
110
|
+
team: {
|
|
111
|
+
$key: string;
|
|
112
|
+
};
|
|
113
|
+
athletes: {
|
|
114
|
+
$key: string;
|
|
115
|
+
statLine: string;
|
|
116
|
+
}[];
|
|
117
|
+
}
|
|
118
|
+
export interface ActiveAthletes {
|
|
119
|
+
displayText: string;
|
|
120
|
+
teams: ActiveAthletesTeam[];
|
|
121
|
+
}
|
|
122
|
+
export interface Meta {
|
|
123
|
+
gp_topic: string;
|
|
124
|
+
picker_topic: string;
|
|
125
|
+
lastUpdatedAt?: string;
|
|
126
|
+
firstPlayWallClock?: string;
|
|
127
|
+
lastPlayWallClock?: string;
|
|
128
|
+
gameState: string;
|
|
129
|
+
syncUrl?: string;
|
|
130
|
+
}
|
|
131
|
+
export interface StatsPromotion {
|
|
132
|
+
title: string;
|
|
133
|
+
description: string;
|
|
134
|
+
logo: string;
|
|
135
|
+
qrCode: string;
|
|
136
|
+
backgroundImage: string;
|
|
137
|
+
}
|
|
138
|
+
export interface StatsApiResponse {
|
|
139
|
+
entities: {
|
|
140
|
+
teams: EntityMap<Team>;
|
|
141
|
+
athletes: EntityMap<Athlete>;
|
|
142
|
+
};
|
|
143
|
+
leaders: Leader[];
|
|
144
|
+
header: Header;
|
|
145
|
+
predictor: Predictor;
|
|
146
|
+
winProbability: WinProbability;
|
|
147
|
+
gameState: string;
|
|
148
|
+
activeAthletes?: ActiveAthletes;
|
|
149
|
+
meta: Meta;
|
|
150
|
+
promotion?: StatsPromotion;
|
|
151
|
+
previousGames?: {
|
|
152
|
+
displayOrder: number;
|
|
153
|
+
team: {
|
|
154
|
+
$key: string;
|
|
155
|
+
};
|
|
156
|
+
events: {
|
|
157
|
+
team: {
|
|
158
|
+
$key: string;
|
|
159
|
+
homeAway: string;
|
|
160
|
+
};
|
|
161
|
+
score: string;
|
|
162
|
+
gameResult: string;
|
|
163
|
+
}[];
|
|
164
|
+
}[];
|
|
165
|
+
}
|
|
166
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { StatsApiResponse } from './interfaces/IStats';
|
|
2
|
+
export declare const MOCK_STATS_API_PRE_GAME_RESPONSE: StatsApiResponse;
|
|
3
|
+
export declare const mockTeamWithStatistics: {
|
|
4
|
+
id: string;
|
|
5
|
+
uid: string;
|
|
6
|
+
abbreviation: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
color: string;
|
|
9
|
+
logo: string;
|
|
10
|
+
homeAway: string;
|
|
11
|
+
statistics: {
|
|
12
|
+
$key: string;
|
|
13
|
+
value: number;
|
|
14
|
+
displayValue: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
export declare const mockAwayTeamWithStatistics: {
|
|
19
|
+
id: string;
|
|
20
|
+
uid: string;
|
|
21
|
+
abbreviation: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
color: string;
|
|
24
|
+
logo: string;
|
|
25
|
+
homeAway: string;
|
|
26
|
+
statistics: {
|
|
27
|
+
$key: string;
|
|
28
|
+
value: number;
|
|
29
|
+
displayValue: string;
|
|
30
|
+
displayName: string;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
33
|
+
export declare const mockStatsResponseWithTeamStats: {
|
|
34
|
+
entities: {
|
|
35
|
+
teams: {
|
|
36
|
+
'12': {
|
|
37
|
+
id: string;
|
|
38
|
+
uid: string;
|
|
39
|
+
abbreviation: string;
|
|
40
|
+
displayName: string;
|
|
41
|
+
color: string;
|
|
42
|
+
logo: string;
|
|
43
|
+
homeAway: string;
|
|
44
|
+
statistics: {
|
|
45
|
+
$key: string;
|
|
46
|
+
value: number;
|
|
47
|
+
displayValue: string;
|
|
48
|
+
displayName: string;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
'21': {
|
|
52
|
+
id: string;
|
|
53
|
+
uid: string;
|
|
54
|
+
abbreviation: string;
|
|
55
|
+
displayName: string;
|
|
56
|
+
color: string;
|
|
57
|
+
logo: string;
|
|
58
|
+
homeAway: string;
|
|
59
|
+
statistics: {
|
|
60
|
+
$key: string;
|
|
61
|
+
value: number;
|
|
62
|
+
displayValue: string;
|
|
63
|
+
displayName: string;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
athletes: {};
|
|
68
|
+
};
|
|
69
|
+
leaders: never[];
|
|
70
|
+
header: {
|
|
71
|
+
teams: never[];
|
|
72
|
+
linescoresHeader: never[];
|
|
73
|
+
};
|
|
74
|
+
predictor: null;
|
|
75
|
+
winProbability: null;
|
|
76
|
+
gameState: string;
|
|
77
|
+
meta: {
|
|
78
|
+
gp_topic: string;
|
|
79
|
+
picker_topic: string;
|
|
80
|
+
gameState: string;
|
|
81
|
+
};
|
|
82
|
+
};
|