@splash-tech/jackpot-sdk 3.0.2 → 3.0.3

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 CHANGED
@@ -22,28 +22,23 @@ npm install @splash-tech/jackpot-sdk
22
22
 
23
23
  # Quick Start
24
24
 
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
-
27
- ```ts
28
- import { createSplashJackpot } from '@splash-tech/jackpot-sdk';
29
-
30
- const splashJackpot = createSplashJackpot({
31
- client: 'defaultClient',
32
- env: 'production',
33
- });
34
- ```
35
-
36
25
  ## Launch Footer Widget
37
26
 
38
27
  ```ts
28
+ import { splashJackpot } from '@splash-tech/jackpot-sdk';
29
+
39
30
  splashJackpot.footerWidget.launch({
40
31
  data: widgetData,
41
32
  });
42
33
  ```
43
34
 
35
+ ---
36
+
44
37
  ## Launch Win Widget
45
38
 
46
39
  ```ts
40
+ import { splashJackpot } from '@splash-tech/jackpot-sdk';
41
+
47
42
  splashJackpot.winWidget.launch({
48
43
  data: winData,
49
44
  });
@@ -51,53 +46,23 @@ splashJackpot.winWidget.launch({
51
46
 
52
47
  ---
53
48
 
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
-
65
49
  # Widget Launch Parameters
66
50
 
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.
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
+ | maxWidth | string | '1300px' | Maximum width of the footer widget |
90
57
 
91
58
  Example:
92
59
 
93
60
  ```ts
94
61
  splashJackpot.footerWidget.launch({
95
62
  data: widgetData,
96
- config: {
97
- position: 'bottom',
98
- maxWidth: '100%',
99
- container: '#game-container',
100
- },
63
+ container: '#game-container',
64
+ mode: 'production',
65
+ maxWidth: '100%',
101
66
  });
102
67
  ```
103
68
 
@@ -105,9 +70,7 @@ splashJackpot.footerWidget.launch({
105
70
 
106
71
  # Widget API
107
72
 
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)
73
+ ## Footer Widget
111
74
 
112
75
  - `launch()` – launch widget
113
76
  - `updateData()` – update jackpot values
@@ -117,11 +80,7 @@ Every client gets the core API. On top of it, a client may have extra methods de
117
80
  - `removeAllEventListeners()` – remove all listeners
118
81
  - `destroy()` – remove widget from DOM
119
82
 
120
- ## Footer Widget (`b2tech` client)
121
-
122
- - `helloWorld()` – placeholder client-specific method
123
-
124
- ## Win Widget (core, all clients)
83
+ ## Win Widget
125
84
 
126
85
  - `launch()`
127
86
  - `isLaunched()`
@@ -134,9 +93,7 @@ Every client gets the core API. On top of it, a client may have extra methods de
134
93
 
135
94
  # Events
136
95
 
137
- Events are client-specific; TypeScript only offers the event names valid for your clientId.
138
-
139
- ## Footer Widget (`defaultClient`)
96
+ ## Footer Widget
140
97
 
141
98
  | Event | Description |
142
99
  | ----------------- | ---------------------------------- |
@@ -144,14 +101,6 @@ Events are client-specific; TypeScript only offers the event names valid for you
144
101
  | hidePopup | Footer popup closed |
145
102
  | participateChange | User toggled jackpot participation |
146
103
 
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
-
155
104
  Example:
156
105
 
157
106
  ```ts
@@ -160,18 +109,14 @@ splashJackpot.footerWidget.addEventListener('showPopup', () => {
160
109
  });
