@maestro_io/maestro-web-sdk 2.1.2 → 2.2.0

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 (186) hide show
  1. package/dist/MaestroEventDelegate.d.ts +1 -0
  2. package/dist/components/atoms/Rive/index.d.ts +1 -0
  3. package/dist/components/atoms/SvgIcon/Icon.d.ts +0 -2
  4. package/dist/components/core/ScrollableContainer/ScrollableContainer.d.ts +3 -1
  5. package/dist/components/molecules/ActionButton/ActionButton.d.ts +1 -0
  6. package/dist/components/molecules/PanelNavButton/PanelNavButton.d.ts +1 -0
  7. package/dist/components/organisms/SegmentController/SegmentController.d.ts +2 -2
  8. package/dist/external/spatial-navigation/index.d.ts +2 -3
  9. package/dist/external/spatial-navigation/spatialNavigation.d.ts +3 -5
  10. package/dist/external/spatial-navigation/withFocusable.d.ts +1 -0
  11. package/dist/interfaces/IMaestroEvent.d.ts +14 -0
  12. package/dist/interfaces/IMaestroEventDelegate.d.ts +19 -6
  13. package/dist/maestro-web-sdk.umd.js +3 -3
  14. package/dist/maestro-web-sdk.umd.js.map +1 -1
  15. package/dist/models/IPanel.d.ts +1 -2
  16. package/dist/modules/bets/view/HotProps/HotPropsView.d.ts +7 -6
  17. package/dist/modules/bets/view/SixPack/SixPackView.d.ts +2 -2
  18. package/dist/modules/bets/view/TabLoadFailureView.d.ts +1 -0
  19. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.d.ts +7 -6
  20. package/dist/modules/bets/view/components/Bet/Bet.d.ts +1 -0
  21. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.d.ts +2 -2
  22. package/dist/modules/key-plays/view/KeyPlayCardView.d.ts +0 -4
  23. package/dist/modules/stats/interfaces/IStats.d.ts +44 -15
  24. package/dist/modules/stats/utils/driveSummaryUtils.d.ts +18 -0
  25. package/dist/modules/stats/utils/renderTeamStatistic.d.ts +21 -0
  26. package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.d.ts +21 -0
  27. package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.d.ts +5 -0
  28. package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.d.ts +10 -0
  29. package/dist/modules/stats/view/ActiveAthletes/index.d.ts +2 -0
  30. package/dist/modules/stats/view/DriveSummary/DrivePlayCard.d.ts +26 -0
  31. package/dist/modules/stats/view/DriveSummary/DriveSummary.d.ts +24 -0
  32. package/dist/modules/stats/view/DriveSummary/index.d.ts +2 -0
  33. package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +15 -25
  34. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +13 -47
  35. package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +11 -21
  36. package/dist/modules/stats/view/StatsItemView.d.ts +19 -0
  37. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.d.ts +1 -0
  38. package/dist/modules/stats/view/StatsView.d.ts +3 -3
  39. package/dist/modules/stats/view/TeamStats/TeamStatsView.d.ts +52 -0
  40. package/dist/modules/stats/view/TeamStats/index.d.ts +2 -0
  41. package/dist/modules/stats/view/Teams/Teams.d.ts +11 -26
  42. package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +11 -21
  43. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.d.ts +19 -3
  44. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.d.ts +2 -8
  45. package/dist/modules/stats/view/index.d.ts +1 -0
  46. package/dist/modules/stats/view-model/StatsViewModel.d.ts +149 -5
  47. package/dist/services/StatsService.d.ts +36 -0
  48. package/dist/view-models/MaestroEventViewModel.d.ts +7 -0
  49. package/package.json +1 -1
  50. package/dist/MaestroEventDelegate.js +0 -60
  51. package/dist/components/atoms/BaseButton/BaseButton.js +0 -11
  52. package/dist/components/atoms/BaseButton/index.js +0 -2
  53. package/dist/components/atoms/Image/index.js +0 -30
  54. package/dist/components/atoms/Rive/index.js +0 -52
  55. package/dist/components/atoms/SvgIcon/BetGeneralIcon.js +0 -9
  56. package/dist/components/atoms/SvgIcon/BetsIcon.js +0 -11
  57. package/dist/components/atoms/SvgIcon/BetsWarningIcon.js +0 -11
  58. package/dist/components/atoms/SvgIcon/CheckmarkIcon.js +0 -6
  59. package/dist/components/atoms/SvgIcon/CollapseIcon.js +0 -6
  60. package/dist/components/atoms/SvgIcon/ExpandIcon.js +0 -6
  61. package/dist/components/atoms/SvgIcon/FantasyIcon.d.ts +0 -6
  62. package/dist/components/atoms/SvgIcon/FantasyIcon.js +0 -8
  63. package/dist/components/atoms/SvgIcon/FlameIcon.js +0 -11
  64. package/dist/components/atoms/SvgIcon/Icon.js +0 -42
  65. package/dist/components/atoms/SvgIcon/KeyPlaysIcon.js +0 -10
  66. package/dist/components/atoms/SvgIcon/MobilePhoneIcon.js +0 -11
  67. package/dist/components/atoms/SvgIcon/PlayIcon.js +0 -8
  68. package/dist/components/atoms/SvgIcon/StatsIcon.js +0 -12
  69. package/dist/components/atoms/SvgIcon/TimesIcon.js +0 -6
  70. package/dist/components/atoms/SvgIcon/WarningIcon.js +0 -8
  71. package/dist/components/atoms/SvgIcon/index.js +0 -2
  72. package/dist/components/core/App/App.js +0 -41
  73. package/dist/components/core/App/index.js +0 -2
  74. package/dist/components/core/OverlayContainer.js +0 -58
  75. package/dist/components/core/PanelManager/PanelManager.js +0 -80
  76. package/dist/components/core/PanelManager/index.js +0 -2
  77. package/dist/components/core/ScrollableContainer/FocusableItem.js +0 -38
  78. package/dist/components/core/ScrollableContainer/ScrollableContainer.js +0 -166
  79. package/dist/components/core/ScrollableContainer/index.js +0 -2
  80. package/dist/components/molecules/ActionButton/ActionButton.js +0 -10
  81. package/dist/components/molecules/ActionButton/index.js +0 -2
  82. package/dist/components/molecules/Overlay/Overlay.js +0 -139
  83. package/dist/components/molecules/Overlay/index.js +0 -2
  84. package/dist/components/molecules/PanelNavButton/PanelNavButton.js +0 -40
  85. package/dist/components/molecules/PanelNavButton/index.js +0 -2
  86. package/dist/components/molecules/SegmentButton/SegmentButton.js +0 -10
  87. package/dist/components/molecules/SegmentButton/index.js +0 -2
  88. package/dist/components/molecules/WatchButton/WatchButton.js +0 -15
  89. package/dist/components/molecules/WatchButton/index.js +0 -2
  90. package/dist/components/organisms/PanelNavigation/PanelNavigation.js +0 -72
  91. package/dist/components/organisms/PanelNavigation/index.js +0 -2
  92. package/dist/components/organisms/SegmentController/SegmentController.js +0 -69
  93. package/dist/components/organisms/SegmentController/index.js +0 -2
  94. package/dist/external/AxiosNetworkClient.js +0 -83
  95. package/dist/external/LocalStorageCacheManager.js +0 -213
  96. package/dist/external/ReactRenderer.js +0 -86
  97. package/dist/external/mocks/MockExternalNetworkClient.js +0 -161
  98. package/dist/external/ports/cacheManager.js +0 -1
  99. package/dist/external/ports/networkClient.js +0 -1
  100. package/dist/external/ports/renderer.js +0 -1
  101. package/dist/external/spatial-navigation/index.js +0 -4
  102. package/dist/external/spatial-navigation/measureLayout.js +0 -30
  103. package/dist/external/spatial-navigation/spatialNavigation.js +0 -875
  104. package/dist/external/spatial-navigation/utils.js +0 -6
  105. package/dist/external/spatial-navigation/visualDebugger.js +0 -76
  106. package/dist/external/spatial-navigation/withFocusable.js +0 -238
  107. package/dist/helpers/Observable.js +0 -37
  108. package/dist/helpers/deliver-focus.d.ts +0 -5
  109. package/dist/helpers/deliver-focus.js +0 -12
  110. package/dist/index.js +0 -192
  111. package/dist/interfaces/IMaestroEvent.js +0 -6
  112. package/dist/interfaces/IMaestroEventDelegate.js +0 -1
  113. package/dist/interfaces/IMaestroManager.js +0 -1
  114. package/dist/models/IModel.js +0 -1
  115. package/dist/models/IPanel.js +0 -53
  116. package/dist/models/ITheme.js +0 -20
  117. package/dist/models/IWinningBet.js +0 -1
  118. package/dist/modules/bets/interfaces/IBets.js +0 -1
  119. package/dist/modules/bets/mocks.js +0 -572
  120. package/dist/modules/bets/view/BetsView.js +0 -116
  121. package/dist/modules/bets/view/HotProps/HotPropsView.js +0 -139
  122. package/dist/modules/bets/view/SixPack/SixPackView.js +0 -103
  123. package/dist/modules/bets/view/TabLoadFailureView.js +0 -12
  124. package/dist/modules/bets/view/UserBets/BetResult/BetResult.js +0 -6
  125. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +0 -122
  126. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +0 -34
  127. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +0 -22
  128. package/dist/modules/bets/view/UserBets/Boost/Boost.js +0 -6
  129. package/dist/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +0 -9
  130. package/dist/modules/bets/view/UserBets/Parlay/Parlay.js +0 -13
  131. package/dist/modules/bets/view/UserBets/Straight/Straight.js +0 -6
  132. package/dist/modules/bets/view/UserBets/Teaser/Teaser.js +0 -13
  133. package/dist/modules/bets/view/UserBets/UserBetsView.js +0 -114
  134. package/dist/modules/bets/view/components/Bet/Bet.js +0 -32
  135. package/dist/modules/bets/view/components/BetPill/BetPill.js +0 -6
  136. package/dist/modules/bets/view/components/BetsCard/BetsCard.js +0 -15
  137. package/dist/modules/bets/view/components/BetsCard/BetsCardHeader.js +0 -20
  138. package/dist/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +0 -14
  139. package/dist/modules/bets/view/components/LocationWarning/LocationWarning.js +0 -16
  140. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +0 -63
  141. package/dist/modules/bets/view/components/PromoCodeBanner/index.js +0 -1
  142. package/dist/modules/bets/view-model/BetsViewModel.js +0 -767
  143. package/dist/modules/key-plays/constants.js +0 -292
  144. package/dist/modules/key-plays/interfaces/IKeyPlays.js +0 -14
  145. package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.js +0 -1
  146. package/dist/modules/key-plays/view/KeyPlayCardScoreTagView.js +0 -13
  147. package/dist/modules/key-plays/view/KeyPlayCardView.js +0 -142
  148. package/dist/modules/key-plays/view/KeyPlayErrorStateView.js +0 -58
  149. package/dist/modules/key-plays/view/KeyPlaysView.js +0 -167
  150. package/dist/modules/key-plays/view-model/KeyPlaysViewModel.js +0 -182
  151. package/dist/modules/stats/interfaces/IStats.js +0 -1
  152. package/dist/modules/stats/mocks.js +0 -546
  153. package/dist/modules/stats/utils.js +0 -62
  154. package/dist/modules/stats/view/GameLeaders/GameLeaders.js +0 -9
  155. package/dist/modules/stats/view/GameLeaders/index.js +0 -2
  156. package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +0 -55
  157. package/dist/modules/stats/view/MatchPredictor/DonutChart/index.js +0 -1
  158. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.js +0 -66
  159. package/dist/modules/stats/view/MatchPredictor/index.js +0 -2
  160. package/dist/modules/stats/view/RecentGames/RecentGames.js +0 -22
  161. package/dist/modules/stats/view/RecentGames/index.js +0 -2
  162. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.js +0 -38
  163. package/dist/modules/stats/view/StatsQRCode/index.js +0 -1
  164. package/dist/modules/stats/view/StatsView.js +0 -87
  165. package/dist/modules/stats/view/Teams/StatsCarousel.js +0 -14
  166. package/dist/modules/stats/view/Teams/StatsProgressBar.js +0 -14
  167. package/dist/modules/stats/view/Teams/Teams.js +0 -35
  168. package/dist/modules/stats/view/Teams/index.js +0 -2
  169. package/dist/modules/stats/view/WinProbability/WinProbability.js +0 -27
  170. package/dist/modules/stats/view/WinProbability/index.js +0 -2
  171. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +0 -28
  172. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +0 -11
  173. package/dist/modules/stats/view/components/AthletesStatistics/index.js +0 -2
  174. package/dist/modules/stats/view/index.js +0 -1
  175. package/dist/modules/stats/view-model/StatsViewModel.js +0 -90
  176. package/dist/services/BetsService.js +0 -102
  177. package/dist/services/NetworkManager/NetworkManager.js +0 -410
  178. package/dist/services/NetworkManager/errors.js +0 -45
  179. package/dist/services/ThemeManager/constants.js +0 -47
  180. package/dist/test-polyfills.js +0 -15
  181. package/dist/types/OverlayTypes.js +0 -4
  182. package/dist/view-models/MaestroEventViewModel.js +0 -156
  183. package/dist/view-models/OverlayViewModel.js +0 -222
  184. package/dist/view-models/PanelManagerViewModel.js +0 -80
  185. package/dist/view-models/ViewModel.js +0 -32
  186. package/dist/view-models/index.js +0 -59
