@maestro_io/maestro-web-sdk 2.1.1 → 2.1.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.
Files changed (171) hide show
  1. package/dist/MaestroEventDelegate.js +60 -0
  2. package/dist/components/atoms/BaseButton/BaseButton.js +11 -0
  3. package/dist/components/atoms/BaseButton/index.js +2 -0
  4. package/dist/components/atoms/Image/index.js +30 -0
  5. package/dist/components/atoms/Rive/index.js +52 -0
  6. package/dist/components/atoms/SvgIcon/BetGeneralIcon.js +9 -0
  7. package/dist/components/atoms/SvgIcon/BetsIcon.js +11 -0
  8. package/dist/components/atoms/SvgIcon/BetsWarningIcon.js +11 -0
  9. package/dist/components/atoms/SvgIcon/CheckmarkIcon.js +6 -0
  10. package/dist/components/atoms/SvgIcon/CollapseIcon.js +6 -0
  11. package/dist/components/atoms/SvgIcon/ExpandIcon.js +6 -0
  12. package/dist/components/atoms/SvgIcon/FantasyIcon.js +8 -0
  13. package/dist/components/atoms/SvgIcon/FlameIcon.js +11 -0
  14. package/dist/components/atoms/SvgIcon/Icon.js +42 -0
  15. package/dist/components/atoms/SvgIcon/KeyPlaysIcon.js +10 -0
  16. package/dist/components/atoms/SvgIcon/MobilePhoneIcon.js +11 -0
  17. package/dist/components/atoms/SvgIcon/PlayIcon.js +8 -0
  18. package/dist/components/atoms/SvgIcon/StatsIcon.js +12 -0
  19. package/dist/components/atoms/SvgIcon/TimesIcon.js +6 -0
  20. package/dist/components/atoms/SvgIcon/WarningIcon.js +8 -0
  21. package/dist/components/atoms/SvgIcon/index.js +2 -0
  22. package/dist/components/core/App/App.js +41 -0
  23. package/dist/components/core/App/index.js +2 -0
  24. package/dist/components/core/OverlayContainer.js +58 -0
  25. package/dist/components/core/PanelManager/PanelManager.js +80 -0
  26. package/dist/components/core/PanelManager/index.js +2 -0
  27. package/dist/components/core/ScrollableContainer/FocusableItem.js +38 -0
  28. package/dist/components/core/ScrollableContainer/ScrollableContainer.js +166 -0
  29. package/dist/components/core/ScrollableContainer/index.js +2 -0
  30. package/dist/components/molecules/ActionButton/ActionButton.js +10 -0
  31. package/dist/components/molecules/ActionButton/index.js +2 -0
  32. package/dist/components/molecules/Overlay/Overlay.js +139 -0
  33. package/dist/components/molecules/Overlay/index.js +2 -0
  34. package/dist/components/molecules/PanelNavButton/PanelNavButton.js +40 -0
  35. package/dist/components/molecules/PanelNavButton/index.js +2 -0
  36. package/dist/components/molecules/SegmentButton/SegmentButton.js +10 -0
  37. package/dist/components/molecules/SegmentButton/index.js +2 -0
  38. package/dist/components/molecules/WatchButton/WatchButton.js +15 -0
  39. package/dist/components/molecules/WatchButton/index.js +2 -0
  40. package/dist/components/organisms/PanelNavigation/PanelNavigation.js +72 -0
  41. package/dist/components/organisms/PanelNavigation/index.js +2 -0
  42. package/dist/components/organisms/SegmentController/SegmentController.js +69 -0
  43. package/dist/components/organisms/SegmentController/index.d.ts +1 -1
  44. package/dist/components/organisms/SegmentController/index.js +2 -0
  45. package/dist/external/AxiosNetworkClient.js +83 -0
  46. package/dist/external/LocalStorageCacheManager.js +213 -0
  47. package/dist/external/ReactRenderer.d.ts +2 -2
  48. package/dist/external/ReactRenderer.js +86 -0
  49. package/dist/external/mocks/MockExternalNetworkClient.js +161 -0
  50. package/dist/external/ports/cacheManager.js +1 -0
  51. package/dist/external/ports/networkClient.js +1 -0
  52. package/dist/external/ports/renderer.js +1 -0
  53. package/dist/external/spatial-navigation/index.d.ts +1 -1
  54. package/dist/external/spatial-navigation/index.js +4 -0
  55. package/dist/external/spatial-navigation/measureLayout.js +30 -0
  56. package/dist/external/spatial-navigation/spatialNavigation.js +875 -0
  57. package/dist/external/spatial-navigation/utils.js +6 -0
  58. package/dist/external/spatial-navigation/visualDebugger.js +76 -0
  59. package/dist/external/spatial-navigation/withFocusable.js +238 -0
  60. package/dist/helpers/Observable.js +37 -0
  61. package/dist/helpers/deliver-focus.js +12 -0
  62. package/dist/index.d.ts +4 -4
  63. package/dist/index.js +192 -0
  64. package/dist/interfaces/IMaestroEvent.js +6 -0
  65. package/dist/interfaces/IMaestroEventDelegate.js +1 -0
  66. package/dist/interfaces/IMaestroManager.js +1 -0
  67. package/dist/maestro-web-sdk.umd.js +3 -3
  68. package/dist/maestro-web-sdk.umd.js.map +1 -1
  69. package/dist/models/IModel.js +1 -0
  70. package/dist/models/IPanel.js +53 -0
  71. package/dist/models/ITheme.js +20 -0
  72. package/dist/models/IWinningBet.js +1 -0
  73. package/dist/modules/bets/interfaces/IBets.js +1 -0
  74. package/dist/modules/bets/mocks.js +572 -0
  75. package/dist/modules/bets/view/BetsView.js +116 -0
  76. package/dist/modules/bets/view/HotProps/HotPropsView.js +139 -0
  77. package/dist/modules/bets/view/SixPack/SixPackView.js +103 -0
  78. package/dist/modules/bets/view/TabLoadFailureView.js +12 -0
  79. package/dist/modules/bets/view/UserBets/BetResult/BetResult.js +6 -0
  80. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +122 -0
  81. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +34 -0
  82. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +22 -0
  83. package/dist/modules/bets/view/UserBets/Boost/Boost.js +6 -0
  84. package/dist/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +9 -0
  85. package/dist/modules/bets/view/UserBets/Parlay/Parlay.js +13 -0
  86. package/dist/modules/bets/view/UserBets/Straight/Straight.js +6 -0
  87. package/dist/modules/bets/view/UserBets/Teaser/Teaser.js +13 -0
  88. package/dist/modules/bets/view/UserBets/UserBetsView.js +114 -0
  89. package/dist/modules/bets/view/components/Bet/Bet.js +32 -0
  90. package/dist/modules/bets/view/components/BetPill/BetPill.js +6 -0
  91. package/dist/modules/bets/view/components/BetsCard/BetsCard.js +15 -0
  92. package/dist/modules/bets/view/components/BetsCard/BetsCardHeader.js +20 -0
  93. package/dist/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +14 -0
  94. package/dist/modules/bets/view/components/LocationWarning/LocationWarning.js +16 -0
  95. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +63 -0
  96. package/dist/modules/bets/view/components/PromoCodeBanner/index.d.ts +1 -1
  97. package/dist/modules/bets/view/components/PromoCodeBanner/index.js +1 -0
  98. package/dist/modules/bets/view-model/BetsViewModel.js +767 -0
  99. package/dist/modules/key-plays/constants.js +292 -0
  100. package/dist/modules/key-plays/interfaces/IKeyPlays.d.ts +4 -4
  101. package/dist/modules/key-plays/interfaces/IKeyPlays.js +14 -0
  102. package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.js +1 -0
  103. package/dist/modules/key-plays/view/KeyPlayCardScoreTagView.js +13 -0
  104. package/dist/modules/key-plays/view/KeyPlayCardView.js +142 -0
  105. package/dist/modules/key-plays/view/KeyPlayErrorStateView.js +58 -0
  106. package/dist/modules/key-plays/view/KeyPlaysView.js +167 -0
  107. package/dist/modules/key-plays/view-model/KeyPlaysViewModel.js +182 -0
  108. package/dist/modules/stats/interfaces/IStats.d.ts +163 -0
  109. package/dist/modules/stats/interfaces/IStats.js +1 -0
  110. package/dist/modules/stats/mocks.d.ts +2 -0
  111. package/dist/modules/stats/mocks.js +546 -0
  112. package/dist/modules/stats/utils.d.ts +39 -0
  113. package/dist/modules/stats/utils.js +62 -0
  114. package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +29 -0
  115. package/dist/modules/stats/view/GameLeaders/GameLeaders.js +9 -0
  116. package/dist/modules/stats/view/GameLeaders/index.d.ts +2 -0
  117. package/dist/modules/stats/view/GameLeaders/index.js +2 -0
  118. package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.d.ts +17 -0
  119. package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +55 -0
  120. package/dist/modules/stats/view/MatchPredictor/DonutChart/index.d.ts +2 -0
  121. package/dist/modules/stats/view/MatchPredictor/DonutChart/index.js +1 -0
  122. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +52 -0
  123. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.js +66 -0
  124. package/dist/modules/stats/view/MatchPredictor/index.d.ts +3 -0
  125. package/dist/modules/stats/view/MatchPredictor/index.js +2 -0
  126. package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +62 -0
  127. package/dist/modules/stats/view/RecentGames/RecentGames.js +22 -0
  128. package/dist/modules/stats/view/RecentGames/index.d.ts +2 -0
  129. package/dist/modules/stats/view/RecentGames/index.js +2 -0
  130. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.d.ts +51 -0
  131. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.js +38 -0
  132. package/dist/modules/stats/view/StatsQRCode/index.d.ts +2 -0
  133. package/dist/modules/stats/view/StatsQRCode/index.js +1 -0
  134. package/dist/modules/stats/view/StatsView.d.ts +20 -0
  135. package/dist/modules/stats/view/StatsView.js +87 -0
  136. package/dist/modules/stats/view/Teams/StatsCarousel.d.ts +8 -0
  137. package/dist/modules/stats/view/Teams/StatsCarousel.js +14 -0
  138. package/dist/modules/stats/view/Teams/StatsProgressBar.d.ts +7 -0
  139. package/dist/modules/stats/view/Teams/StatsProgressBar.js +14 -0
  140. package/dist/modules/stats/view/Teams/Teams.d.ts +67 -0
  141. package/dist/modules/stats/view/Teams/Teams.js +35 -0
  142. package/dist/modules/stats/view/Teams/index.d.ts +2 -0
  143. package/dist/modules/stats/view/Teams/index.js +2 -0
  144. package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +62 -0
  145. package/dist/modules/stats/view/WinProbability/WinProbability.js +27 -0
  146. package/dist/modules/stats/view/WinProbability/index.d.ts +2 -0
  147. package/dist/modules/stats/view/WinProbability/index.js +2 -0
  148. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.d.ts +51 -0
  149. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +28 -0
  150. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.d.ts +10 -0
  151. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +11 -0
  152. package/dist/modules/stats/view/components/AthletesStatistics/index.d.ts +2 -0
  153. package/dist/modules/stats/view/components/AthletesStatistics/index.js +2 -0
  154. package/dist/modules/stats/view/index.d.ts +1 -0
  155. package/dist/modules/stats/view/index.js +1 -0
  156. package/dist/modules/stats/view-model/StatsViewModel.d.ts +31 -0
  157. package/dist/modules/stats/view-model/StatsViewModel.js +90 -0
  158. package/dist/services/BetsService.js +102 -0
  159. package/dist/services/NetworkManager/NetworkManager.js +410 -0
  160. package/dist/services/NetworkManager/errors.js +45 -0
  161. package/dist/services/ThemeManager/constants.js +47 -0
  162. package/dist/test-polyfills.d.ts +1 -0
  163. package/dist/test-polyfills.js +15 -0
  164. package/dist/types/OverlayTypes.js +4 -0
  165. package/dist/view-models/MaestroEventViewModel.d.ts +2 -0
  166. package/dist/view-models/MaestroEventViewModel.js +156 -0
  167. package/dist/view-models/OverlayViewModel.js +222 -0
  168. package/dist/view-models/PanelManagerViewModel.js +80 -0
  169. package/dist/view-models/ViewModel.js +32 -0
  170. package/dist/view-models/index.js +59 -0
  171. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ export const DIRECTION_LEFT = 'left';
