@01tech/sportsbook-vue 0.66.0 → 0.68.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 (3) hide show
  1. package/dist/index.d.ts +115 -90
  2. package/dist/index.js +89 -114
  3. package/package.json +5 -5
package/dist/index.d.ts CHANGED
@@ -1,28 +1,16 @@
1
1
  import * as vue from 'vue';
2
2
 
3
- type SportsFramePlatformType = 'mobile' | 'tablet' | 'desktop';
3
+ type SportsbookPlatformType = 'mobile' | 'tablet' | 'desktop';
4
4
 
5
- type SportsFrameColorSchemeType = 'light' | 'dark';
5
+ type SportsbookColorScheme = 'light' | 'dark';
6
6
 
7
- type SportsFrameColorSchemeModalType = SportsFrameColorSchemeType | 'auto';
8
-
9
- interface SportsFrameNotificationEventPayload {
7
+ type SportsbookNotificationPayload = {
10
8
  variant: 'success' | 'info' | 'error';
11
9
  title: string;
12
10
  text?: string;
13
- }
14
-
15
- interface SportsFrameImageVariant {
16
- url: string;
17
- /**
18
- * Mostly used to avoid unnecessary layout shift; in most cases, recommended to use.
19
- */
20
- height?: number;
21
- width?: number;
22
- // srcset?: [];
23
- }
11
+ };
24
12
 
25
- type SportsFrameCoefFormat =
13
+ type SportsbookCoefFormat =
26
14
  | 'decimal'
27
15
  | 'fractional'
28
16
  | 'american'
@@ -30,8 +18,8 @@ type SportsFrameCoefFormat =
30
18
  | 'indonesian'
31
19
  | 'malay';
32
20
 
