@splash-tech/jackpot-sdk 3.0.5 → 3.0.7
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 +9 -7
- package/dist/clients/h4n8w3vt/FooterWidget.d.ts +1 -0
- package/dist/clients/h4n8w3vt/FooterWidget.js +15 -0
- package/dist/clients/x7k2m9qp/FooterWidget.js +4 -0
- package/dist/compat/v2/mapLaunchParams.d.ts +2 -2
- package/dist/compat/v2/mapLaunchParams.js +5 -2
- package/dist/compat/v2/types.d.ts +2 -0
- package/dist/core/FooterWidgetBase.d.ts +6 -2
- package/dist/core/FooterWidgetBase.js +17 -1
- package/dist/core/types.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,13 +48,14 @@ splashJackpot.winWidget.launch({
|
|
|
48
48
|
|
|
49
49
|
# Widget Launch Parameters
|
|
50
50
|
|
|
51
|
-
| Parameter
|
|
52
|
-
|
|
|
53
|
-
| data
|
|
54
|
-
| container
|
|
55
|
-
| mode
|
|
56
|
-
| maxWidth
|
|
57
|
-
| height
|
|
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 |
|
|
57
|
+
| height | string | '50px' | Height of the footer widget |
|
|
58
|
+
| showLevelIcons | boolean | true | Whether to show jackpot level icons in the footer widget |
|
|
58
59
|
|
|
59
60
|
Example:
|
|
60
61
|
|
|
@@ -65,6 +66,7 @@ splashJackpot.footerWidget.launch({
|
|
|
65
66
|
mode: 'production',
|
|
66
67
|
maxWidth: '100%',
|
|
67
68
|
height: '80px',
|
|
69
|
+
showLevelIcons: true,
|
|
68
70
|
});
|
|
69
71
|
```
|
|
70
72
|
|
|
@@ -5,5 +5,6 @@ export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, F
|
|
|
5
5
|
protected sendInitialData(): void;
|
|
6
6
|
protected sendDataUpdate(partialData: object): void;
|
|
7
7
|
protected handleChildMessage(type: string | undefined): boolean;
|
|
8
|
+
showPopup(): void;
|
|
8
9
|
showWinPopup(data: unknown): void;
|
|
9
10
|
}
|
|
@@ -2,6 +2,7 @@ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
|
|
|
2
2
|
var IncomingEvent;
|
|
3
3
|
(function (IncomingEvent) {
|
|
4
4
|
IncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
|
|
5
|
+
IncomingEvent["ready"] = "jackpot-footer-widget-ready";
|
|
5
6
|
IncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
|
|
6
7
|
IncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
|
|
7
8
|
IncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
|
|
@@ -12,6 +13,7 @@ var OutgoingEvent;
|
|
|
12
13
|
OutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
|
|
13
14
|
OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
|
|
14
15
|
OutgoingEvent["showWinPopup"] = "jackpot-footer-widget-win-popup-show";
|
|
16
|
+
OutgoingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
|
|
15
17
|
})(OutgoingEvent || (OutgoingEvent = {}));
|
|
16
18
|
export class FooterWidget extends FooterWidgetBase {
|
|
17
19
|
constructor() {
|
|
@@ -36,6 +38,9 @@ export class FooterWidget extends FooterWidgetBase {
|
|
|
36
38
|
case IncomingEvent.footerWidgetLoaded:
|
|
37
39
|
this.sendInitialData();
|
|
38
40
|
return true;
|
|
41
|
+
case IncomingEvent.ready:
|
|
42
|
+
this.onChildAppLoaded();
|
|
43
|
+
return true;
|
|
39
44
|
case IncomingEvent.participateChange:
|
|
40
45
|
this.emit('participateChange');
|
|
41
46
|
return true;
|
|
@@ -55,6 +60,16 @@ export class FooterWidget extends FooterWidgetBase {
|
|
|
55
60
|
return false;
|
|
56
61
|
}
|
|
57
62
|
}
|
|
63
|
+
showPopup() {
|
|
64
|
+
if (!this.isLaunched()) {
|
|
65
|
+
console.warn('Footer widget must be launched before showPopup');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.sendToChild({
|
|
69
|
+
type: OutgoingEvent.showPopup,
|
|
70
|
+
data: null,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
58
73
|
showWinPopup(data) {
|
|
59
74
|
if (!this.isLaunched()) {
|
|
60
75
|
console.warn('Footer widget must be launched before showWinPopup');
|
|
@@ -2,6 +2,7 @@ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
|
|
|
2
2
|
var IncomingEvent;
|
|
3
3
|
(function (IncomingEvent) {
|
|
4
4
|
IncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
|
|
5
|
+
IncomingEvent["ready"] = "jackpot-footer-widget-ready";
|
|
5
6
|
IncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
|
|
6
7
|
IncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
|
|
7
8
|
IncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
|
|
@@ -34,6 +35,9 @@ export class FooterWidget extends FooterWidgetBase {
|
|
|
34
35
|
case IncomingEvent.footerWidgetLoaded:
|
|
35
36
|
this.sendInitialData();
|
|
36
37
|
return true;
|
|
38
|
+
case IncomingEvent.ready:
|
|
39
|
+
this.onChildAppLoaded();
|
|
40
|
+
return true;
|
|
37
41
|
case IncomingEvent.showPopup:
|
|
38
42
|
this.emit('showPopup');
|
|
39
43
|
this.expandIframe();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FooterWidgetLaunchParams, WidgetLaunchParams, WinWidgetBaseConfig } from '../../core/types';
|
|
2
2
|
import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
|
|
3
|
-
export declare function mapV2FooterWidgetLaunchParams(params: V2FooterWidgetLaunchParams):
|
|
3
|
+
export declare function mapV2FooterWidgetLaunchParams(params: V2FooterWidgetLaunchParams): FooterWidgetLaunchParams;
|
|
4
4
|
export declare function mapV2WinWidgetLaunchParams(params: V2WinWidgetLaunchParams): WidgetLaunchParams<WinWidgetBaseConfig & {
|
|
5
5
|
animation?: 'wheel' | 'airplane';
|
|
6
6
|
}>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export function mapV2FooterWidgetLaunchParams(params) {
|
|
2
2
|
return {
|
|
3
3
|
data: params.data,
|
|
4
|
-
|
|
4
|
+
onLoad: params.onLoad,
|
|
5
|
+
config: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
|
|
5
6
|
? { container: params.container }
|
|
6
|
-
: {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})), (params.height !== undefined ? { height: params.height } : {})),
|
|
7
|
+
: {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})), (params.height !== undefined ? { height: params.height } : {})), (params.showLevelIcons !== undefined
|
|
8
|
+
? { showLevelIcons: params.showLevelIcons }
|
|
9
|
+
: {})),
|
|
7
10
|
};
|
|
8
11
|
}
|
|
9
12
|
export function mapV2WinWidgetLaunchParams(params) {
|
|
@@ -7,7 +7,9 @@ export interface V2FooterWidgetLaunchParams {
|
|
|
7
7
|
position?: FooterWidgetBaseConfig['position'];
|
|
8
8
|
maxWidth?: string;
|
|
9
9
|
height?: string;
|
|
10
|
+
showLevelIcons?: boolean;
|
|
10
11
|
container?: string;
|
|
12
|
+
onLoad?: () => void;
|
|
11
13
|
}
|
|
12
14
|
export interface V2WinWidgetLaunchParams {
|
|
13
15
|
data: unknown;
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { BaseWidget } from './BaseWidget';
|
|
2
|
-
import { FooterWidgetBaseConfig,
|
|
2
|
+
import { FooterWidgetBaseConfig, FooterWidgetLaunchParams } from './types';
|
|
3
3
|
export declare abstract class FooterWidgetBase<TConfig extends FooterWidgetBaseConfig, TEvents> extends BaseWidget<TConfig, TEvents> {
|
|
4
4
|
protected abstract readonly route: string;
|
|
5
5
|
protected container: string;
|
|
6
6
|
protected position: "top" | "bottom";
|
|
7
7
|
protected maxWidth: string;
|
|
8
8
|
protected height: string;
|
|
9
|
+
protected showLevelIcons: boolean;
|
|
10
|
+
private onLoadHandler?;
|
|
11
|
+
private onLoadCalled;
|
|
9
12
|
protected abstract sendInitialData(): void;
|
|
10
13
|
protected abstract sendDataUpdate(partialData: object): void;
|
|
11
|
-
launch(params:
|
|
14
|
+
launch(params: FooterWidgetLaunchParams<TConfig>): void;
|
|
12
15
|
updateData(partialData: object): void;
|
|
13
16
|
destroy(): void;
|
|
14
17
|
protected styleIframe(iframe: HTMLIFrameElement): HTMLIFrameElement;
|
|
15
18
|
protected expandIframe(): void;
|
|
16
19
|
protected collapseIframe(): void;
|
|
17
20
|
private setIframeHeight;
|
|
21
|
+
protected onChildAppLoaded(): void;
|
|
18
22
|
}
|
|
@@ -5,6 +5,7 @@ const defaults = {
|
|
|
5
5
|
position: 'bottom',
|
|
6
6
|
maxWidth: '1300px',
|
|
7
7
|
height: '50px',
|
|
8
|
+
showLevelIcons: true,
|
|
8
9
|
};
|
|
9
10
|
export class FooterWidgetBase extends BaseWidget {
|
|
10
11
|
constructor() {
|
|
@@ -13,19 +14,24 @@ export class FooterWidgetBase extends BaseWidget {
|
|
|
13
14
|
this.position = defaults.position;
|
|
14
15
|
this.maxWidth = defaults.maxWidth;
|
|
15
16
|
this.height = defaults.height;
|
|
17
|
+
this.showLevelIcons = defaults.showLevelIcons;
|
|
18
|
+
this.onLoadCalled = false;
|
|
16
19
|
}
|
|
17
20
|
launch(params) {
|
|
18
|
-
var _a, _b, _c, _d, _e;
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
22
|
if (this.isLaunched()) {
|
|
20
23
|
console.warn('Footer widget is already launched');
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
26
|
this.config = (_a = params.config) !== null && _a !== void 0 ? _a : {};
|
|
24
27
|
this.data = params.data;
|
|
28
|
+
this.onLoadHandler = params.onLoad;
|
|
29
|
+
this.onLoadCalled = false;
|
|
25
30
|
this.container = (_b = this.config.container) !== null && _b !== void 0 ? _b : defaults.container;
|
|
26
31
|
this.position = (_c = this.config.position) !== null && _c !== void 0 ? _c : defaults.position;
|
|
27
32
|
this.maxWidth = (_d = this.config.maxWidth) !== null && _d !== void 0 ? _d : defaults.maxWidth;
|
|
28
33
|
this.height = (_e = this.config.height) !== null && _e !== void 0 ? _e : defaults.height;
|
|
34
|
+
this.showLevelIcons = (_f = this.config.showLevelIcons) !== null && _f !== void 0 ? _f : defaults.showLevelIcons;
|
|
29
35
|
this.iframe = this.createIframe();
|
|
30
36
|
this.iframe = this.styleIframe(this.iframe);
|
|
31
37
|
this.iframe.src = `${this.childAppOrigin}${this.route}`;
|
|
@@ -39,10 +45,13 @@ export class FooterWidgetBase extends BaseWidget {
|
|
|
39
45
|
this.sendDataUpdate(partialData);
|
|
40
46
|
}
|
|
41
47
|
destroy() {
|
|
48
|
+
this.onLoadHandler = undefined;
|
|
49
|
+
this.onLoadCalled = false;
|
|
42
50
|
this.container = defaults.container;
|
|
43
51
|
this.position = defaults.position;
|
|
44
52
|
this.maxWidth = defaults.maxWidth;
|
|
45
53
|
this.height = defaults.height;
|
|
54
|
+
this.showLevelIcons = defaults.showLevelIcons;
|
|
46
55
|
this.stopListening();
|
|
47
56
|
this.removeIframe();
|
|
48
57
|
}
|
|
@@ -72,4 +81,11 @@ export class FooterWidgetBase extends BaseWidget {
|
|
|
72
81
|
this.iframe.style.height = height;
|
|
73
82
|
}
|
|
74
83
|
}
|
|
84
|
+
onChildAppLoaded() {
|
|
85
|
+
var _a;
|
|
86
|
+
if (this.onLoadCalled)
|
|
87
|
+
return;
|
|
88
|
+
this.onLoadCalled = true;
|
|
89
|
+
(_a = this.onLoadHandler) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
90
|
+
}
|
|
75
91
|
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -2,11 +2,15 @@ export interface WidgetLaunchParams<TConfig> {
|
|
|
2
2
|
config?: TConfig;
|
|
3
3
|
data: unknown;
|
|
4
4
|
}
|
|
5
|
+
export interface FooterWidgetLaunchParams<TConfig extends FooterWidgetBaseConfig = FooterWidgetBaseConfig> extends WidgetLaunchParams<TConfig> {
|
|
6
|
+
onLoad?: () => void;
|
|
7
|
+
}
|
|
5
8
|
export interface FooterWidgetBaseConfig {
|
|
6
9
|
container?: string;
|
|
7
10
|
position?: 'top' | 'bottom';
|
|
8
11
|
maxWidth?: string;
|
|
9
12
|
height?: string;
|
|
13
|
+
showLevelIcons?: boolean;
|
|
10
14
|
}
|
|
11
15
|
export interface WinWidgetBaseConfig {
|
|
12
16
|
container?: string;
|