@maestro_io/maestro-web-sdk 3.1.2 → 3.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 (53) hide show
  1. package/dist/maestro-web-sdk.esm.js +5 -5
  2. package/dist/maestro-web-sdk.esm.js.map +1 -1
  3. package/dist/maestro-web-sdk.umd.js +5 -5
  4. package/dist/maestro-web-sdk.umd.js.map +1 -1
  5. package/dist/src/components/atoms/SvgIcon/FantasyIcon.d.ts +7 -0
  6. package/dist/src/components/atoms/SvgIcon/Icon.d.ts +2 -0
  7. package/dist/src/components/molecules/HeadshotImage/HeadshotImage.d.ts +16 -0
  8. package/dist/src/components/molecules/HeadshotImage/index.d.ts +2 -0
  9. package/dist/src/development/MaestroEventDelegate.d.ts +2 -1
  10. package/dist/src/helpers/strings.d.ts +1 -0
  11. package/dist/src/index.d.ts +3 -3
  12. package/dist/src/interfaces/IMaestroEventDelegate.d.ts +15 -0
  13. package/dist/src/interfaces/IUserSettings.d.ts +4 -0
  14. package/dist/src/models/IPanel.d.ts +1 -6
  15. package/dist/src/modules/bets/view-model/BetsViewModel.d.ts +0 -5
  16. package/dist/src/modules/fantasy/components/ExpandedAthleteList/ExpandedAthletesList.d.ts +28 -0
  17. package/dist/src/modules/fantasy/components/ExpandedAthleteList/index.d.ts +1 -0
  18. package/dist/src/modules/fantasy/components/LeagueCard/LeagueCard.d.ts +56 -0
  19. package/dist/src/modules/fantasy/components/LeagueCard/index.d.ts +2 -0
  20. package/dist/src/modules/fantasy/components/TopPlayerCard/TopPlayerCard.d.ts +53 -0
  21. package/dist/src/modules/fantasy/components/TopPlayerCard/index.d.ts +2 -0
  22. package/dist/src/modules/fantasy/types.d.ts +176 -0
  23. package/dist/src/modules/fantasy/view/ActiveAthletesMarquee/ActiveAthletesMarquee.d.ts +21 -0
  24. package/dist/src/modules/fantasy/view/ActiveAthletesMarquee/index.d.ts +2 -0
  25. package/dist/src/modules/fantasy/view/FantasyItemView.d.ts +21 -0
  26. package/dist/src/modules/fantasy/view/FantasyView.d.ts +27 -0
  27. package/dist/src/modules/fantasy/view/InactiveLeague/DraftDateCountdown.d.ts +23 -0
  28. package/dist/src/modules/fantasy/view/InactiveLeague/InactiveLeague.d.ts +52 -0
  29. package/dist/src/modules/fantasy/view/InactiveLeague/index.d.ts +2 -0
  30. package/dist/src/modules/fantasy/view/LoginView/LoginView.d.ts +48 -0
  31. package/dist/src/modules/fantasy/view/LoginView/index.d.ts +2 -0
  32. package/dist/src/modules/fantasy/view/MatchupPair/DoubleAthleteCard/DoubleAthleteCard.d.ts +49 -0
  33. package/dist/src/modules/fantasy/view/MatchupPair/DoubleAthleteCard/index.d.ts +2 -0
  34. package/dist/src/modules/fantasy/view/MatchupPair/ExpandedDoubleAthleteCards.d.ts +14 -0
  35. package/dist/src/modules/fantasy/view/MatchupPair/MatchupPair.d.ts +54 -0
  36. package/dist/src/modules/fantasy/view/MatchupPair/index.d.ts +2 -0
  37. package/dist/src/modules/fantasy/view/MatchupSingle/ExpandedSingleAthleteCards.d.ts +14 -0
  38. package/dist/src/modules/fantasy/view/MatchupSingle/MatchupSingle.d.ts +54 -0
  39. package/dist/src/modules/fantasy/view/MatchupSingle/SingleAthleteCard/SingleAthleteCard.d.ts +49 -0
  40. package/dist/src/modules/fantasy/view/MatchupSingle/SingleAthleteCard/index.d.ts +2 -0
  41. package/dist/src/modules/fantasy/view/MatchupSingle/index.d.ts +2 -0
  42. package/dist/src/modules/fantasy/view/PromoView/PromoView.d.ts +52 -0
  43. package/dist/src/modules/fantasy/view/PromoView/index.d.ts +2 -0
  44. package/dist/src/modules/fantasy/view/index.d.ts +2 -0
  45. package/dist/src/modules/fantasy/view-model/FantasyViewModel.FantasyPolling.d.ts +34 -0
  46. package/dist/src/modules/fantasy/view-model/FantasyViewModel.LeagueManagerPolling.d.ts +32 -0
  47. package/dist/src/modules/fantasy/view-model/FantasyViewModel.d.ts +146 -0
  48. package/dist/src/modules/stats/view-model/StatsViewModel.d.ts +0 -5
  49. package/dist/src/services/AnalyticsService/AnalyticsService.d.ts +10 -3
  50. package/dist/src/services/FantasyService.d.ts +54 -0
  51. package/dist/src/services/NetworkManager/types.d.ts +1 -0
  52. package/dist/src/view-models/MaestroEventViewModel.d.ts +3 -1
  53. package/package.json +1 -1
