@splash-tech/jackpot-sdk 1.0.5 → 1.0.6
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/dist/types.d.ts +3 -3
- package/dist/widgets/footerWidget/types/event.js +1 -1
- package/dist/widgets/wonJackpotWidget/WonJackpotWidget.d.ts +2 -0
- package/dist/widgets/wonJackpotWidget/WonJackpotWidget.js +15 -2
- package/dist/widgets/wonJackpotWidget/types/event.d.ts +7 -6
- package/dist/widgets/wonJackpotWidget/types/event.js +10 -7
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FooterWidgetParams } from './widgets/footerWidget/types/data';
|
|
|
2
2
|
import { FooterWidgetEvents } from './widgets/footerWidget/types/event';
|
|
3
3
|
import { WidgetEventHandler } from './widgets/shared/types';
|
|
4
4
|
import { WonJackpotWidgetParams } from './widgets/wonJackpotWidget/types/data';
|
|
5
|
-
import {
|
|
5
|
+
import { winWidgetWidgetEvents } from './widgets/wonJackpotWidget/types/event';
|
|
6
6
|
export interface SplashJackpotSDK {
|
|
7
7
|
footer: {
|
|
8
8
|
isLaunched: () => boolean;
|
|
@@ -18,7 +18,7 @@ export interface SplashJackpotSDK {
|
|
|
18
18
|
isLaunched: () => boolean;
|
|
19
19
|
launch: (params: WonJackpotWidgetParams) => void;
|
|
20
20
|
destroy: () => void;
|
|
21
|
-
addEventListener(event: keyof
|
|
22
|
-
removeEventListener(event: keyof
|
|
21
|
+
addEventListener(event: keyof winWidgetWidgetEvents, handler: WidgetEventHandler): void;
|
|
22
|
+
removeEventListener(event: keyof winWidgetWidgetEvents, handler: WidgetEventHandler): void;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -6,7 +6,7 @@ export var FooterIframeIncomingEvent;
|
|
|
6
6
|
FooterIframeIncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
|
|
7
7
|
FooterIframeIncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
|
|
8
8
|
})(FooterIframeIncomingEvent || (FooterIframeIncomingEvent = {}));
|
|
9
|
-
// events emitted by SDK to the
|
|
9
|
+
// events emitted by SDK to the app inside iframe - Internal use
|
|
10
10
|
export var FooterIframeOutgoingEvent;
|
|
11
11
|
(function (FooterIframeOutgoingEvent) {
|
|
12
12
|
FooterIframeOutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
|
|
@@ -3,9 +3,11 @@ import { WonJackpotWidgetParams } from './types/data';
|
|
|
3
3
|
export declare class WonJackpotWidget extends BaseWidget {
|
|
4
4
|
private static instance;
|
|
5
5
|
private childAppOrigin;
|
|
6
|
+
private data;
|
|
6
7
|
private constructor();
|
|
7
8
|
static getInstance(): WonJackpotWidget;
|
|
8
9
|
private childMessageHandler;
|
|
9
10
|
launchWonJackpot(params: WonJackpotWidgetParams): void;
|
|
11
|
+
private sendDataToChild;
|
|
10
12
|
destroyWonJackpot(): void;
|
|
11
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseWidget } from '../BaseWidget';
|
|
2
|
-
import {
|
|
2
|
+
import { winWidgetIframeIncomingEvent, winWidgetIframeOutgoingEvent, } from './types/event';
|
|
3
3
|
export class WonJackpotWidget extends BaseWidget {
|
|
4
4
|
constructor() {
|
|
5
5
|
super();
|
|
@@ -10,7 +10,10 @@ export class WonJackpotWidget extends BaseWidget {
|
|
|
10
10
|
if (event.origin !== this.childAppOrigin)
|
|
11
11
|
return;
|
|
12
12
|
switch ((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) {
|
|
13
|
-
case
|
|
13
|
+
case winWidgetIframeIncomingEvent.winWidgetLoaded:
|
|
14
|
+
this.sendDataToChild(winWidgetIframeOutgoingEvent.winWidgetDataIntitial, this.data);
|
|
15
|
+
break;
|
|
16
|
+
case winWidgetIframeIncomingEvent.winWidgetClose:
|
|
14
17
|
this.emit('close');
|
|
15
18
|
break;
|
|
16
19
|
}
|
|
@@ -28,6 +31,7 @@ export class WonJackpotWidget extends BaseWidget {
|
|
|
28
31
|
console.warn('Won Jackpot widget is already launched');
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
34
|
+
this.data = params.data;
|
|
31
35
|
this.childAppOrigin = this.getBaseUrl((_a = params.mode) !== null && _a !== void 0 ? _a : 'production');
|
|
32
36
|
this.iframe = this.createIframe();
|
|
33
37
|
this.iframe.style.top = '0';
|
|
@@ -41,6 +45,15 @@ export class WonJackpotWidget extends BaseWidget {
|
|
|
41
45
|
this.setLaunched(true);
|
|
42
46
|
window.addEventListener('message', this.childMessageHandler);
|
|
43
47
|
}
|
|
48
|
+
sendDataToChild(type, data) {
|
|
49
|
+
var _a;
|
|
50
|
+
if (((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) && data !== undefined) {
|
|
51
|
+
this.iframe.contentWindow.postMessage({
|
|
52
|
+
type,
|
|
53
|
+
payload: data,
|
|
54
|
+
}, this.childAppOrigin);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
44
57
|
destroyWonJackpot() {
|
|
45
58
|
window.removeEventListener('message', this.childMessageHandler);
|
|
46
59
|
this.removeIframe();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export declare enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
showPopup = "jackpot-footer-widget-popup-show",
|
|
5
|
-
jackpotWinClose = "jackpot-win-close"
|
|
1
|
+
export declare enum winWidgetIframeIncomingEvent {
|
|
2
|
+
winWidgetLoaded = "jackpot-win-widget-loaded",
|
|
3
|
+
winWidgetClose = "jackpot-win-widget-close"
|
|
6
4
|
}
|
|
7
|
-
export
|
|
5
|
+
export declare enum winWidgetIframeOutgoingEvent {
|
|
6
|
+
winWidgetDataIntitial = "jackpot-win-widget-data-initial"
|
|
7
|
+
}
|
|
8
|
+
export type winWidgetWidgetEvents = {
|
|
8
9
|
close: void;
|
|
9
10
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// events emitted by app inside iframe to the SDK - Internal use
|
|
2
|
-
export var
|
|
3
|
-
(function (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export var winWidgetIframeIncomingEvent;
|
|
3
|
+
(function (winWidgetIframeIncomingEvent) {
|
|
4
|
+
winWidgetIframeIncomingEvent["winWidgetLoaded"] = "jackpot-win-widget-loaded";
|
|
5
|
+
winWidgetIframeIncomingEvent["winWidgetClose"] = "jackpot-win-widget-close";
|
|
6
|
+
})(winWidgetIframeIncomingEvent || (winWidgetIframeIncomingEvent = {}));
|
|
7
|
+
// events emitted by SDK to the app inside iframe - Internal use
|
|
8
|
+
export var winWidgetIframeOutgoingEvent;
|
|
9
|
+
(function (winWidgetIframeOutgoingEvent) {
|
|
10
|
+
winWidgetIframeOutgoingEvent["winWidgetDataIntitial"] = "jackpot-win-widget-data-initial";
|
|
11
|
+
})(winWidgetIframeOutgoingEvent || (winWidgetIframeOutgoingEvent = {}));
|