@splash-tech/jackpot-sdk 2.0.1 → 3.0.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 (42) hide show
  1. package/README.md +123 -25
  2. package/dist/clients/b2tech/B2TechFooterWidget.d.ts +11 -0
  3. package/dist/clients/b2tech/B2TechFooterWidget.js +74 -0
  4. package/dist/clients/b2tech/types.d.ts +6 -0
  5. package/dist/clients/defaultClient/DefaultClientFooterWidget.d.ts +9 -0
  6. package/dist/clients/defaultClient/DefaultClientFooterWidget.js +53 -0
  7. package/dist/clients/defaultClient/DefaultClientWinWidget.d.ts +9 -0
  8. package/dist/clients/defaultClient/DefaultClientWinWidget.js +95 -0
  9. package/dist/clients/defaultClient/types.d.ts +14 -0
  10. package/dist/clients/registry.d.ts +24 -0
  11. package/dist/clients/registry.js +28 -0
  12. package/dist/core/BaseWidget.d.ts +24 -0
  13. package/dist/core/BaseWidget.js +96 -0
  14. package/dist/core/FooterWidgetBase.d.ts +18 -0
  15. package/dist/core/FooterWidgetBase.js +71 -0
  16. package/dist/core/WinWidgetBase.d.ts +12 -0
  17. package/dist/core/WinWidgetBase.js +47 -0
  18. package/dist/core/types.d.ts +21 -0
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +11 -25
  21. package/dist/shared/validation.d.ts +1 -0
  22. package/dist/shared/validation.js +11 -0
  23. package/dist/types.d.ts +6 -23
  24. package/package.json +9 -1
  25. package/dist/widgets/BaseWidget.d.ts +0 -28
  26. package/dist/widgets/BaseWidget.js +0 -104
  27. package/dist/widgets/footerWidget/FooterWidget.d.ts +0 -16
  28. package/dist/widgets/footerWidget/FooterWidget.js +0 -110
  29. package/dist/widgets/footerWidget/types/data.d.ts +0 -12
  30. package/dist/widgets/footerWidget/types/events.d.ts +0 -15
  31. package/dist/widgets/footerWidget/types/events.js +0 -14
  32. package/dist/widgets/shared/types.d.ts +0 -18
  33. package/dist/widgets/winWidget/WinWidget copy.d.ts +0 -13
  34. package/dist/widgets/winWidget/WinWidget copy.js +0 -131
  35. package/dist/widgets/winWidget/WinWidget.d.ts +0 -14
  36. package/dist/widgets/winWidget/WinWidget.js +0 -134
  37. package/dist/widgets/winWidget/types/data.d.ts +0 -12
  38. package/dist/widgets/winWidget/types/events.d.ts +0 -10
  39. package/dist/widgets/winWidget/types/events.js +0 -11
  40. /package/dist/{widgets/shared → clients/b2tech}/types.js +0 -0
  41. /package/dist/{widgets/footerWidget/types/data.js → clients/defaultClient/types.js} +0 -0
  42. /package/dist/{widgets/winWidget/types/data.js → core/types.js} +0 -0
package/README.md CHANGED
@@ -22,23 +22,28 @@ npm install @splash-tech/jackpot-sdk
22
22
 
23
23
  # Quick Start
24
24
 
25
- ## Launch Footer Widget
25
+ The SDK is initialized once with your **clientId**. The clientId determines which widget app is loaded, which launch options are available, and which events are emitted — all fully typed.
26
26
 
27
27
  ```ts
28
- import { splashJackpot } from '@splash-tech/jackpot-sdk';
28
+ import { createSplashJackpot } from '@splash-tech/jackpot-sdk';
29
+
30
+ const splashJackpot = createSplashJackpot({
31
+ client: 'defaultClient',
32
+ env: 'production',
33
+ });
34
+ ```
35
+
36
+ ## Launch Footer Widget
29
37
 
38
+ ```ts
30
39
  splashJackpot.footerWidget.launch({
31
40
  data: widgetData,
32
41
  });
33
42
  ```
34
43
 
35
- ---
36
-
37
44
  ## Launch Win Widget
38
45
 