@@ -0,0 +1,146 @@
1
+ import { Observable } from '@/helpers/Observable';
2
+ import IMaestroEventDelegate from '@/interfaces/IMaestroEventDelegate';
3
+ type NotLoggedInFantasyItem = {
4
+ id: string;
5
+ type: 'notLoggedIn';
6
+ };
7
+ export type PromoFantasyItem = {
8
+ id: string;
9
+ type: 'promo';
10
+ background: string;
11
+ logo: string;
12
+ title: string;
13
+ qrCode: string;
14
+ description: string;
15
+ };
16
+ export type InactiveLeague = {
17
+ id: string;
18
+ type: 'inactiveLeague';
19
+ leagueName: string;
20
+ draftDate?: number;
21
+ leagueLogo: string;
22
+ leagueColor: string;
23
+ };
24
+ type MatchupSingleTeam = {
25
+ points: number;
26
+ logo: string;
27
+ scoringType: string;
28
+ };
29
+ export type MatchupSingleRoster = {
30
+ athleteHeadshot: string;
31
+ athleteAbbrevName: string;
32
+ athletesSlot: string;
33
+ teamTriCode: string;
34
+ proGameStatusLines: string[];
35
+ };
36
+ export type MatchupActiveAthlete = {
37
+ abbrevName: string;
38
+ points: string;
39
+ };
40
+ export type MatchupSingleItem = {
41
+ id: string;
42
+ type: 'matchup-single';
43
+ league: {
44
+ title: string;
45
+ subtitle: string | undefined;
46
+ color: string;
47
+ logo: string;
48
+ };
49
+ team: MatchupSingleTeam;
50
+ roster: MatchupSingleRoster[];
51
+ activeAthletes: MatchupActiveAthlete[];
52
+ topPlayers: TopPlayer[];
53
+ };
54
+ export type TopPlayer = {
55
+ abbrevName: string;
56
+ headshot: string;
57
+ position: string;
58
+ teamTriCode: string;
59
+ points: number;
60
+ rosteredBy: string;
61
+ };
62
+ type MatchupPairTeam = {
63
+ name: string | undefined;
64
+ record: string | undefined;
65
+ points: string | undefined;
66
+ projectedPoints: string | undefined;
67
+ logo: string | undefined;
68
+ winProbability: number | undefined;
69
+ };
70
+ type MatchupPairRosterData = {
71
+ headshot: string;
72
+ abbrevName: string;
73
+ slot: string;
74
+ triCode: string;
75
+ points?: number;
76
+ projectedPoints?: number;
77
+ stats: string[];
78
+ };
79
+ export type MatchupPairRoster = {
80
+ away: MatchupPairRosterData;
81
+ home: MatchupPairRosterData;
82
+ };
83
+ export type MatchupPairItem = {
84
+ id: string;
85
+ type: 'matchup-pair';
86
+ league: {
87
+ title: string | undefined;
88
+ subtitle: string | undefined;
89
+ color: string;
90
+ logo: string;
91
+ };
92
+ awayTeam: MatchupPairTeam;
93
+ homeTeam: MatchupPairTeam;
94
+ roster: MatchupPairRoster[];
95
+ activeAthletes: MatchupActiveAthlete[];
96
+ topPlayers: TopPlayer[];
97
+ };
98
+ export type FantasyItem = NotLoggedInFantasyItem | MatchupPairItem | MatchupSingleItem | InactiveLeague | PromoFantasyItem;
99
+ declare const FANTASY_ERROR_STATE: {
100
+ readonly NONE: "none";
101
+ readonly TAB_LOAD_FAILURE: "tabLoadFailure";
102
+ };
103
+ export type FantasyErrorState = typeof FANTASY_ERROR_STATE[keyof typeof FANTASY_ERROR_STATE];
104
+ export declare class FantasyViewModel {
105
+ fantasyItems: Observable<FantasyItem[]>;
106
+ isDataLoading: Observable<boolean>;
107
+ hasEverSuccessfullyLoaded: Observable<boolean>;
108
+ private eventId;
109
+ private delegate;
110
+ private analyticsService;
111
+ private fantasyService;
112
+ private useMockData;
113
+ private fantasyPolling;
114
+ private leagueManagerPolling;
115
+ errorState: Observable<FantasyErrorState>;
116
+ constructor(eventId: string, delegate: IMaestroEventDelegate, options?: {
117
+ useMockData?: boolean;
118
+ });
119
+ /**
120
+ * Initialize the ViewModel and start data fetching
121
+ */
122
+ init(): Promise<void>;
123
+ private fetchData;
124
+ onEngage(type: FantasyItem['type']): void;
125
+ onAskLogin(): void;
126
+ /**
127
+ * Clean up resources when the ViewModel is no longer needed
128
+ */
129
+ cleanup(): void;
130
+ /**
131
+ * Track panel view event
132
+ */
133
+ private trackPanelView;
134
+ private processFantasy;
135
+ private parseRoto;
136
+ append(item: FantasyItem | null): void;
137
+ private parseHeadToHead;
138
+ private parseTopPlayers;
139
+ private parseInactiveLeague;
140
+ /**
141
+ * Fetch mock data for testing
142
+ */
143
+ private fetchMockData;
144
+ clearTabLoadFailure(): void;
145
+ }
146
+ export default FantasyViewModel;
@@ -233,9 +233,4 @@ export declare class StatsViewModel extends ViewModel {
233
233
  */
234
234
  simulateUseCase<T = any>(_useCase: TestUseCase, testData?: T): void;
235
235
  }
