@maestro_io/maestro-web-sdk 2.2.3 → 2.2.4

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.
@@ -115,12 +115,13 @@ export declare class StatsViewModel extends ViewModel {
115
115
  currentGameState: Observable<string>;
116
116
  statsService: StatsService;
117
117
  analyticsService: AnalyticsService;
118
- private pollingInterval;
119
118
  private useMockData;
120
- private pollingTask;
121
119
  private lastResponseHash;
120
+ private currentPlayerTimeCode;
121
+ private timecodePollingTask;
122
+ private smartPollingTimeout;
123
+ private timecodePollingState;
122
124
  constructor(eventId: string, delegate: IMaestroEventDelegate, options?: {
123
- pollingInterval?: number;
124
125
  useMockData?: boolean;
125
126
  });
126
127
  /**
@@ -133,27 +134,66 @@ export declare class StatsViewModel extends ViewModel {
133
134
  */
134
135
  cleanup(): void;
135
136
  /**
136
- * Fetch new stats data immediately (one-time)
137
+ * Handle player timecode updates with enhanced logging and validation
138
+ *
139
+ * @param playerTimeCode - The timecode in milliseconds, or null for live
137
140
  */
138
- fetchNewData(): Promise<void>;
141
+ onUpdatePlayerTimeCode(playerTimeCode: number | null): void;
139
142
  /**
140
- * Fetch mock data for testing
143
+ * Implement smart polling strategy: immediate API call + delayed polling resumption
144
+ *
145
+ * @param syncUrl - The sync URL to use for the API call
141
146
  */
142
- private fetchMockData;
147
+ private performSmartPolling;
148
+ /**
149
+ * Enhanced error handling for timecode-related operations
150
+ *
151
+ * @param context - Description of where the error occurred
152
+ * @param error - The error that occurred
153
+ */
154
+ private handleTimecodeError;
155
+ /**
156
+ * Clear any pending smart polling timeout
157
+ */
158
+ private clearSmartPollingTimeout;
159
+ /**
160
+ * Reset timecode polling state
161
+ */
162
+ private resetTimecodePollingState;
143
163
  /**
144
- * Refresh polling for bet data
164
+ * Build sync URL for timecode-based stats fetching with enhanced logging
165
+ * Enhanced with comprehensive validation and fallback strategies
166
+ *
167
+ * @param timeCode - The timecode in milliseconds, or null for 'latest'
168
+ * @returns Complete sync URL for the fauxcast stats endpoint
169
+ * @throws Error if page config is not available or required fields are missing
145
170
  */
146
- refreshPolling(): void;
171
+ private buildSyncUrl;
147
172
  /**
148
- * Poll with the correct method based on authentication status
173
+ * Format timecode for API consumption
174
+ * @param timeCode - Timecode in milliseconds or null
175
+ * @returns ISO date string, "pre.json" for pre-game, or "latest" for post-game
149
176
  */
150
- private pollWithInterval;
177
+ private formatTimeCodeForAPI;
151
178
  /**
152
- * Handle errors that occur during polling
179
+ * Start timecode-based polling with enhanced logging
180
+ *
181
+ * @param syncUrl - The sync URL to poll
153
182
  */
154
- private handlePollingError;
183
+ private startTimecodePolling;
155
184
  /**
156
- * Process data received from polling
185
+ * Stop timecode-based polling with enhanced logging
186
+ */
187
+ private stopTimecodePolling;
188
+ /**
189
+ * Fetch mock data for testing
190
+ */
191
+ private fetchMockData;
192
+ /**
193
+ * Process polled data with hash comparison to avoid unnecessary re-renders
194
+ * Enhanced with comprehensive logging to show data changes
195
+ *
196
+ * @param data - The stats data received from the API
157
197
  */
158
198
  private processPolledData;
159
199
  private processData;
@@ -171,10 +211,6 @@ export declare class StatsViewModel extends ViewModel {
171
211
  * Simulate a use case using mock StatsApiResponse data
172
212
  */
173
213
  simulateUseCase<T = any>(_useCase: TestUseCase, testData?: T): void;
174
- /**
175
- * Stop polling for bet data
176
- */
177
- stopPolling(): void;
178
214
  }
179
215
  declare global {
180
216
  interface String {
@@ -8,29 +8,30 @@ declare class StatsService {
8
8
  networkManager: IStatsNetworkManager;
9
9
  constructor(delegate: IMaestroEventDelegate);
10
10
  /**
11
- * Get stats for an event
11
+ * Get stats using a full sync URL (for timecode support)
12
12
  *
13
- * @param eventID - The ID of the event
14
- * @param gameState - Optional game state filter (e.g., 'pre', 'in', 'post')
13
+ * @param syncUrl - Complete sync URL (e.g., https://client.espn.com/fauxcast/stats/...)
15
14
  * @returns Promise with the stats data
16
15
  */
17
- getStats(eventID: string, gameState?: string): Promise<StatsApiResponse>;
16
+ getStatsByUrl(syncUrl: string): Promise<StatsApiResponse>;
18
17
  /**
19
- * Start polling for stats
18
+ * Start polling using a full sync URL (for timecode support)
20
19
  *
21
- * @param eventID - The ID of the event
22
- * @param gameState - Optional game state filter (e.g., 'pre', 'in', 'post')
20
+ * @param syncUrl - Complete sync URL (e.g., https://client.espn.com/fauxcast/stats/...)
23
21
  * @param interval - The polling interval in milliseconds
24
22
  * @param onData - Callback for successful data fetch
25
23
  * @param onError - Callback for errors
26
24
  * @returns Object with a stop function to stop polling
27
25
  */
28
- pollStats(eventID: string, gameState: string | undefined, interval: number, onData: (data: StatsApiResponse) => void, onError?: (error: Error) => void): {
26
+ pollStatsByUrl(syncUrl: string, interval: number, onData: (data: StatsApiResponse) => void, onError?: (error: Error) => void): {
29
27
  stop: () => void;
30
28
  };
31
29
  /**
32
- * Get the endpoint for stats
30
+ * Parse a sync URL into base URL and endpoint
31
+ *
32
+ * @param syncUrl - Complete sync URL
33
+ * @returns Object with baseUrl and endpoint
33
34
  */
34
- statsEndpoint(eventID: string): string;
35
+ private parseSyncUrl;
35
36
  }
36
37
  export default StatsService;
@@ -9,6 +9,7 @@ import StatsViewModel from '../modules/stats/view-model/StatsViewModel';
9
9
  import IMaestroKeyPlaysResponse from '../modules/key-plays/interfaces/IKeyPlaysResponse';
10
10
  import { MaestroPanelType } from '@/models/IPanel';
11
11
  import { IUserSettings } from '../interfaces/IUserSettings';
12
+ import { PanelManagerViewModel } from './PanelManagerViewModel';
12
13
  export declare class MaestroEventViewModel extends ViewModel implements IMaestroEvent {
13
14
  private _eventId;
14
15
  private _title;
@@ -19,8 +20,10 @@ export declare class MaestroEventViewModel extends ViewModel implements IMaestro
19
20
  keyPlaysViewModel: KeyPlaysViewModel;
20
21
  betsViewModel: BetsViewModel;
21
22
  statsViewModel: StatsViewModel;
23
+ panelManagerViewModel: PanelManagerViewModel;
22
24
  navigation: SpatialNavigation;
23
25
  constructor(eventId: string | undefined, delegate: IMaestroEventDelegate);
26
+ setActivePanel(panelType: MaestroPanelType): void;
24
27
  updatePlayerTimeCode(timestamp: number): void;
25
28
  getPlayerTimeCode(): number | null;
26
29
  deinit(): void;
@@ -7,7 +7,6 @@ export type PanelInfo = {
7
7
  export declare class PanelManagerViewModel {
8
8
  private _panels;
9
9
  private _currentPanel;
10
- private _newlyFocusedPanel;
11
10
  private settingsManager;
12
11
  private settingsUnsubscribe;
13
12
  private readonly ALL_PANELS;
@@ -39,8 +38,7 @@ export declare class PanelManagerViewModel {
39
38
  get currentPanel(): MaestroPanelType | null;
40
39
  set currentPanel(value: MaestroPanelType | null);
41
40
  get currentPanelObservable(): Observable<MaestroPanelType | null>;
42
- get newlyFocusedPanel(): MaestroPanelType | null;
43
- set newlyFocusedPanel(value: MaestroPanelType | null);
41
+ setActivePanel(panelType: MaestroPanelType): void;
44
42
  getIndex(forPanelType: MaestroPanelType): number | null;
45
43
  getPanelType(atIndex: number): MaestroPanelType | null;
46
44
  get panelTypeToLeft(): MaestroPanelType | null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maestro_io/maestro-web-sdk",
3
3
  "private": false,
4
- "version": "2.2.3",
4
+ "version": "2.2.4",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "main": "dist/maestro-web-sdk.umd.js",
@@ -1,23 +0,0 @@
1
- import { MaestroEventViewModel } from './MaestroEventViewModel';
2
- import { PanelManagerViewModel } from './PanelManagerViewModel';
3
- import { OverlayViewModel } from './OverlayViewModel';
4
- import IMaestroEventDelegate from '../interfaces/IMaestroEventDelegate';
5
- import KeyPlaysViewModel from '../modules/key-plays/view-model/KeyPlaysViewModel';
6
- /**
7
- * Aggregates all View Models
8
- */
9
- export declare class MaestroViewModels {
10
- readonly eventViewModel: MaestroEventViewModel;
11
- readonly panelManagerViewModel: PanelManagerViewModel;
12
- readonly keyPlaysViewModel: KeyPlaysViewModel;
13
- readonly overlayViewModel: OverlayViewModel;
14
- constructor(eventViewModel: MaestroEventViewModel);
15
- /**
16
- * Cleanup all view models
17
- */
18
- cleanup(): void;
19
- /**
20
- * Creates view models from an event ID
21
- */
22
- static fromEventId(eventId: string, delegate: IMaestroEventDelegate): Promise<MaestroViewModels | null>;
23
- }