39
46
  ```ts
40
- import { splashJackpot } from '@splash-tech/jackpot-sdk';
41
-
42
47
  splashJackpot.winWidget.launch({
43
48
  data: winData,
44
49
  });
@@ -46,27 +51,53 @@ splashJackpot.winWidget.launch({
46
51
 
47
52
  ---
48
53
 
54
+ # Initialization Options
55
+
56
+ | Option | Type | Default | Description |
57
+ | ------ | ------ | ---------- | ---------------------------------------------------------- |
58
+ | client | string | (required) | Client integration to use (`defaultClient`, `b2tech`) |
59
+ | env | string | production | SDK environment (`local`, `dev`, `staging`, `production`) |
60
+
61
+ An unknown `client` throws at initialization.
62
+
63
+ ---
64
+
49
65
  # Widget Launch Parameters
50
66
 
51
- | Parameter | Type | Default | Description |
52
- | --------- | ------ | ------------- | --------------------------------------------------------- |
53
- | data | object | null | Widget data from Splash backend |
54
- | container | string | document.body | CSS selector where widget will be injected |
55
- | mode | string | production | SDK environment (`local`, `dev`, `staging`, `production`) |
56
- | jackpotId | string | undefined | Jackpot identifier |
57
- | tag | string | undefined | Game tag |
58
- | brand | string | undefined | Operator brand |
67
+ Both widgets accept the same base parameters. Presentation options are grouped under `config`, and the available `config` fields depend on the clientId chosen at initialization.
68
+
69
+ | Parameter | Type | Default | Description |
70
+ | --------- | ------ | ------- | ------------------------------------------ |
71
+ | data | object | null | Widget data from Splash backend |
72
+ | config | object | — | Client-specific presentation options below |
73
+
74
+ ## Footer Widget `config`
75
+
76
+ | Field | Type | Default | Description |
77
+ | --------- | ----------------- | ------------- | ------------------------------------------ |
78
+ | position | 'top' \| 'bottom' | per client | Where the footer bar is docked |
79
+ | maxWidth | string | per client | Maximum width of the footer widget |
80
+ | container | string | document.body | CSS selector where widget will be injected |
81
+
82
+ ## Win Widget `config`
83
+
84
+ | Field | Type | Default | Description |
85
+ | --------- | --------------------- | ------------- | ------------------------------------------------------- |
86
+ | animation | 'wheel' \| 'airplane' | 'wheel' | Win animation to play (`defaultClient` only) |
87
+ | container | string | document.body | CSS selector where widget will be injected |
88
+
89
+ Clients may have additional `config` fields; TypeScript only offers the fields valid for your clientId.
59
90
 
60
91
  Example:
61
92
 
62
93
  ```ts
63
94
  splashJackpot.footerWidget.launch({
64
95
  data: widgetData,
65
- container: '#game-container',
66
- mode: 'production',
67
- jackpotId: 'jackpot-id',
68
- tag: 'game-tag',
69
- brand: 'brand-name',
96
+ config: {
97
+ position: 'bottom',
98
+ maxWidth: '100%',
99
+ container: '#game-container',
100
+ },
70
101
  });
71
102
  ```
72
103
 
@@ -74,7 +105,9 @@ splashJackpot.footerWidget.launch({
74
105
 
75
106
  # Widget API
76
107
 
77
- ## Footer Widget
108
+ Every client gets the core API. On top of it, a client may have extra methods defined by the SDK for that clientId — TypeScript only offers the methods valid for your clientId, and integrators cannot add methods of their own.
109
+
110
+ ## Footer Widget (core, all clients)
78
111
 
79
112
  - `launch()` – launch widget
80
113
  - `updateData()` – update jackpot values
@@ -84,7 +117,11 @@ splashJackpot.footerWidget.launch({
84
117
  - `removeAllEventListeners()` – remove all listeners
85
118
  - `destroy()` – remove widget from DOM
86
119
 
87
- ## Win Widget
120
+ ## Footer Widget (`b2tech` client)
121
+
122
+ - `helloWorld()` – placeholder client-specific method
123
+
124
+ ## Win Widget (core, all clients)
88
125
 
89
126
  - `launch()`
90
127
  - `isLaunched()`
@@ -97,7 +134,9 @@ splashJackpot.footerWidget.launch({
97
134
 
98
135
  # Events
99
136
 
100
- ## Footer Widget
137
+ Events are client-specific; TypeScript only offers the event names valid for your clientId.
138
+
139
+ ## Footer Widget (`defaultClient`)
101
140
 
102
141
  | Event | Description |
103
142
  | ----------------- | ---------------------------------- |
@@ -105,6 +144,14 @@ splashJackpot.footerWidget.launch({
105
144
  | hidePopup | Footer popup closed |
106
145
  | participateChange | User toggled jackpot participation |
107
146
 
147
+ ## Footer Widget (`b2tech` client)
148
+
149
+ | Event | Description |
150
+ | ------------------ | ------------------------------- |
151
+ | panelOpen | Footer panel opened |
152
+ | panelClose | Footer panel closed |
153
+ | subscriptionChange | User toggled their subscription |
154
+
108
155
  Example:
109
156
 
110
157
  ```ts
