@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,76 @@
|
|
|
1
|
+
// We'll make VisualDebugger no-op for any environments lacking a DOM (e.g. SSR and React Native non-web platforms).
|
|
2
|
+
const hasDOM = typeof window !== 'undefined' && window.document;
|
|
3
|
+
const WIDTH = hasDOM ? window.innerWidth : 0;
|
|
4
|
+
const HEIGHT = hasDOM ? window.innerHeight : 0;
|
|
5
|
+
class VisualDebugger {
|
|
6
|
+
constructor() {
|
|
7
|
+
Object.defineProperty(this, "debugCtx", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value: void 0
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(this, "layoutsCtx", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
if (hasDOM) {
|
|
20
|
+
this.debugCtx = VisualDebugger.createCanvas('sn-debug', 1010);
|
|
21
|
+
this.layoutsCtx = VisualDebugger.createCanvas('sn-layouts', 1000);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.debugCtx = null;
|
|
25
|
+
this.layoutsCtx = null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
static createCanvas(id, zIndex) {
|
|
29
|
+
const canvas = (document.querySelector(`#${id}`) ||
|
|
30
|
+
document.createElement('canvas'));
|
|
31
|
+
canvas.setAttribute('id', id);
|
|
32
|
+
const ctx = canvas.getContext('2d');
|
|
33
|
+
if (!ctx) {
|
|
34
|
+
throw new Error('Could not get 2d context from canvas');
|
|
35
|
+
}
|
|
36
|
+
canvas.style.cssText = `position: fixed; top: 0; left: 0; z-index: ${zIndex}`;
|
|
37
|
+
document.body.appendChild(canvas);
|
|
38
|
+
canvas.width = WIDTH;
|
|
39
|
+
canvas.height = HEIGHT;
|
|
40
|
+
return ctx;
|
|
41
|
+
}
|
|
42
|
+
clear() {
|
|
43
|
+
if (!hasDOM || !this.debugCtx) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.debugCtx.clearRect(0, 0, WIDTH, HEIGHT);
|
|
47
|
+
}
|
|
48
|
+
clearLayouts() {
|
|
49
|
+
if (!hasDOM || !this.layoutsCtx) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.layoutsCtx.clearRect(0, 0, WIDTH, HEIGHT);
|
|
53
|
+
}
|
|
54
|
+
drawLayout(layout, focusKey, parentFocusKey) {
|
|
55
|
+
if (!hasDOM || !this.layoutsCtx) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.layoutsCtx.strokeStyle = 'green';
|
|
59
|
+
this.layoutsCtx.strokeRect(layout.left, layout.top, layout.width, layout.height);
|
|
60
|
+
this.layoutsCtx.font = '8px monospace';
|
|
61
|
+
this.layoutsCtx.fillStyle = 'red';
|
|
62
|
+
this.layoutsCtx.fillText(focusKey, layout.left, layout.top + 10);
|
|
63
|
+
this.layoutsCtx.fillText(parentFocusKey, layout.left, layout.top + 25);
|
|
64
|
+
this.layoutsCtx.fillText(`left: ${layout.left}`, layout.left, layout.top + 40);
|
|
65
|
+
this.layoutsCtx.fillText(`top: ${layout.top}`, layout.left, layout.top + 55);
|
|
66
|
+
}
|
|
67
|
+
drawPoint(x, y, color = 'blue', size = 10) {
|
|
68
|
+
if (!hasDOM || !this.debugCtx) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.debugCtx.strokeStyle = color;
|
|
72
|
+
this.debugCtx.lineWidth = 3;
|
|
73
|
+
this.debugCtx.strokeRect(x - size / 2, y - size / 2, size, size);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export default VisualDebugger;
|
|
@@ -34,6 +34,7 @@ export interface WithFocusableState {
|
|
|
34
34
|
declare const withFocusable: <P extends object>({ forgetLastFocusedChild: configForgetLastFocusedChild, trackChildren: configTrackChildren, autoRestoreFocus: configAutoRestoreFocus, blockNavigationOut: configBlockNavigationOut, }?: WithFocusableConfig) => (WrappedComponent: import("react").ComponentType<P & WithFocusableProps>) => {
|
|
35
35
|
new (props?: (P & WithFocusableProps) | undefined, context?: any): {
|
|
36
36
|
state: WithFocusableState;
|
|
37
|
+
navigation: import("./spatialNavigation").default;
|
|
37
38
|
getChildContext(): {
|
|
38
39
|
parentFocusKey: string;
|
|
39
40
|
};
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/* eslint-disable react/no-find-dom-node */
|
|
2
|
+
import { findDOMNode } from 'react-dom';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { Component, createElement } from 'react';
|
|
5
|
+
import { ROOT_FOCUS_KEY } from './spatialNavigation';
|
|
6
|
+
import SDK from '@/index';
|
|
7
|
+
// Helper functions to replace lodash and recompose
|
|
8
|
+
const uniqueId = (prefix) => `${prefix}${Math.random().toString(36).substr(2, 9)}`;
|
|
9
|
+
const noop = () => { };
|
|
10
|
+
const omit = (obj, keys) => {
|
|
11
|
+
const result = { ...obj };
|
|
12
|
+
keys.forEach((key) => delete result[key]);
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild = false, trackChildren: configTrackChildren = false, autoRestoreFocus: configAutoRestoreFocus, blockNavigationOut: configBlockNavigationOut = false, } = {}) => {
|
|
16
|
+
return (WrappedComponent) => {
|
|
17
|
+
var _a;
|
|
18
|
+
return _a = class WithFocusable extends Component {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
Object.defineProperty(this, "state", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: {
|
|
26
|
+
realFocusKey: this.props.focusKey || uniqueId('sn:focusable-item-'),
|
|
27
|
+
focused: false,
|
|
28
|
+
hasFocusedChild: false,
|
|
29
|
+
parentFocusKey: this.props.parentFocusKey || ROOT_FOCUS_KEY,
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(this, "navigation", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: SDK.getMaestroEventViewModel().navigation
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "setFocus", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: (focusKey) => {
|
|
43
|
+
if (!this.navigation.isNativeMode()) {
|
|
44
|
+
this.navigation.setFocus(focusKey);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(this, "navigateByDirection", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: this.navigation.navigateByDirection
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(this, "stealFocus", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
value: () => {
|
|
59
|
+
this.navigation.setFocus(this.state.realFocusKey, {
|
|
60
|
+
focusKey: this.state.realFocusKey,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(this, "onUpdateFocus", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true,
|
|
68
|
+
value: (focused) => {
|
|
69
|
+
this.setState({ focused });
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(this, "onUpdateHasFocusedChild", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
writable: true,
|
|
76
|
+
value: (hasFocusedChild) => {
|
|
77
|
+
this.setState({ hasFocusedChild });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, "onEnterPressHandler", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: (details) => {
|
|
85
|
+
const { onEnterPress = noop, ...rest } = this.props;
|
|
86
|
+
onEnterPress(rest, details);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(this, "onEnterReleaseHandler", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: () => {
|
|
94
|
+
const { onEnterRelease = noop, ...rest } = this.props;
|
|
95
|
+
onEnterRelease(rest);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, "onBackPressHandler", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: (details) => {
|
|
103
|
+
const { onBackPress = noop, ...rest } = this.props;
|
|
104
|
+
onBackPress(rest, details);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(this, "onArrowPressHandler", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
configurable: true,
|
|
110
|
+
writable: true,
|
|
111
|
+
value: (direction, details) => {
|
|
112
|
+
const { onArrowPress = noop, ...rest } = this.props;
|
|
113
|
+
return onArrowPress(direction, rest, details);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(this, "onBecameFocusedHandler", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: (layout, details) => {
|
|
121
|
+
const { onBecameFocused = noop, ...rest } = this.props;
|
|
122
|
+
onBecameFocused(layout, rest, details);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(this, "onBecameBlurredHandler", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
writable: true,
|
|
129
|
+
value: (layout, details) => {
|
|
130
|
+
const { onBecameBlurred = noop, ...rest } = this.props;
|
|
131
|
+
onBecameBlurred(layout, rest, details);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
getChildContext() {
|
|
136
|
+
return {
|
|
137
|
+
parentFocusKey: this.state.realFocusKey,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
componentDidMount() {
|
|
141
|
+
const { realFocusKey: focusKey, parentFocusKey } = this.state;
|
|
142
|
+
const { preferredChildFocusKey, forgetLastFocusedChild = false, trackChildren, focusable = true, autoRestoreFocus = true, blockNavigationOut = false, } = this.props;
|
|
143
|
+
let node;
|
|
144
|
+
if (this.navigation.isNativeMode()) {
|
|
145
|
+
node = document.createElement('div');
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const domNode = findDOMNode(this);
|
|
149
|
+
if (!domNode) {
|
|
150
|
+
throw new Error('Could not find DOM node');
|
|
151
|
+
}
|
|
152
|
+
node = domNode;
|
|
153
|
+
}
|
|
154
|
+
this.navigation.addFocusable({
|
|
155
|
+
focusKey,
|
|
156
|
+
node,
|
|
157
|
+
parentFocusKey,
|
|
158
|
+
preferredChildFocusKey,
|
|
159
|
+
onEnterPressHandler: this.onEnterPressHandler,
|
|
160
|
+
onEnterReleaseHandler: this.onEnterReleaseHandler,
|
|
161
|
+
onBackPressHandler: this.onBackPressHandler,
|
|
162
|
+
onArrowPressHandler: this.onArrowPressHandler,
|
|
163
|
+
onBecameFocusedHandler: this.onBecameFocusedHandler,
|
|
164
|
+
onBecameBlurredHandler: this.onBecameBlurredHandler,
|
|
165
|
+
onUpdateFocus: this.onUpdateFocus,
|
|
166
|
+
onUpdateHasFocusedChild: this.onUpdateHasFocusedChild,
|
|
167
|
+
forgetLastFocusedChild: configForgetLastFocusedChild || forgetLastFocusedChild,
|
|
168
|
+
trackChildren: configTrackChildren || trackChildren,
|
|
169
|
+
blockNavigationOut: configBlockNavigationOut || blockNavigationOut,
|
|
170
|
+
autoRestoreFocus: configAutoRestoreFocus !== undefined
|
|
171
|
+
? configAutoRestoreFocus
|
|
172
|
+
: autoRestoreFocus,
|
|
173
|
+
focusable,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
componentDidUpdate() {
|
|
177
|
+
const { realFocusKey: focusKey } = this.state;
|
|
178
|
+
const { preferredChildFocusKey, focusable = true, blockNavigationOut = false, } = this.props;
|
|
179
|
+
let node;
|
|
180
|
+
if (this.navigation.isNativeMode()) {
|
|
181
|
+
node = document.createElement('div');
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const domNode = findDOMNode(this);
|
|
185
|
+
if (!domNode) {
|
|
186
|
+
throw new Error('Could not find DOM node');
|
|
187
|
+
}
|
|
188
|
+
node = domNode;
|
|
189
|
+
}
|
|
190
|
+
this.navigation.updateFocusable(focusKey, {
|
|
191
|
+
node,
|
|
192
|
+
preferredChildFocusKey,
|
|
193
|
+
focusable,
|
|
194
|
+
blockNavigationOut: configBlockNavigationOut || blockNavigationOut,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
componentWillUnmount() {
|
|
198
|
+
const { realFocusKey: focusKey } = this.state;
|
|
199
|
+
this.navigation.removeFocusable({ focusKey });
|
|
200
|
+
}
|
|
201
|
+
render() {
|
|
202
|
+
const props = {
|
|
203
|
+
...this.props,
|
|
204
|
+
...this.state,
|
|
205
|
+
setFocus: this.setFocus,
|
|
206
|
+
navigateByDirection: this.navigateByDirection,
|
|
207
|
+
stealFocus: this.stealFocus,
|
|
208
|
+
onUpdateFocus: this.onUpdateFocus,
|
|
209
|
+
onUpdateHasFocusedChild: this.onUpdateHasFocusedChild,
|
|
210
|
+
};
|
|
211
|
+
const filteredProps = omit(props, [
|
|
212
|
+
'onBecameFocusedHandler',
|
|
213
|
+
'onBecameBlurredHandler',
|
|
214
|
+
'onEnterPressHandler',
|
|
215
|
+
'onEnterReleaseHandler',
|
|
216
|
+
'onArrowPressHandler',
|
|
217
|
+
'onUpdateFocus',
|
|
218
|
+
'onUpdateHasFocusedChild',
|
|
219
|
+
'forgetLastFocusedChild',
|
|
220
|
+
'trackChildren',
|
|
221
|
+
'autoRestoreFocus',
|
|
222
|
+
]);
|
|
223
|
+
return createElement(WrappedComponent, filteredProps);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
Object.defineProperty(_a, "contextTypes", {
|
|
227
|
+
enumerable: true,
|
|
228
|
+
configurable: true,
|
|
229
|
+
writable: true,
|
|
230
|
+
value: {
|
|
231
|
+
parentFocusKey: PropTypes.string,
|
|
232
|
+
}
|
|
233
|
+
}),
|
|
234
|
+
Object.defineProperty(_a, "childContextTypes", {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
configurable: true,
|
|
237
|
+
writable: true,
|
|
238
|
+
value: {
|
|
239
|
+
parentFocusKey: PropTypes.string,
|
|
240
|
+
}
|
|
241
|
+
}),
|
|
242
|
+
_a;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
export default withFocusable;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic observable implementation for view models
|
|
3
|
+
*/
|
|
4
|
+
export class Observable {
|
|
5
|
+
constructor(initialValue) {
|
|
6
|
+
Object.defineProperty(this, "listeners", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: []
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "_value", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
this._value = initialValue;
|
|
19
|
+
}
|
|
20
|
+
get value() {
|
|
21
|
+
return this._value;
|
|
22
|
+
}
|
|
23
|
+
set value(newValue) {
|
|
24
|
+
this._value = newValue;
|
|
25
|
+
this.notify();
|
|
26
|
+
}
|
|
27
|
+
subscribe(listener) {
|
|
28
|
+
this.listeners.push(listener);
|
|
29
|
+
// Return unsubscribe function
|
|
30
|
+
return () => {
|
|
31
|
+
this.listeners = this.listeners.filter((l) => l !== listener);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
notify() {
|
|
35
|
+
this.listeners.forEach((listener) => listener(this._value));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { pause } from '@/external/spatial-navigation';
|
|
2
|
+
import SDK from '..';
|
|
3
|
+
/**
|
|
4
|
+
* @description Useful when you want to lose the focus of the SDK and delegate it to the Client App.
|
|
5
|
+
*/
|
|
6
|
+
const deliverFocus = (e) => {
|
|
7
|
+
const eventVm = SDK.getMaestroEventViewModel();
|
|
8
|
+
e.dataset['focused'] = 'false';
|
|
9
|
+
pause();
|
|
10
|
+
eventVm.delegate.startFocusManagement();
|
|
11
|
+
};
|
|
12
|
+
export default deliverFocus;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import IMaestroEventDelegate from './interfaces/IMaestroEventDelegate';
|
|
|
2
2
|
import IMaestroManager, { SDKConfigParams } from './interfaces/IMaestroManager';
|
|
3
3
|
import IMaestroEvent from './interfaces/IMaestroEvent';
|
|
4
4
|
import { MaestroEventViewModel } from './view-models/MaestroEventViewModel';
|
|
5
|
-
import
|
|
5
|
+
import IMaestroKeyPlaysResponse from './modules/key-plays/interfaces/IKeyPlaysResponse';
|
|
6
6
|
export { default as Overlay } from './components/molecules/Overlay/Overlay';
|
|
7
|
-
export { OverlayType,
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
7
|
+
export { OverlayType, IMaestroOverlayEvent, IOverlaySize, IOverlayPosition, IFantasyPayload, IOverlayAnalyticsEvent, } from './types/OverlayTypes';
|
|
8
|
+
export { IWinningBet } from './models/IWinningBet';
|
|
9
|
+
export { IMaestroEventDelegate, IMaestroEvent, IMaestroKeyPlaysResponse };
|
|
10
10
|
export type Environment = 'development' | 'staging' | 'production';
|
|
11
11
|
/**
|
|
12
12
|
* Main SDK class that serves as the entry point for the Maestro TV SDK
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import ReactRenderer from './external/ReactRenderer';
|
|
2
|
+
import { MaestroEventViewModel } from './view-models/MaestroEventViewModel';
|
|
3
|
+
// Export overlay components and types for client apps
|
|
4
|
+
export { default as Overlay } from './components/molecules/Overlay/Overlay';
|
|
5
|
+
export { OverlayType, } from './types/OverlayTypes';
|
|
6
|
+
const AUTHORIZED_CLIENTS = ['664b9c57d59a7a431542d814'];
|
|
7
|
+
/**
|
|
8
|
+
* Main SDK class that serves as the entry point for the Maestro TV SDK
|
|
9
|
+
* Follows a singleton pattern similar to the Swift implementation
|
|
10
|
+
*/
|
|
11
|
+
class MaestroWebSDK {
|
|
12
|
+
constructor(renderer) {
|
|
13
|
+
Object.defineProperty(this, "renderer", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "siteID", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "userID", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "maestroJwt", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(this, "clientAppToken", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "clientAppSwid", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: void 0
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, "maestroEventViewModel", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: null
|
|
54
|
+
});
|
|
55
|
+
this.renderer = renderer;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @description Returns the MaestroWebSDK instance
|
|
59
|
+
* @returns {MaestroWebSDK} - The MaestroWebSDK instance
|
|
60
|
+
*/
|
|
61
|
+
static getInstance() {
|
|
62
|
+
if (!MaestroWebSDK.instance) {
|
|
63
|
+
const renderer = new ReactRenderer();
|
|
64
|
+
MaestroWebSDK.instance = new MaestroWebSDK(renderer);
|
|
65
|
+
}
|
|
66
|
+
return MaestroWebSDK.instance;
|
|
67
|
+
}
|
|
68
|
+
async userDidStartWatchingEvent(eventID, delegate) {
|
|
69
|
+
if (!this.isAuthorizedClient) {
|
|
70
|
+
throw new Error('Unauthorized use of SDK');
|
|
71
|
+
}
|
|
72
|
+
this.maestroEventViewModel = new MaestroEventViewModel(eventID, delegate);
|
|
73
|
+
return this.maestroEventViewModel;
|
|
74
|
+
}
|
|
75
|
+
userDidStopWatchingEvent(_) {
|
|
76
|
+
if (this.maestroEventViewModel) {
|
|
77
|
+
this.maestroEventViewModel.deinit();
|
|
78
|
+
this.maestroEventViewModel = null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
configure(configParams) {
|
|
82
|
+
if (configParams.siteID) {
|
|
83
|
+
this.setSiteID(configParams.siteID);
|
|
84
|
+
}
|
|
85
|
+
if (configParams.maestroJwt) {
|
|
86
|
+
this.setMaestroJwt(configParams.maestroJwt);
|
|
87
|
+
}
|
|
88
|
+
if (configParams.clientAppToken) {
|
|
89
|
+
this.setClientAppToken(configParams.clientAppToken);
|
|
90
|
+
}
|
|
91
|
+
if (configParams.clientAppSwid) {
|
|
92
|
+
this.setClientAppSwid(configParams.clientAppSwid);
|
|
93
|
+
}
|
|
94
|
+
console.info('MaestroWebSDK configured', configParams);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Checks if this is an authorized client based on siteID
|
|
98
|
+
*/
|
|
99
|
+
get isAuthorizedClient() {
|
|
100
|
+
const siteID = this.getSiteID();
|
|
101
|
+
return Boolean(siteID && AUTHORIZED_CLIENTS.includes(siteID));
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Sets the site ID for the SDK
|
|
105
|
+
* @param siteID The site ID to set
|
|
106
|
+
*/
|
|
107
|
+
setSiteID(siteID) {
|
|
108
|
+
this.siteID = siteID;
|
|
109
|
+
}
|
|
110
|
+
getSiteID() {
|
|
111
|
+
return this.siteID;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Sets the user ID for the SDK
|
|
115
|
+
* @param userID The user ID to set
|
|
116
|
+
*/
|
|
117
|
+
setUserID(userID) {
|
|
118
|
+
this.userID = userID;
|
|
119
|
+
}
|
|
120
|
+
getUserID() {
|
|
121
|
+
return this.userID;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Gets the event view model
|
|
125
|
+
* @returns The current event view model
|
|
126
|
+
*/
|
|
127
|
+
getMaestroEventViewModel() {
|
|
128
|
+
if (!this.maestroEventViewModel) {
|
|
129
|
+
throw new Error('No Maestro Event View Model set');
|
|
130
|
+
}
|
|
131
|
+
return this.maestroEventViewModel;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Gets the view models container
|
|
135
|
+
* @returns The current view models
|
|
136
|
+
*/
|
|
137
|
+
getMaestroViewModels() {
|
|
138
|
+
return this.renderer.viewModels;
|
|
139
|
+
}
|
|
140
|
+
async renderPanel(id) {
|
|
141
|
+
if (!this.renderer.viewModels) {
|
|
142
|
+
if (!this.maestroEventViewModel) {
|
|
143
|
+
throw new Error('No Maestro Event View Model set.');
|
|
144
|
+
}
|
|
145
|
+
let eventId = 'default-event-id';
|
|
146
|
+
if (id) {
|
|
147
|
+
eventId = id;
|
|
148
|
+
}
|
|
149
|
+
await this.renderer.setViewModels(eventId, this.maestroEventViewModel.delegate);
|
|
150
|
+
}
|
|
151
|
+
return this.renderer.renderPanel(id);
|
|
152
|
+
}
|
|
153
|
+
setMaestroJwt(jwt) {
|
|
154
|
+
this.maestroJwt = jwt;
|
|
155
|
+
}
|
|
156
|
+
setClientAppSwid(swid) {
|
|
157
|
+
this.clientAppSwid = swid;
|
|
158
|
+
}
|
|
159
|
+
setClientAppToken(jwt) {
|
|
160
|
+
this.clientAppToken = jwt;
|
|
161
|
+
}
|
|
162
|
+
async authenticateUser(swid, token) {
|
|
163
|
+
this.setClientAppSwid(swid);
|
|
164
|
+
this.setClientAppToken(token);
|
|
165
|
+
if (this.getMaestroEventViewModel().betsViewModel.initialized) {
|
|
166
|
+
// Stop polling bets if the user is deauthenticated
|
|
167
|
+
this.getMaestroEventViewModel().betsViewModel.refreshPolling();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async deauthenticateUser() {
|
|
171
|
+
this.setClientAppSwid(undefined);
|
|
172
|
+
this.setClientAppToken(undefined);
|
|
173
|
+
if (this.getMaestroEventViewModel().betsViewModel.initialized) {
|
|
174
|
+
// Stop polling bets if the user is deauthenticated
|
|
175
|
+
this.getMaestroEventViewModel().betsViewModel.refreshPolling();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
getCurrentMaestroJwt() {
|
|
179
|
+
return this.maestroJwt;
|
|
180
|
+
}
|
|
181
|
+
getClientAppToken() {
|
|
182
|
+
return this.clientAppToken;
|
|
183
|
+
}
|
|
184
|
+
getCurrentUserID() {
|
|
185
|
+
return this.userID;
|
|
186
|
+
}
|
|
187
|
+
getClientAppSwid() {
|
|
188
|
+
return this.clientAppSwid;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const SDK = MaestroWebSDK.getInstance();
|
|
192
|
+
export default SDK;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|