161
110
  ```
162
111
 
163
- ## Win Widget (`defaultClient`)
112
+ ---
113
+
114
+ ## Win Widget
164
115
 
165
116
  | Event | Description |
166
117
  | ----- | ----------------- |
167
118
  | close | Win widget closed |
168
119
 
169
- ## Win Widget (`b2tech` client)
170
-
171
- | Event | Description |
172
- | --------- | -------------------- |
173
- | dismissed | Win widget dismissed |
174
-
175
120
  ---
176
121
 
177
122
  # Cleanup
@@ -185,53 +130,6 @@ splashJackpot.footerWidget.destroy();
185
130
 
186
131
  ---
187
132
 
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
-
235
133
  # Documentation
236
134
 
237
135
  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).
@@ -1,11 +1,10 @@
1
1
  import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
- import { B2TechFooterWidgetConfig, B2TechFooterWidgetEvents } from './types';
3
- export declare class B2TechFooterWidget extends FooterWidgetBase<B2TechFooterWidgetConfig, B2TechFooterWidgetEvents> {
2
+ import { FooterWidgetConfig, FooterWidgetEvents } from './types';
3
+ export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, FooterWidgetEvents> {
4
4
  protected readonly route = "/footer-widget";
5
5
  protected readonly height = "64px";
6
6
  protected sendInitialData(): void;
7
7
  protected sendDataUpdate(partialData: object): void;
8
8
  protected handleChildMessage(type: string | undefined): boolean;
9
9
  showWinPopup(data: unknown): void;
10
- hideWinPopup(): void;
11
10
  }
@@ -1,19 +1,19 @@
1
1
  import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
2
  var IncomingEvent;
3
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";
4
+ IncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
5
+ IncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
6
+ IncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
7
+ IncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
8
+ IncomingEvent["hideWinPopup"] = "jackpot-footer-widget-win-popup-hide";
8
9
  })(IncomingEvent || (IncomingEvent = {}));
9
10
  var OutgoingEvent;
10
11
  (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";
12
+ OutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
13
+ OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
14
+ OutgoingEvent["showWinPopup"] = "jackpot-footer-widget-win-popup-show";
15
15
  })(OutgoingEvent || (OutgoingEvent = {}));
16
- export class B2TechFooterWidget extends FooterWidgetBase {
16
+ export class FooterWidget extends FooterWidgetBase {
17
17
  constructor() {
18
18
  super(...arguments);
19
19
  this.route = '/footer-widget';
@@ -37,15 +37,20 @@ export class B2TechFooterWidget extends FooterWidgetBase {
37
37
  case IncomingEvent.footerWidgetLoaded:
38
38
  this.sendInitialData();
39
39
  return true;
40
+ case IncomingEvent.participateChange:
41
+ this.emit('participateChange');
42
+ return true;
40
43
  case IncomingEvent.showPopup:
44
+ this.emit('showPopup');
41
45
  this.expandIframe();
42
46
  return true;
43
47
  case IncomingEvent.hidePopup:
48
+ this.emit('hidePopup');
44
49
  this.collapseIframe();
45
50
  return true;
46
- case IncomingEvent.winPopupClosed:
51
+ case IncomingEvent.hideWinPopup:
52
+ this.emit('hideWinPopup');
47
53
  this.collapseIframe();
48
- this.emit('winPopupClosed');
49
54
  return true;
50
55
  default:
51
56
  return false;
@@ -57,18 +62,9 @@ export class B2TechFooterWidget extends FooterWidgetBase {
57
62
  return;
58
63
  }
59
64
  this.sendToChild({
60
- type: OutgoingEvent.winPopupShow,
65
+ type: OutgoingEvent.showWinPopup,
61
66
  data,
62
67
  });
63
68
  this.expandIframe();
64
69
  }
65
- hideWinPopup() {
66
- if (!this.isLaunched())
67
- return;
68
- this.sendToChild({
69
- type: OutgoingEvent.winPopupHide,
70
- data: null,
71
- });
72
- this.collapseIframe();
73
- }
74
70
  }
@@ -0,0 +1,9 @@
1
+ import { FooterWidgetBaseConfig } from '../../core/types';
2
+ export interface FooterWidgetConfig extends FooterWidgetBaseConfig {
3
+ }
4
+ export interface FooterWidgetEvents {
5
+ participateChange: void;
6
+ showPopup: void;
7
+ hidePopup: void;
8
+ hideWinPopup: void;
9
+ }
@@ -1,18 +1,22 @@
1
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;
2
+ import { FooterWidget as FooterWidgetH4 } from './h4n8w3vt/FooterWidget';
3
+ import { FooterWidget as FooterWidgetX7 } from './x7k2m9qp/FooterWidget';
4
+ import { WinWidget as WinWidgetX7 } from './x7k2m9qp/WinWidget';
5
+ export declare const Clients: {
6
+ readonly x7k2m9qp: "x7k2m9qp";
7
+ readonly h4n8w3vt: "h4n8w3vt";
8
+ };
9
+ export type ClientId = (typeof Clients)[keyof typeof Clients];
10
+ export interface X7Widgets {
11
+ footerWidget: FooterWidgetX7;
12
+ winWidget: WinWidgetX7;
9
13
  }
10
- export interface B2TechWidgets {
11
- footerWidget: B2TechFooterWidget;
14
+ export interface H4Widgets {
15
+ footerWidget: FooterWidgetH4;
12
16
  }
13
17
  export interface ClientWidgets {
14
- defaultClient: DefaultClientWidgets;
15
- b2tech: B2TechWidgets;
18
+ [Clients.x7k2m9qp]: X7Widgets;
19
+ [Clients.h4n8w3vt]: H4Widgets;
16
20
  }
17
21
  interface ClientDefinition<C extends ClientId> {
18
22
  baseUrls: Record<SDKEnv, string>;
@@ -1,8 +1,12 @@
1
- import { B2TechFooterWidget } from './b2tech/B2TechFooterWidget';
2
- import { DefaultClientFooterWidget } from './defaultClient/DefaultClientFooterWidget';
3
- import { DefaultClientWinWidget } from './defaultClient/DefaultClientWinWidget';
1
+ import { FooterWidget as FooterWidgetH4 } from './h4n8w3vt/FooterWidget';
2
+ import { FooterWidget as FooterWidgetX7 } from './x7k2m9qp/FooterWidget';
3
+ import { WinWidget as WinWidgetX7 } from './x7k2m9qp/WinWidget';
4
+ export const Clients = {
5
+ x7k2m9qp: 'x7k2m9qp',
6
+ h4n8w3vt: 'h4n8w3vt',
7
+ };
4
8
  export const clientRegistry = {
5
- defaultClient: {
9
+ [Clients.x7k2m9qp]: {
6
10
  baseUrls: {
7
11
  local: 'http://localhost:4741',
8
12
  dev: 'https://jackpot-widget-dev.splash.tech',
@@ -10,11 +14,11 @@ export const clientRegistry = {
10
14
  production: 'https://jackpot-widget.splash.tech',
11
15
  },
12
16
  createWidgets: (origin) => ({
13
- footerWidget: new DefaultClientFooterWidget(origin),
14
- winWidget: new DefaultClientWinWidget(origin),
17
+ footerWidget: new FooterWidgetX7(origin),
18
+ winWidget: new WinWidgetX7(origin),
15
19
  }),
16
20
  },
17
- b2tech: {
21
+ [Clients.h4n8w3vt]: {
18
22
  baseUrls: {
19
23
  local: 'http://localhost:4742',
20
24
  dev: 'https://jackpot-widget-b2tech-dev.splash.tech',
@@ -22,7 +26,7 @@ export const clientRegistry = {
22
26
  production: 'https://jackpot-widget-b2tech.splash.tech',
23
27
  },
24
28
  createWidgets: (origin) => ({
25
- footerWidget: new B2TechFooterWidget(origin),
29
+ footerWidget: new FooterWidgetH4(origin),
26
30
  }),
27
31
  },
28
32
  };
@@ -1,6 +1,6 @@
1
1
  import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
- import { DefaultClientFooterWidgetConfig, DefaultClientFooterWidgetEvents } from './types';
3
- export declare class DefaultClientFooterWidget extends FooterWidgetBase<DefaultClientFooterWidgetConfig, DefaultClientFooterWidgetEvents> {
2
+ import { FooterWidgetConfig, FooterWidgetEvents } from './types';
3
+ export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, FooterWidgetEvents> {
4
4
  protected readonly route = "/footer-widget";
5
5
  protected readonly height = "50px";
6
6
  protected sendInitialData(): void;
@@ -11,7 +11,7 @@ var OutgoingEvent;
11
11
  OutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
12
12
  OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
13
13
  })(OutgoingEvent || (OutgoingEvent = {}));
14
- export class DefaultClientFooterWidget extends FooterWidgetBase {
14
+ export class FooterWidget extends FooterWidgetBase {
15
15
  constructor() {
16
16
  super(...arguments);
17
17
  this.route = '/footer-widget';
@@ -1,6 +1,6 @@
1
1
  import { WinWidgetBase } from '../../core/WinWidgetBase';
2
- import { DefaultClientWinWidgetConfig, DefaultClientWinWidgetEvents } from './types';
3
- export declare class DefaultClientWinWidget extends WinWidgetBase<DefaultClientWinWidgetConfig, DefaultClientWinWidgetEvents> {
2
+ import { WinWidgetConfig, WinWidgetEvents } from './types';
3
+ export declare class WinWidget extends WinWidgetBase<WinWidgetConfig, WinWidgetEvents> {
4
4
  protected get route(): string;
5
5
  protected sendInitialData(): void;
6
6
  protected handleChildMessage(type: string | undefined): boolean;
@@ -8,7 +8,7 @@ var OutgoingEvent;
8
8
  (function (OutgoingEvent) {
9
9
  OutgoingEvent["winWidgetDataInitial"] = "jackpot-win-widget-data-initial";
10
10
  })(OutgoingEvent || (OutgoingEvent = {}));
11
- export class DefaultClientWinWidget extends WinWidgetBase {
11
+ export class WinWidget extends WinWidgetBase {
12
12
  get route() {
13
13
  var _a;
14
14
  return `/win-animation-widget?animation=${(_a = this.config.animation) !== null && _a !== void 0 ? _a : 'wheel'}`;
@@ -0,0 +1,14 @@
1
+ import { FooterWidgetBaseConfig, WinWidgetBaseConfig } from '../../core/types';
2
+ export interface FooterWidgetConfig extends FooterWidgetBaseConfig {
3
+ }
4
+ export interface WinWidgetConfig extends WinWidgetBaseConfig {
5
+ animation?: 'wheel' | 'airplane';
6
+ }
7
+ export interface FooterWidgetEvents {
8
+ participateChange: void;
9
+ showPopup: void;
10
+ hidePopup: void;
11
+ }
12
+ export interface WinWidgetEvents {
13
+ close: void;
14
+ }
@@ -0,0 +1,18 @@
1
+ import { FooterWidgetBaseConfig, SDKEnv, WidgetLaunchParams, WinWidgetBaseConfig } from '../../core/types';
2
+ export interface V2FooterWidgetLaunchParams {
3
+ data: unknown;
4
+ mode?: SDKEnv;
5
+ position?: FooterWidgetBaseConfig['position'];
6
+ maxWidth?: string;
7
+ container?: string;
8
+ }
9
+ export interface V2WinWidgetLaunchParams {
10
+ data: unknown;
11
+ mode?: SDKEnv;
12
+ animation?: 'wheel' | 'airplane';
13
+ container?: string;
14
+ }
15
+ export declare function mapV2FooterWidgetLaunchParams(params: V2FooterWidgetLaunchParams): WidgetLaunchParams<FooterWidgetBaseConfig>;
16
+ export declare function mapV2WinWidgetLaunchParams(params: V2WinWidgetLaunchParams): WidgetLaunchParams<WinWidgetBaseConfig & {
17
+ animation?: 'wheel' | 'airplane';
18
+ }>;
@@ -0,0 +1,18 @@
1
+ export function mapV2FooterWidgetLaunchParams(params) {
2
+ return {
3
+ data: params.data,
4
+ config: Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
5
+ ? { container: params.container }
6
+ : {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})),
7
+ };
8
+ }
9
+ export function mapV2WinWidgetLaunchParams(params) {
10
+ return {
11
+ data: params.data,
12
+ config: Object.assign(Object.assign({}, (params.container !== undefined
13
+ ? { container: params.container }
14
+ : {})), (params.animation !== undefined
15
+ ? { animation: params.animation }
16
+ : {})),
17
+ };
18
+ }
@@ -0,0 +1,22 @@
1
+ import { FooterWidgetEvents, WinWidgetEvents } from '../../clients/x7k2m9qp/types';
2
+ import { WidgetEventHandler } from '../../core/types';
3
+ import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './mapLaunchParams';
4
+ export declare const splashJackpot: {
5
+ footerWidget: {
6
+ isLaunched: () => boolean;
7
+ launch: (params: V2FooterWidgetLaunchParams) => void;
8
+ updateData: (partialData: object) => void;
9
+ destroy: () => void;
10
+ addEventListener: (event: keyof FooterWidgetEvents, handler: WidgetEventHandler) => void;
11
+ removeEventListener: (event: keyof FooterWidgetEvents, handler: WidgetEventHandler) => void;
12
+ removeAllEventListeners: () => void;
13
+ };
14
+ winWidget: {
15
+ isLaunched: () => boolean;
16
+ launch: (params: V2WinWidgetLaunchParams) => void;
17
+ destroy: () => void;
18
+ addEventListener: (event: keyof WinWidgetEvents, handler: WidgetEventHandler) => void;
19
+ removeEventListener: (event: keyof WinWidgetEvents, handler: WidgetEventHandler) => void;
20
+ removeAllEventListeners: () => void;
21
+ };
22
+ };
@@ -0,0 +1,91 @@
1
+ import { Clients } from '../../clients/registry';
2
+ import { createSplashJackpot } from '../v3/createSplashJackpot';
3
+ import { mapV2FooterWidgetLaunchParams, mapV2WinWidgetLaunchParams, } from './mapLaunchParams';
4
+ // Facade for legacy v2.
5
+ // v2 way of using sdk gets mapped into v3.
6
+ // Internally, widgets do everything in v3 way.
7
+ // When all clients update to v3, this can be removed without touching existing widgets.
8
+ function createV2SplashJackpot() {
9
+ let instance = null;
10
+ const footerWidgetListeners = new Map();
11
+ const winWidgetListeners = new Map();
12
+ function createInstance(mode) {
13
+ if (instance)
14
+ return instance;
15
+ instance = createSplashJackpot({
16
+ client: Clients.x7k2m9qp,
17
+ env: mode !== null && mode !== void 0 ? mode : 'production',
18
+ });
19
+ for (const [event, handlers] of footerWidgetListeners) {
20
+ for (const handler of handlers) {
21
+ instance.footerWidget.addEventListener(event, handler);
22
+ }
23
+ }
24
+ for (const [event, handlers] of winWidgetListeners) {
25
+ for (const handler of handlers) {
26
+ instance.winWidget.addEventListener(event, handler);
27
+ }
28
+ }
29
+ return instance;
30
+ }
31
+ return {
32
+ footerWidget: {
33
+ isLaunched: () => { var _a; return (_a = instance === null || instance === void 0 ? void 0 : instance.footerWidget.isLaunched()) !== null && _a !== void 0 ? _a : false; },
34
+ launch: (params) => {
35
+ createInstance(params.mode).footerWidget.launch(mapV2FooterWidgetLaunchParams(params));
36
+ },
37
+ updateData: (partialData) => {
38
+ instance === null || instance === void 0 ? void 0 : instance.footerWidget.updateData(partialData);
39
+ },
40
+ destroy: () => {
41
+ instance === null || instance === void 0 ? void 0 : instance.footerWidget.destroy();
42
+ },
43
+ addEventListener: (event, handler) => {
44
+ if (!footerWidgetListeners.has(event)) {
45
+ footerWidgetListeners.set(event, []);
46
+ }
47
+ footerWidgetListeners.get(event).push(handler);
48
+ instance === null || instance === void 0 ? void 0 : instance.footerWidget.addEventListener(event, handler);
49
+ },
50
+ removeEventListener: (event, handler) => {
51
+ const handlers = footerWidgetListeners.get(event);
52
+ if (handlers) {
53
+ footerWidgetListeners.set(event, handlers.filter((h) => h !== handler));
54
+ }
55
+ instance === null || instance === void 0 ? void 0 : instance.footerWidget.removeEventListener(event, handler);
56
+ },
57
+ removeAllEventListeners: () => {
58
+ footerWidgetListeners.clear();
59
+ instance === null || instance === void 0 ? void 0 : instance.footerWidget.removeAllEventListeners();
60
+ },
61
+ },
62
+ winWidget: {
63
+ isLaunched: () => { var _a; return (_a = instance === null || instance === void 0 ? void 0 : instance.winWidget.isLaunched()) !== null && _a !== void 0 ? _a : false; },
64
+ launch: (params) => {
65
+ createInstance(params.mode).winWidget.launch(mapV2WinWidgetLaunchParams(params));
66
+ },
67
+ destroy: () => {
68
+ instance === null || instance === void 0 ? void 0 : instance.winWidget.destroy();
69
+ },
70
+ addEventListener: (event, handler) => {
71
+ if (!winWidgetListeners.has(event)) {
72
+ winWidgetListeners.set(event, []);
73
+ }
74
+ winWidgetListeners.get(event).push(handler);
75
+ instance === null || instance === void 0 ? void 0 : instance.winWidget.addEventListener(event, handler);
76
+ },
77
+ removeEventListener: (event, handler) => {
78
+ const handlers = winWidgetListeners.get(event);
79
+ if (handlers) {
80
+ winWidgetListeners.set(event, handlers.filter((h) => h !== handler));
81
+ }
82
+ instance === null || instance === void 0 ? void 0 : instance.winWidget.removeEventListener(event, handler);
83
+ },
84
+ removeAllEventListeners: () => {
85
+ winWidgetListeners.clear();
86
+ instance === null || instance === void 0 ? void 0 : instance.winWidget.removeAllEventListeners();
87
+ },
88
+ },
89
+ };
90
+ }
91
+ export const splashJackpot = createV2SplashJackpot();
@@ -0,0 +1,3 @@
1
+ import { ClientId } from '../../clients/registry';
2
+ import { SplashJackpotInitOptions, SplashJackpotSDK } from '../../types';
3
+ export declare function createSplashJackpot<C extends ClientId>(options: SplashJackpotInitOptions<C>): SplashJackpotSDK<C>;
@@ -0,0 +1,11 @@
1
+ import { clientRegistry } from '../../clients/registry';
2
+ export function createSplashJackpot(options) {
3
+ var _a;
4
+ const client = clientRegistry[options.client];
5
+ if (!client) {
6
+ throw new Error(`createSplashJackpot: unknown client "${options.client}".`);
7
+ }
8
+ const env = (_a = options.env) !== null && _a !== void 0 ? _a : 'production';
9
+ const childAppOrigin = client.baseUrls[env];
10
+ return client.createWidgets(childAppOrigin);
11
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { ClientId } from './clients/registry';
2
- import { SplashJackpotInitOptions, SplashJackpotSDK } from './types';
3
- export declare function createSplashJackpot<C extends ClientId>(options: SplashJackpotInitOptions<C>): SplashJackpotSDK<C>;
1
+ export { Clients } from './clients/registry';
2
+ export { splashJackpot } from './compat/v2/splashJackpot';
3
+ export { createSplashJackpot } from './compat/v3/createSplashJackpot';
package/dist/index.js CHANGED
@@ -1,11 +1,5 @@
1
- import { clientRegistry } from './clients/registry';
2
- export function createSplashJackpot(options) {
3
- var _a;
4
- const client = clientRegistry[options.client];
5
- if (!client) {
6
- throw new Error(`createSplashJackpot: unknown client "${options.client}".`);
7
- }
8
- const env = (_a = options.env) !== null && _a !== void 0 ? _a : 'production';
9
- const childAppOrigin = client.baseUrls[env];
10
- return client.createWidgets(childAppOrigin);
11
- }
1
+ export { Clients } from './clients/registry';
2
+ // v2
3
+ export { splashJackpot } from './compat/v2/splashJackpot';
4
+ // v3
5
+ export { createSplashJackpot } from './compat/v3/createSplashJackpot';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splash-tech/jackpot-sdk",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "SDK for managing jackpot widgets in iframes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +0,0 @@
1
- import { FooterWidgetBaseConfig } from '../../core/types';
2
- export interface B2TechFooterWidgetConfig extends FooterWidgetBaseConfig {
3
- }
4
- export interface B2TechFooterWidgetEvents {
5
- winPopupClosed: void;
6
- }
@@ -1,14 +0,0 @@
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
- }
File without changes