@@ -113,14 +160,18 @@ splashJackpot.footerWidget.addEventListener('showPopup', () => {
113
160
  });
114
161
  ```
115
162
 
116
- ---
117
-
118
- ## Win Widget
163
+ ## Win Widget (`defaultClient`)
119
164
 
120
165
  | Event | Description |
121
166
  | ----- | ----------------- |
122
167
  | close | Win widget closed |
123
168
 
169
+ ## Win Widget (`b2tech` client)
170
+
171
+ | Event | Description |
172
+ | --------- | -------------------- |
173
+ | dismissed | Win widget dismissed |
174
+
124
175
  ---
125
176
 
126
177
  # Cleanup
@@ -134,6 +185,53 @@ splashJackpot.footerWidget.destroy();
134
185
 
135
186
  ---
136
187
 
188
+ # Migrating from 2.x
189
+
190
+ ```ts
191
+ // 2.x
192
+ import { splashJackpot } from '@splash-tech/jackpot-sdk';
193
+
194
+ splashJackpot.footerWidget.launch({
195
+ data: widgetData,
196
+ mode: 'production',
197
+ position: 'bottom',
198
+ maxWidth: '100%',
199
+ container: '#game-container',
200
+ });
201
+
202
+ // 3.x
203
+ import { createSplashJackpot } from '@splash-tech/jackpot-sdk';
204
+
205
+ const splashJackpot = createSplashJackpot({
206
+ client: 'defaultClient',
207
+ env: 'production',
208
+ });
209
+
210
+ splashJackpot.footerWidget.launch({
211
+ data: widgetData,
212
+ config: {
213
+ position: 'bottom',
214
+ maxWidth: '100%',
215
+ container: '#game-container',
216
+ },
217
+ });
218
+ ```
219
+
220
+ - `client` and `env` moved from `launch()` to `createSplashJackpot()`.
221
+ - Presentation options (`position`, `maxWidth`, `animation`, `container`) moved under `config`.
222
+ - Everything else (`updateData`, events, `destroy`) is unchanged.
223
+
224
+ ---
225
+
226
+ # Adding a New Client (SDK maintainers)
227
+
228
+ 1. Create `src/clients/<name>/` with `client.ts`, `FooterWidgetProtocol.ts`, `WinWidgetProtocol.ts`, and `types.ts` (launch `config` shapes, event maps, and host-facing method interfaces — empty interfaces if the client has none).
229
+ 2. Implement the client's extra host-facing methods in each protocol's `createMethods(ctx)` factory. `ctx` is a controller exposing `sendToChild`, `expandIframe`/`collapseIframe` (footer), `emit`, `destroy`, and `isLaunched`. Keep the return type annotation on `createMethods` so methods outside the declared interface fail compilation. Core behavior (`launch`, `updateData`, events, `destroy`) lives in the widgets and is not client-definable.
230
+ 3. For the win widget, optionally provide `presentation` (`applyLaunchPresentation`/`cleanupPresentation`) on the protocol for a custom enter/exit animation; omit it for a plain iframe.
231
+ 4. Register it in `src/clients/registry.ts`: add the id to `ClientId`, the config to `clientRegistry`, and the types to the six type maps. Missing entries fail compilation.
232
+
233
+ ---
234
+
137
235
  # Documentation
138
236
 
139
237
  For full integration instructions, backend communication flow, and advanced usage, refer to the complete [documentation](https://www.notion.so/Jackpot-Widgets-320975a6f2ab80118284e6165d569843?pvs=25#325975a6f2ab8096be15dfc7eda06028).
@@ -0,0 +1,11 @@
1
+ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
+ import { B2TechFooterWidgetConfig, B2TechFooterWidgetEvents } from './types';
3
+ export declare class B2TechFooterWidget extends FooterWidgetBase<B2TechFooterWidgetConfig, B2TechFooterWidgetEvents> {
4
+ protected readonly route = "/footer-widget";
5
+ protected readonly height = "64px";
6
+ protected sendInitialData(): void;
7
+ protected sendDataUpdate(partialData: object): void;
8
+ protected handleChildMessage(type: string | undefined): boolean;
9
+ showWinPopup(data: unknown): void;
10
+ hideWinPopup(): void;
11
+ }
@@ -0,0 +1,74 @@
1
+ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
+ var IncomingEvent;
3
+ (function (IncomingEvent) {
4
+ IncomingEvent["footerWidgetLoaded"] = "jackpot-b2tech-footer-widget-loaded";
5
+ IncomingEvent["showPopup"] = "jackpot-b2tech-footer-widget-popup-show";
6
+ IncomingEvent["hidePopup"] = "jackpot-b2tech-footer-widget-popup-hide";
7
+ IncomingEvent["winPopupClosed"] = "jackpot-b2tech-footer-widget-win-popup-closed";
8
+ })(IncomingEvent || (IncomingEvent = {}));
9
+ var OutgoingEvent;
10
+ (function (OutgoingEvent) {
11
+ OutgoingEvent["footerWidgetDataInitial"] = "jackpot-b2tech-footer-widget-data-initial";
12
+ OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-b2tech-footer-widget-data-updated";
13
+ OutgoingEvent["winPopupShow"] = "jackpot-b2tech-footer-widget-win-popup-show";
14
+ OutgoingEvent["winPopupHide"] = "jackpot-b2tech-footer-widget-win-popup-hide";
15
+ })(OutgoingEvent || (OutgoingEvent = {}));
16
+ export class B2TechFooterWidget extends FooterWidgetBase {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.route = '/footer-widget';
20
+ this.height = '64px';
21
+ }
22
+ sendInitialData() {
23
+ this.sendToChild({
24
+ type: OutgoingEvent.footerWidgetDataInitial,
25
+ data: this.data,
26
+ config: this.config,
27
+ });
28
+ }
29
+ sendDataUpdate(partialData) {
30
+ this.sendToChild({
31
+ type: OutgoingEvent.footerWidgetDataUpdated,
32
+ data: partialData,
33
+ });
34
+ }
35
+ handleChildMessage(type) {
36
+ switch (type) {
37
+ case IncomingEvent.footerWidgetLoaded:
38
+ this.sendInitialData();
39
+ return true;
40
+ case IncomingEvent.showPopup:
41
+ this.expandIframe();
42
+ return true;
43
+ case IncomingEvent.hidePopup:
44
+ this.collapseIframe();
45
+ return true;
46
+ case IncomingEvent.winPopupClosed:
47
+ this.collapseIframe();
48
+ this.emit('winPopupClosed');
49
+ return true;
50
+ default:
51
+ return false;
52
+ }
53
+ }
54
+ showWinPopup(data) {
55
+ if (!this.isLaunched()) {
56
+ console.warn('Footer widget must be launched before showWinPopup');
57
+ return;
58
+ }
59
+ this.sendToChild({
60
+ type: OutgoingEvent.winPopupShow,
61
+ data,
62
+ });
63
+ this.expandIframe();
64
+ }
65
+ hideWinPopup() {
66
+ if (!this.isLaunched())
67
+ return;
68
+ this.sendToChild({
69
+ type: OutgoingEvent.winPopupHide,
70
+ data: null,
71
+ });
72
+ this.collapseIframe();
73
+ }
74
+ }
@@ -0,0 +1,6 @@
1
+ import { FooterWidgetBaseConfig } from '../../core/types';
2
+ export interface B2TechFooterWidgetConfig extends FooterWidgetBaseConfig {
3
+ }
4
+ export interface B2TechFooterWidgetEvents {
5
+ winPopupClosed: void;
6
+ }
@@ -0,0 +1,9 @@
1
+ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
+ import { DefaultClientFooterWidgetConfig, DefaultClientFooterWidgetEvents } from './types';
3
+ export declare class DefaultClientFooterWidget extends FooterWidgetBase<DefaultClientFooterWidgetConfig, DefaultClientFooterWidgetEvents> {
4
+ protected readonly route = "/footer-widget";
5
+ protected readonly height = "50px";
6
+ protected sendInitialData(): void;
7
+ protected sendDataUpdate(partialData: object): void;
8
+ protected handleChildMessage(type: string | undefined): boolean;
9
+ }
@@ -0,0 +1,53 @@
1
+ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
+ var IncomingEvent;
3
+ (function (IncomingEvent) {
4
+ IncomingEvent["footerWidgetLoaded"] = "jackpot-default-footer-widget-loaded";
5
+ IncomingEvent["participateChange"] = "jackpot-default-footer-widget-participate-change";
6
+ IncomingEvent["showPopup"] = "jackpot-default-footer-widget-popup-show";
7
+ IncomingEvent["hidePopup"] = "jackpot-default-footer-widget-popup-hide";
8
+ })(IncomingEvent || (IncomingEvent = {}));
9
+ var OutgoingEvent;
10
+ (function (OutgoingEvent) {
11
+ OutgoingEvent["footerWidgetDataInitial"] = "jackpot-default-footer-widget-data-initial";
12
+ OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-default-footer-widget-data-updated";
13
+ })(OutgoingEvent || (OutgoingEvent = {}));
14
+ export class DefaultClientFooterWidget extends FooterWidgetBase {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.route = '/footer-widget';
18
+ this.height = '50px';
19
+ }
20
+ sendInitialData() {
21
+ this.sendToChild({
22
+ type: OutgoingEvent.footerWidgetDataInitial,
23
+ data: this.data,
24
+ config: this.config,
25
+ });
26
+ }
27
+ sendDataUpdate(partialData) {
28
+ this.sendToChild({
29
+ type: OutgoingEvent.footerWidgetDataUpdated,
30
+ data: partialData,
31
+ });
32
+ }
33
+ handleChildMessage(type) {
34
+ switch (type) {
35
+ case IncomingEvent.footerWidgetLoaded:
36
+ this.sendInitialData();
37
+ return true;
38
+ case IncomingEvent.showPopup:
39
+ this.emit('showPopup');
40
+ this.expandIframe();
41
+ return true;
42
+ case IncomingEvent.hidePopup:
43
+ this.emit('hidePopup');
44
+ this.collapseIframe();
45
+ return true;
46
+ case IncomingEvent.participateChange:
47
+ this.emit('participateChange');
48
+ return true;
49
+ default:
50
+ return false;
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,9 @@
1
+ import { WinWidgetBase } from '../../core/WinWidgetBase';
2
+ import { DefaultClientWinWidgetConfig, DefaultClientWinWidgetEvents } from './types';
3
+ export declare class DefaultClientWinWidget extends WinWidgetBase<DefaultClientWinWidgetConfig, DefaultClientWinWidgetEvents> {
4
+ protected get route(): string;
5
+ protected sendInitialData(): void;
6
+ protected handleChildMessage(type: string | undefined): boolean;
7
+ protected applyLaunchAnimation(iframe: HTMLIFrameElement): void;
8
+ protected cleanupLaunchAnimation(): void;
9
+ }
@@ -0,0 +1,95 @@
1
+ import { WinWidgetBase } from '../../core/WinWidgetBase';
2
+ var IncomingEvent;
3
+ (function (IncomingEvent) {
4
+ IncomingEvent["winWidgetLoaded"] = "jackpot-default-win-widget-loaded";
5
+ IncomingEvent["winWidgetClose"] = "jackpot-default-win-widget-close";
6
+ })(IncomingEvent || (IncomingEvent = {}));
7
+ var OutgoingEvent;
8
+ (function (OutgoingEvent) {
9
+ OutgoingEvent["winWidgetDataInitial"] = "jackpot-default-win-widget-data-initial";
10
+ })(OutgoingEvent || (OutgoingEvent = {}));
11
+ export class DefaultClientWinWidget extends WinWidgetBase {
12
+ get route() {
13
+ var _a;
14
+ return `/win-animation-widget?animation=${(_a = this.config.animation) !== null && _a !== void 0 ? _a : 'wheel'}`;
15
+ }
16
+ sendInitialData() {
17
+ this.sendToChild({
18
+ type: OutgoingEvent.winWidgetDataInitial,
19
+ data: this.data,
20
+ config: this.config,
21
+ });
22
+ }
23
+ handleChildMessage(type) {
24
+ switch (type) {
25
+ case IncomingEvent.winWidgetLoaded:
26
+ this.sendInitialData();
27
+ return true;
28
+ case IncomingEvent.winWidgetClose:
29
+ this.destroy();
30
+ this.emit('close');
31
+ return true;
32
+ default:
33
+ return false;
34
+ }
35
+ }
36
+ applyLaunchAnimation(iframe) {
37
+ const targetContainer = this.container
38
+ ? document.querySelector(this.container)
39
+ : document.body;
40
+ if (!targetContainer) {
41
+ console.error(`Failed to show win widget. Container "${this.container}" not found`);
42
+ return;
43
+ }
44
+ const isCustomContainer = !!this.container;
45
+ if (isCustomContainer) {
46
+ const style = window.getComputedStyle(targetContainer);
47
+ if (style.position === 'static') {
48
+ targetContainer.style.position = 'relative';
49
+ }
50
+ }
51
+ const container = document.createElement('div');
52
+ container.dataset.winWidget = 'container';
53
+ Object.assign(container.style, {
54
+ position: isCustomContainer ? 'absolute' : 'fixed',
55
+ inset: '0',
56
+ width: '100%',
57
+ height: '100%',
58
+ overflow: 'hidden',
59
+ zIndex: '99999999', // 8
60
+ clipPath: 'circle(0% at 50% 50%)',
61
+ transition: 'clip-path 1.2s cubic-bezier(0.22, 1, 0.36, 1)',
62
+ });
63
+ targetContainer.appendChild(container);
64
+ container.appendChild(iframe);
65
+ const overlay = document.createElement('div');
66
+ overlay.dataset.winWidget = 'overlay';
67
+ Object.assign(overlay.style, {
68
+ position: isCustomContainer ? 'absolute' : 'fixed',
69
+ inset: '0',
70
+ width: '100%',
71
+ height: '100%',
72
+ background: 'rgba(0,0,0,0)',
73
+ zIndex: '9999999', // 7
74
+ backdropFilter: 'blur(0px)',
75
+ transition: 'background 0.8s ease, backdrop-filter 0.8s ease',
76
+ });
77
+ targetContainer.appendChild(overlay);
78
+ setTimeout(() => {
79
+ overlay.style.background = 'rgba(0,0,0,0.4)';
80
+ overlay.style.backdropFilter = 'blur(8px)';
81
+ }, 200);
82
+ setTimeout(() => {
83
+ container.style.clipPath = 'circle(150% at 50% 50%)';
84
+ }, 1000);
85
+ this.setLaunched(true);
86
+ }
87
+ cleanupLaunchAnimation() {
88
+ var _a, _b;
89
+ const root = this.container
90
+ ? document.querySelector(this.container) || document
91
+ : document;
92
+ (_a = root.querySelector('[data-win-widget="overlay"]')) === null || _a === void 0 ? void 0 : _a.remove();
93
+ (_b = root.querySelector('[data-win-widget="container"]')) === null || _b === void 0 ? void 0 : _b.remove();
94
+ }
95
+ }
@@ -0,0 +1,14 @@
1
+ import { FooterWidgetBaseConfig, WinWidgetBaseConfig } from '../../core/types';
2
+ export interface DefaultClientFooterWidgetConfig extends FooterWidgetBaseConfig {
3
+ }
4
+ export interface DefaultClientWinWidgetConfig extends WinWidgetBaseConfig {
5
+ animation?: 'wheel' | 'airplane';
6
+ }
7
+ export interface DefaultClientFooterWidgetEvents {
8
+ participateChange: void;
9
+ showPopup: void;
10
+ hidePopup: void;
11
+ }
12
+ export interface DefaultClientWinWidgetEvents {
13
+ close: void;
14
+ }
@@ -0,0 +1,24 @@
1
+ import { SDKEnv } from '../core/types';
2
+ import { B2TechFooterWidget } from './b2tech/B2TechFooterWidget';
3
+ import { DefaultClientFooterWidget } from './defaultClient/DefaultClientFooterWidget';
4
+ import { DefaultClientWinWidget } from './defaultClient/DefaultClientWinWidget';
5
+ export type ClientId = 'defaultClient' | 'b2tech';
6
+ export interface DefaultClientWidgets {
7
+ footerWidget: DefaultClientFooterWidget;
8
+ winWidget: DefaultClientWinWidget;
9
+ }
10
+ export interface B2TechWidgets {
11
+ footerWidget: B2TechFooterWidget;
12
+ }
13
+ export interface ClientWidgets {
14
+ defaultClient: DefaultClientWidgets;
15
+ b2tech: B2TechWidgets;
16
+ }
17
+ interface ClientDefinition<C extends ClientId> {
18
+ baseUrls: Record<SDKEnv, string>;
19
+ createWidgets: (origin: string) => ClientWidgets[C];
20
+ }
21
+ export declare const clientRegistry: {
22
+ [K in ClientId]: ClientDefinition<K>;
23
+ };
24
+ export {};
@@ -0,0 +1,28 @@
1
+ import { B2TechFooterWidget } from './b2tech/B2TechFooterWidget';
2
+ import { DefaultClientFooterWidget } from './defaultClient/DefaultClientFooterWidget';
3
+ import { DefaultClientWinWidget } from './defaultClient/DefaultClientWinWidget';
4
+ export const clientRegistry = {
5
+ defaultClient: {
6
+ baseUrls: {
7
+ local: 'http://localhost:4741',
8
+ dev: 'https://jackpot-widget-dev.splash.tech',
9
+ staging: 'https://jackpot-widget-staging.splash.tech',
10
+ production: 'https://jackpot-widget.splash.tech',
11
+ },
12
+ createWidgets: (origin) => ({
13
+ footerWidget: new DefaultClientFooterWidget(origin),
14
+ winWidget: new DefaultClientWinWidget(origin),
15
+ }),
16
+ },
17
+ b2tech: {
18
+ baseUrls: {
19
+ local: 'http://localhost:4742',
20
+ dev: 'https://jackpot-widget-b2tech-dev.splash.tech',
21
+ staging: 'https://jackpot-widget-b2tech-staging.splash.tech',
22
+ production: 'https://jackpot-widget-b2tech.splash.tech',
23
+ },
24
+ createWidgets: (origin) => ({
25
+ footerWidget: new B2TechFooterWidget(origin),
26
+ }),
27
+ },
28
+ };
@@ -0,0 +1,24 @@
1
+ import { ChildMessage, InitialChildMessage, WidgetEventHandler } from './types';
2
+ export declare abstract class BaseWidget<TConfig, TEvents> {
3
+ protected readonly childAppOrigin: string;
4
+ protected iframe: HTMLIFrameElement | null;
5
+ protected config: TConfig;
6
+ protected data: unknown;
7
+ private launched;
8
+ private listeners;
9
+ constructor(childAppOrigin: string);
10
+ protected abstract handleChildMessage(type: string | undefined): boolean;
11
+ isLaunched(): boolean;
12
+ addEventListener(event: keyof TEvents & string, handler: WidgetEventHandler): void;
13
+ removeEventListener(event: keyof TEvents & string, handler: WidgetEventHandler): void;
14
+ removeAllEventListeners(): void;
15
+ protected emit(event: keyof TEvents & string): void;
16
+ protected setLaunched(launched: boolean): void;
17
+ protected createIframe(): HTMLIFrameElement;
18
+ protected appendIframe(iframe: HTMLIFrameElement, container?: string): void;
19
+ protected removeIframe(): void;
20
+ protected sendToChild(message: ChildMessage | InitialChildMessage<TConfig>): void;
21
+ protected startListening(): void;
22
+ protected stopListening(): void;
23
+ private childMessageHandler;
24
+ }