@maestro_io/maestro-web-sdk 3.3.0 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +91 -0
- package/dist/src/__mocks__/sentry.d.ts +4 -0
- package/dist/src/components/atoms/BaseButton/BaseButton.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/src/components/atoms/Image/index.js +34 -0
- package/dist/src/components/atoms/Rive/index.d.ts +141 -11
- package/dist/src/components/atoms/Rive/index.js +53 -0
- package/dist/src/components/atoms/SvgIcon/BetGeneralIcon.d.ts +1 -2
- package/dist/src/components/atoms/SvgIcon/BetGeneralIcon.js +9 -0
- package/dist/src/components/atoms/SvgIcon/BetsIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/BetsIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/BetsWarningIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/BetsWarningIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/CheckmarkIcon.d.ts +1 -2
- package/dist/src/components/atoms/SvgIcon/CheckmarkIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/CollapseIcon.d.ts +1 -2
- package/dist/src/components/atoms/SvgIcon/CollapseIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/ExpandIcon.d.ts +1 -2
- package/dist/src/components/atoms/SvgIcon/ExpandIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/FantasyIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/FantasyIcon.js +15 -0
- package/dist/src/components/atoms/SvgIcon/FlameIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/FlameIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/Icon.d.ts +5 -5
- package/dist/src/components/atoms/SvgIcon/Icon.js +44 -0
- package/dist/src/components/atoms/SvgIcon/KeyPlaysIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/KeyPlaysIcon.js +10 -0
- package/dist/src/components/atoms/SvgIcon/MobilePhoneIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/MobilePhoneIcon.js +11 -0
- package/dist/src/components/atoms/SvgIcon/PlayIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/PlayIcon.js +8 -0
- package/dist/src/components/atoms/SvgIcon/ShopIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/ShopIcon.js +7 -0
- package/dist/src/components/atoms/SvgIcon/StatsIcon.d.ts +1 -1
- package/dist/src/components/atoms/SvgIcon/StatsIcon.js +12 -0
- package/dist/src/components/atoms/SvgIcon/TimesIcon.d.ts +1 -2
- package/dist/src/components/atoms/SvgIcon/TimesIcon.js +6 -0
- package/dist/src/components/atoms/SvgIcon/WarningIcon.d.ts +1 -1
- 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.d.ts +1 -1
- 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.d.ts +1 -1
- 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.d.ts +8 -7
- package/dist/src/components/core/ScrollableContainer/ScrollableContainer.js +169 -0
- package/dist/src/components/core/ScrollableContainer/index.js +2 -0
- package/dist/src/components/molecules/ActionButton/ActionButton.d.ts +53 -7
- 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.d.ts +1 -1
- 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.d.ts +1 -1
- 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.d.ts +57 -10
- 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.d.ts +53 -7
- 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.d.ts +1 -1
- 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.d.ts +1 -1
- 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.d.ts +5 -4
- 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.d.ts +1 -1
- package/dist/src/development/TimeSeek.js +218 -0
- package/dist/src/development/development.js +36 -0
- package/dist/src/external/AxiosNetworkClient.js +110 -0
- package/dist/src/external/LocalStorageCacheManager.js +213 -0
- package/dist/src/external/ReactRenderer.js +65 -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.d.ts +53 -7
- 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.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.d.ts +3 -3
- package/dist/src/modules/bets/view/BetsView.js +143 -0
- package/dist/src/modules/bets/view/HotProps/HotPropsView.d.ts +53 -7
- package/dist/src/modules/bets/view/HotProps/HotPropsView.js +150 -0
- package/dist/src/modules/bets/view/SixPack/SixPackView.d.ts +5 -4
- package/dist/src/modules/bets/view/SixPack/SixPackView.js +110 -0
- package/dist/src/modules/bets/view/UserBets/BetResult/BetResult.d.ts +1 -1
- package/dist/src/modules/bets/view/UserBets/BetResult/BetResult.js +6 -0
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCard.d.ts +53 -7
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCard.js +149 -0
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardEvent.d.ts +5 -4
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +34 -0
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardFooter.d.ts +1 -2
- package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +18 -0
- package/dist/src/modules/bets/view/UserBets/Boost/Boost.d.ts +1 -2
- package/dist/src/modules/bets/view/UserBets/Boost/Boost.js +6 -0
- package/dist/src/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.d.ts +1 -2
- package/dist/src/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +9 -0
- package/dist/src/modules/bets/view/UserBets/Parlay/Parlay.d.ts +1 -2
- package/dist/src/modules/bets/view/UserBets/Parlay/Parlay.js +13 -0
- package/dist/src/modules/bets/view/UserBets/Straight/Straight.d.ts +1 -2
- package/dist/src/modules/bets/view/UserBets/Straight/Straight.js +6 -0
- package/dist/src/modules/bets/view/UserBets/Teaser/Teaser.d.ts +1 -2
- package/dist/src/modules/bets/view/UserBets/Teaser/Teaser.js +13 -0
- package/dist/src/modules/bets/view/UserBets/UserBetsView.d.ts +3 -3
- package/dist/src/modules/bets/view/UserBets/UserBetsView.js +107 -0
- package/dist/src/modules/bets/view/components/Bet/Bet.d.ts +99 -11
- package/dist/src/modules/bets/view/components/Bet/Bet.js +32 -0
- package/dist/src/modules/bets/view/components/BetPill/BetPill.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/src/modules/bets/view/components/BetsCard/BetsCardHeader.js +20 -0
- package/dist/src/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.d.ts +1 -1
- package/dist/src/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +14 -0
- package/dist/src/modules/bets/view/components/LocationWarning/LocationWarning.d.ts +1 -1
- package/dist/src/modules/bets/view/components/LocationWarning/LocationWarning.js +16 -0
- package/dist/src/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.d.ts +5 -4
- 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.d.ts +1 -1
- 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.d.ts +53 -7
- 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.d.ts +53 -7
- 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.d.ts +1 -1
- 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.d.ts +6 -5
- package/dist/src/modules/fantasy/view/FantasyItemView.js +74 -0
- package/dist/src/modules/fantasy/view/FantasyView.d.ts +3 -3
- package/dist/src/modules/fantasy/view/FantasyView.js +133 -0
- package/dist/src/modules/fantasy/view/InactiveLeague/DraftDateCountdown.d.ts +1 -1
- package/dist/src/modules/fantasy/view/InactiveLeague/DraftDateCountdown.js +95 -0
- package/dist/src/modules/fantasy/view/InactiveLeague/InactiveLeague.d.ts +53 -7
- 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.d.ts +53 -7
- 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.d.ts +53 -7
- 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.d.ts +1 -1
- package/dist/src/modules/fantasy/view/MatchupPair/ExpandedDoubleAthleteCards.js +9 -0
- package/dist/src/modules/fantasy/view/MatchupPair/MatchupPair.d.ts +53 -7
- 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.d.ts +1 -1
- package/dist/src/modules/fantasy/view/MatchupSingle/ExpandedSingleAthleteCards.js +9 -0
- package/dist/src/modules/fantasy/view/MatchupSingle/MatchupSingle.d.ts +53 -7
- package/dist/src/modules/fantasy/view/MatchupSingle/MatchupSingle.js +108 -0
- package/dist/src/modules/fantasy/view/MatchupSingle/SingleAthleteCard/SingleAthleteCard.d.ts +53 -7
- 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.d.ts +53 -7
- 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.d.ts +1 -1
- package/dist/src/modules/key-plays/view/KeyPlayCardScoreTagView.js +16 -0
- package/dist/src/modules/key-plays/view/KeyPlayCardView.d.ts +7 -6
- package/dist/src/modules/key-plays/view/KeyPlayCardView.js +139 -0
- package/dist/src/modules/key-plays/view/KeyPlayErrorStateView.d.ts +1 -1
- package/dist/src/modules/key-plays/view/KeyPlayErrorStateView.js +65 -0
- package/dist/src/modules/key-plays/view/KeyPlaysView.d.ts +3 -3
- package/dist/src/modules/key-plays/view/KeyPlaysView.js +151 -0
- package/dist/src/modules/key-plays/view-model/KeyPlaysViewModel.js +247 -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.d.ts +1 -2
- 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.d.ts +3 -3
- package/dist/src/modules/shop/view/ShopView.js +182 -0
- package/dist/src/modules/shop/view/components/BrowseCard/BrowseCard.d.ts +54 -8
- 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.d.ts +53 -7
- 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.d.ts +1 -2
- 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 +6 -4
- 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.d.ts +1 -2
- 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.d.ts +2 -2
- package/dist/src/modules/stats/view/ActiveAthletes/ActiveAthletes.js +98 -0
- package/dist/src/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.d.ts +1 -2
- package/dist/src/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.js +27 -0
- package/dist/src/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.d.ts +1 -1
- 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.d.ts +53 -7
- package/dist/src/modules/stats/view/DriveSummary/DrivePlayCard.js +70 -0
- package/dist/src/modules/stats/view/DriveSummary/DriveSummary.d.ts +1 -1
- package/dist/src/modules/stats/view/DriveSummary/DriveSummary.js +87 -0
- package/dist/src/modules/stats/view/DriveSummary/ExpandedItems/DriveSummaryExpanded.d.ts +1 -1
- package/dist/src/modules/stats/view/DriveSummary/ExpandedItems/DriveSummaryExpanded.js +129 -0
- package/dist/src/modules/stats/view/DriveSummary/Header/DriveSummaryHeader.d.ts +1 -2
- package/dist/src/modules/stats/view/DriveSummary/Header/DriveSummaryHeader.js +26 -0
- package/dist/src/modules/stats/view/DriveSummary/MainStat/MainStat.d.ts +1 -2
- 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.d.ts +5 -4
- 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.d.ts +2 -2
- 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.d.ts +53 -7
- 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.d.ts +1 -2
- 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.d.ts +53 -7
- 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.d.ts +1 -1
- 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.d.ts +53 -7
- 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.d.ts +1 -2
- 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.d.ts +2 -2
- 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.d.ts +6 -5
- package/dist/src/modules/stats/view/StatsItemView.js +92 -0
- package/dist/src/modules/stats/view/StatsQRCode/StatsQRCodeView.d.ts +53 -7
- 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.d.ts +3 -3
- package/dist/src/modules/stats/view/StatsView.js +137 -0
- package/dist/src/modules/stats/view/TeamStats/TeamStatsView.d.ts +53 -7
- 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.d.ts +2 -2
- package/dist/src/modules/stats/view/Teams/StatsCarousel.js +83 -0
- package/dist/src/modules/stats/view/Teams/StatsProgressBar.d.ts +1 -2
- package/dist/src/modules/stats/view/Teams/StatsProgressBar.js +19 -0
- package/dist/src/modules/stats/view/Teams/Teams.d.ts +53 -7
- package/dist/src/modules/stats/view/Teams/Teams.js +43 -0
- package/dist/src/modules/stats/view/Teams/index.js +2 -0
- package/dist/src/modules/stats/view/WinProbability/WinProbability.d.ts +53 -7
- 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.d.ts +53 -7
- package/dist/src/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +89 -0
- package/dist/src/modules/stats/view/components/AthletesStatistics/StatisticTable.d.ts +1 -2
- 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.js +966 -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.js +136 -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 +0 -2
- package/dist/src/view-models/MaestroEventViewModel.js +280 -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 +13 -9
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import AxiosNetworkClient from '../../external/AxiosNetworkClient';
|
|
2
|
+
import LocalStorageCacheManager from '../../external/LocalStorageCacheManager';
|
|
3
|
+
import { AuthError, BadRequestError, NetworkError, NotFoundError, ServerError, } from './errors';
|
|
4
|
+
export const MAESTRO_BASE_URL = 'https://api.maestro.io';
|
|
5
|
+
export const SDK_FLAVOR = 'MaestroKit_Web';
|
|
6
|
+
// Common endpoints
|
|
7
|
+
export const ENDPOINTS = {
|
|
8
|
+
CAN_I_PLAY: '/caniplay/v1',
|
|
9
|
+
STREAM: '/stream/v1',
|
|
10
|
+
USER_PROFILE: '/userprofile/v1',
|
|
11
|
+
ACTIVE_USER: '/active/v2',
|
|
12
|
+
// Add more endpoints as needed
|
|
13
|
+
};
|
|
14
|
+
// HTTP methods
|
|
15
|
+
export const HttpMethod = {
|
|
16
|
+
GET: 'GET',
|
|
17
|
+
POST: 'POST',
|
|
18
|
+
PUT: 'PUT',
|
|
19
|
+
DELETE: 'DELETE',
|
|
20
|
+
};
|
|
21
|
+
class NetworkManager {
|
|
22
|
+
constructor(options = {}, localStorageOverride) {
|
|
23
|
+
Object.defineProperty(this, "cacheManager", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "maestroClient", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "externalClient", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: void 0
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(this, "pollingTasks", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: void 0
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(this, "localStorage", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: void 0
|
|
52
|
+
});
|
|
53
|
+
this.pollingTasks = new Map();
|
|
54
|
+
// Initialize cache manager
|
|
55
|
+
this.cacheManager =
|
|
56
|
+
options.cacheManager ||
|
|
57
|
+
new LocalStorageCacheManager(options.defaultCacheDuration);
|
|
58
|
+
// Initialize Maestro API client
|
|
59
|
+
this.maestroClient =
|
|
60
|
+
options.networkClient ||
|
|
61
|
+
new AxiosNetworkClient({
|
|
62
|
+
baseURL: MAESTRO_BASE_URL,
|
|
63
|
+
retries: 3,
|
|
64
|
+
delay: 1000,
|
|
65
|
+
backoff: 2,
|
|
66
|
+
});
|
|
67
|
+
// Initialize External API client
|
|
68
|
+
this.externalClient =
|
|
69
|
+
options.externalNetworkClient ||
|
|
70
|
+
new AxiosNetworkClient({
|
|
71
|
+
baseURL: options.externalBaseURL || '',
|
|
72
|
+
retries: 3,
|
|
73
|
+
delay: 1000,
|
|
74
|
+
backoff: 2,
|
|
75
|
+
});
|
|
76
|
+
this.localStorage = localStorageOverride ||
|
|
77
|
+
(typeof globalThis !== 'undefined' && globalThis.localStorage) || {
|
|
78
|
+
length: 0,
|
|
79
|
+
clear: () => { },
|
|
80
|
+
getItem: () => null,
|
|
81
|
+
key: () => null,
|
|
82
|
+
removeItem: () => { },
|
|
83
|
+
setItem: () => { },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Set authentication for Maestro APIs
|
|
88
|
+
*/
|
|
89
|
+
setAuthentication(token, apiKey) {
|
|
90
|
+
this.maestroClient.setAuthentication(token, apiKey);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Handle errors from network requests
|
|
94
|
+
*/
|
|
95
|
+
handleError(error) {
|
|
96
|
+
// Check if it's an Axios error with a response
|
|
97
|
+
if (error.response) {
|
|
98
|
+
const status = error.response.status;
|
|
99
|
+
const message = error.response.data?.message || error.message;
|
|
100
|
+
if (status === 401 || status === 403) {
|
|
101
|
+
throw new AuthError(message);
|
|
102
|
+
}
|
|
103
|
+
else if (status === 404) {
|
|
104
|
+
throw new NotFoundError(message);
|
|
105
|
+
}
|
|
106
|
+
else if (status >= 500) {
|
|
107
|
+
throw new ServerError(status, message);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new BadRequestError(status, message);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (error.request) {
|
|
114
|
+
// Request was made but no response received
|
|
115
|
+
throw new NetworkError('Network request failed');
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Something else happened while setting up the request
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Make a request to the Maestro API
|
|
124
|
+
*/
|
|
125
|
+
async maestroApiRequest({ endpoint, method = HttpMethod.GET, params = {}, data = null, headers = {}, useCache = true, maestroDefaultHeaders = null, skipResponseBodyDeserialization = false, }) {
|
|
126
|
+
// Add SDK flavor to headers
|
|
127
|
+
const requestHeaders = {
|
|
128
|
+
'x-maestro-maestro-kit-flavor': SDK_FLAVOR,
|
|
129
|
+
...headers,
|
|
130
|
+
};
|
|
131
|
+
// Add Maestro default headers if provided
|
|
132
|
+
if (maestroDefaultHeaders) {
|
|
133
|
+
requestHeaders['x-maestro-client-id'] = maestroDefaultHeaders.siteId;
|
|
134
|
+
requestHeaders['Authorization'] = `Bearer ${maestroDefaultHeaders.jwt}`;
|
|
135
|
+
requestHeaders['Content-type'] = 'application/json';
|
|
136
|
+
}
|
|
137
|
+
// Check cache if using GET and cache is enabled
|
|
138
|
+
if (method === HttpMethod.GET && useCache) {
|
|
139
|
+
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
140
|
+
endpoint,
|
|
141
|
+
params,
|
|
142
|
+
data: null,
|
|
143
|
+
}));
|
|
144
|
+
const cachedData = this.cacheManager.getCache(cacheKey);
|
|
145
|
+
if (cachedData) {
|
|
146
|
+
return cachedData;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
let response;
|
|
151
|
+
if (method === HttpMethod.GET) {
|
|
152
|
+
response = await this.maestroClient.get(endpoint, params, requestHeaders);
|
|
153
|
+
}
|
|
154
|
+
else if (method === HttpMethod.POST) {
|
|
155
|
+
response = await this.maestroClient.post(endpoint, data);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
throw new Error(`Method ${method} not implemented`);
|
|
159
|
+
}
|
|
160
|
+
// Handle empty response if needed
|
|
161
|
+
if (skipResponseBodyDeserialization && !response) {
|
|
162
|
+
response = {};
|
|
163
|
+
}
|
|
164
|
+
// Cache the response for GET requests
|
|
165
|
+
if (method === HttpMethod.GET && useCache) {
|
|
166
|
+
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
167
|
+
endpoint,
|
|
168
|
+
params,
|
|
169
|
+
data: null,
|
|
170
|
+
}));
|
|
171
|
+
this.cacheManager.setCache(cacheKey, response);
|
|
172
|
+
}
|
|
173
|
+
return response;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
return this.handleError(error);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Make a request to an external API
|
|
181
|
+
*/
|
|
182
|
+
async externalApiRequest({ endpoint, method = HttpMethod.GET, params = {}, data = null, headers = {}, useCache = true, skipResponseBodyDeserialization = false, }) {
|
|
183
|
+
// Check cache if using GET and cache is enabled
|
|
184
|
+
if (method === HttpMethod.GET && useCache) {
|
|
185
|
+
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
186
|
+
endpoint,
|
|
187
|
+
params,
|
|
188
|
+
data: null,
|
|
189
|
+
}));
|
|
190
|
+
const cachedData = this.cacheManager.getCache(cacheKey);
|
|
191
|
+
if (cachedData) {
|
|
192
|
+
return cachedData;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
let response;
|
|
197
|
+
if (method === HttpMethod.GET) {
|
|
198
|
+
response = await this.externalClient.get(endpoint, params, headers);
|
|
199
|
+
}
|
|
200
|
+
else if (method === HttpMethod.POST) {
|
|
201
|
+
response = await this.externalClient.post(endpoint, data);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
throw new Error(`Method ${method} not implemented`);
|
|
205
|
+
}
|
|
206
|
+
// Handle empty response if needed
|
|
207
|
+
if (skipResponseBodyDeserialization && !response) {
|
|
208
|
+
response = {};
|
|
209
|
+
}
|
|
210
|
+
// Cache the response for GET requests
|
|
211
|
+
if (method === HttpMethod.GET && useCache) {
|
|
212
|
+
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
213
|
+
endpoint,
|
|
214
|
+
params,
|
|
215
|
+
data: null,
|
|
216
|
+
}));
|
|
217
|
+
this.cacheManager.setCache(cacheKey, response);
|
|
218
|
+
}
|
|
219
|
+
return response;
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
return this.handleError(error);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Make a request to an external API and return both data and headers
|
|
227
|
+
*/
|
|
228
|
+
async externalApiRequestWithHeaders({ endpoint, method = HttpMethod.GET, params = {}, data = null, headers = {}, useCache = true, skipResponseBodyDeserialization = false, }) {
|
|
229
|
+
// Check cache if using GET and cache is enabled
|
|
230
|
+
if (method === HttpMethod.GET && useCache) {
|
|
231
|
+
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
232
|
+
endpoint,
|
|
233
|
+
params,
|
|
234
|
+
data: null,
|
|
235
|
+
}));
|
|
236
|
+
const cachedData = this.cacheManager.getCache(cacheKey);
|
|
237
|
+
if (cachedData) {
|
|
238
|
+
// Return cached data with empty headers since we don't cache headers
|
|
239
|
+
return { data: cachedData, headers: {} };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
let response;
|
|
244
|
+
if (method === HttpMethod.GET) {
|
|
245
|
+
response = await this.externalClient.getWithHeaders(endpoint, params, headers);
|
|
246
|
+
}
|
|
247
|
+
else if (method === HttpMethod.POST) {
|
|
248
|
+
response = await this.externalClient.postWithHeaders(endpoint, data, params, headers);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
throw new Error(`Method ${method} not implemented`);
|
|
252
|
+
}
|
|
253
|
+
// Handle empty response if needed
|
|
254
|
+
if (skipResponseBodyDeserialization && !response.data) {
|
|
255
|
+
response.data = {};
|
|
256
|
+
}
|
|
257
|
+
// Cache the response data for GET requests (headers are not cached)
|
|
258
|
+
if (method === HttpMethod.GET && useCache) {
|
|
259
|
+
const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
|
|
260
|
+
endpoint,
|
|
261
|
+
params,
|
|
262
|
+
data: null,
|
|
263
|
+
}));
|
|
264
|
+
this.cacheManager.setCache(cacheKey, response.data);
|
|
265
|
+
}
|
|
266
|
+
return response;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
return this.handleError(error);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Start polling a Maestro API endpoint at specified interval
|
|
274
|
+
*/
|
|
275
|
+
pollMaestroApiRequest({ endpoint, interval, method = HttpMethod.GET, params = {}, data = null, headers = {}, maestroDefaultHeaders = null, skipResponseBodyDeserialization = false, onData, onError, }) {
|
|
276
|
+
// Create a unique key for this polling task
|
|
277
|
+
const taskKey = `${endpoint}-${JSON.stringify(params)}-${JSON.stringify(data)}`;
|
|
278
|
+
// Stop existing polling for this endpoint if it exists
|
|
279
|
+
if (this.pollingTasks.has(taskKey)) {
|
|
280
|
+
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
281
|
+
this.pollingTasks.delete(taskKey);
|
|
282
|
+
}
|
|
283
|
+
// Create a new abort controller for cancellation
|
|
284
|
+
const controller = new AbortController();
|
|
285
|
+
const signal = controller.signal;
|
|
286
|
+
// Start the polling
|
|
287
|
+
(async () => {
|
|
288
|
+
while (!signal.aborted) {
|
|
289
|
+
try {
|
|
290
|
+
const response = await this.maestroApiRequest({
|
|
291
|
+
endpoint,
|
|
292
|
+
method,
|
|
293
|
+
params,
|
|
294
|
+
data,
|
|
295
|
+
headers,
|
|
296
|
+
maestroDefaultHeaders,
|
|
297
|
+
skipResponseBodyDeserialization,
|
|
298
|
+
useCache: false, // Don't use cache for polling
|
|
299
|
+
});
|
|
300
|
+
// Call the callback with the data
|
|
301
|
+
onData(response);
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
// Call the error callback if provided
|
|
305
|
+
if (onError) {
|
|
306
|
+
onError(error);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Wait for the interval before next poll
|
|
310
|
+
if (!signal.aborted) {
|
|
311
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
})();
|
|
315
|
+
// Store the controller for later cancellation
|
|
316
|
+
this.pollingTasks.set(taskKey, { controller, interval });
|
|
317
|
+
// Return a function to stop polling
|
|
318
|
+
return {
|
|
319
|
+
stop: () => {
|
|
320
|
+
if (this.pollingTasks.has(taskKey)) {
|
|
321
|
+
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
322
|
+
this.pollingTasks.delete(taskKey);
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Start polling an external API endpoint at specified interval
|
|
329
|
+
*/
|
|
330
|
+
pollExternalApiRequest({ endpoint, interval, method = HttpMethod.GET, params = {}, data = null, headers = {}, skipResponseBodyDeserialization = false, onData, onError, }) {
|
|
331
|
+
// Create a unique key for this polling task
|
|
332
|
+
const taskKey = `external-${endpoint}-${JSON.stringify(params)}-${JSON.stringify(data)}`;
|
|
333
|
+
// Stop existing polling for this endpoint if it exists
|
|
334
|
+
if (this.pollingTasks.has(taskKey)) {
|
|
335
|
+
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
336
|
+
this.pollingTasks.delete(taskKey);
|
|
337
|
+
}
|
|
338
|
+
// Create a new abort controller for cancellation
|
|
339
|
+
const controller = new AbortController();
|
|
340
|
+
const signal = controller.signal;
|
|
341
|
+
// Start the polling
|
|
342
|
+
(async () => {
|
|
343
|
+
while (!signal.aborted) {
|
|
344
|
+
try {
|
|
345
|
+
const response = await this.externalApiRequest({
|
|
346
|
+
endpoint,
|
|
347
|
+
method,
|
|
348
|
+
params,
|
|
349
|
+
data,
|
|
350
|
+
headers,
|
|
351
|
+
skipResponseBodyDeserialization,
|
|
352
|
+
useCache: false, // Don't use cache for polling
|
|
353
|
+
});
|
|
354
|
+
// Call the callback with the data
|
|
355
|
+
onData(response);
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
// Call the error callback if provided
|
|
359
|
+
if (onError) {
|
|
360
|
+
onError(error);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// Wait for the interval before next poll
|
|
364
|
+
if (!signal.aborted) {
|
|
365
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
})();
|
|
369
|
+
// Store the controller for later cancellation
|
|
370
|
+
this.pollingTasks.set(taskKey, { controller, interval });
|
|
371
|
+
// Return a function to stop polling
|
|
372
|
+
return {
|
|
373
|
+
stop: () => {
|
|
374
|
+
if (this.pollingTasks.has(taskKey)) {
|
|
375
|
+
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
376
|
+
this.pollingTasks.delete(taskKey);
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Start polling an external API endpoint at specified interval and return both data and headers
|
|
383
|
+
*/
|
|
384
|
+
pollExternalApiRequestWithHeaders({ endpoint, interval, method = HttpMethod.GET, params = {}, data = null, headers = {}, skipResponseBodyDeserialization = false, onData, onError, }) {
|
|
385
|
+
// Create a unique key for this polling task
|
|
386
|
+
const taskKey = `external-headers-${endpoint}-${JSON.stringify(params)}-${JSON.stringify(data)}`;
|
|
387
|
+
// Stop existing polling for this endpoint if it exists
|
|
388
|
+
if (this.pollingTasks.has(taskKey)) {
|
|
389
|
+
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
390
|
+
this.pollingTasks.delete(taskKey);
|
|
391
|
+
}
|
|
392
|
+
// Create a new abort controller for cancellation
|
|
393
|
+
const controller = new AbortController();
|
|
394
|
+
const signal = controller.signal;
|
|
395
|
+
// Start the polling
|
|
396
|
+
(async () => {
|
|
397
|
+
while (!signal.aborted) {
|
|
398
|
+
try {
|
|
399
|
+
const response = await this.externalApiRequestWithHeaders({
|
|
400
|
+
endpoint,
|
|
401
|
+
method,
|
|
402
|
+
params,
|
|
403
|
+
data,
|
|
404
|
+
headers,
|
|
405
|
+
skipResponseBodyDeserialization,
|
|
406
|
+
useCache: false, // Don't use cache for polling
|
|
407
|
+
});
|
|
408
|
+
// Call the callback with both data and headers
|
|
409
|
+
onData(response);
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
// Call the error callback if provided
|
|
413
|
+
if (onError) {
|
|
414
|
+
onError(error);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
// Wait for the interval before next poll
|
|
418
|
+
if (!signal.aborted) {
|
|
419
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
})();
|
|
423
|
+
// Store the controller for later cancellation
|
|
424
|
+
this.pollingTasks.set(taskKey, { controller, interval });
|
|
425
|
+
// Return a function to stop polling
|
|
426
|
+
return {
|
|
427
|
+
stop: () => {
|
|
428
|
+
if (this.pollingTasks.has(taskKey)) {
|
|
429
|
+
this.pollingTasks.get(taskKey)?.controller.abort();
|
|
430
|
+
this.pollingTasks.delete(taskKey);
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Stop all polling tasks
|
|
437
|
+
*/
|
|
438
|
+
stopAllPolling() {
|
|
439
|
+
for (const [key, { controller }] of this.pollingTasks.entries()) {
|
|
440
|
+
controller.abort();
|
|
441
|
+
this.pollingTasks.delete(key);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Clear all cached data
|
|
446
|
+
*/
|
|
447
|
+
clearAllCache() {
|
|
448
|
+
const originalLength = this.localStorage.length;
|
|
449
|
+
for (let i = 0; i < originalLength; i++) {
|
|
450
|
+
const key = this.localStorage.key(i);
|
|
451
|
+
if (key && key.startsWith('maestro-cache-')) {
|
|
452
|
+
this.localStorage.removeItem(key);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
export default NetworkManager;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import NetworkManager from './NetworkManager';
|
|
2
|
+
import { ServiceType, } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Service-specific NetworkManager that includes metadata about its service type
|
|
5
|
+
*/
|
|
6
|
+
class ServiceNetworkManager extends NetworkManager {
|
|
7
|
+
constructor(serviceType, externalBaseURL, options = {}, localStorageOverride) {
|
|
8
|
+
super(options, localStorageOverride);
|
|
9
|
+
Object.defineProperty(this, "serviceType", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: void 0
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "externalBaseURL", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: void 0
|
|
20
|
+
});
|
|
21
|
+
this.serviceType = serviceType;
|
|
22
|
+
this.externalBaseURL = externalBaseURL;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Factory for creating service-specific NetworkManager instances
|
|
27
|
+
* This replaces the singleton pattern with a factory pattern
|
|
28
|
+
*/
|
|
29
|
+
export class NetworkManagerFactory {
|
|
30
|
+
/**
|
|
31
|
+
* Configure factory defaults
|
|
32
|
+
*/
|
|
33
|
+
static configure(config) {
|
|
34
|
+
this.defaultConfig = { ...this.defaultConfig, ...config };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a Stats service NetworkManager
|
|
38
|
+
*/
|
|
39
|
+
static createStatsNetworkManager(externalBaseURL, options = {}) {
|
|
40
|
+
const networkManagerOptions = {
|
|
41
|
+
defaultCacheDuration: this.defaultConfig.defaultCacheDuration,
|
|
42
|
+
externalBaseURL,
|
|
43
|
+
...options,
|
|
44
|
+
};
|
|
45
|
+
return new ServiceNetworkManager(ServiceType.STATS, externalBaseURL, networkManagerOptions, undefined // Keep localStorage default
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create a Bets service NetworkManager
|
|
50
|
+
*/
|
|
51
|
+
static createBetsNetworkManager(externalBaseURL, options = {}) {
|
|
52
|
+
const networkManagerOptions = {
|
|
53
|
+
defaultCacheDuration: this.defaultConfig.defaultCacheDuration,
|
|
54
|
+
externalBaseURL,
|
|
55
|
+
...options,
|
|
56
|
+
};
|
|
57
|
+
return new ServiceNetworkManager(ServiceType.BETS, externalBaseURL, networkManagerOptions, undefined // Keep localStorage default
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a Maestro service NetworkManager
|
|
62
|
+
*/
|
|
63
|
+
static createMaestroNetworkManager(options = {}) {
|
|
64
|
+
const networkManagerOptions = {
|
|
65
|
+
defaultCacheDuration: this.defaultConfig.defaultCacheDuration,
|
|
66
|
+
...options,
|
|
67
|
+
};
|
|
68
|
+
return new ServiceNetworkManager(ServiceType.MAESTRO, '', // Maestro doesn't use external base URL
|
|
69
|
+
networkManagerOptions, undefined // Keep localStorage default
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create a NetworkManager for any service type
|
|
74
|
+
*/
|
|
75
|
+
static createForService(config, options = {}) {
|
|
76
|
+
const networkManagerOptions = {
|
|
77
|
+
defaultCacheDuration: config.defaultCacheDuration || this.defaultConfig.defaultCacheDuration,
|
|
78
|
+
externalBaseURL: config.externalBaseURL,
|
|
79
|
+
...options,
|
|
80
|
+
};
|
|
81
|
+
return new ServiceNetworkManager(config.serviceType, config.externalBaseURL, networkManagerOptions, undefined // Keep localStorage default
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Reset factory to defaults (useful for testing)
|
|
86
|
+
*/
|
|
87
|
+
static reset() {
|
|
88
|
+
this.defaultConfig = {
|
|
89
|
+
defaultCacheDuration: 60000,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
Object.defineProperty(NetworkManagerFactory, "defaultConfig", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true,
|
|
97
|
+
value: {
|
|
98
|
+
defaultCacheDuration: 60000, // 1 minute
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
export default NetworkManagerFactory;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Network error types
|
|
2
|
+
export class NetworkError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'NetworkError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class AuthError extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'AuthError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class NotFoundError extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'NotFoundError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class ServerError extends Error {
|
|
21
|
+
constructor(statusCode, message) {
|
|
22
|
+
super(message);
|
|
23
|
+
Object.defineProperty(this, "statusCode", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
this.name = 'ServerError';
|
|
30
|
+
this.statusCode = statusCode;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class BadRequestError extends Error {
|
|
34
|
+
constructor(statusCode, message) {
|
|
35
|
+
super(message);
|
|
36
|
+
Object.defineProperty(this, "statusCode", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
this.name = 'BadRequestError';
|
|
43
|
+
this.statusCode = statusCode;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Observable } from '../../helpers/Observable';
|
|
2
|
+
import { PageConfig } from './types';
|
|
3
|
+
export default class PageService {
|
|
4
|
+
configObservable: Observable<PageConfig | null>;
|
|
5
|
+
private client;
|
|
6
|
+
constructor();
|
|
7
|
+
fetchPageConfig(siteId: string, eventId: string): Promise<PageConfig | null>;
|
|
8
|
+
static isPanelAvailable(pageConfig: PageConfig | null, panelType: string): boolean | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Observable } from '../../helpers/Observable';
|
|
2
|
+
import AxiosNetworkClient from '@/external/AxiosNetworkClient';
|
|
3
|
+
import { captureException } from '@/sentry';
|
|
4
|
+
export default class PageService {
|
|
5
|
+
constructor() {
|
|
6
|
+
Object.defineProperty(this, "configObservable", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: new Observable(null)
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "client", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
this.client = new AxiosNetworkClient({
|
|
19
|
+
backoff: 2,
|
|
20
|
+
baseURL: 'https://static-prod.us-central1-espn-prod.gcp.maestro.io/pages/sites',
|
|
21
|
+
delay: 1000,
|
|
22
|
+
retries: 5,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async fetchPageConfig(siteId, eventId) {
|
|
26
|
+
try {
|
|
27
|
+
return this.client.get(`/${siteId}/metadata/${eventId}.json`);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
captureException(err, { siteId, eventId });
|
|
31
|
+
console.error(`Failed to fetch page configuration for site ${siteId} and event ${eventId}:`, err instanceof Error ? err.message : String(err));
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
static isPanelAvailable(pageConfig, panelType) {
|
|
36
|
+
return pageConfig?.panels?.some((panel) => panel.panel_type === panelType &&
|
|
37
|
+
panel.renderer?.supported_platforms?.bbd !== false);
|
|
38
|
+
}
|
|
39
|
+
}
|