@maestro_io/maestro-web-sdk 3.3.1 → 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/f8820fca3a2a7957f753167da0884f9d.png +0 -0
- package/dist/maestro-web-sdk.esm.js +12 -12
- package/dist/maestro-web-sdk.esm.js.map +1 -1
- package/dist/maestro-web-sdk.umd.js +12 -12
- package/dist/maestro-web-sdk.umd.js.map +1 -1
- package/dist/package.json +87 -0
- package/dist/src/__mocks__/sentry.d.ts +4 -0
- package/dist/src/components/atoms/BaseButton/BaseButton.js +11 -0
- package/dist/src/components/atoms/BaseButton/index.js +2 -0
- package/dist/src/components/atoms/Image/index.js +34 -0
- package/dist/src/components/atoms/Rive/index.js +53 -0
- package/dist/src/components/atoms/SvgIcon/BetGeneralIcon.js +9 -0
- package/dist/src/components/atoms/SvgIcon/BetsIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/BetsWarningIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/CheckmarkIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/CollapseIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/ExpandIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/FantasyIcon.js +15 -0
- package/dist/src/components/atoms/SvgIcon/FlameIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/Icon.js +44 -0
- package/dist/src/components/atoms/SvgIcon/KeyPlaysIcon.js +10 -0
- package/dist/src/components/atoms/SvgIcon/MobilePhoneIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/PlayIcon.js +8 -0
- package/dist/src/components/atoms/SvgIcon/ShopIcon.js +7 -0
- package/dist/src/components/atoms/SvgIcon/StatsIcon.js +12 -0
- package/dist/src/components/atoms/SvgIcon/TimesIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/WarningIcon.js +8 -0
- package/dist/src/components/atoms/SvgIcon/index.js +2 -0
- package/dist/src/components/core/App/App.js +35 -0
- package/dist/src/components/core/App/index.js +2 -0
- package/dist/src/components/core/OverlayContainer.js +58 -0
- package/dist/src/components/core/PanelManager/PanelManager.js +86 -0
- package/dist/src/components/core/PanelManager/index.js +2 -0
- package/dist/src/components/core/ScrollableContainer/FocusableItem.js +38 -0
- package/dist/src/components/core/ScrollableContainer/ScrollableContainer.js +168 -0
- package/dist/src/components/core/ScrollableContainer/index.js +2 -0
- package/dist/src/components/molecules/ActionButton/ActionButton.js +10 -0
- package/dist/src/components/molecules/ActionButton/index.js +2 -0
- package/dist/src/components/molecules/HeadshotImage/HeadshotImage.js +50 -0
- package/dist/src/components/molecules/HeadshotImage/index.js +2 -0
- package/dist/src/components/molecules/Overlay/Overlay.js +139 -0
- package/dist/src/components/molecules/Overlay/index.js +2 -0
- package/dist/src/components/molecules/PanelNavButton/PanelNavButton.js +27 -0
- package/dist/src/components/molecules/PanelNavButton/index.js +2 -0
- package/dist/src/components/molecules/SegmentButton/SegmentButton.js +10 -0
- package/dist/src/components/molecules/SegmentButton/index.js +2 -0
- package/dist/src/components/molecules/TabLoadError/TabLoadError.js +14 -0
- package/dist/src/components/molecules/TabLoadError/index.js +2 -0
- package/dist/src/components/molecules/WatchButton/WatchButton.js +15 -0
- package/dist/src/components/molecules/WatchButton/index.js +2 -0
- package/dist/src/components/organisms/PanelNavigation/PanelNavigation.js +60 -0
- package/dist/src/components/organisms/PanelNavigation/index.js +2 -0
- package/dist/src/components/organisms/SegmentController/SegmentController.js +76 -0
- package/dist/src/components/organisms/SegmentController/index.js +2 -0
- package/dist/src/development/MaestroEventDelegate.js +109 -0
- package/dist/src/development/TimeSeek.js +218 -0
- package/dist/src/development/development.js +33 -0
- package/dist/src/external/AxiosNetworkClient.js +110 -0
- package/dist/src/external/LocalStorageCacheManager.js +213 -0
- package/dist/src/external/ReactRenderer.js +53 -0
- package/dist/src/external/mocks/MockExternalNetworkClient.js +187 -0
- package/dist/src/external/ports/cacheManager.js +1 -0
- package/dist/src/external/ports/networkClient.js +1 -0
- package/dist/src/external/ports/renderer.d.ts +1 -2
- package/dist/src/external/ports/renderer.js +1 -0
- package/dist/src/external/spatial-navigation/__mocks__/withFocusable.d.ts +8 -0
- package/dist/src/external/spatial-navigation/__mocks__/withFocusable.js +7 -0
- package/dist/src/external/spatial-navigation/index.js +3 -0
- package/dist/src/external/spatial-navigation/measureLayout.js +30 -0
- package/dist/src/external/spatial-navigation/spatialNavigation.js +876 -0
- package/dist/src/external/spatial-navigation/utils.js +6 -0
- package/dist/src/external/spatial-navigation/visualDebugger.js +76 -0
- package/dist/src/external/spatial-navigation/withFocusable.js +245 -0
- package/dist/src/helpers/Observable.js +37 -0
- package/dist/src/helpers/strings.js +14 -0
- package/dist/src/helpers/url.js +12 -0
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.js +165 -0
- package/dist/src/interfaces/IMaestroEvent.d.ts +12 -0
- package/dist/src/interfaces/IMaestroEvent.js +18 -0
- package/dist/src/interfaces/IMaestroEventDelegate.js +1 -0
- package/dist/src/interfaces/IMaestroManager.js +1 -0
- package/dist/src/interfaces/IUserSettings.js +20 -0
- package/dist/src/models/IModel.js +1 -0
- package/dist/src/models/IPanel.js +40 -0
- package/dist/src/models/ITheme.js +20 -0
- package/dist/src/models/IWinningBet.js +1 -0
- package/dist/src/modules/bets/interfaces/IBets.js +1 -0
- package/dist/src/modules/bets/mocks.js +573 -0
- package/dist/src/modules/bets/types/BetsAnalyticsTypes.js +1 -0
- package/dist/src/modules/bets/view/BetsView.js +143 -0
- package/dist/src/modules/bets/view/HotProps/HotPropsView.js +150 -0
- package/dist/src/modules/bets/view/SixPack/SixPackView.js +110 -0
- package/dist/src/modules/bets/view/UserBets/BetResult/BetResult.js +6 -0
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCard.js +149 -0
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +34 -0
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +18 -0
- package/dist/src/modules/bets/view/UserBets/Boost/Boost.js +6 -0
- package/dist/src/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +9 -0
- package/dist/src/modules/bets/view/UserBets/Parlay/Parlay.js +13 -0
- package/dist/src/modules/bets/view/UserBets/Straight/Straight.js +6 -0
- package/dist/src/modules/bets/view/UserBets/Teaser/Teaser.js +13 -0
- package/dist/src/modules/bets/view/UserBets/UserBetsView.js +107 -0
- package/dist/src/modules/bets/view/components/Bet/Bet.js +32 -0
- package/dist/src/modules/bets/view/components/BetPill/BetPill.js +6 -0
- package/dist/src/modules/bets/view/components/BetsCard/BetsCard.js +15 -0
- package/dist/src/modules/bets/view/components/BetsCard/BetsCardHeader.js +20 -0
- package/dist/src/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +14 -0
- package/dist/src/modules/bets/view/components/LocationWarning/LocationWarning.js +16 -0
- package/dist/src/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +78 -0
- package/dist/src/modules/bets/view/components/PromoCodeBanner/index.js +1 -0
- package/dist/src/modules/bets/view-model/BetsViewModel.js +974 -0
- package/dist/src/modules/fantasy/components/ExpandedAthleteList/ExpandedAthletesList.js +107 -0
- package/dist/src/modules/fantasy/components/ExpandedAthleteList/index.js +1 -0
- package/dist/src/modules/fantasy/components/LeagueCard/LeagueCard.js +20 -0
- package/dist/src/modules/fantasy/components/LeagueCard/index.js +2 -0
- package/dist/src/modules/fantasy/components/TopPlayerCard/TopPlayerCard.js +29 -0
- package/dist/src/modules/fantasy/components/TopPlayerCard/index.js +2 -0
- package/dist/src/modules/fantasy/mocks.js +3682 -0
- package/dist/src/modules/fantasy/types.js +6 -0
- package/dist/src/modules/fantasy/view/ActiveAthletesMarquee/ActiveAthletesMarquee.js +74 -0
- package/dist/src/modules/fantasy/view/ActiveAthletesMarquee/index.js +2 -0
- package/dist/src/modules/fantasy/view/ErrorBoundary.d.ts +13 -0
- package/dist/src/modules/fantasy/view/FantasyItemView.js +74 -0
- package/dist/src/modules/fantasy/view/FantasyView.js +133 -0
- package/dist/src/modules/fantasy/view/InactiveLeague/DraftDateCountdown.js +95 -0
- package/dist/src/modules/fantasy/view/InactiveLeague/InactiveLeague.js +13 -0
- package/dist/src/modules/fantasy/view/InactiveLeague/index.js +2 -0
- package/dist/src/modules/fantasy/view/LoginView/LoginView.js +27 -0
- package/dist/src/modules/fantasy/view/LoginView/index.js +2 -0
- package/dist/src/modules/fantasy/view/MatchupPair/DoubleAthleteCard/DoubleAthleteCard.js +25 -0
- package/dist/src/modules/fantasy/view/MatchupPair/DoubleAthleteCard/index.js +2 -0
- package/dist/src/modules/fantasy/view/MatchupPair/ExpandedDoubleAthleteCards.js +9 -0
- package/dist/src/modules/fantasy/view/MatchupPair/MatchupPair.js +118 -0
- package/dist/src/modules/fantasy/view/MatchupPair/index.js +2 -0
- package/dist/src/modules/fantasy/view/MatchupSingle/ExpandedSingleAthleteCards.js +9 -0
- package/dist/src/modules/fantasy/view/MatchupSingle/MatchupSingle.js +108 -0
- package/dist/src/modules/fantasy/view/MatchupSingle/SingleAthleteCard/SingleAthleteCard.js +18 -0
- package/dist/src/modules/fantasy/view/MatchupSingle/SingleAthleteCard/index.js +2 -0
- package/dist/src/modules/fantasy/view/MatchupSingle/index.js +2 -0
- package/dist/src/modules/fantasy/view/PromoView/PromoView.js +12 -0
- package/dist/src/modules/fantasy/view/PromoView/index.js +2 -0
- package/dist/src/modules/fantasy/view/index.js +2 -0
- package/dist/src/modules/fantasy/view-model/FantasyViewModel.FantasyPolling.js +132 -0
- package/dist/src/modules/fantasy/view-model/FantasyViewModel.LeagueManagerPolling.js +141 -0
- package/dist/src/modules/fantasy/view-model/FantasyViewModel.js +534 -0
- package/dist/src/modules/key-plays/constants.js +292 -0
- package/dist/src/modules/key-plays/interfaces/IKeyPlays.js +14 -0
- package/dist/src/modules/key-plays/interfaces/IKeyPlaysResponse.js +1 -0
- package/dist/src/modules/key-plays/view/KeyPlayCardScoreTagView.js +16 -0
- package/dist/src/modules/key-plays/view/KeyPlayCardView.js +144 -0
- package/dist/src/modules/key-plays/view/KeyPlayErrorStateView.js +65 -0
- package/dist/src/modules/key-plays/view/KeyPlaysView.js +151 -0
- package/dist/src/modules/key-plays/view-model/KeyPlaysViewModel.js +246 -0
- package/dist/src/modules/shop/mocks.js +390 -0
- package/dist/src/modules/shop/types.js +7 -0
- package/dist/src/modules/shop/view/ProductDetailView/ProductDetailView.js +56 -0
- package/dist/src/modules/shop/view/ProductDetailView/index.js +2 -0
- package/dist/src/modules/shop/view/ShopView.js +182 -0
- package/dist/src/modules/shop/view/components/BrowseCard/BrowseCard.js +23 -0
- package/dist/src/modules/shop/view/components/BrowseCard/index.js +2 -0
- package/dist/src/modules/shop/view/components/ProductSummaryCard/ProductSummaryCard.js +26 -0
- package/dist/src/modules/shop/view/components/ProductSummaryCard/index.js +1 -0
- package/dist/src/modules/shop/view/components/ShopPromoView/ShopPromoView.js +19 -0
- package/dist/src/modules/shop/view/components/ShopPromoView/index.js +1 -0
- package/dist/src/modules/shop/view/components/ShopSection/ShopSection.d.ts +1 -0
- package/dist/src/modules/shop/view/components/ShopSection/ShopSection.js +61 -0
- package/dist/src/modules/shop/view/components/ShopSection/ShopSectionItem.d.ts +18 -0
- package/dist/src/modules/shop/view/components/ShopSection/ShopSectionItem.js +22 -0
- package/dist/src/modules/shop/view/components/ShopSection/index.js +1 -0
- package/dist/src/modules/shop/view/index.js +2 -0
- package/dist/src/modules/shop/view-model/ShopViewModel.ShopPolling.js +111 -0
- package/dist/src/modules/shop/view-model/ShopViewModel.js +353 -0
- package/dist/src/modules/stats/interfaces/IStats.js +1 -0
- package/dist/src/modules/stats/mocks.js +746 -0
- package/dist/src/modules/stats/utils/driveSummaryUtils.js +48 -0
- package/dist/src/modules/stats/utils/renderTeamStatistic.js +16 -0
- package/dist/src/modules/stats/utils.js +62 -0
- package/dist/src/modules/stats/view/ActiveAthletes/ActiveAthletes.js +98 -0
- package/dist/src/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.js +27 -0
- package/dist/src/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.js +89 -0
- package/dist/src/modules/stats/view/ActiveAthletes/index.js +2 -0
- package/dist/src/modules/stats/view/DriveSummary/DrivePlayCard.js +70 -0
- package/dist/src/modules/stats/view/DriveSummary/DriveSummary.js +87 -0
- package/dist/src/modules/stats/view/DriveSummary/ExpandedItems/DriveSummaryExpanded.js +129 -0
- package/dist/src/modules/stats/view/DriveSummary/Header/DriveSummaryHeader.js +26 -0
- package/dist/src/modules/stats/view/DriveSummary/MainStat/MainStat.js +24 -0
- package/dist/src/modules/stats/view/DriveSummary/index.js +2 -0
- package/dist/src/modules/stats/view/GameLeaders/GameLeaders.js +48 -0
- package/dist/src/modules/stats/view/GameLeaders/index.js +2 -0
- package/dist/src/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +55 -0
- package/dist/src/modules/stats/view/MatchPredictor/DonutChart/index.js +1 -0
- package/dist/src/modules/stats/view/MatchPredictor/MatchPredictorView.js +60 -0
- package/dist/src/modules/stats/view/MatchPredictor/index.js +2 -0
- package/dist/src/modules/stats/view/Penalties/Penalties.js +6 -0
- package/dist/src/modules/stats/view/Penalties/index.js +2 -0
- package/dist/src/modules/stats/view/RecentGames/RecentGames.js +23 -0
- package/dist/src/modules/stats/view/RecentGames/index.js +2 -0
- package/dist/src/modules/stats/view/ScoringSummary/ExpandedScores/ExpandedScores.js +121 -0
- package/dist/src/modules/stats/view/ScoringSummary/ExpandedScores/index.js +2 -0
- package/dist/src/modules/stats/view/ScoringSummary/ScoreItem/ScoreItem.js +62 -0
- package/dist/src/modules/stats/view/ScoringSummary/ScoreItem/index.js +2 -0
- package/dist/src/modules/stats/view/ScoringSummary/ScoresSection/ScoresSection.js +23 -0
- package/dist/src/modules/stats/view/ScoringSummary/ScoresSection/index.js +2 -0
- package/dist/src/modules/stats/view/ScoringSummary/ScoringSummary.js +106 -0
- package/dist/src/modules/stats/view/ScoringSummary/index.js +2 -0
- package/dist/src/modules/stats/view/StatsItemView.js +92 -0
- package/dist/src/modules/stats/view/StatsQRCode/StatsQRCodeView.js +36 -0
- package/dist/src/modules/stats/view/StatsQRCode/index.js +1 -0
- package/dist/src/modules/stats/view/StatsView.js +137 -0
- package/dist/src/modules/stats/view/TeamStats/TeamStatsView.js +43 -0
- package/dist/src/modules/stats/view/TeamStats/index.js +1 -0
- package/dist/src/modules/stats/view/Teams/StatsCarousel.js +83 -0
- package/dist/src/modules/stats/view/Teams/StatsProgressBar.js +19 -0
- package/dist/src/modules/stats/view/Teams/Teams.js +27 -0
- package/dist/src/modules/stats/view/Teams/index.js +2 -0
- package/dist/src/modules/stats/view/WinProbability/WinProbability.js +28 -0
- package/dist/src/modules/stats/view/WinProbability/index.js +2 -0
- package/dist/src/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +89 -0
- package/dist/src/modules/stats/view/components/AthletesStatistics/StatisticTable.js +12 -0
- package/dist/src/modules/stats/view/components/AthletesStatistics/index.js +2 -0
- package/dist/src/modules/stats/view/index.js +2 -0
- package/dist/src/modules/stats/view-model/StatsViewModel.d.ts +5 -0
- package/dist/src/modules/stats/view-model/StatsViewModel.js +989 -0
- package/dist/src/sentry.js +31 -0
- package/dist/src/services/AnalyticsService/AnalyticsService.d.ts +12 -7
- package/dist/src/services/AnalyticsService/AnalyticsService.js +402 -0
- package/dist/src/services/AnalyticsService/types.js +1 -0
- package/dist/src/services/BetsService.js +122 -0
- package/dist/src/services/FantasyService.js +92 -0
- package/dist/src/services/GlobalService/GlobalService.d.ts +9 -0
- package/dist/src/services/GlobalService/PageService.d.ts +9 -0
- package/dist/src/services/GlobalService/index.d.ts +2 -0
- package/dist/src/services/GlobalService/mocks.d.ts +2 -0
- package/dist/src/services/GlobalService/types.d.ts +11 -0
- package/dist/src/services/InsightsService/InsightsPayloadBuilder.d.ts +1 -2
- package/dist/src/services/InsightsService/InsightsPayloadBuilder.js +386 -0
- package/dist/src/services/InsightsService/InsightsService.js +74 -0
- package/dist/src/services/NetworkManager/NetworkManager.js +457 -0
- package/dist/src/services/NetworkManager/NetworkManagerFactory.js +101 -0
- package/dist/src/services/NetworkManager/errors.js +45 -0
- package/dist/src/services/NetworkManager/types.js +10 -0
- package/dist/src/services/PageService/PageService.d.ts +9 -0
- package/dist/src/services/PageService/PageService.js +39 -0
- package/dist/src/services/PageService/index.d.ts +2 -0
- package/dist/src/services/PageService/index.js +2 -0
- package/dist/src/services/PageService/mocks.d.ts +2 -0
- package/dist/src/services/PageService/mocks.js +104 -0
- package/dist/src/services/PageService/types.d.ts +76 -0
- package/dist/src/services/PageService/types.js +1 -0
- package/dist/src/services/ShopService.js +46 -0
- package/dist/src/services/StaticService/PageService.d.ts +9 -0
- package/dist/src/services/StaticService/StaticService.d.ts +3 -1
- package/dist/src/services/StaticService/StaticService.js +59 -0
- package/dist/src/services/StaticService/index.js +2 -0
- package/dist/src/services/StaticService/mocks.js +104 -0
- package/dist/src/services/StaticService/types.js +1 -0
- package/dist/src/services/StatsService.d.ts +1 -0
- package/dist/src/services/StatsService.js +147 -0
- package/dist/src/services/ThemeManager/constants.js +47 -0
- package/dist/src/services/UserSettingsManager.js +155 -0
- package/dist/src/test-polyfills.js +15 -0
- package/dist/src/types/OverlayTypes.js +4 -0
- package/dist/src/view-models/MaestroEventViewModel.d.ts +1 -2
- package/dist/src/view-models/MaestroEventViewModel.js +307 -0
- package/dist/src/view-models/OverlayViewModel.js +222 -0
- package/dist/src/view-models/PanelManagerViewModel.js +212 -0
- package/dist/src/view-models/ViewModel.js +32 -0
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Observable } from '@/helpers/Observable';
|
|
2
|
+
import { DEFAULT_USER_SETTINGS, } from '@/interfaces/IUserSettings';
|
|
3
|
+
import { MaestroPanelType } from '@/models/IPanel';
|
|
4
|
+
const PANEL_TYPE_SETTINGS_KEY_MAP = {
|
|
5
|
+
[MaestroPanelType.BETS]: 'bets',
|
|
6
|
+
[MaestroPanelType.STATS]: 'stats',
|
|
7
|
+
[MaestroPanelType.KEY_PLAYS]: 'keyPlays',
|
|
8
|
+
[MaestroPanelType.FANTASY]: 'fantasy',
|
|
9
|
+
[MaestroPanelType.SHOP]: 'shop',
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* UserSettingsManager - Singleton service for managing user settings
|
|
13
|
+
* Uses Observable pattern for reactive updates across the SDK
|
|
14
|
+
*/
|
|
15
|
+
export class UserSettingsManager {
|
|
16
|
+
constructor() {
|
|
17
|
+
Object.defineProperty(this, "_settings", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
this._settings = new Observable(DEFAULT_USER_SETTINGS);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the singleton instance of UserSettingsManager
|
|
27
|
+
*/
|
|
28
|
+
static getInstance() {
|
|
29
|
+
if (!UserSettingsManager.instance) {
|
|
30
|
+
UserSettingsManager.instance = new UserSettingsManager();
|
|
31
|
+
}
|
|
32
|
+
return UserSettingsManager.instance;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the current settings as an Observable
|
|
36
|
+
*/
|
|
37
|
+
get settings() {
|
|
38
|
+
return this._settings;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the current settings value (snapshot)
|
|
42
|
+
*/
|
|
43
|
+
getCurrentSettings() {
|
|
44
|
+
return this._settings.value;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Update user settings with validation and merge logic
|
|
48
|
+
* @param userSettings - New settings to apply
|
|
49
|
+
*/
|
|
50
|
+
updateSettings(userSettings) {
|
|
51
|
+
if (!this.validateSettings(userSettings)) {
|
|
52
|
+
console.warn('Invalid user settings provided, using default setting');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const mergedSettings = this.mergeSettings(this._settings.value, userSettings);
|
|
56
|
+
this._settings.value = mergedSettings;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get settings for a specific panel type
|
|
60
|
+
* @param panelType - Panel type to get settings for
|
|
61
|
+
*/
|
|
62
|
+
getPanelSettings(panelType) {
|
|
63
|
+
return this._settings.value.panels?.[panelType];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if a panel should be hidden
|
|
67
|
+
* @param panelType - Panel type to check
|
|
68
|
+
*/
|
|
69
|
+
isPanelHidden(panelType) {
|
|
70
|
+
const panelKey = this.mapPanelTypeToSettingsKey(panelType);
|
|
71
|
+
if (!panelKey)
|
|
72
|
+
return false;
|
|
73
|
+
const panelSettings = this.getPanelSettings(panelKey);
|
|
74
|
+
return panelSettings?.hidePanel === true;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if wagers should be hidden for betting panel
|
|
78
|
+
*/
|
|
79
|
+
shouldHideWagers() {
|
|
80
|
+
const betsSettings = this.getPanelSettings('bets');
|
|
81
|
+
return betsSettings?.hideWagers === true;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Reset settings to defaults
|
|
85
|
+
*/
|
|
86
|
+
resetToDefaults() {
|
|
87
|
+
this._settings.value = DEFAULT_USER_SETTINGS;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate settings structure and values
|
|
91
|
+
* @param settings - Settings to validate
|
|
92
|
+
*/
|
|
93
|
+
validateSettings(settings) {
|
|
94
|
+
if (!settings || typeof settings !== 'object') {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
// Validate panels object if present
|
|
98
|
+
if (settings.panels && typeof settings.panels !== 'object') {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
// Validate individual panel settings
|
|
102
|
+
if (settings.panels) {
|
|
103
|
+
for (const [panelKey, panelSettings] of Object.entries(settings.panels)) {
|
|
104
|
+
if (panelSettings && typeof panelSettings !== 'object') {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
// Validate boolean properties
|
|
108
|
+
if (panelSettings) {
|
|
109
|
+
for (const [key, value] of Object.entries(panelSettings)) {
|
|
110
|
+
if (value !== undefined && typeof value !== 'boolean') {
|
|
111
|
+
console.warn(`Invalid setting value for ${panelKey}.${key}: expected boolean, got ${typeof value}`);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Merge user settings with current settings (deep merge)
|
|
122
|
+
* @param currentSettings - Current settings
|
|
123
|
+
* @param userSettings - New settings to merge
|
|
124
|
+
*/
|
|
125
|
+
mergeSettings(currentSettings, userSettings) {
|
|
126
|
+
const merged = {
|
|
127
|
+
panels: {
|
|
128
|
+
...currentSettings.panels,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
if (userSettings.panels) {
|
|
132
|
+
for (const [panelKey, panelSettings] of Object.entries(userSettings.panels)) {
|
|
133
|
+
if (panelSettings) {
|
|
134
|
+
const currentPanelSettings = merged.panels[panelKey];
|
|
135
|
+
const mergedPanelSettings = { ...currentPanelSettings };
|
|
136
|
+
// Filter out undefined values and only merge defined ones
|
|
137
|
+
for (const [settingKey, settingValue] of Object.entries(panelSettings)) {
|
|
138
|
+
if (settingValue !== undefined) {
|
|
139
|
+
mergedPanelSettings[settingKey] = settingValue;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
merged.panels[panelKey] = mergedPanelSettings;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return merged;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Map MaestroPanelType to settings key
|
|
150
|
+
* @param panelType - Panel type from MaestroPanelType enum
|
|
151
|
+
*/
|
|
152
|
+
mapPanelTypeToSettingsKey(panelType) {
|
|
153
|
+
return PANEL_TYPE_SETTINGS_KEY_MAP[panelType] || null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This file must be the first import in test files
|
|
2
|
+
// Handle globalThis for Node.js < 12
|
|
3
|
+
if (typeof globalThis === 'undefined') {
|
|
4
|
+
global.globalThis = global;
|
|
5
|
+
}
|
|
6
|
+
// Polyfill for FinalizationRegistry in Node.js < 14.6.0
|
|
7
|
+
const globalWithFR = globalThis;
|
|
8
|
+
if (typeof globalWithFR.FinalizationRegistry === 'undefined') {
|
|
9
|
+
globalWithFR.FinalizationRegistry = class FinalizationRegistry {
|
|
10
|
+
constructor(_callback) { }
|
|
11
|
+
register(_target, _heldValue, _unregisterToken) { }
|
|
12
|
+
unregister(_unregisterToken) { }
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -10,7 +10,6 @@ import IMaestroKeyPlaysResponse from '../modules/key-plays/interfaces/IKeyPlaysR
|
|
|
10
10
|
import { MaestroPanelType } from '@/models/IPanel';
|
|
11
11
|
import { IUserSettings } from '../interfaces/IUserSettings';
|
|
12
12
|
import { PanelManagerViewModel } from './PanelManagerViewModel';
|
|
13
|
-
import AnalyticsService from '@/services/AnalyticsService/AnalyticsService';
|
|
14
13
|
import FantasyViewModel from '@/modules/fantasy/view-model/FantasyViewModel';
|
|
15
14
|
import ShopViewModel from '@/modules/shop/view-model/ShopViewModel';
|
|
16
15
|
export declare class MaestroEventViewModel extends ViewModel implements IMaestroEvent {
|
|
@@ -27,11 +26,11 @@ export declare class MaestroEventViewModel extends ViewModel implements IMaestro
|
|
|
27
26
|
shopViewModel: ShopViewModel | null;
|
|
28
27
|
panelManagerViewModel: PanelManagerViewModel;
|
|
29
28
|
navigation: SpatialNavigation;
|
|
30
|
-
analyticsService: AnalyticsService;
|
|
31
29
|
constructor(eventId: string | undefined, delegate: IMaestroEventDelegate);
|
|
32
30
|
setActivePanel(panelType: MaestroPanelType): void;
|
|
33
31
|
updatePlayerTimeCode(timestamp: number): void;
|
|
34
32
|
getPlayerTimeCode(): number | null;
|
|
33
|
+
setPanelData(panelData: Record<string, any>): void;
|
|
35
34
|
deinit(): Promise<void>;
|
|
36
35
|
updateKeyPlaysData(data: IMaestroKeyPlaysResponse | null): Promise<void>;
|
|
37
36
|
updateUserSettings(settings: IUserSettings): Promise<void>;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { Observable } from '../helpers/Observable';
|
|
2
|
+
import { ViewModel } from './ViewModel';
|
|
3
|
+
import KeyPlaysViewModel from '../modules/key-plays/view-model/KeyPlaysViewModel';
|
|
4
|
+
import BetsViewModel from '../modules/bets/view-model/BetsViewModel';
|
|
5
|
+
import SpatialNavigation from '@/external/spatial-navigation/spatialNavigation';
|
|
6
|
+
import StatsViewModel from '../modules/stats/view-model/StatsViewModel';
|
|
7
|
+
import { UserSettingsManager } from '../services/UserSettingsManager';
|
|
8
|
+
import { PanelManagerViewModel } from './PanelManagerViewModel';
|
|
9
|
+
import SDK from '..';
|
|
10
|
+
import StaticService from '@/services/StaticService';
|
|
11
|
+
import FantasyViewModel from '@/modules/fantasy/view-model/FantasyViewModel';
|
|
12
|
+
import ShopViewModel from '@/modules/shop/view-model/ShopViewModel';
|
|
13
|
+
export class MaestroEventViewModel extends ViewModel {
|
|
14
|
+
constructor(eventId = '', delegate) {
|
|
15
|
+
super();
|
|
16
|
+
Object.defineProperty(this, "_eventId", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: new Observable('')
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "_title", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: new Observable('')
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "_isLive", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: new Observable(false)
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "_isShowingPanel", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: new Observable(false)
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "playerTimeCode", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: null
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(this, "delegate", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true,
|
|
50
|
+
value: void 0
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(this, "keyPlaysViewModel", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: void 0
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(this, "fantasyViewModel", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(this, "betsViewModel", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true,
|
|
68
|
+
value: void 0
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(this, "statsViewModel", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
value: void 0
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(this, "shopViewModel", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
configurable: true,
|
|
79
|
+
writable: true,
|
|
80
|
+
value: void 0
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(this, "panelManagerViewModel", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
configurable: true,
|
|
85
|
+
writable: true,
|
|
86
|
+
value: void 0
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(this, "navigation", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: void 0
|
|
93
|
+
});
|
|
94
|
+
this._eventId.value = eventId;
|
|
95
|
+
this.delegate = delegate;
|
|
96
|
+
const pageConfig = SDK.getPageConfig();
|
|
97
|
+
// Conditionally instantiate view models based on page configuration
|
|
98
|
+
this.keyPlaysViewModel = StaticService.isPanelAvailable(pageConfig, 'espnKeyPlays')
|
|
99
|
+
? new KeyPlaysViewModel()
|
|
100
|
+
: null;
|
|
101
|
+
this.betsViewModel = StaticService.isPanelAvailable(pageConfig, 'espnBet')
|
|
102
|
+
? new BetsViewModel(eventId, delegate)
|
|
103
|
+
: null;
|
|
104
|
+
this.statsViewModel = StaticService.isPanelAvailable(pageConfig, 'espnStats')
|
|
105
|
+
? new StatsViewModel(eventId, delegate)
|
|
106
|
+
: null;
|
|
107
|
+
this.fantasyViewModel = StaticService.isPanelAvailable(pageConfig, 'espnFantasy')
|
|
108
|
+
? new FantasyViewModel(eventId, delegate)
|
|
109
|
+
: null;
|
|
110
|
+
this.shopViewModel = StaticService.isPanelAvailable(pageConfig, 'espnShop')
|
|
111
|
+
? new ShopViewModel(eventId)
|
|
112
|
+
: null;
|
|
113
|
+
this.panelManagerViewModel = new PanelManagerViewModel();
|
|
114
|
+
this.navigation = new SpatialNavigation({
|
|
115
|
+
throttle: 150,
|
|
116
|
+
throttleKeypresses: true,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
setActivePanel(panelType) {
|
|
120
|
+
const index = this.panelManagerViewModel.getIndex(panelType);
|
|
121
|
+
if (index === null) {
|
|
122
|
+
console.warn(`Panel type "${panelType}" not found.`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (!this.navigation.paused) {
|
|
126
|
+
console.warn('Cannot set active panel while navigation is not paused. Doing so will cause focus issues.');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.panelManagerViewModel.setActivePanel(panelType);
|
|
130
|
+
this.navigation.focusKey = `PANEL_NAV_BUTTON_${index}`;
|
|
131
|
+
}
|
|
132
|
+
updatePlayerTimeCode(timestamp) {
|
|
133
|
+
const timestampDate = new Date(timestamp);
|
|
134
|
+
if (isNaN(timestampDate.getTime())) {
|
|
135
|
+
console.warn('Invalid timestamp provided:', timestamp);
|
|
136
|
+
console.warn('Make sure the timestamp is a valid number. \nhttps://developers.maestro.io/sdk/web/maestro-event-interface/state/updatePlayerTimeCode');
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.playerTimeCode = timestamp;
|
|
140
|
+
this.keyPlaysViewModel?.onUpdatePlayerTimeCode(this.playerTimeCode);
|
|
141
|
+
this.statsViewModel?.onUpdatePlayerTimeCode(this.playerTimeCode);
|
|
142
|
+
}
|
|
143
|
+
getPlayerTimeCode() {
|
|
144
|
+
return this.playerTimeCode;
|
|
145
|
+
}
|
|
146
|
+
setPanelData(panelData) {
|
|
147
|
+
const panelTypes = Object.keys(panelData);
|
|
148
|
+
// Map panel types to view model instances
|
|
149
|
+
const viewModels = {
|
|
150
|
+
espnStats: this.statsViewModel,
|
|
151
|
+
espnBet: this.betsViewModel,
|
|
152
|
+
espnKeyPlays: this.keyPlaysViewModel,
|
|
153
|
+
espnFantasy: this.fantasyViewModel,
|
|
154
|
+
espnShop: this.shopViewModel,
|
|
155
|
+
};
|
|
156
|
+
for (const panelType of panelTypes) {
|
|
157
|
+
const data = panelData[panelType];
|
|
158
|
+
if (!data)
|
|
159
|
+
continue;
|
|
160
|
+
const viewModel = viewModels[panelType];
|
|
161
|
+
if (!viewModel) {
|
|
162
|
+
// Panel is not initialized, so we ignore the data
|
|
163
|
+
console.log(`[setPanelData] Panel '${panelType}' not initialized/supported. Data ignored.`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Panel exists, call its setPanelData method
|
|
167
|
+
if (panelType === 'espnStats' && viewModel.setPanelData) {
|
|
168
|
+
viewModel.setPanelData(data);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async deinit() {
|
|
174
|
+
this.betsViewModel?.cleanup();
|
|
175
|
+
this.statsViewModel?.cleanup();
|
|
176
|
+
this.fantasyViewModel?.cleanup();
|
|
177
|
+
this.shopViewModel?.cleanup();
|
|
178
|
+
this.navigation.destroy();
|
|
179
|
+
try {
|
|
180
|
+
await this.didHidePanel();
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
console.error('Error during didHidePanel in deinit:', error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
updateKeyPlaysData(data) {
|
|
187
|
+
if (!this.keyPlaysViewModel) {
|
|
188
|
+
return Promise.resolve();
|
|
189
|
+
}
|
|
190
|
+
return this.keyPlaysViewModel.setKeyPlays(data, this.playerTimeCode);
|
|
191
|
+
}
|
|
192
|
+
updateUserSettings(settings) {
|
|
193
|
+
return new Promise((resolve) => {
|
|
194
|
+
UserSettingsManager.getInstance().updateSettings(settings);
|
|
195
|
+
resolve();
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
startFocusManagement() {
|
|
199
|
+
this.navigation.setCurrentFocusedKey(this.navigation.focusKey || 'PANEL_NAV_BUTTON_0', {});
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
this.navigation.resume();
|
|
202
|
+
}, 0);
|
|
203
|
+
return Promise.resolve();
|
|
204
|
+
}
|
|
205
|
+
didStartPlayingClip(index) {
|
|
206
|
+
if (!this.keyPlaysViewModel)
|
|
207
|
+
return;
|
|
208
|
+
this.keyPlaysViewModel.lastPlayedClipIndex.value = index;
|
|
209
|
+
this.keyPlaysViewModel.currentClipPlaybackProgress.value = 0;
|
|
210
|
+
this.keyPlaysViewModel.currentlyPlayingClipIndex.value = index;
|
|
211
|
+
this.keyPlaysViewModel.clearLoadFailureStatus(index);
|
|
212
|
+
}
|
|
213
|
+
didStopPlayingClip(index) {
|
|
214
|
+
if (!this.keyPlaysViewModel)
|
|
215
|
+
return;
|
|
216
|
+
this.keyPlaysViewModel.lastPlayedClipIndex.value = index;
|
|
217
|
+
this.keyPlaysViewModel.currentlyPlayingClipIndex.value = null;
|
|
218
|
+
this.keyPlaysViewModel.currentClipPlaybackProgress.value = null;
|
|
219
|
+
}
|
|
220
|
+
didFailToPlayClip(index) {
|
|
221
|
+
this.keyPlaysViewModel?.handleKeyPlayLoadFailure(index);
|
|
222
|
+
}
|
|
223
|
+
didUpdatePlaybackProgressOfClip(index, to) {
|
|
224
|
+
if (!this.keyPlaysViewModel)
|
|
225
|
+
return;
|
|
226
|
+
this.keyPlaysViewModel.currentClipPlaybackProgress.value = to;
|
|
227
|
+
this.keyPlaysViewModel.clearLoadFailureStatus(index);
|
|
228
|
+
}
|
|
229
|
+
async didShowPanel() {
|
|
230
|
+
this.isShowingPanel = true;
|
|
231
|
+
}
|
|
232
|
+
async didHidePanel() {
|
|
233
|
+
this.isShowingPanel = false;
|
|
234
|
+
this.navigation.focusKey = null;
|
|
235
|
+
}
|
|
236
|
+
didShowOverlay() {
|
|
237
|
+
throw new Error('Method not implemented.');
|
|
238
|
+
}
|
|
239
|
+
didHideOverlay() {
|
|
240
|
+
throw new Error('Method not implemented.');
|
|
241
|
+
}
|
|
242
|
+
currentEventDoesNotSupportKeyPlays() {
|
|
243
|
+
if (this.keyPlaysViewModel) {
|
|
244
|
+
this.keyPlaysViewModel.errorState.value = 'unsupportedEvent';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
getCurrentEventID() {
|
|
248
|
+
return this.eventId.value;
|
|
249
|
+
}
|
|
250
|
+
getCurrentlyPlayingClipIndex() {
|
|
251
|
+
return this.keyPlaysViewModel?.currentlyPlayingClipIndex.value ?? null;
|
|
252
|
+
}
|
|
253
|
+
getLastPlayedClipIndex() {
|
|
254
|
+
return this.keyPlaysViewModel?.lastPlayedClipIndex.value ?? null;
|
|
255
|
+
}
|
|
256
|
+
getCurrentClipPlaybackProgress() {
|
|
257
|
+
return this.keyPlaysViewModel?.currentClipPlaybackProgress.value ?? null;
|
|
258
|
+
}
|
|
259
|
+
getKeyPlaysCount() {
|
|
260
|
+
return this.keyPlaysViewModel?.allItems.length ?? 0;
|
|
261
|
+
}
|
|
262
|
+
get eventId() {
|
|
263
|
+
return this._eventId;
|
|
264
|
+
}
|
|
265
|
+
get title() {
|
|
266
|
+
return this._title;
|
|
267
|
+
}
|
|
268
|
+
get isLive() {
|
|
269
|
+
return this._isLive;
|
|
270
|
+
}
|
|
271
|
+
get isShowingPanel() {
|
|
272
|
+
return this._isShowingPanel.value;
|
|
273
|
+
}
|
|
274
|
+
set isShowingPanel(value) {
|
|
275
|
+
this._isShowingPanel.value = value;
|
|
276
|
+
}
|
|
277
|
+
simulateUseCase(useCase, panelType, testData) {
|
|
278
|
+
switch (panelType) {
|
|
279
|
+
case 'bets':
|
|
280
|
+
if (this.betsViewModel) {
|
|
281
|
+
this.betsViewModel.simulateUseCase(useCase, testData);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
console.warn('BetsViewModel is not initialized');
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
case 'stats':
|
|
288
|
+
if (this.statsViewModel) {
|
|
289
|
+
this.statsViewModel.simulateUseCase(useCase, testData);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
console.warn('StatsViewModel is not initialized');
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
default:
|
|
296
|
+
throw new Error(`Unsupported panel type: ${panelType}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* This method is called when the user navigates to the MaestroEventViewModel.
|
|
301
|
+
* It will pause navigation and start focus management.
|
|
302
|
+
*/
|
|
303
|
+
deliverFocus() {
|
|
304
|
+
this.navigation.pause();
|
|
305
|
+
this.delegate.startFocusManagement();
|
|
306
|
+
}
|
|
307
|
+
}
|