@01tech/sportsbook-web 0.64.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/README.md +1 -0
- package/dist/index.d.ts +238 -0
- package/dist/index.js +49 -0
- package/package.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @01tech/sportsbook-web
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
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 {
|
|
13
|
+
variant: 'success' | 'info' | 'error';
|
|
14
|
+
title: string;
|
|
15
|
+
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
|
+
}
|
|
44
|
+
|
|
45
|
+
interface SportsFrameNavigationModeSync {
|
|
46
|
+
type: 'sync';
|
|
47
|
+
initialPath: string;
|
|
48
|
+
push(path: string): Promise<void>;
|
|
49
|
+
replace(path: string): Promise<void>;
|
|
50
|
+
back(): void;
|
|
51
|
+
forward(): void;
|
|
52
|
+
}
|
|
53
|
+
interface SportsFrameNavigationModeAuto {
|
|
54
|
+
type: 'auto';
|
|
55
|
+
}
|
|
56
|
+
type SportsFrameNavigation = SportsFrameNavigationModeSync | SportsFrameNavigationModeAuto;
|
|
57
|
+
|
|
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;
|
|
67
|
+
/**
|
|
68
|
+
* The bonus has its own currency and does not use the system-defined currency.
|
|
69
|
+
*/
|
|
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
|
+
readonly sharedBet?: boolean;
|
|
80
|
+
readonly broadcast?: boolean;
|
|
81
|
+
/**
|
|
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.
|
|
85
|
+
*/
|
|
86
|
+
readonly colorThemeSwitcher?: boolean;
|
|
87
|
+
readonly trends?: boolean;
|
|
88
|
+
}
|
|
89
|
+
interface SportsFrameAppearanceConfig {
|
|
90
|
+
/**
|
|
91
|
+
* z-index values for different floating UI elements.
|
|
92
|
+
* Accepts either a number or a string. The string can be a raw value (like '1000'),
|
|
93
|
+
* a CSS variable (e.g., 'var(--z-modal)'), or any custom value as needed.
|
|
94
|
+
* Used to control the stacking order of UI elements like popups, modals, and tooltips.
|
|
95
|
+
*/
|
|
96
|
+
readonly index?: {
|
|
97
|
+
/**
|
|
98
|
+
* z-index for popup elements.
|
|
99
|
+
*/
|
|
100
|
+
readonly popup?: number | string;
|
|
101
|
+
/**
|
|
102
|
+
* z-index for modal windows.
|
|
103
|
+
*/
|
|
104
|
+
readonly modal?: number | string;
|
|
105
|
+
/**
|
|
106
|
+
* z-index for tooltip components.
|
|
107
|
+
*/
|
|
108
|
+
readonly tooltip?: number | string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Safe area offsets used when positioning floating elements that stick to the
|
|
112
|
+
* top or bottom edges of the screen. Helps ensure elements like top popups, match score board
|
|
113
|
+
* or bottom-fixed buttons (e.g. a betslip trigger above a tab bar)
|
|
114
|
+
*/
|
|
115
|
+
readonly safeArea?: {
|
|
116
|
+
/**
|
|
117
|
+
* Safe spacing from the top edge — useful for floating elements that appear from the top.
|
|
118
|
+
*/
|
|
119
|
+
readonly top?: number | string;
|
|
120
|
+
/**
|
|
121
|
+
* Safe spacing from the bottom edge — useful for sticky buttons or
|
|
122
|
+
* bottom-aligned elements that must avoid overlapping with the tab bar or similar UI.
|
|
123
|
+
*/
|
|
124
|
+
readonly bottom?: number | string;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface SportsFrameInitOptions {
|
|
128
|
+
/**
|
|
129
|
+
* Api Url
|
|
130
|
+
*/
|
|
131
|
+
baseUrl: string;
|
|
132
|
+
navigation?: SportsFrameNavigation;
|
|
133
|
+
apiUrl: string;
|
|
134
|
+
cdnUrl?: string;
|
|
135
|
+
partnerId: string;
|
|
136
|
+
token?: string;
|
|
137
|
+
authed: boolean;
|
|
138
|
+
languageCode?: string;
|
|
139
|
+
rtl?: boolean;
|
|
140
|
+
currencyCode?: string;
|
|
141
|
+
balanceAmount?: number;
|
|
142
|
+
bonusWallet?: SportsFrameBonusWalletOptions;
|
|
143
|
+
platform: SportsFramePlatformType;
|
|
144
|
+
colorScheme?: SportsFrameColorSchemeType;
|
|
145
|
+
colorSchemeModal?: SportsFrameColorSchemeModalType;
|
|
146
|
+
theme?: SportsFrameThemeConfig;
|
|
147
|
+
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
|
+
};
|
|
176
|
+
/**
|
|
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'
|
|
180
|
+
*/
|
|
181
|
+
_contentResourcesPrefix?: string;
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated
|
|
184
|
+
*
|
|
185
|
+
* frontend/frontend backward compatibility
|
|
186
|
+
*/
|
|
187
|
+
assetsUrl?: string;
|
|
188
|
+
__sdk?: {
|
|
189
|
+
cssStyleUrl: string;
|
|
190
|
+
version: string;
|
|
191
|
+
stage: string;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
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
|
+
/**
|
|
207
|
+
* @public
|
|
208
|
+
*/
|
|
209
|
+
interface SportFrameApp extends TypedEventListener<SportFrameEvents> {
|
|
210
|
+
mount(el: HTMLElement): void;
|
|
211
|
+
destroy(): void;
|
|
212
|
+
setToken(token: string | undefined): void;
|
|
213
|
+
setPlatform(platform: SportsFramePlatformType): void;
|
|
214
|
+
setLanguageCode(languageCode: string | undefined): void;
|
|
215
|
+
setRtl(rtl: boolean | undefined): void;
|
|
216
|
+
setColorScheme(colorScheme: SportsFrameColorSchemeType): void;
|
|
217
|
+
setColorSchemeModal(colorScheme: SportsFrameColorSchemeModalType): void;
|
|
218
|
+
setAuthed(authed: boolean): void;
|
|
219
|
+
setInert(inert: boolean): void;
|
|
220
|
+
setCurrencyCode(currencyCode: string | undefined): void;
|
|
221
|
+
setBalanceAmount(balance: number | undefined): void;
|
|
222
|
+
setBonusWallet(wallet: SportsFrameBonusWalletOptions | undefined): void;
|
|
223
|
+
setAppearance(appearance: SportsFrameAppearanceConfig): void;
|
|
224
|
+
navigateTo(path: string, type?: 'push' | 'replace'): void;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
type Options = {
|
|
228
|
+
cdnUrl?: string;
|
|
229
|
+
};
|
|
230
|
+
declare function loadAppModule(cdnUrl: string, version: string): Promise<{
|
|
231
|
+
createSportsbookFrame: (config: SportFrameInitOptionsInternal) => SportFrameApp;
|
|
232
|
+
}>;
|
|
233
|
+
declare function loadSportsbookFrameModule(options: Options): Promise<{
|
|
234
|
+
createApp: (config: SportsFrameInitOptions) => SportFrameApp;
|
|
235
|
+
}>;
|
|
236
|
+
|
|
237
|
+
export { loadAppModule, loadSportsbookFrameModule };
|
|
238
|
+
export type { SportFrameApp };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
async function i(s) {
|
|
2
|
+
const e = `${s.cdnUrl}/manifest/v1/stable/sportsbook/manifest.json`, t = await fetch(e);
|
|
3
|
+
if (!t.ok)
|
|
4
|
+
throw new Error(`Failed to fetch manifest: ${t.status} ${t.statusText}`);
|
|
5
|
+
return await t.json();
|
|
6
|
+
}
|
|
7
|
+
const l = "1.0.0-rc.1", m = "https://01-sports-frame-cdn.com";
|
|
8
|
+
async function p(s, e) {
|
|
9
|
+
return {
|
|
10
|
+
createSportsbookFrame: (await import(
|
|
11
|
+
/* @vite-ignore */
|
|
12
|
+
`${s}/sportsbook/v1/core/v/${e}/esm/entry.js`
|
|
13
|
+
)).createSportsbookFrame
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
async function f(s) {
|
|
17
|
+
const e = s, { cdnUrl: t = m } = e;
|
|
18
|
+
let o;
|
|
19
|
+
try {
|
|
20
|
+
o = (await i({
|
|
21
|
+
cdnUrl: t,
|
|
22
|
+
stage: "stable"
|
|
23
|
+
})).v1.main.version;
|
|
24
|
+
} catch (r) {
|
|
25
|
+
throw console.error("Error loading manifest:", r), r;
|
|
26
|
+
}
|
|
27
|
+
console.log("Version:", o);
|
|
28
|
+
const a = `${t}/sportsbook/v1/core/v/${o}/esm/style.css`, c = await p(t, o);
|
|
29
|
+
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,
|
|
37
|
+
__sdk: {
|
|
38
|
+
stage: "stable",
|
|
39
|
+
version: l,
|
|
40
|
+
cssStyleUrl: a
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
p as loadAppModule,
|
|
48
|
+
f as loadSportsbookFrameModule
|
|
49
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@01tech/sportsbook-web",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.64.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"sdk:build:prepare": "rm -rf ./dist",
|
|
8
|
+
"sdk:build:dts": "rollup -c rollup.dts.config.mjs",
|
|
9
|
+
"sdk:build:js": "NODE_ENV=production vite build --config vite.config.ts",
|
|
10
|
+
"sdk:build": "npm run sdk:build:prepare && npm run sdk:build:dts && npm run sdk:build:js",
|
|
11
|
+
"sdk:dev": "NODE_ENV=development vite build --watch --config vite.config.ts"
|
|
12
|
+
},
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|