236
- declare global {
237
- interface String {
238
- hashCode(): number;
239
- }
240
- }
241
236
  export default StatsViewModel;
@@ -30,7 +30,14 @@ type StatsItemClickedAction = {
30
30
  game_state: string[];
31
31
  };
32
32
  };
33
- type PanelClickPayload = KeyPlaysClickedAction | BetsItemClickedAction | StatsItemClickedAction;
33
+ type FantasyItemClickedAction = {
34
+ type: 'espnFantasy';
35
+ name: 'fantasy_item_clicked';
36
+ metadata: {
37
+ card: string;
38
+ };
39
+ };
40
+ type PanelClickPayload = KeyPlaysClickedAction | BetsItemClickedAction | StatsItemClickedAction | FantasyItemClickedAction;
34
41
  type PanelData = {
35
42
  panel_type: string;
36
43
  panel_id: string;
@@ -46,10 +53,10 @@ declare class AnalyticsService {
46
53
  constructor();
47
54
  private trackAction;
48
55
  private trackImpression;
49
- panelView(panelType: 'espnStats' | 'espnKeyPlays' | 'espnBet', metadata?: Record<string, any>): Promise<void>;
56
+ panelView(panelType: 'espnStats' | 'espnKeyPlays' | 'espnBet' | 'espnFantasy', metadata?: Record<string, any>): Promise<void>;
50
57
  panelClick({ type, metadata, name }: PanelClickPayload): Promise<void>;
51
58
  getBaseMetadataFromPageConfig(pageConfig: PageConfig | null): BaseMetadata;
52
- getPanelDataFromPageConfig(type: 'espnBet' | 'espnStats' | 'espnKeyPlays', pageConfig: PageConfig | null): PanelData;
59
+ getPanelDataFromPageConfig(type: 'espnBet' | 'espnStats' | 'espnKeyPlays' | 'espnFantasy', pageConfig: PageConfig | null): PanelData;
53
60
  sessionStart(): Promise<void>;
54
61
  sessionEnd(): Promise<void>;
55
62
  private scheduleNextBeacon;
@@ -0,0 +1,54 @@
1
+ import NetworkManager from './NetworkManager/NetworkManager';
2
+ import { IFantasyResponse, ILeagueManagerResponse, IPromoResponse } from '@/modules/fantasy/types';
3
+ export type LeagueManagerPollingParams = {
4
+ /**
5
+ * NBA, NFL, etc.
6
+ */
7
+ game: string;
8
+ /**
9
+ * 2025
10
+ */
11
+ seasonId: number;
12
+ /**
13
+ * The league ID
14
+ */
15
+ leagueId: number;
16
+ token: string;
17
+ proGameId: string;
18
+ teamId: number;
19
+ };
20
+ export type FantasyPollingParams = {
21
+ swid: string;
22
+ jwt: string;
23
+ eventId: string;
24
+ };
25
+ /**
26
+ * Service for handling fantasy API calls
27
+ */
28
+ declare class FantasyService {
29
+ fantasyClient: NetworkManager;
30
+ leagueManagerClient: NetworkManager;
31
+ promoClient: NetworkManager;
32
+ constructor();
33
+ /**
34
+ * Polls the fantasy API at regular intervals
35
+ * @param swid - The SWID of the user
36
+ * @param interval - Polling interval in milliseconds
37
+ * @param onData - Callback invoked with the data on each successful poll
38
+ * @param onError - Optional callback invoked on error
39
+ */
40
+ pollFantasy({ eventId, jwt, swid }: FantasyPollingParams, interval: number, onData: (data: {
41
+ data: IFantasyResponse;
42
+ headers: Record<string, string>;
43
+ }) => void, onError?: (error: Error) => void): {
44
+ stop: () => void;
45
+ };
46
+ pollLeagueManager({ game, leagueId, seasonId, token, proGameId, teamId, }: LeagueManagerPollingParams, interval: number, onData: (data: {
47
+ data: ILeagueManagerResponse;
48
+ headers: Record<string, string>;
49
+ }) => void, onError?: (error: Error) => void): {
50
+ stop: () => void;
51
+ };
52
+ getPromo(): Promise<IPromoResponse>;
53
+ }
54
+ export default FantasyService;
@@ -5,6 +5,7 @@ export declare const ServiceType: {
5
5
  readonly STATS: "stats";
6
6
  readonly BETS: "bets";
7
7
  readonly MAESTRO: "maestro";
8
+ readonly FANTASY: "fantasy";
8
9
  };
9
10
  export type ServiceType = typeof ServiceType[keyof typeof ServiceType];
10
11
  /**
@@ -11,6 +11,7 @@ import { MaestroPanelType } from '@/models/IPanel';
11
11
  import { IUserSettings } from '../interfaces/IUserSettings';
12
12
  import { PanelManagerViewModel } from './PanelManagerViewModel';
13
13
  import AnalyticsService from '@/services/AnalyticsService/AnalyticsService';
14
+ import FantasyViewModel from '@/modules/fantasy/view-model/FantasyViewModel';
14
15
  export declare class MaestroEventViewModel extends ViewModel implements IMaestroEvent {
15
16
  private _eventId;
16
17
  private _title;
@@ -19,6 +20,7 @@ export declare class MaestroEventViewModel extends ViewModel implements IMaestro
19
20
  private playerTimeCode;
20
21
  delegate: IMaestroEventDelegate;
21
22
  keyPlaysViewModel: KeyPlaysViewModel | null;
23
+ fantasyViewModel: FantasyViewModel | null;
22
24
  betsViewModel: BetsViewModel | null;
23
25
  statsViewModel: StatsViewModel | null;
24
26
  panelManagerViewModel: PanelManagerViewModel;
@@ -28,7 +30,7 @@ export declare class MaestroEventViewModel extends ViewModel implements IMaestro
28
30
  setActivePanel(panelType: MaestroPanelType): void;
29
31
  updatePlayerTimeCode(timestamp: number): void;
30
32
  getPlayerTimeCode(): number | null;
31
- deinit(): void;
33
+ deinit(): Promise<void>;
32
34
  updateKeyPlaysData(data: IMaestroKeyPlaysResponse | null): Promise<void>;
33
35
  updateUserSettings(settings: IUserSettings): Promise<void>;
34
36
  startFocusManagement(): Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maestro_io/maestro-web-sdk",
3
3
  "private": false,
4
- "version": "3.1.2",
4
+ "version": "3.2.0",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "main": "dist/maestro-web-sdk.umd.js",