33
- interface SportsFrameNavigationModeSync {
34
- type: 'sync';
21
+ interface SportsbookNavigationModeManual {
22
+ type: 'manual';
35
23
  initialPath: string;
36
24
  push(path: string): Promise<void>;
37
25
  replace(path: string): Promise<void>;
@@ -39,48 +27,54 @@ interface SportsFrameNavigationModeSync {
39
27
  forward(): void;
40
28
  }
41
29
 
42
- interface SportsFrameNavigationModeAuto {
43
- type: 'auto';
44
- }
30
+ type SportsbookNavigationModeHistory = {
31
+ type: 'web-history';
32
+ };
45
33
 
46
- type SportsFrameNavigation = SportsFrameNavigationModeSync | SportsFrameNavigationModeAuto;
34
+ type SportsbookNavigationModeMemory = {
35
+ type: 'memory';
36
+ initialPath?: string;
37
+ };
47
38
 
48
- interface SportsFrameThemeConfig {
49
- readonly preset?: {
50
- readonly name: string;
51
- readonly env?: 'prod' | 'preprod';
52
- };
53
- }
39
+ type SportsbookNavigation =
40
+ | SportsbookNavigationModeManual
41
+ | SportsbookNavigationModeHistory
42
+ | SportsbookNavigationModeMemory;
54
43
 
55
- interface SportsFrameBonusWalletOptions {
56
- readonly bonusId: string;
57
- readonly amount: number;
44
+ type SportsbookFeatures = {
58
45
  /**
59
- * The bonus has its own currency and does not use the system-defined currency.
46
+ * @default true
60
47
  */
61
- readonly currencyCode: string;
62
- }
63
-
64
- interface SportsFrameGraphicsConfig {
65
- readonly betslipEmpty?: SportsFrameImageVariant;
66
- readonly betslipSuccess?: SportsFrameImageVariant;
67
- readonly freebetPromoBanner?: SportsFrameImageVariant;
68
- readonly watermarkLogo?: SportsFrameImageVariant;
69
- }
70
-
71
- interface SportsFrameFeaturesConfig {
72
48
  readonly sharedBet?: boolean;
49
+ /**
50
+ * @default true
51
+ */
73
52
  readonly broadcast?: boolean;
74
53
  /**
75
- * Enables the ability to switch themes within the frame.
76
- * This is a stateless setting — you must manually subscribe to theme change events
77
- * and update the corresponding parameter inside the frame accordingly.
54
+ * @deprecated
55
+ * @default true
78
56
  */
79
- readonly colorThemeSwitcher?: boolean;
80
- readonly trends?: boolean;
81
- }
57
+ readonly expressBonus?: boolean;
58
+ };
82
59
 
83
- interface SportsFrameAppearanceConfig {
60
+ type OnNavigateEventPayload = {
61
+ fullPath: string;
62
+ };
63
+
64
+ /**
65
+ * @public
66
+ */
67
+ type SportsbookThemeConfig = {
68
+ readonly preset?: {
69
+ readonly name: string;
70
+ readonly env?: 'prod' | 'preprod';
71
+ };
72
+ };
73
+
74
+ /**
75
+ * @public
76
+ */
77
+ type SportsbookAppearance = {
84
78
  /**
85
79
  * z-index values for different floating UI elements.
86
80
  * Accepts either a number or a string. The string can be a raw value (like '1000'),
@@ -121,58 +115,89 @@ interface SportsFrameAppearanceConfig {
121
115
  */
122
116
  readonly bottom?: number | string;
123
117
  };
124
- }
118
+ };
125
119
 
126
- interface SportsFrameInitOptions {
120
+ /**
121
+ * @public
122
+ */
123
+ type SportsbookInitOptions = {
127
124
  /**
128
- * Api Url
125
+ * The base path relative to which the sportsbook is rendered. This will be used for navigating and generating promo links.
129
126
  */
130
- baseUrl: string;
131
- navigation?: SportsFrameNavigation;
127
+ baseUrl?: string;
128
+ navigation?: SportsbookNavigation;
132
129
  apiUrl: string;
133
130
  cdnUrl?: string;
134
131
  partnerId: string;
135
132
  token?: string;
136
- authed: boolean;
133
+ authed?: boolean;
137
134
  languageCode?: string;
135
+ countryCode?: string;
138
136
  rtl?: boolean;
139
137
  currencyCode?: string;
140
138
  balanceAmount?: number;
141
- bonusWallet?: SportsFrameBonusWalletOptions;
142
- platform: SportsFramePlatformType;
143
- colorScheme?: SportsFrameColorSchemeType;
144
- colorSchemeModal?: SportsFrameColorSchemeModalType;
145
- theme?: SportsFrameThemeConfig;
139
+ platform: SportsbookPlatformType;
140
+ colorScheme?: SportsbookColorScheme;
141
+ theme?: SportsbookThemeConfig;
142
+ /**
143
+ * @default false
144
+ */
146
145
  inert?: boolean;
147
- appearance?: SportsFrameAppearanceConfig;
148
- features?: SportsFrameFeaturesConfig;
149
- graphics?: SportsFrameGraphicsConfig;
150
- shareLinkBehavior?: 'native' | 'manual' | 'hidden';
151
- defaultCoefFormat?: SportsFrameCoefFormat;
146
+ appearance?: SportsbookAppearance;
147
+ /**
148
+ * @default 'decimal'
149
+ */
150
+ defaultCoefFormat?: SportsbookCoefFormat;
151
+ /**
152
+ * @default false
153
+ */
154
+ production?: boolean;
155
+ /**
156
+ * @default '01tech-sportsbook'
157
+ */
158
+ localStoragePrefix?: string;
159
+ features?: SportsbookFeatures;
160
+ // handlers
161
+ onReady?: () => void;
162
+ onError?: (err?: Error) => void;
163
+ onLogin?: (place?: 'bets' | 'wheel' | undefined) => void;
164
+ onDeposit?: () => void;
165
+ onRenewToken?: () => void;
166
+ onNavigate?: (options?: OnNavigateEventPayload) => void;
167
+ onSendNotification?: (payload: SportsbookNotificationPayload) => void;
168
+ };
169
+
170
+ interface SportsbookBonusWalletOptions {
171
+ readonly bonusId: string;
172
+ readonly amount: number;
173
+ /**
174
+ * The bonus has its own currency and does not use the system-defined currency.
175
+ */
176
+ readonly currencyCode: string;
177
+ }
178
+
179
+ /**
180
+ * @public
181
+ */
182
+ interface SportsbookApp {
183
+ mount(el: HTMLElement): void;
184
+ destroy(): void;
185
+ setToken(token: string | undefined): void;
186
+ setPlatform(platform: SportsbookPlatformType): void;
187
+ setLanguageCode(languageCode: string | undefined): void;
188
+ setRtl(rtl: boolean | undefined): void;
189
+ setColorScheme(colorScheme: SportsbookColorScheme): void;
190
+ setAuthed(authed: boolean): void;
191
+ setInert(inert: boolean): void;
192
+ setCurrencyCode(currencyCode: string | undefined): void;
193
+ setBalanceAmount(balance: number | undefined): void;
194
+ setBonusWallet(wallet: SportsbookBonusWalletOptions | undefined): void;
195
+ setAppearance(appearance: SportsbookAppearance): void;
196
+ navigateTo(path: string, type?: 'push' | 'replace'): void;
152
197
  }
153
198
 
154
- declare const _default: vue.DefineComponent<SportsFrameInitOptions, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {} & {
155
- ready: () => any;
156
- login: () => any;
157
- renewToken: () => any;
158
- notify: (options: SportsFrameNotificationEventPayload) => any;
159
- shareLink: (options: string) => any;
160
- changeModalState: (options: {
161
- opened: boolean;
162
- }) => any;
163
- topUpBalance: () => any;
164
- changeColorScheme: (options: "light" | "dark") => any;
165
- }, string, vue.PublicProps, Readonly<SportsFrameInitOptions> & Readonly<{
166
- onReady?: (() => any) | undefined;
167
- onLogin?: (() => any) | undefined;
168
- onRenewToken?: (() => any) | undefined;
169
- onNotify?: ((options: SportsFrameNotificationEventPayload) => any) | undefined;
170
- onShareLink?: ((options: string) => any) | undefined;
171
- onChangeModalState?: ((options: {
172
- opened: boolean;
173
- }) => any) | undefined;
174
- onTopUpBalance?: (() => any) | undefined;
175
- onChangeColorScheme?: ((options: "light" | "dark") => any) | undefined;
176
- }>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
199
+ declare const _default: vue.DefineComponent<SportsbookInitOptions, {
200
+ app: Readonly<vue.Ref<vue.ShallowRef<SportsbookApp | undefined, SportsbookApp | undefined>, vue.ShallowRef<SportsbookApp | undefined, SportsbookApp | undefined>>>;
201
+ }, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<SportsbookInitOptions> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
177
202
 
178
203
  export { _default as SportsbookFrame };
package/dist/index.js CHANGED
@@ -1,67 +1,81 @@
1
- import { watch as s, nextTick as f, shallowRef as h, getCurrentInstance as v, onMounted as k, defineComponent as y, useTemplateRef as b, effectScope as g, ref as S, computed as U, onScopeDispose as C, createElementBlock as w, openBlock as L } from "vue";
1
+ import { watch as s, nextTick as h, shallowRef as d, getCurrentInstance as k, onMounted as b, defineComponent as g, useAttrs as S, useTemplateRef as F, effectScope as w, ref as C, computed as U, onScopeDispose as _, toRef as A, createElementBlock as R, openBlock as B } from "vue";
2
2
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
3
- function E(a, n, e) {
4
- const r = s(a, (l, i, c) => {
5
- l && (e?.once && f(() => r()), n(l, i, c));
3
+ function x(o, t, e) {
4
+ const c = s(o, (r, l, u) => {
5
+ r && (e?.once && h(() => c()), t(r, l, u));
6
6
  }, {
7
7
  ...e,
8
8
  once: !1
9
9
  });
10
- return r;
10
+ return c;
11
11
  }
12
12
  // @__NO_SIDE_EFFECTS__
13
- function B() {
14
- const a = h(!1), n = v();
15
- return n && k(() => {
16
- a.value = !0;
17
- }, n), a;
13
+ function T() {
14
+ const o = d(!1), t = k();
15
+ return t && b(() => {
16
+ o.value = !0;
17
+ }, t), o;
18
18
  }
19
- async function _(a) {
20
- const n = `${a.cdnUrl}/manifest/v1/stable/sportsbook/manifest.json`, e = await fetch(n);
19
+ function m(o) {
20
+ return o.endsWith("/") ? o.slice(0, -1) : o;
21
+ }
22
+ function $(o) {
23
+ let t = o;
24
+ for (; t.startsWith("/"); ) t = t.slice(1);
25
+ return t;
26
+ }
27
+ function p(o, ...t) {
28
+ let e = m(o);
29
+ for (const c of t) {
30
+ const r = $(c);
31
+ r && (e = e + "/" + r);
32
+ }
33
+ return e;
34
+ }
35
+ async function M(o) {
36
+ const t = p(o.cdnUrl, `manifest/v1/${o.stage}/sportsbook/manifest.json`), e = await fetch(t);
21
37
  if (!e.ok)
22
38
  throw new Error(`Failed to fetch manifest: ${e.status} ${e.statusText}`);
23
39
  return await e.json();
24
40
  }
25
- const A = "0.66.0", F = "https://01-sports-frame-cdn.com";
26
- async function M(a, n) {
41
+ const E = "0.68.0", W = "https://01-sports-frame-cdn.com";
42
+ async function j(o, t) {
27
43
  return {
28
44
  createSportsbookFrame: (await import(
29
45
  /* @vite-ignore */
30
- `${a}/sportsbook/v1/core/v/${n}/esm/entry.js`
46
+ `${o}/sportsbook/v1/core/v/${t}/esm/entry.js`
31
47
  )).createSportsbookFrame
32
48
  };
33
49
  }
34
- async function T(a) {
35
- const n = a, { cdnUrl: e = F } = n;
36
- let r;
50
+ async function L(o = {}) {
51
+ const t = m(o.cdnUrl ?? W);
52
+ let e;
37
53
  try {
38
- r = (await _({
39
- cdnUrl: e,
54
+ e = (await M({
55
+ cdnUrl: t,
40
56
  stage: "stable"
41
57
  })).v1.main.version;
42
- } catch (c) {
43
- throw console.error("Error loading manifest:", c), c;
58
+ } catch (l) {
59
+ throw console.error("Error loading manifest:", l), l;
44
60
  }
45
- console.log("Version:", r);
46
- const l = `${e}/sportsbook/v1/core/v/${r}/esm/style.css`, i = await M(e, r);
61
+ const c = p(t, `sportsbook/v1/core/v/${e}/esm/style.css`), r = await j(t, e);
47
62
  return {
48
- createApp: (c) => {
49
- const d = c;
50
- return i.createSportsbookFrame({
51
- ...d,
52
- // TODO: add path resolver
53
- assetsUrl: d.cdnUrl + "/sportsbook/v1/static/",
54
- cdnUrl: d.cdnUrl ?? e,
63
+ createApp: (l) => {
64
+ const u = l;
65
+ return r.createSportsbookFrame({
66
+ ...u,
67
+ assetsUrl: p(t, "sportsbook/v1/static"),
68
+ cdnUrl: t,
55
69
  __sdk: {
56
70
  stage: "stable",
57
- version: A,
58
- cssStyleUrl: l
71
+ version: E,
72
+ cssStyleUrl: c
59
73
  }
60
74
  });
61
75
  }
62
76
  };
63
77
  }
64
- const W = ["dir"], x = /* @__PURE__ */ y({
78
+ const D = ["dir"], I = /* @__PURE__ */ g({
65
79
  inheritAttrs: !1,
66
80
  __name: "SportsbookFrame",
67
81
  props: {
@@ -73,120 +87,81 @@ const W = ["dir"], x = /* @__PURE__ */ y({
73
87
  token: {},
74
88
  authed: { type: Boolean },
75
89
  languageCode: {},
90
+ countryCode: {},
76
91
  rtl: { type: Boolean },
77
92
  currencyCode: {},
78
93
  balanceAmount: {},
79
- bonusWallet: {},
80
94
  platform: {},
81
95
  colorScheme: {},
82
- colorSchemeModal: {},
83
96
  theme: {},
84
97
  inert: { type: Boolean },
85
98
  appearance: {},
99
+ defaultCoefFormat: {},
100
+ production: { type: Boolean },
101
+ localStoragePrefix: {},
86
102
  features: {},
87
- graphics: {},
88
- shareLinkBehavior: {},
89
- defaultCoefFormat: {}
103
+ onReady: { type: Function },
104
+ onError: { type: Function },
105
+ onLogin: { type: Function },
106
+ onDeposit: { type: Function },
107
+ onRenewToken: { type: Function },
108
+ onNavigate: { type: Function },
109
+ onSendNotification: { type: Function }
90
110
  },
91
- emits: ["ready", "login", "renewToken", "notify", "changeModalState", "topUpBalance", "changeColorScheme", "shareLink"],
92
- setup(a, { emit: n }) {
93
- const e = a, r = n, l = b("el"), i = g(), c = /* @__PURE__ */ B(), d = S(!1), p = U(() => e.rtl ? "rtl" : "ltr");
94
- let u;
95
- return C(() => {
96
- u?.destroy();
97
- }), i.run(async () => {
98
- const o = (await T({ cdnUrl: e.cdnUrl })).createApp({
99
- // assetsUrl: props.assetUrl,
100
- baseUrl: e.baseUrl,
101
- navigation: { type: "auto" },
102
- partnerId: e.partnerId ?? "",
103
- apiUrl: e.apiUrl,
104
- cdnUrl: e.cdnUrl ?? "",
105
- token: e.token ?? "",
106
- authed: e.authed ?? !1,
107
- balanceAmount: e.balanceAmount,
108
- bonusWallet: e.bonusWallet,
109
- languageCode: e.languageCode,
110
- rtl: e.rtl,
111
- currencyCode: e.currencyCode,
112
- platform: e.platform,
113
- colorScheme: e.colorScheme,
114
- // colorSchemeModal: props.modalColorScheme,
115
- theme: e.theme,
116
- appearance: e.appearance,
117
- features: e.features,
118
- shareLinkBehavior: e.shareLinkBehavior,
119
- defaultCoefFormat: e.defaultCoefFormat
120
- // _experiments: props.experiments,
121
- // _debug: props.debug,
122
- // _contentResourcesPrefix: props.contentResourcesPrefix,
123
- // _trackEvent(payload) {
124
- // emit('trackEvent', payload);
125
- // },
111
+ setup(o, { expose: t }) {
112
+ const e = o, c = S(), r = F("el"), l = w(), u = /* @__PURE__ */ T(), f = C(!1), y = U(() => e.rtl ? "rtl" : "ltr"), i = d();
113
+ return _(() => {
114
+ i.value?.destroy();
115
+ }), t({
116
+ app: A(() => i)
117
+ }), l.run(async () => {
118
+ const a = (await L({ cdnUrl: e.cdnUrl })).createApp({
119
+ ...e,
120
+ ...c,
121
+ onReady() {
122
+ f.value = !0, e.onReady?.();
123
+ }
126
124
  });
127
- o.addEventListener("ready", () => {
128
- d.value = !0;
129
- }), u = o, o.addEventListener("shareLink", (t) => {
130
- r("shareLink", t);
131
- }), o.addEventListener("ready", () => {
132
- d.value = !0, r("ready");
133
- }), o.addEventListener("login", () => {
134
- r("login");
135
- }), o.addEventListener("deposit", () => {
136
- r("topUpBalance");
137
- }), o.addEventListener("notify", (t) => {
138
- r("notify", t);
139
- }), o.addEventListener("renewToken", () => {
140
- r("renewToken");
141
- }), o.addEventListener("setModalState", ({ opened: t }) => {
142
- r("changeModalState", { opened: t });
143
- }), o.addEventListener("setColorScheme", (t) => {
144
- r("changeColorScheme", t);
145
- }), s(
125
+ i.value = a, s(
146
126
  () => e.languageCode,
147
- (t) => o.setLanguageCode(t)
127
+ (n) => a.setLanguageCode(n)
148
128
  ), s(
149
129
  () => e.rtl,
150
- (t) => o.setRtl(t)
130
+ (n) => a.setRtl(n)
151
131
  ), s(
152
132
  () => e.platform,
153
- (t) => o.setPlatform(t)
133
+ (n) => a.setPlatform(n)
154
134
  ), s(
155
135
  () => e.token,
156
- (t) => o.setToken(t)
136
+ (n) => a.setToken(n)
157
137
  ), s(
158
138
  () => e.authed,
159
- (t) => o.setAuthed(t)
139
+ (n) => a.setAuthed(n)
160
140
  ), s(
161
141
  () => e.colorScheme,
162
- (t) => o.setColorScheme(t ?? "dark")
142
+ (n) => a.setColorScheme(n ?? "dark")
163
143
  ), s(
164
144
  () => e.currencyCode,
165
- (t) => o.setCurrencyCode(t)
145
+ (n) => a.setCurrencyCode(n)
166
146
  ), s(
167
147
  () => e.balanceAmount,
168
- (t) => o.setBalanceAmount(t)
169
- ), s(
170
- () => e.bonusWallet,
171
- (t) => o.setBonusWallet(t)
148
+ (n) => a.setBalanceAmount(n)
172
149
  );
173
- }), E(
174
- () => c.value && d.value,
150
+ }), x(
151
+ () => u.value && f.value,
175
152
  () => {
176
- if (!l.value || !u)
177
- throw new Error("unexpected error");
178
- u.mount(l.value);
153
+ !r.value || !i.value || i.value.mount(r.value);
179
154
  },
180
155
  { once: !0 }
181
- ), (m, o) => (L(), w("div", {
156
+ ), (v, a) => (B(), R("div", {
182
157
  id: "sport-frame",
183
158
  ref_key: "el",
184
- ref: l,
185
- dir: p.value,
159
+ ref: r,
160
+ dir: y.value,
186
161
  "data-sport-frame": ""
187
- }, null, 8, W));
162
+ }, null, 8, D));
188
163
  }
189
164
  });
190
165
  export {
191
- x as SportsbookFrame
166
+ I as SportsbookFrame
192
167
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@01tech/sportsbook-vue",
3
3
  "private": false,
4
- "version": "0.66.0",
4
+ "version": "0.68.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -9,16 +9,14 @@
9
9
  "sdk:build:prepare": "rm -rf ./dist",
10
10
  "dts-compile": "vue-tsc --project ./tsconfig.dts.json",
11
11
  "dts-resolve": "rollup -c rollup.dts.config.mjs",
12
+ "dev:micro": "rollup -c rollup.dts.config.mjs --watch",
12
13
  "sdk:build:dts": "npm run dts-compile && npm run dts-resolve",
13
14
  "sdk:build:js": "NODE_ENV=production vite build --config vite.config.ts",
14
15
  "sdk:build": "npm run sdk:build:prepare && npm run sdk:build:dts && npm run sdk:build:js",
15
16
  "sdk:dev": "NODE_ENV=development vite build --watch --config vite.config.ts"
16
17
  },
17
- "devDependencies": {
18
- "@01tech/sportsbook-web": "*"
19
- },
20
18
  "peerDependencies": {
21
- "vue": "^3.5.13",
19
+ "vue": "^3.5.0",
22
20
  "vue-router": "~4.5.1"
23
21
  },
24
22
  "peerDependenciesMeta": {
@@ -26,8 +24,10 @@
26
24
  "optional": true
27
25
  }
28
26
  },
27
+ "types": "./dist/index.d.ts",
29
28
  "exports": {
30
29
  ".": {
30
+ "development": "./src/index.ts",
31
31
  "types": "./dist/index.d.ts",
32
32
  "default": "./dist/index.js"
33
33
  }