@01tech/sportsbook-web 0.64.0 → 0.67.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.
package/dist/index.d.ts CHANGED
@@ -1,92 +1,58 @@
1
- interface EventMap {
2
- [key: string]: unknown;
3
- }
4
- interface TypedEventListener<TEventMap extends EventMap> {
5
- addEventListener<TEvent extends keyof TEventMap>(event: TEvent, listener: (...payload: TEventMap[TEvent] extends void ? [] : [TEventMap[TEvent]]) => void): void;
6
- removeEventListener<TEvent extends keyof TEventMap>(event: TEvent, listener: (...args: unknown[]) => void): void;
7
- }
8
-
9
- type SportsFramePlatformType = 'mobile' | 'tablet' | 'desktop';
10
- type SportsFrameColorSchemeType = 'light' | 'dark';
11
- type SportsFrameColorSchemeModalType = SportsFrameColorSchemeType | 'auto';
12
- interface SportsFrameNotificationEventPayload {
1
+ type SportsbookPlatformType = 'mobile' | 'tablet' | 'desktop';
2
+ type SportsbookColorScheme = 'light' | 'dark';
3
+ /**
4
+ * @public
5
+ */
6
+ type SportsbookNotificationPayload = {
13
7
  variant: 'success' | 'info' | 'error';
14
8
  title: string;
15
9
  text?: string;
16
- }
17
- interface SportsFrameModalState {
18
- opened: boolean;
19
- }
20
- interface SportsFrameImageVariant {
21
- url: string;
22
- /**
23
- * Mostly used to avoid unnecessary layout shift; in most cases, recommended to use.
24
- */
25
- height?: number;
26
- width?: number;
27
- }
28
- type SportsFrameCoefFormat = 'decimal' | 'fractional' | 'american' | 'hong_kong' | 'indonesian' | 'malay';
29
-
30
- interface ExperimentPayload {
31
- /**
32
- * The key of the experiment.
33
- */
34
- key?: string;
35
- /**
36
- * The value of the experiment
37
- */
38
- value?: string;
39
- }
40
- interface SportFrameExperimentAdapter {
41
- get(name: string): ExperimentPayload | undefined;
42
- exposure(name: string): void;
43
- }
10
+ };
11
+ type SportsbookCoefFormat = 'decimal' | 'fractional' | 'american' | 'hong_kong' | 'indonesian' | 'malay';
44
12
 