2
+ export const DIRECTION_RIGHT = 'right';
3
+ export const DIRECTION_UP = 'up';
4
+ export const DIRECTION_DOWN = 'down';
5
+ export const KEY_ENTER = 'enter';
6
+ export const KEY_BACK = 'back';
@@ -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;
@@ -0,0 +1,238 @@
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 SpatialNavigation, { ROOT_FOCUS_KEY } from './spatialNavigation';
6
+ // Helper functions to replace lodash and recompose
7
+ const uniqueId = (prefix) => `${prefix}${Math.random().toString(36).substr(2, 9)}`;
8
+ const noop = () => { };
9
+ const omit = (obj, keys) => {
10
+ const result = { ...obj };
11
+ keys.forEach((key) => delete result[key]);
12
+ return result;
13
+ };
14
+ const withFocusable = ({ forgetLastFocusedChild: configForgetLastFocusedChild = false, trackChildren: configTrackChildren = false, autoRestoreFocus: configAutoRestoreFocus, blockNavigationOut: configBlockNavigationOut = false, } = {}) => {
15
+ return (WrappedComponent) => {
16
+ var _a;
17
+ return _a = class WithFocusable extends Component {
18
+ constructor() {
19
+ super(...arguments);
20
+ Object.defineProperty(this, "state", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: {
25
+ realFocusKey: this.props.focusKey || uniqueId('sn:focusable-item-'),
26
+ focused: false,
27
+ hasFocusedChild: false,
28
+ parentFocusKey: this.props.parentFocusKey || ROOT_FOCUS_KEY,
29
+ }
30
+ });
31
+ Object.defineProperty(this, "setFocus", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: (focusKey) => {
36
+ if (!SpatialNavigation.isNativeMode()) {
37
+ SpatialNavigation.setFocus(focusKey);
38
+ }
39
+ }
40
+ });
41
+ Object.defineProperty(this, "navigateByDirection", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: SpatialNavigation.navigateByDirection
46
+ });
47
+ Object.defineProperty(this, "stealFocus", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: () => {
52
+ SpatialNavigation.setFocus(this.state.realFocusKey, {
53
+ focusKey: this.state.realFocusKey,
54
+ });
55
+ }
56
+ });
57
+ Object.defineProperty(this, "onUpdateFocus", {
58
+ enumerable: true,
59
+ configurable: true,
60
+ writable: true,
61
+ value: (focused) => {
62
+ this.setState({ focused });
63
+ }
64
+ });
65
+ Object.defineProperty(this, "onUpdateHasFocusedChild", {
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true,
69
+ value: (hasFocusedChild) => {
70
+ this.setState({ hasFocusedChild });
71
+ }
72
+ });
73
+ Object.defineProperty(this, "onEnterPressHandler", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: (details) => {
78
+ const { onEnterPress = noop, ...rest } = this.props;
79
+ onEnterPress(rest, details);
80
+ }
81
+ });
82
+ Object.defineProperty(this, "onEnterReleaseHandler", {
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true,
86
+ value: () => {
87
+ const { onEnterRelease = noop, ...rest } = this.props;
88
+ onEnterRelease(rest);
89
+ }
90
+ });
91
+ Object.defineProperty(this, "onBackPressHandler", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: (details) => {
96
+ const { onBackPress = noop, ...rest } = this.props;
97
+ onBackPress(rest, details);
98
+ }
99
+ });
100
+ Object.defineProperty(this, "onArrowPressHandler", {
101
+ enumerable: true,
102
+ configurable: true,
103
+ writable: true,
104
+ value: (direction, details) => {
105
+ const { onArrowPress = noop, ...rest } = this.props;
106
+ return onArrowPress(direction, rest, details);
107
+ }
108
+ });
109
+ Object.defineProperty(this, "onBecameFocusedHandler", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: (layout, details) => {
114
+ const { onBecameFocused = noop, ...rest } = this.props;
115
+ onBecameFocused(layout, rest, details);
116
+ }
117
+ });
118
+ Object.defineProperty(this, "onBecameBlurredHandler", {
119
+ enumerable: true,
120
+ configurable: true,
121
+ writable: true,
122
+ value: (layout, details) => {
123
+ const { onBecameBlurred = noop, ...rest } = this.props;
124
+ onBecameBlurred(layout, rest, details);
125
+ }
126
+ });
127
+ }
128
+ getChildContext() {
129
+ return {
130
+ parentFocusKey: this.state.realFocusKey,
131
+ };
132
+ }
133
+ componentDidMount() {
134
+ const { realFocusKey: focusKey, parentFocusKey } = this.state;
135
+ const { preferredChildFocusKey, forgetLastFocusedChild = false, trackChildren, focusable = true, autoRestoreFocus = true, blockNavigationOut = false, } = this.props;
136
+ let node;
137
+ if (SpatialNavigation.isNativeMode()) {
138
+ node = document.createElement('div');
139
+ }
140
+ else {
141
+ const domNode = findDOMNode(this);
142
+ if (!domNode) {
143
+ throw new Error('Could not find DOM node');
144
+ }
145
+ node = domNode;
146
+ }
147
+ SpatialNavigation.addFocusable({
148
+ focusKey,
149
+ node,
150
+ parentFocusKey,
151
+ preferredChildFocusKey,
152
+ onEnterPressHandler: this.onEnterPressHandler,
153
+ onEnterReleaseHandler: this.onEnterReleaseHandler,
154
+ onBackPressHandler: this.onBackPressHandler,
155
+ onArrowPressHandler: this.onArrowPressHandler,
156
+ onBecameFocusedHandler: this.onBecameFocusedHandler,
157
+ onBecameBlurredHandler: this.onBecameBlurredHandler,
158
+ onUpdateFocus: this.onUpdateFocus,
159
+ onUpdateHasFocusedChild: this.onUpdateHasFocusedChild,
160
+ forgetLastFocusedChild: configForgetLastFocusedChild || forgetLastFocusedChild,
161
+ trackChildren: configTrackChildren || trackChildren,
162
+ blockNavigationOut: configBlockNavigationOut || blockNavigationOut,
163
+ autoRestoreFocus: configAutoRestoreFocus !== undefined
164
+ ? configAutoRestoreFocus
165
+ : autoRestoreFocus,
166
+ focusable,
167
+ });
168
+ }
169
+ componentDidUpdate() {
170
+ const { realFocusKey: focusKey } = this.state;
171
+ const { preferredChildFocusKey, focusable = true, blockNavigationOut = false, } = this.props;
172
+ let node;
173
+ if (SpatialNavigation.isNativeMode()) {
174
+ node = document.createElement('div');
175
+ }
176
+ else {
177
+ const domNode = findDOMNode(this);
178
+ if (!domNode) {
179
+ throw new Error('Could not find DOM node');
180
+ }
181
+ node = domNode;
182
+ }
183
+ SpatialNavigation.updateFocusable(focusKey, {
184
+ node,
185
+ preferredChildFocusKey,
186
+ focusable,
187
+ blockNavigationOut: configBlockNavigationOut || blockNavigationOut,
188
+ });
189
+ }
190
+ componentWillUnmount() {
191
+ const { realFocusKey: focusKey } = this.state;
192
+ SpatialNavigation.removeFocusable({ focusKey });
193
+ }
194
+ render() {
195
+ const props = {
196
+ ...this.props,
197
+ ...this.state,
198
+ setFocus: this.setFocus,
199
+ navigateByDirection: this.navigateByDirection,
200
+ stealFocus: this.stealFocus,
201
+ onUpdateFocus: this.onUpdateFocus,
202
+ onUpdateHasFocusedChild: this.onUpdateHasFocusedChild,
203
+ };
204
+ const filteredProps = omit(props, [
205
+ 'onBecameFocusedHandler',
206
+ 'onBecameBlurredHandler',
207
+ 'onEnterPressHandler',
208
+ 'onEnterReleaseHandler',
209
+ 'onArrowPressHandler',
210
+ 'onUpdateFocus',
211
+ 'onUpdateHasFocusedChild',
212
+ 'forgetLastFocusedChild',
213
+ 'trackChildren',
214
+ 'autoRestoreFocus',
215
+ ]);
216
+ return createElement(WrappedComponent, filteredProps);
217
+ }
218
+ },
219
+ Object.defineProperty(_a, "contextTypes", {
220
+ enumerable: true,
221
+ configurable: true,
222
+ writable: true,
223
+ value: {
224
+ parentFocusKey: PropTypes.string,
225
+ }
226
+ }),
227
+ Object.defineProperty(_a, "childContextTypes", {
228
+ enumerable: true,
229
+ configurable: true,
230
+ writable: true,
231
+ value: {
232
+ parentFocusKey: PropTypes.string,
233
+ }
234
+ }),
235
+ _a;
236
+ };
237
+ };
238
+ 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 type IMaestroKeyPlaysResponse from './modules/key-plays/interfaces/IKeyPlaysResponse';
5
+ import IMaestroKeyPlaysResponse from './modules/key-plays/interfaces/IKeyPlaysResponse';
6
6
  export { default as Overlay } from './components/molecules/Overlay/Overlay';
7
- export { OverlayType, type IMaestroOverlayEvent, type IOverlaySize, type IOverlayPosition, type IFantasyPayload, type IOverlayAnalyticsEvent } from './types/OverlayTypes';
8
- export { type IWinningBet } from './models/IWinningBet';
9
- export { type IMaestroEventDelegate, type IMaestroEvent, type IMaestroKeyPlaysResponse, };
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,6 @@
1
+ const TEST_USE_CASES = {
2
+ betsTabLoadFailure: 'betsTabLoadFailure',
3
+ betsMockData: 'betsMockData',
4
+ betsLiveData: 'betsLiveData',
5
+ };
6
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};