@@ -1,410 +0,0 @@
1
- import AxiosNetworkClient from '../../external/AxiosNetworkClient';
2
- import LocalStorageCacheManager from '../../external/LocalStorageCacheManager';
3
- import { AuthError, BadRequestError, NetworkError, NotFoundError, ServerError, } from './errors';
4
- // Environment configuration
5
- export const WorkingEnvironment = {
6
- DEVELOPMENT: 'development',
7
- STAGING: 'staging',
8
- PRODUCTION: 'production',
9
- };
10
- // URL configurations based on environment
11
- export const MAESTRO_BASE_URLS = {
12
- [WorkingEnvironment.DEVELOPMENT]: 'https://dev.api.maestro.io',
13
- [WorkingEnvironment.STAGING]: 'https://api.us-central1-staging.gcp.maestro.io',
14
- [WorkingEnvironment.PRODUCTION]: 'https://api.maestro.io',
15
- };
16
- export const SDK_FLAVOR = 'MaestroKit_Web';
17
- // Common endpoints
18
- export const ENDPOINTS = {
19
- CAN_I_PLAY: '/caniplay/v1',
20
- STREAM: '/stream/v1',
21
- USER_PROFILE: '/userprofile/v1',
22
- ACTIVE_USER: '/active/v2',
23
- // Add more endpoints as needed
24
- };
25
- // HTTP methods
26
- export const HttpMethod = {
27
- GET: 'GET',
28
- POST: 'POST',
29
- PUT: 'PUT',
30
- DELETE: 'DELETE',
31
- };
32
- class NetworkManager {
33
- constructor(options = {}, localStorageOverride) {
34
- Object.defineProperty(this, "cacheManager", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
- Object.defineProperty(this, "maestroClient", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: void 0
45
- });
46
- Object.defineProperty(this, "externalClient", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: void 0
51
- });
52
- Object.defineProperty(this, "environment", {
53
- enumerable: true,
54
- configurable: true,
55
- writable: true,
56
- value: void 0
57
- });
58
- Object.defineProperty(this, "pollingTasks", {
59
- enumerable: true,
60
- configurable: true,
61
- writable: true,
62
- value: void 0
63
- });
64
- Object.defineProperty(this, "localStorage", {
65
- enumerable: true,
66
- configurable: true,
67
- writable: true,
68
- value: void 0
69
- });
70
- this.environment = options.environment || WorkingEnvironment.PRODUCTION;
71
- this.pollingTasks = new Map();
72
- // Initialize cache manager
73
- this.cacheManager =
74
- options.cacheManager ||
75
- new LocalStorageCacheManager(options.defaultCacheDuration);
76
- // Initialize Maestro API client
77
- this.maestroClient =
78
- options.networkClient ||
79
- new AxiosNetworkClient({
80
- baseURL: MAESTRO_BASE_URLS[this.environment],
81
- retries: 3,
82
- delay: 1000,
83
- backoff: 2,
84
- });
85
- // Initialize External API client
86
- this.externalClient =
87
- options.externalNetworkClient ||
88
- new AxiosNetworkClient({
89
- baseURL: options.externalBaseURL || '',
90
- retries: 3,
91
- delay: 1000,
92
- backoff: 2,
93
- });
94
- this.localStorage = localStorageOverride ||
95
- (typeof globalThis !== 'undefined' && globalThis.localStorage) || {
96
- length: 0,
97
- clear: () => { },
98
- getItem: () => null,
99
- key: () => null,
100
- removeItem: () => { },
101
- setItem: () => { },
102
- };
103
- }
104
- static getInstance(options, localStorageOverride) {
105
- if (!this.instance) {
106
- this.instance = new NetworkManager(options, localStorageOverride);
107
- }
108
- else if (options) {
109
- // Update environment if provided
110
- if (options.environment) {
111
- this.instance.setEnvironment(options.environment);
112
- }
113
- }
114
- return this.instance;
115
- }
116
- /**
117
- * Sets the working environment (development, staging, production)
118
- */
119
- setEnvironment(environment) {
120
- this.environment = environment;
121
- // Update base URLs for clients if they have a client property
122
- // This is needed for testing and for real clients
123
- try {
124
- if (this.maestroClient.client?.defaults) {
125
- this.maestroClient.client.defaults.baseURL =
126
- MAESTRO_BASE_URLS[environment];
127
- }
128
- }
129
- catch (error) {
130
- throw new Error(`Failed to update client base URLs: ${error}`);
131
- }
132
- }
133
- /**
134
- * Get current environment
135
- */
136
- getEnvironment() {
137
- return this.environment;
138
- }
139
- /**
140
- * Set authentication for Maestro APIs
141
- */
142
- setAuthentication(token, apiKey) {
143
- this.maestroClient.setAuthentication(token, apiKey);
144
- }
145
- /**
146
- * Handle errors from network requests
147
- */
148
- handleError(error) {
149
- // Check if it's an Axios error with a response
150
- if (error.response) {
151
- const status = error.response.status;
152
- const message = error.response.data?.message || error.message;
153
- if (status === 401 || status === 403) {
154
- throw new AuthError(message);
155
- }
156
- else if (status === 404) {
157
- throw new NotFoundError(message);
158
- }
159
- else if (status >= 500) {
160
- throw new ServerError(status, message);
161
- }
162
- else {
163
- throw new BadRequestError(status, message);
164
- }
165
- }
166
- else if (error.request) {
167
- // Request was made but no response received
168
- throw new NetworkError('Network request failed');
169
- }
170
- else {
171
- // Something else happened while setting up the request
172
- throw error;
173
- }
174
- }
175
- /**
176
- * Make a request to the Maestro API
177
- */
178
- async maestroApiRequest({ endpoint, method = HttpMethod.GET, params = {}, data = null, headers = {}, useCache = true, maestroDefaultHeaders = null, skipResponseBodyDeserialization = false, }) {
179
- // Add SDK flavor to headers
180
- const requestHeaders = {
181
- 'x-maestro-maestro-kit-flavor': SDK_FLAVOR,
182
- ...headers,
183
- };
184
- // Add Maestro default headers if provided
185
- if (maestroDefaultHeaders) {
186
- requestHeaders['x-maestro-client-id'] = maestroDefaultHeaders.siteId;
187
- requestHeaders['Authorization'] = `Bearer ${maestroDefaultHeaders.jwt}`;
188
- requestHeaders['Content-type'] = 'application/json';
189
- }
190
- // Check cache if using GET and cache is enabled
191
- if (method === HttpMethod.GET && useCache) {
192
- const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
193
- endpoint,
194
- params,
195
- data: null,
196
- }));
197
- const cachedData = this.cacheManager.getCache(cacheKey);
198
- if (cachedData) {
199
- return cachedData;
200
- }
201
- }
202
- try {
203
- let response;
204
- if (method === HttpMethod.GET) {
205
- response = await this.maestroClient.get(endpoint, params, requestHeaders);
206
- }
207
- else if (method === HttpMethod.POST) {
208
- response = await this.maestroClient.post(endpoint, data);
209
- }
210
- else {
211
- throw new Error(`Method ${method} not implemented`);
212
- }
213
- // Handle empty response if needed
214
- if (skipResponseBodyDeserialization && !response) {
215
- response = {};
216
- }
217
- // Cache the response for GET requests
218
- if (method === HttpMethod.GET && useCache) {
219
- const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
220
- endpoint,
221
- params,
222
- data: null,
223
- }));
224
- this.cacheManager.setCache(cacheKey, response);
225
- }
226
- return response;
227
- }
228
- catch (error) {
229
- return this.handleError(error);
230
- }
231
- }
232
- /**
233
- * Make a request to an external API
234
- */
235
- async externalApiRequest({ endpoint, method = HttpMethod.GET, params = {}, data = null, headers = {}, useCache = true, skipResponseBodyDeserialization = false, }) {
236
- // Check cache if using GET and cache is enabled
237
- if (method === HttpMethod.GET && useCache) {
238
- const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
239
- endpoint,
240
- params,
241
- data: null,
242
- }));
243
- const cachedData = this.cacheManager.getCache(cacheKey);
244
- if (cachedData) {
245
- return cachedData;
246
- }
247
- }
248
- try {
249
- let response;
250
- if (method === HttpMethod.GET) {
251
- response = await this.externalClient.get(endpoint, params, headers);
252
- }
253
- else if (method === HttpMethod.POST) {
254
- response = await this.externalClient.post(endpoint, data);
255
- }
256
- else {
257
- throw new Error(`Method ${method} not implemented`);
258
- }
259
- // Handle empty response if needed
260
- if (skipResponseBodyDeserialization && !response) {
261
- response = {};
262
- }
263
- // Cache the response for GET requests
264
- if (method === HttpMethod.GET && useCache) {
265
- const cacheKey = this.cacheManager.produceCacheKey(JSON.stringify({
266
- endpoint,
267
- params,
268
- data: null,
269
- }));
270
- this.cacheManager.setCache(cacheKey, response);
271
- }
272
- return response;
273
- }
274
- catch (error) {
275
- return this.handleError(error);
276
- }
277
- }
278
- /**
279
- * Start polling a Maestro API endpoint at specified interval
280
- */
281
- pollMaestroApiRequest({ endpoint, interval, method = HttpMethod.GET, params = {}, data = null, headers = {}, maestroDefaultHeaders = null, skipResponseBodyDeserialization = false, onData, onError, }) {
282
- // Create a unique key for this polling task
283
- const taskKey = `${endpoint}-${JSON.stringify(params)}-${JSON.stringify(data)}`;
284
- // Stop existing polling for this endpoint if it exists
285
- if (this.pollingTasks.has(taskKey)) {
286
- this.pollingTasks.get(taskKey)?.controller.abort();
287
- this.pollingTasks.delete(taskKey);
288
- }
289
- // Create a new abort controller for cancellation
290
- const controller = new AbortController();
291
- const signal = controller.signal;
292
- // Start the polling
293
- (async () => {
294
- while (!signal.aborted) {
295
- try {
296
- const response = await this.maestroApiRequest({
297
- endpoint,
298
- method,
299
- params,
300
- data,
301
- headers,
302
- maestroDefaultHeaders,
303
- skipResponseBodyDeserialization,
304
- useCache: false, // Don't use cache for polling
305
- });
306
- // Call the callback with the data
307
- onData(response);
308
- }
309
- catch (error) {
310
- // Call the error callback if provided
311
- if (onError) {
312
- onError(error);
313
- }
314
- }
315
- // Wait for the interval before next poll
316
- if (!signal.aborted) {
317
- await new Promise((resolve) => setTimeout(resolve, interval));
318
- }
319
- }
320
- })();
321
- // Store the controller for later cancellation
322
- this.pollingTasks.set(taskKey, { controller, interval });
323
- // Return a function to stop polling
324
- return {
325
- stop: () => {
326
- if (this.pollingTasks.has(taskKey)) {
327
- this.pollingTasks.get(taskKey)?.controller.abort();
328
- this.pollingTasks.delete(taskKey);
329
- }
330
- },
331
- };
332
- }
333
- /**
334
- * Start polling an external API endpoint at specified interval
335
- */
336
- pollExternalApiRequest({ endpoint, interval, method = HttpMethod.GET, params = {}, data = null, headers = {}, skipResponseBodyDeserialization = false, onData, onError, }) {
337
- // Create a unique key for this polling task
338
- const taskKey = `external-${endpoint}-${JSON.stringify(params)}-${JSON.stringify(data)}`;
339
- // Stop existing polling for this endpoint if it exists
340
- if (this.pollingTasks.has(taskKey)) {
341
- this.pollingTasks.get(taskKey)?.controller.abort();
342
- this.pollingTasks.delete(taskKey);
343
- }
344
- // Create a new abort controller for cancellation
345
- const controller = new AbortController();
346
- const signal = controller.signal;
347
- // Start the polling
348
- (async () => {
349
- while (!signal.aborted) {
350
- try {
351
- const response = await this.externalApiRequest({
352
- endpoint,
353
- method,
354
- params,
355
- data,
356
- headers,
357
- skipResponseBodyDeserialization,
358
- useCache: false, // Don't use cache for polling
359
- });
360
- // Call the callback with the data
361
- onData(response);
362
- }
363
- catch (error) {
364
- // Call the error callback if provided
365
- if (onError) {
366
- onError(error);
367
- }
368
- }
369
- // Wait for the interval before next poll
370
- if (!signal.aborted) {
371
- await new Promise((resolve) => setTimeout(resolve, interval));
372
- }
373
- }
374
- })();
375
- // Store the controller for later cancellation
376
- this.pollingTasks.set(taskKey, { controller, interval });
377
- // Return a function to stop polling
378
- return {
379
- stop: () => {
380
- if (this.pollingTasks.has(taskKey)) {
381
- this.pollingTasks.get(taskKey)?.controller.abort();
382
- this.pollingTasks.delete(taskKey);
383
- }
384
- },
385
- };
386
- }
387
- /**
388
- * Stop all polling tasks
389
- */
390
- stopAllPolling() {
391
- for (const [key, { controller }] of this.pollingTasks.entries()) {
392
- controller.abort();
393
- this.pollingTasks.delete(key);
394
- }
395
- }
396
- /**
397
- * Clear all cached data
398
- */
399
- clearAllCache() {
400
- const originalLength = this.localStorage.length;
401
- for (let i = 0; i < originalLength; i++) {
402
- const key = this.localStorage.key(i);
403
- if (key && key.startsWith('maestro-cache-')) {
404
- this.localStorage.removeItem(key);
405
- }
406
- }
407
- }
408
- }
409
- // Export singleton instance as default
410
- export default NetworkManager;
@@ -1,45 +0,0 @@
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
- }
@@ -1,47 +0,0 @@
1
- import { BORDER_RADIUS, TEXT_CAPITALIZATION, THEME_MODES, THEME_TYPES, } from '@/models/ITheme';
2
- const FONT_FAMILY = 'BentonSans-Medium';
3
- export const DARK_THEME = {
4
- _id: '6274067af74b66a544018dac',
5
- button: {
6
- borderRadius: BORDER_RADIUS.rounded,
7
- textCapitalization: TEXT_CAPITALIZATION.uppercase,
8
- },
9
- colors: {
10
- // Accent colors
11
- accentPrimary: '#FFFFFF',
12
- // Secondary accent colors
13
- accentSecondary: '#3C3F47',
14
- // Tertiary accent colors
15
- accentTertiary: '#0C0C0E',
16
- // Surface Colors
17
- surface1: '#080A0C',
18
- surface2: '#12141A',
19
- surface3: '#1B1E26',
20
- surface4: '#242833',
21
- surface5: '#363C4D',
22
- surface6: '#3E4759',
23
- // Highlight colors
24
- highlightPrimary: '#FFFFFF',
25
- highlightSecondary: '#9A9EA9',
26
- highlightTertiary: '#0A0C0F',
27
- // Alert colors
28
- alertConfirmation: '#43D48F',
29
- alertWarning: '#F58B00',
30
- alertError: '#FF0000',
31
- // Text colors
32
- text100: '#F8F9FA',
33
- text200: '#C2C5CB',
34
- text300: '#8D919D',
35
- text400: '#5C606B',
36
- text500: '#0C0C0E',
37
- },
38
- creator: '016901e60000000000000000',
39
- name: 'Dark Mode',
40
- type: THEME_TYPES.CLASSIC,
41
- mode: THEME_MODES.DARK,
42
- owner: '016901e60000000000000000',
43
- typography: {
44
- body: FONT_FAMILY,
45
- headline: FONT_FAMILY,
46
- },
47
- };
@@ -1,15 +0,0 @@
1
- // This file must be the first import in test files
2
- // Handle globalThis for Node.js < 12
3
- if (typeof globalThis === 'undefined') {
4
- global.globalThis = global;
5
- }
6
- // Polyfill for FinalizationRegistry in Node.js < 14.6.0
7
- const globalWithFR = globalThis;
8
- if (typeof globalWithFR.FinalizationRegistry === 'undefined') {
9
- globalWithFR.FinalizationRegistry = class FinalizationRegistry {
10
- constructor(_callback) { }
11
- register(_target, _heldValue, _unregisterToken) { }
12
- unregister(_unregisterToken) { }
13
- };
14
- }
15
- export {};
@@ -1,4 +0,0 @@
1
- export const OverlayType = {
2
- WinningBet: 'winningBet',
3
- FantasyPlayerEvent: 'fantasyPlayerEvent',
4
- };
@@ -1,156 +0,0 @@
1
- import { Observable } from '../helpers/Observable';
2
- import { ViewModel } from './ViewModel';
3
- import KeyPlaysViewModel from '../modules/key-plays/view-model/KeyPlaysViewModel';
4
- import BetsViewModel from '../modules/bets/view-model/BetsViewModel';
5
- import SpatialNavigation from '@/external/spatial-navigation/spatialNavigation';
6
- import StatsViewModel from '../modules/stats/view-model/StatsViewModel';
7
- export class MaestroEventViewModel extends ViewModel {
8
- constructor(eventId = '', delegate) {
9
- super();
10
- Object.defineProperty(this, "_eventId", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: new Observable('')
15
- });
16
- Object.defineProperty(this, "_title", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: new Observable('')
21
- });
22
- Object.defineProperty(this, "_isLive", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: new Observable(false)
27
- });
28
- Object.defineProperty(this, "_isShowingPanel", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: new Observable(false)
33
- });
34
- Object.defineProperty(this, "delegate", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
- Object.defineProperty(this, "keyPlaysViewModel", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: new KeyPlaysViewModel()
45
- });
46
- Object.defineProperty(this, "betsViewModel", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: void 0
51
- });
52
- Object.defineProperty(this, "statsViewModel", {
53
- enumerable: true,
54
- configurable: true,
55
- writable: true,
56
- value: void 0
57
- });
58
- this._eventId.value = eventId;
59
- this.delegate = delegate;
60
- this.betsViewModel = new BetsViewModel(eventId, delegate);
61
- this.statsViewModel = new StatsViewModel(eventId, { useMockData: true });
62
- SpatialNavigation.init();
63
- }
64
- deinit() {
65
- this.betsViewModel.cleanup();
66
- this.statsViewModel.cleanup();
67
- SpatialNavigation.destroy();
68
- }
69
- updateKeyPlaysData(data) {
70
- return this.keyPlaysViewModel.setKeyPlays(data);
71
- }
72
- startFocusManagement() {
73
- SpatialNavigation.setFocus('');
74
- SpatialNavigation.resume();
75
- setTimeout(() => {
76
- SpatialNavigation.setFocus('PANEL_NAV_BUTTON_0');
77
- }, 0);
78
- return Promise.resolve();
79
- }
80
- didStartPlayingClip(index) {
81
- this.keyPlaysViewModel.lastPlayedClipIndex.value = index;
82
- this.keyPlaysViewModel.currentClipPlaybackProgress.value = 0;
83
- this.keyPlaysViewModel.currentlyPlayingClipIndex.value = index;
84
- this.keyPlaysViewModel.clearLoadFailureStatus(index);
85
- }
86
- didStopPlayingClip(index) {
87
- this.keyPlaysViewModel.lastPlayedClipIndex.value = index;
88
- this.keyPlaysViewModel.currentlyPlayingClipIndex.value = null;
89
- this.keyPlaysViewModel.currentClipPlaybackProgress.value = null;
90
- }
91
- didFailToPlayClip(index) {
92
- this.keyPlaysViewModel.handleKeyPlayLoadFailure(index);
93
- }
94
- didUpdatePlaybackProgressOfClip(index, to) {
95
- this.keyPlaysViewModel.currentClipPlaybackProgress.value = to;
96
- this.keyPlaysViewModel.clearLoadFailureStatus(index);
97
- }
98
- didShowPanel() {
99
- this.isShowingPanel = true;
100
- // Analytics call ?
101
- return Promise.resolve();
102
- }
103
- async didHidePanel() {
104
- this.isShowingPanel = false;
105
- SpatialNavigation.pause();
106
- // Analytics call?
107
- }
108
- didShowOverlay() {
109
- throw new Error('Method not implemented.');
110
- }
111
- didHideOverlay() {
112
- throw new Error('Method not implemented.');
113
- }
114
- currentEventDoesNotSupportKeyPlays() {
115
- this.keyPlaysViewModel.errorState.value = 'unsupportedEvent';
116
- }
117
- getCurrentEventID() {
118
- return this.eventId.value;
119
- }
120
- getCurrentlyPlayingClipIndex() {
121
- return this.keyPlaysViewModel.currentlyPlayingClipIndex.value;
122
- }
123
- getLastPlayedClipIndex() {
124
- return this.keyPlaysViewModel.lastPlayedClipIndex.value;
125
- }
126
- getCurrentClipPlaybackProgress() {
127
- return this.keyPlaysViewModel.currentClipPlaybackProgress.value;
128
- }
129
- getKeyPlaysCount() {
130
- return this.keyPlaysViewModel.allItems.length;
131
- }
132
- get eventId() {
133
- return this._eventId;
134
- }
135
- get title() {
136
- return this._title;
137
- }
138
- get isLive() {
139
- return this._isLive;
140
- }
141
- get isShowingPanel() {
142
- return this._isShowingPanel.value;
143
- }
144
- set isShowingPanel(value) {
145
- this._isShowingPanel.value = value;
146
- }
147
- simulateUseCase(useCase, panelType, testData) {
148
- switch (panelType) {
149
- case 'bets':
150
- this.betsViewModel.simulateUseCase(useCase, testData);
151
- break;
152
- default:
153
- throw new Error(`Unsupported panel type: ${panelType}`);
154
- }
155
- }
156
- }