45
- interface SportsFrameNavigationModeSync {
46
- type: 'sync';
13
+ interface SportsbookNavigationModeManual {
14
+ type: 'manual';
47
15
  initialPath: string;
48
16
  push(path: string): Promise<void>;
49
17
  replace(path: string): Promise<void>;
50
18
  back(): void;
51
19
  forward(): void;
52
20
  }
53
- interface SportsFrameNavigationModeAuto {
54
- type: 'auto';
55
- }
56
- type SportsFrameNavigation = SportsFrameNavigationModeSync | SportsFrameNavigationModeAuto;
21
+ type SportsbookNavigationModeHistory = {
22
+ type: 'web-history';
23
+ };
24
+ type SportsbookNavigationModeMemory = {
25
+ type: 'memory';
26
+ };
27
+ type SportsbookNavigation = SportsbookNavigationModeManual | SportsbookNavigationModeHistory | SportsbookNavigationModeMemory;
57
28
 
58
- interface SportsFrameThemeConfig {
59
- readonly preset?: {
60
- readonly name: string;
61
- readonly env?: 'prod' | 'preprod';
62
- };
63
- }
64
- interface SportsFrameBonusWalletOptions {
65
- readonly bonusId: string;
66
- readonly amount: number;
29
+ type SportsbookFeatures = {
67
30
  /**
68
- * The bonus has its own currency and does not use the system-defined currency.
31
+ * @default true
69
32
  */
70
- readonly currencyCode: string;
71
- }
72
- interface SportsFrameGraphicsConfig {
73
- readonly betslipEmpty?: SportsFrameImageVariant;
74
- readonly betslipSuccess?: SportsFrameImageVariant;
75
- readonly freebetPromoBanner?: SportsFrameImageVariant;
76
- readonly watermarkLogo?: SportsFrameImageVariant;
77
- }
78
- interface SportsFrameFeaturesConfig {
79
33
  readonly sharedBet?: boolean;
80
- readonly broadcast?: boolean;
81
34
  /**
82
- * Enables the ability to switch themes within the frame.
83
- * This is a stateless setting — you must manually subscribe to theme change events
84
- * and update the corresponding parameter inside the frame accordingly.
35
+ * @default true
85
36
  */
86
- readonly colorThemeSwitcher?: boolean;
87
- readonly trends?: boolean;
37
+ readonly broadcast?: boolean;
38
+ };
39
+
40
+ /**
41
+ * @public
42
+ */
43
+ interface SportsbookThemeConfig {
44
+ readonly preset?: {
45
+ /**
46
+ * theme name
47
+ */
48
+ readonly name: string;
49
+ readonly env?: 'prod' | 'preprod';
50
+ };
88
51
  }
89
- interface SportsFrameAppearanceConfig {
52
+ /**
53
+ * @public
54
+ */
55
+ type SportsbookAppearance = {
90
56
  /**
91
57
  * z-index values for different floating UI elements.
92
58
  * Accepts either a number or a string. The string can be a raw value (like '1000'),
@@ -123,104 +89,71 @@ interface SportsFrameAppearanceConfig {
123
89
  */
124
90
  readonly bottom?: number | string;
125
91
  };
126
- }
127
- interface SportsFrameInitOptions {
92
+ };
93
+ /**
94
+ * @public
95
+ */
96
+ type SportsbookInitOptions = {
128
97
  /**
129
- * Api Url
98
+ * The base path relative to which the sportsbook is rendered. This will be used for navigating and generating promo links.
130
99
  */
131
- baseUrl: string;
132
- navigation?: SportsFrameNavigation;
100
+ baseUrl?: string;
101
+ navigation?: SportsbookNavigation;
133
102
  apiUrl: string;
134
103
  cdnUrl?: string;
135
104
  partnerId: string;
136
105
  token?: string;
137
- authed: boolean;
106
+ authed?: boolean;
138
107
  languageCode?: string;
108
+ countryCode?: string;
139
109
  rtl?: boolean;
140
110
  currencyCode?: string;
141
111
  balanceAmount?: number;
142
- bonusWallet?: SportsFrameBonusWalletOptions;
143
- platform: SportsFramePlatformType;
144
- colorScheme?: SportsFrameColorSchemeType;
145
- colorSchemeModal?: SportsFrameColorSchemeModalType;
146
- theme?: SportsFrameThemeConfig;
112
+ platform: SportsbookPlatformType;
113
+ colorScheme?: SportsbookColorScheme;
114
+ theme?: SportsbookThemeConfig;
147
115
  inert?: boolean;
148
- appearance?: SportsFrameAppearanceConfig;
149
- features?: SportsFrameFeaturesConfig;
150
- graphics?: SportsFrameGraphicsConfig;
151
- shareLinkBehavior?: 'native' | 'manual' | 'hidden';
152
- defaultCoefFormat?: SportsFrameCoefFormat;
153
- }
154
- /**
155
- * @private
156
- */
157
- interface SportFrameTrackEventPayload {
158
- event: string;
159
- eventCat: string;
160
- eventName: string;
161
- payload: Record<string, string | number>;
162
- }
163
- /**
164
- * Так как это конфигурация для внутреннего использования, все параметры должны быть опциональные
165
- * данный конфиг не должен попасть в публичный sdk
166
- *
167
- * @private
168
- */
169
- interface SportFrameInitOptionsInternal extends SportsFrameInitOptions {
170
- _debug?: boolean;
171
- _trackEvent?: (payload: SportFrameTrackEventPayload) => void;
172
- _experiments?: SportFrameExperimentAdapter;
173
- _monitoring?: {
174
- error?: boolean;
175
- };
116
+ appearance?: SportsbookAppearance;
117
+ defaultCoefFormat?: SportsbookCoefFormat;
176
118
  /**
177
- * Configuration for proxying backend images
178
- * prefix: '/imageproxy/path' will transform 'https://somecdn.com/flag.png'
179
- * to '/imageproxy/path/https://somecdn.com/flag.png'
119
+ * @default '01tech-sportsbook'
180
120
  */
181
- _contentResourcesPrefix?: string;
121
+ localStoragePrefix?: string;
122
+ features?: SportsbookFeatures;
123
+ onReady?: () => void;
124
+ onError?: (err?: Error) => void;
125
+ onLogin?: (place?: 'bets' | 'wheel' | undefined) => void;
126
+ onDeposit?: () => void;
127
+ onRenewToken?: () => void;
128
+ onSendNotification?: (payload: SportsbookNotificationPayload) => void;
129
+ };
130
+
131
+ interface SportsbookBonusWalletOptions {
132
+ readonly bonusId: string;
133
+ readonly amount: number;
182
134
  /**
183
- * @deprecated
184
- *
185
- * frontend/frontend backward compatibility
135
+ * The bonus has its own currency and does not use the system-defined currency.
186
136
  */
187
- assetsUrl?: string;
188
- __sdk?: {
189
- cssStyleUrl: string;
190
- version: string;
191
- stage: string;
192
- };
137
+ readonly currencyCode: string;
193
138
  }
194
139
 
195
- type SportFrameEvents = {
196
- ready: void;
197
- error: Error;
198
- login: 'bets' | 'wheel' | undefined;
199
- deposit: void;
200
- renewToken: void;
201
- notify: SportsFrameNotificationEventPayload;
202
- setModalState: SportsFrameModalState;
203
- shareLink: string;
204
- setColorScheme: SportsFrameColorSchemeType;
205
- };
206
140
  /**
207
141
  * @public
208
142
  */
209
- interface SportFrameApp extends TypedEventListener<SportFrameEvents> {
143
+ interface SportsbookApp {
210
144
  mount(el: HTMLElement): void;
211
145
  destroy(): void;
212
146
  setToken(token: string | undefined): void;
213
- setPlatform(platform: SportsFramePlatformType): void;
147
+ setPlatform(platform: SportsbookPlatformType): void;
214
148
  setLanguageCode(languageCode: string | undefined): void;
215
149
  setRtl(rtl: boolean | undefined): void;
216
- setColorScheme(colorScheme: SportsFrameColorSchemeType): void;
217
- setColorSchemeModal(colorScheme: SportsFrameColorSchemeModalType): void;
150
+ setColorScheme(colorScheme: SportsbookColorScheme): void;
218
151
  setAuthed(authed: boolean): void;
219
152
  setInert(inert: boolean): void;
220
153
  setCurrencyCode(currencyCode: string | undefined): void;
221
154
  setBalanceAmount(balance: number | undefined): void;
222
- setBonusWallet(wallet: SportsFrameBonusWalletOptions | undefined): void;
223
- setAppearance(appearance: SportsFrameAppearanceConfig): void;
155
+ setBonusWallet(wallet: SportsbookBonusWalletOptions | undefined): void;
156
+ setAppearance(appearance: SportsbookAppearance): void;
224
157
  navigateTo(path: string, type?: 'push' | 'replace'): void;
225
158
  }
226
159
 
@@ -228,11 +161,11 @@ type Options = {
228
161
  cdnUrl?: string;
229
162
  };
230
163
  declare function loadAppModule(cdnUrl: string, version: string): Promise<{
231
- createSportsbookFrame: (config: SportFrameInitOptionsInternal) => SportFrameApp;
164
+ createSportsbookFrame: (config: SportsbookInitOptions) => SportsbookApp;
232
165
  }>;
233
166
  declare function loadSportsbookFrameModule(options: Options): Promise<{
234
- createApp: (config: SportsFrameInitOptions) => SportFrameApp;
167
+ createApp: (config: SportsbookInitOptions) => SportsbookApp;
235
168
  }>;
236
169
 
237
170
  export { loadAppModule, loadSportsbookFrameModule };
238
- export type { SportFrameApp };
171
+ export type { SportsbookApp };
package/dist/index.js CHANGED
@@ -1,49 +1,63 @@
1
- async function i(s) {
2
- const e = `${s.cdnUrl}/manifest/v1/stable/sportsbook/manifest.json`, t = await fetch(e);
1
+ function c(o) {
2
+ return o.endsWith("/") ? o.slice(0, -1) : o;
3
+ }
4
+ function f(o) {
5
+ let s = o;
6
+ for (; s.startsWith("/"); ) s = s.slice(1);
7
+ return s;
8
+ }
9
+ function a(o, ...s) {
10
+ let t = c(o);
11
+ for (const e of s) {
12
+ const r = f(e);
13
+ r && (t = t + "/" + r);
14
+ }
15
+ return t;
16
+ }
17
+ async function m(o) {
18
+ const s = a(o.cdnUrl, `manifest/v1/${o.stage}/sportsbook/manifest.json`), t = await fetch(s);
3
19
  if (!t.ok)
4
20
  throw new Error(`Failed to fetch manifest: ${t.status} ${t.statusText}`);
5
21
  return await t.json();
6
22
  }
7
- const l = "1.0.0-rc.1", m = "https://01-sports-frame-cdn.com";
8
- async function p(s, e) {
23
+ const p = "0.67.0", u = "https://01-sports-frame-cdn.com";
24
+ async function d(o, s) {
9
25
  return {
10
26
  createSportsbookFrame: (await import(
11
27
  /* @vite-ignore */
12
- `${s}/sportsbook/v1/core/v/${e}/esm/entry.js`
28
+ `${o}/sportsbook/v1/core/v/${s}/esm/entry.js`
13
29
  )).createSportsbookFrame
14
30
  };
15
31
  }
16
- async function f(s) {
17
- const e = s, { cdnUrl: t = m } = e;
18
- let o;
32
+ async function h(o) {
33
+ const t = c(o.cdnUrl ?? u);
34
+ let e;
19
35
  try {
20
- o = (await i({
36
+ e = (await m({
21
37
  cdnUrl: t,
22
38
  stage: "stable"
23
39
  })).v1.main.version;
24
- } catch (r) {
25
- throw console.error("Error loading manifest:", r), r;
40
+ } catch (n) {
41
+ throw console.error("Error loading manifest:", n), n;
26
42
  }
27
- console.log("Version:", o);
28
- const a = `${t}/sportsbook/v1/core/v/${o}/esm/style.css`, c = await p(t, o);
43
+ const r = a(t, `sportsbook/v1/core/v/${e}/esm/style.css`), i = await d(t, e);
29
44
  return {
30
- createApp: (r) => {
31
- const n = r;
32
- return c.createSportsbookFrame({
33
- ...n,
34
- // TODO: add path resolver
35
- assetsUrl: n.cdnUrl + "/sportsbook/v1/static/",
36
- cdnUrl: n.cdnUrl ?? t,
45
+ createApp: (n) => {
46
+ const l = n;
47
+ return i.createSportsbookFrame({
48
+ ...l,
49
+ assetsUrl: a(t, "sportsbook/v1/static"),
50
+ cdnUrl: t,
37
51
  __sdk: {
38
52
  stage: "stable",
39
- version: l,
40
- cssStyleUrl: a
53
+ version: p,
54
+ cssStyleUrl: r
41
55
  }
42
56
  });
43
57
  }
44
58
  };
45
59
  }
46
60
  export {
47
- p as loadAppModule,
48
- f as loadSportsbookFrameModule
61
+ d as loadAppModule,
62
+ h as loadSportsbookFrameModule
49
63
  };
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@01tech/sportsbook-web",
3
3
  "private": false,
4
- "version": "0.64.0",
4
+ "version": "0.67.0",
5
5
  "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
6
9
  "scripts": {
7
10
  "sdk:build:prepare": "rm -rf ./dist",
8
11
  "sdk:build:dts": "rollup -c rollup.dts.config.mjs",