@splash-tech/jackpot-sdk 1.1.2 → 1.1.4

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
@@ -1,94 +1,139 @@
1
1
  # Splash Jackpot SDK
2
2
 
3
- A TypeScript library for managing jackpot widgets
3
+ Splash Jackpot SDK allows operators to integrate jackpot widgets into their applications.
4
4
 
5
- ### SDK Initialization
5
+ The SDK provides two widgets:
6
6
 
7
- You can include the SDK directly in your HTML file:
7
+ - **Footer Widget** – displays current jackpot values to players
8
+ - **Win Widget** – shows a full-screen animation when a jackpot is won
8
9
 
9
- ```html
10
- <script src="http://jackpot-lib.splash.tech/splash-jackpots.js"></script>
10
+ Widgets run inside **isolated iframes hosted by Splash infrastructure**.
11
+ Communication between the host application and widgets is handled automatically by the SDK using `postMessage`.
12
+
13
+ ---
14
+
15
+ # Installation
16
+
17
+ ```bash
18
+ npm install @splash-tech/jackpot-sdk
11
19
  ```
12
20
 
13
- ## Usage
21
+ ---
14
22
 
15
- The SDK allows you to specify a target container for the widgets:
23
+ # Quick Start
16
24
 
17
- - Use any valid CSS selector (e.g., '#my-container', '.my-class')
18
- - If the container is not found, the widget will fall back to the body
19
- - When using a container:
20
- - The widget will be positioned relative to the container
21
- - The container will be set to `position: relative`
22
- - The widget will maintain its size but be contained within the target element
25
+ ## Launch Footer Widget
23
26
 
24
- ```typescript
25
- // Launch footer widget in default container (body)
26
- SplashJackpots.footer.launch({
27
- data: 'your-data', // pass data to footer widget
27
+ ```ts
28
+ import { splashJackpot } from '@splash-tech/jackpot-sdk';
29
+
30
+ splashJackpot.footerWidget.launch({
31
+ data: widgetData,
28
32
  });
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Launch Win Widget
29
38
 
30
- // Launch footer widget inside a specific container
31
- SplashJackpots.footer.launch({
32
- container: '#footer-container', // CSS selector for the container
33
- data: 'your-data', // pass data to footer widget
39
+ ```ts
40
+ import { splashJackpot } from '@splash-tech/jackpot-sdk';
41
+
42
+ splashJackpot.winWidget.launch({
43
+ data: winData,
34
44
  });
45
+ ```
35
46
 
36
- // Destroy footer widget
37
- SplashJackpots.footer.destroy();
47
+ ---
48
+
49
+ # Widget Launch Parameters
50
+
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 |
59
+
60
+ Example:
61
+
62
+ ```ts
63
+ splashJackpot.footerWidget.launch({
64
+ data: widgetData,
65
+ container: '#game-container',
66
+ mode: 'production',
67
+ jackpotId: 'jackpot-id',
68
+ tag: 'game-tag',
69
+ brand: 'brand-name',
70
+ });
38
71
  ```
39
72
 
40
- In order to avoid typescript errors, you need to add the following jackpot-widget.d.ts file to your project:
41
-
42
- _NOTE: Name of the file could be different_
43
-
44
- ```typescript
45
- export interface WidgetParams {
46
- container?: string; // Optional container ID/selector
47
- data: unknown;
48
- }
49
-
50
- export interface SplashJackpotsSDK {
51
- footer: {
52
- isLaunched: () => boolean;
53
- launch: (params: WidgetParams) => void;
54
- destroy: () => void;
55
- };
56
- winWidget: {
57
- isLaunched: () => boolean;
58
- launch: (params: WidgetParams) => void;
59
- destroy: () => void;
60
- };
61
- }
62
-
63
- declare global {
64
- const SplashJackpots: SplashJackpotsSDK;
65
-
66
- interface Window {
67
- SplashJackpots: SplashJackpotsSDK;
68
- }
69
- }
73
+ ---
74
+
75
+ # Widget API
76
+
77
+ ## Footer Widget
78
+
79
+ - `launch()` – launch widget
80
+ - `updateData()` – update jackpot values
81
+ - `isLaunched()` – check if widget is active
82
+ - `addEventListener()` – listen to widget events
83
+ - `removeEventListener()` – remove specific listener
84
+ - `removeAllEventListeners()` – remove all listeners
85
+ - `destroy()` – remove widget from DOM
86
+
87
+ ## Win Widget
88
+
89
+ - `launch()`
90
+ - `isLaunched()`
91
+ - `addEventListener()`
92
+ - `removeEventListener()`
93
+ - `removeAllEventListeners()`
94
+ - `destroy()`
95
+
96
+ ---
97
+
98
+ # Events
99
+
100
+ ## Footer Widget
101
+
102
+ | Event | Description |
103
+ | ----------------- | ---------------------------------- |
104
+ | showPopup | Footer popup opened |
105
+ | hidePopup | Footer popup closed |
106
+ | participateChange | User toggled jackpot participation |
107
+
108
+ Example:
109
+
110
+ ```ts
111
+ splashJackpot.footerWidget.addEventListener('showPopup', () => {
112
+ console.log('Popup opened');
113
+ });
70
114
  ```
71
115
 
72
- ## Development
116
+ ---
73
117
 
74
- ```bash
75
- # Install dependencies
76
- npm install
77
-
78
- # Build the library
79
- npm run build # Local build
80
- npm run build:dev # Development build
81
- npm run build:staging # Staging build
82
- npm run build:prod # Production build
83
-
84
- # Run server
85
- npm run serve # Local environment
86
- npm run serve:dev # Development environment
87
- npm run serve:staging # Staging environment
88
- npm run serve:prod # Production environment
118
+ ## Win Widget
119
+
120
+ | Event | Description |
121
+ | ----- | ----------------- |
122
+ | close | Win widget closed |
123
+
124
+ ---
125
+
126
+ # Cleanup
127
+
128
+ When the widget is no longer needed:
129
+
130
+ ```ts
131
+ splashJackpot.footerWidget.removeAllEventListeners();
132
+ splashJackpot.footerWidget.destroy();
89
133
  ```
90
134
 
91
- Build script will create a `dist` folder containing:
135
+ ---
136
+
137
+ # Documentation
92
138
 
93
- - `splash-jackpots.js` - The bundled library
94
- - `splash-jackpots.d.ts` - TypeScript type definitions
139
+ 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).
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ const splashJackpot = {
10
10
  destroy: () => footerWidget.destroy(),
11
11
  addEventListener: (event, handler) => footerWidget.addEventListener(event, handler),
12
12
  removeEventListener: (event, handler) => footerWidget.removeEventListener(event, handler),
13
+ removeAllEventListeners: () => footerWidget.removeAllEventListeners(),
13
14
  },
14
15
  winWidget: {
15
16
  isLaunched: () => winWidget.isWidgetLaunched(),
@@ -17,6 +18,7 @@ const splashJackpot = {
17
18
  destroy: () => winWidget.destroy(),
18
19
  addEventListener: (event, handler) => winWidget.addEventListener(event, handler),
19
20
  removeEventListener: (event, handler) => winWidget.removeEventListener(event, handler),
21
+ removeAllEventListeners: () => winWidget.removeAllEventListeners(),
20
22
  },
21
23
  };
22
24
  // export
package/dist/types.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface SplashJackpotSDK {
11
11
  destroy: () => void;
12
12
  addEventListener(event: keyof FooterWidgetEvents, handler: WidgetEventHandler): void;
13
13
  removeEventListener(event: keyof FooterWidgetEvents, handler: WidgetEventHandler): void;
14
+ removeAllEventListeners(): void;
14
15
  };
15
16
  winWidget: {
16
17
  isLaunched: () => boolean;
@@ -18,5 +19,6 @@ export interface SplashJackpotSDK {
18
19
  destroy: () => void;
19
20
  addEventListener(event: keyof WinWidgetWidgetEvents, handler: WidgetEventHandler): void;
20
21
  removeEventListener(event: keyof WinWidgetWidgetEvents, handler: WidgetEventHandler): void;
22
+ removeAllEventListeners(): void;
21
23
  };
22
24
  }
@@ -10,5 +10,6 @@ export declare class FooterWidget extends BaseWidget {
10
10
  private validateNonEmptyObject;
11
11
  private showPopup;
12
12
  private hidePopup;
13
+ removeAllEventListeners(): void;
13
14
  destroy(): void;
14
15
  }
@@ -89,9 +89,11 @@ export class FooterWidget extends BaseWidget {
89
89
  this.iframe.style.height = '50px';
90
90
  }
91
91
  }
92
+ removeAllEventListeners() {
93
+ this.removeAllEventListeners();
94
+ }
92
95
  destroy() {
93
96
  window.removeEventListener('message', this.childMessageHandler);
94
- // this.removeAllEventListeners();
95
97
  this.removeIframe();
96
98
  }
97
99
  }
@@ -6,5 +6,6 @@ export declare class WinWidget extends BaseWidget {
6
6
  static getInstance(): WinWidget;
7
7
  private childMessageHandler;
8
8
  launch(params: WinWidgetParams): void;
9
+ removeAllEventListeners(): void;
9
10
  destroy(): void;
10
11
  }
@@ -49,9 +49,11 @@ export class WinWidget extends BaseWidget {
49
49
  this.setLaunched(true);
50
50
  window.addEventListener('message', this.childMessageHandler);
51
51
  }
52
+ removeAllEventListeners() {
53
+ this.removeAllEventListeners();
54
+ }
52
55
  destroy() {
53
56
  window.removeEventListener('message', this.childMessageHandler);
54
- // this.removeAllEventListeners();
55
57
  this.removeIframe();
56
58
  }
57
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splash-tech/jackpot-sdk",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "SDK for managing jackpot widgets in iframes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",