@splash-tech/jackpot-sdk 1.1.3 → 1.1.5
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
|
-
|
|
3
|
+
Splash Jackpot SDK allows operators to integrate jackpot widgets into their applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The SDK provides two widgets:
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
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
|
-
|
|
21
|
+
---
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
# Quick Start
|
|
16
24
|
|
|
17
|
-
|
|
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
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
```ts
|
|
40
|
+
import { splashJackpot } from '@splash-tech/jackpot-sdk';
|
|
41
|
+
|
|
42
|
+
splashJackpot.winWidget.launch({
|
|
43
|
+
data: winData,
|
|
34
44
|
});
|
|
45
|
+
```
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
116
|
+
---
|
|
73
117
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
# Documentation
|
|
92
138
|
|
|
93
|
-
|
|
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).
|
|
@@ -6,6 +6,8 @@ export declare class WinWidget extends BaseWidget {
|
|
|
6
6
|
static getInstance(): WinWidget;
|
|
7
7
|
private childMessageHandler;
|
|
8
8
|
launch(params: WinWidgetParams): void;
|
|
9
|
+
private animateEnter;
|
|
10
|
+
private cleanupAnimation;
|
|
9
11
|
removeAllEventListeners(): void;
|
|
10
12
|
destroy(): void;
|
|
11
13
|
}
|
|
@@ -20,6 +20,7 @@ export class WinWidget extends BaseWidget {
|
|
|
20
20
|
});
|
|
21
21
|
break;
|
|
22
22
|
case WinWidgetIframeIncomingEvent.winWidgetClose:
|
|
23
|
+
this.cleanupAnimation();
|
|
23
24
|
this.emit('close');
|
|
24
25
|
break;
|
|
25
26
|
}
|
|
@@ -42,15 +43,83 @@ export class WinWidget extends BaseWidget {
|
|
|
42
43
|
this.iframe.style.left = '0';
|
|
43
44
|
this.iframe.style.width = '100%';
|
|
44
45
|
this.iframe.style.height = '100%';
|
|
45
|
-
this.iframe.style.zIndex = '
|
|
46
|
+
this.iframe.style.zIndex = '99999999'; // 8
|
|
46
47
|
this.iframe.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
|
47
48
|
this.iframe.src = `${this.childAppOrigin}/win-animation-widget`;
|
|
48
|
-
this.
|
|
49
|
-
this.setLaunched(true);
|
|
49
|
+
this.animateEnter(this.iframe, params.container);
|
|
50
50
|
window.addEventListener('message', this.childMessageHandler);
|
|
51
51
|
}
|
|
52
|
+
animateEnter(iframe, containerSelector) {
|
|
53
|
+
if (!iframe) {
|
|
54
|
+
console.error('Failed to show win widget. Iframe not found.');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const targetContainer = containerSelector
|
|
58
|
+
? document.querySelector(containerSelector)
|
|
59
|
+
: document.body;
|
|
60
|
+
if (!targetContainer) {
|
|
61
|
+
console.error(`Failed to show win widget. Container "${containerSelector}" not found`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const isCustomContainer = !!containerSelector;
|
|
65
|
+
if (isCustomContainer) {
|
|
66
|
+
const style = window.getComputedStyle(targetContainer);
|
|
67
|
+
if (style.position === 'static') {
|
|
68
|
+
targetContainer.style.position = 'relative';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// create circular container
|
|
72
|
+
const container = document.createElement('div');
|
|
73
|
+
container.dataset.winWidget = 'container';
|
|
74
|
+
Object.assign(container.style, {
|
|
75
|
+
position: isCustomContainer ? 'absolute' : 'fixed',
|
|
76
|
+
inset: '0',
|
|
77
|
+
width: '100%',
|
|
78
|
+
height: '100%',
|
|
79
|
+
overflow: 'hidden',
|
|
80
|
+
zIndex: '99999999', // 8
|
|
81
|
+
clipPath: 'circle(0% at 50% 50%)',
|
|
82
|
+
transition: 'clip-path 1.2s cubic-bezier(0.22, 1, 0.36, 1)',
|
|
83
|
+
});
|
|
84
|
+
// append circular container into targetContainer, and iframe into circular container
|
|
85
|
+
targetContainer.appendChild(container);
|
|
86
|
+
container.appendChild(iframe);
|
|
87
|
+
// create overlay
|
|
88
|
+
const overlay = document.createElement('div');
|
|
89
|
+
overlay.dataset.winWidget = 'overlay';
|
|
90
|
+
Object.assign(overlay.style, {
|
|
91
|
+
position: isCustomContainer ? 'absolute' : 'fixed',
|
|
92
|
+
inset: '0',
|
|
93
|
+
width: '100%',
|
|
94
|
+
height: '100%',
|
|
95
|
+
background: 'rgba(0,0,0,0)',
|
|
96
|
+
zIndex: '9999999', // 7
|
|
97
|
+
backdropFilter: 'blur(0px)',
|
|
98
|
+
transition: 'background 0.8s ease, backdrop-filter 0.8s ease',
|
|
99
|
+
});
|
|
100
|
+
// append overlay
|
|
101
|
+
targetContainer.appendChild(overlay);
|
|
102
|
+
// animate overlay blur
|
|
103
|
+
requestAnimationFrame(() => {
|
|
104
|
+
overlay.style.background = 'rgba(0,0,0,0.4)';
|
|
105
|
+
overlay.style.backdropFilter = 'blur(8px)';
|
|
106
|
+
});
|
|
107
|
+
// animate circular container growth
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
container.style.clipPath = 'circle(150% at 50% 50%)';
|
|
110
|
+
}, 800);
|
|
111
|
+
this.setLaunched(true);
|
|
112
|
+
}
|
|
113
|
+
cleanupAnimation(containerSelector) {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
const container = containerSelector
|
|
116
|
+
? document.querySelector(containerSelector) || document
|
|
117
|
+
: document;
|
|
118
|
+
(_a = container.querySelector('[data-win-widget="overlay"]')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
119
|
+
(_b = container.querySelector('[data-win-widget="container"]')) === null || _b === void 0 ? void 0 : _b.remove();
|
|
120
|
+
}
|
|
52
121
|
removeAllEventListeners() {
|
|
53
|
-
|
|
122
|
+
super.removeAllEventListeners();
|
|
54
123
|
}
|
|
55
124
|
destroy() {
|
|
56
125
|
window.removeEventListener('message', this.childMessageHandler);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splash-tech/jackpot-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "SDK for managing jackpot widgets in iframes",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,11 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"clean": "rm -rf dist",
|
|
13
|
-
"build
|
|
14
|
-
"
|
|
15
|
-
"build:staging": "npm run clean && tsc",
|
|
16
|
-
"build:prod": "npm run clean && tsc",
|
|
17
|
-
"publish": "npm run build:prod && npm publish",
|
|
13
|
+
"build": "npm run clean && tsc",
|
|
14
|
+
"publish": "npm run build && npm publish",
|
|
18
15
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
16
|
},
|
|
20
17
|
"keywords": [
|