@splash-tech/jackpot-sdk 1.0.3 → 1.0.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/dist/environments/environment.prod.js +1 -4
- package/dist/index.js +18 -31
- package/dist/types.js +1 -2
- package/dist/widgets/BaseWidget.js +26 -31
- package/dist/widgets/footerWidget/FooterWidget.js +38 -60
- package/dist/widgets/footerWidget/types/data.js +1 -2
- package/dist/widgets/footerWidget/types/event.js +4 -7
- package/dist/widgets/shared/types.js +1 -2
- package/dist/widgets/wonJackpotWidget/WonJackpotWidget.js +20 -42
- package/dist/widgets/wonJackpotWidget/types/data.js +1 -2
- package/dist/widgets/wonJackpotWidget/types/event.js +2 -5
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var footerWidget = FooterWidget_1.FooterWidget.getInstance();
|
|
7
|
-
var wonJackpotWidget = WonJackpotWidget_1.WonJackpotWidget.getInstance();
|
|
8
|
-
exports.splashJackpot = {
|
|
1
|
+
import { FooterWidget } from './widgets/footerWidget/FooterWidget';
|
|
2
|
+
import { WonJackpotWidget } from './widgets/wonJackpotWidget/WonJackpotWidget';
|
|
3
|
+
const footerWidget = FooterWidget.getInstance();
|
|
4
|
+
const wonJackpotWidget = WonJackpotWidget.getInstance();
|
|
5
|
+
export const splashJackpot = {
|
|
9
6
|
footer: {
|
|
10
|
-
isLaunched:
|
|
11
|
-
launch:
|
|
12
|
-
updateData:
|
|
13
|
-
showPopup:
|
|
14
|
-
hidePopup:
|
|
15
|
-
destroy:
|
|
16
|
-
addEventListener:
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
removeEventListener: function (event, handler) {
|
|
20
|
-
return footerWidget.removeEventListener(event, handler);
|
|
21
|
-
},
|
|
7
|
+
isLaunched: () => footerWidget.isWidgetLaunched(),
|
|
8
|
+
launch: (params) => footerWidget.launchFooter(params),
|
|
9
|
+
updateData: (partialData) => footerWidget.updateData(partialData),
|
|
10
|
+
showPopup: () => footerWidget.showPopup(),
|
|
11
|
+
hidePopup: () => footerWidget.hidePopup(),
|
|
12
|
+
destroy: () => footerWidget.destroyFooter(),
|
|
13
|
+
addEventListener: (event, handler) => footerWidget.addEventListener(event, handler),
|
|
14
|
+
removeEventListener: (event, handler) => footerWidget.removeEventListener(event, handler),
|
|
22
15
|
},
|
|
23
16
|
wonJackpot: {
|
|
24
|
-
isLaunched:
|
|
25
|
-
launch:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
addEventListener: function (event, handler) {
|
|
30
|
-
return wonJackpotWidget.addEventListener(event, handler);
|
|
31
|
-
},
|
|
32
|
-
removeEventListener: function (event, handler) {
|
|
33
|
-
return wonJackpotWidget.removeEventListener(event, handler);
|
|
34
|
-
},
|
|
17
|
+
isLaunched: () => wonJackpotWidget.isWidgetLaunched(),
|
|
18
|
+
launch: (params) => wonJackpotWidget.launchWonJackpot(params),
|
|
19
|
+
destroy: () => wonJackpotWidget.destroyWonJackpot(),
|
|
20
|
+
addEventListener: (event, handler) => wonJackpotWidget.addEventListener(event, handler),
|
|
21
|
+
removeEventListener: (event, handler) => wonJackpotWidget.removeEventListener(event, handler),
|
|
35
22
|
},
|
|
36
23
|
};
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BaseWidget = void 0;
|
|
4
|
-
var BaseWidget = /** @class */ (function () {
|
|
5
|
-
function BaseWidget() {
|
|
1
|
+
export class BaseWidget {
|
|
2
|
+
constructor() {
|
|
6
3
|
this.iframe = null;
|
|
7
4
|
this.isLaunched = false;
|
|
8
5
|
this.listeners = new Map();
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
handlers === null || handlers === void 0 ? void 0 : handlers.forEach(
|
|
13
|
-
}
|
|
14
|
-
|
|
7
|
+
emit(event, payload) {
|
|
8
|
+
const handlers = this.listeners.get(event);
|
|
9
|
+
handlers === null || handlers === void 0 ? void 0 : handlers.forEach((handler) => handler());
|
|
10
|
+
}
|
|
11
|
+
addEventListener(event, handler) {
|
|
15
12
|
if (!this.listeners.has(event)) {
|
|
16
13
|
this.listeners.set(event, []);
|
|
17
14
|
}
|
|
18
15
|
this.listeners.get(event).push(handler);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
}
|
|
17
|
+
removeEventListener(event, handler) {
|
|
18
|
+
const handlers = this.listeners.get(event);
|
|
22
19
|
if (!handlers)
|
|
23
20
|
return;
|
|
24
|
-
this.listeners.set(event, handlers.filter(
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
this.listeners.set(event, handlers.filter((h) => h !== handler));
|
|
22
|
+
}
|
|
23
|
+
createIframe() {
|
|
24
|
+
const iframe = document.createElement('iframe');
|
|
28
25
|
iframe.style.border = 'none';
|
|
29
26
|
iframe.style.position = 'fixed';
|
|
30
27
|
iframe.style.zIndex = '999999';
|
|
31
28
|
return iframe;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
}
|
|
30
|
+
appendIframe(iframe, container) {
|
|
31
|
+
const targetContainer = container
|
|
35
32
|
? document.querySelector(container)
|
|
36
33
|
: document.body;
|
|
37
34
|
if (!targetContainer) {
|
|
38
|
-
console.error(
|
|
35
|
+
console.error(`Container "${container}" not found`);
|
|
39
36
|
document.body.appendChild(iframe);
|
|
40
37
|
}
|
|
41
38
|
else {
|
|
@@ -45,20 +42,18 @@ var BaseWidget = /** @class */ (function () {
|
|
|
45
42
|
}
|
|
46
43
|
targetContainer.appendChild(iframe);
|
|
47
44
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
45
|
+
}
|
|
46
|
+
removeIframe() {
|
|
50
47
|
if (this.iframe && this.iframe.parentNode) {
|
|
51
48
|
this.iframe.parentNode.removeChild(this.iframe);
|
|
52
49
|
this.iframe = null;
|
|
53
50
|
this.isLaunched = false;
|
|
54
51
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
52
|
+
}
|
|
53
|
+
setLaunched(launched) {
|
|
57
54
|
this.isLaunched = launched;
|
|
58
|
-
}
|
|
59
|
-
|
|
55
|
+
}
|
|
56
|
+
isWidgetLaunched() {
|
|
60
57
|
return this.isLaunched;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}());
|
|
64
|
-
exports.BaseWidget = BaseWidget;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,74 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.FooterWidget = void 0;
|
|
19
|
-
var BaseWidget_1 = require("../BaseWidget");
|
|
20
|
-
var _environment_1 = require("../../environments/environment.prod.js");
|
|
21
|
-
var event_1 = require("./types/event");
|
|
22
|
-
var FooterWidget = /** @class */ (function (_super) {
|
|
23
|
-
__extends(FooterWidget, _super);
|
|
24
|
-
function FooterWidget() {
|
|
25
|
-
var _this = _super.call(this) || this;
|
|
26
|
-
_this.childAppOrigin = _environment_1.environment.jackpotWidgetUrl;
|
|
1
|
+
import { BaseWidget } from '../BaseWidget';
|
|
2
|
+
import { environment } from '../../environments/environment.prod.js';
|
|
3
|
+
import { FooterIframeIncomingEvent, FooterIframeOutgoingEvent, } from './types/event';
|
|
4
|
+
export class FooterWidget extends BaseWidget {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.childAppOrigin = environment.jackpotWidgetUrl;
|
|
27
8
|
// listen for messages of an app that is inside iframe
|
|
28
|
-
|
|
9
|
+
this.childMessageHandler = (event) => {
|
|
29
10
|
var _a, _b;
|
|
30
|
-
if (!((_a =
|
|
11
|
+
if (!((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.src))
|
|
31
12
|
return;
|
|
32
|
-
if (event.origin !==
|
|
13
|
+
if (event.origin !== this.childAppOrigin)
|
|
33
14
|
return;
|
|
34
15
|
switch ((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) {
|
|
35
|
-
case
|
|
36
|
-
|
|
16
|
+
case FooterIframeIncomingEvent.footerWidgetLoaded:
|
|
17
|
+
this.sendDataToChild(FooterIframeOutgoingEvent.footerWidgetDataInitial, this.data);
|
|
37
18
|
break;
|
|
38
|
-
case
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
case FooterIframeIncomingEvent.showPopup: {
|
|
20
|
+
this.emit('showPopup');
|
|
21
|
+
this.showPopup();
|
|
41
22
|
break;
|
|
42
23
|
}
|
|
43
|
-
case
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
case FooterIframeIncomingEvent.hidePopup: {
|
|
25
|
+
this.emit('hidePopup');
|
|
26
|
+
this.hidePopup();
|
|
46
27
|
break;
|
|
47
28
|
}
|
|
48
|
-
case
|
|
49
|
-
|
|
29
|
+
case FooterIframeIncomingEvent.participateChange: {
|
|
30
|
+
this.emit('participateChange');
|
|
50
31
|
break;
|
|
51
32
|
}
|
|
52
33
|
}
|
|
53
34
|
};
|
|
54
|
-
return _this;
|
|
55
35
|
}
|
|
56
|
-
|
|
36
|
+
static getInstance() {
|
|
57
37
|
if (!FooterWidget.instance) {
|
|
58
38
|
FooterWidget.instance = new FooterWidget();
|
|
59
39
|
}
|
|
60
40
|
return FooterWidget.instance;
|
|
61
|
-
}
|
|
62
|
-
|
|
41
|
+
}
|
|
42
|
+
sendDataToChild(type, data) {
|
|
63
43
|
var _a;
|
|
64
44
|
if (((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) && data !== undefined) {
|
|
65
45
|
this.iframe.contentWindow.postMessage({
|
|
66
|
-
type
|
|
46
|
+
type,
|
|
67
47
|
payload: data,
|
|
68
48
|
}, this.childAppOrigin);
|
|
69
49
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
50
|
+
}
|
|
51
|
+
launchFooter(params) {
|
|
72
52
|
if (this.isWidgetLaunched()) {
|
|
73
53
|
console.warn('Footer widget is already launched');
|
|
74
54
|
return;
|
|
@@ -80,12 +60,12 @@ var FooterWidget = /** @class */ (function (_super) {
|
|
|
80
60
|
this.iframe.style.width = '100%';
|
|
81
61
|
this.iframe.style.height = '50px';
|
|
82
62
|
this.iframe.style.zIndex = '999999'; // 6
|
|
83
|
-
this.iframe.src =
|
|
63
|
+
this.iframe.src = `${environment.jackpotWidgetUrl}/footer-widget`;
|
|
84
64
|
this.appendIframe(this.iframe, params.container);
|
|
85
65
|
this.setLaunched(true);
|
|
86
66
|
window.addEventListener('message', this.childMessageHandler);
|
|
87
|
-
}
|
|
88
|
-
|
|
67
|
+
}
|
|
68
|
+
updateData(partialData) {
|
|
89
69
|
// must be a non-null object
|
|
90
70
|
if (!partialData || typeof partialData !== 'object') {
|
|
91
71
|
console.error('FooterWidget.updateData: invalid payload', partialData);
|
|
@@ -96,22 +76,20 @@ var FooterWidget = /** @class */ (function (_super) {
|
|
|
96
76
|
console.error('FooterWidget.updateData: empty object provided');
|
|
97
77
|
return;
|
|
98
78
|
}
|
|
99
|
-
this.sendDataToChild(
|
|
100
|
-
}
|
|
101
|
-
|
|
79
|
+
this.sendDataToChild(FooterIframeOutgoingEvent.footerWidgetDataUpdated, partialData);
|
|
80
|
+
}
|
|
81
|
+
showPopup() {
|
|
102
82
|
if (this.iframe) {
|
|
103
83
|
this.iframe.style.height = '100%';
|
|
104
84
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
85
|
+
}
|
|
86
|
+
hidePopup() {
|
|
107
87
|
if (this.iframe) {
|
|
108
88
|
this.iframe.style.height = '50px';
|
|
109
89
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
90
|
+
}
|
|
91
|
+
destroyFooter() {
|
|
112
92
|
window.removeEventListener('message', this.childMessageHandler);
|
|
113
93
|
this.removeIframe();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}(BaseWidget_1.BaseWidget));
|
|
117
|
-
exports.FooterWidget = FooterWidget;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FooterIframeOutgoingEvent = exports.FooterIframeIncomingEvent = void 0;
|
|
4
1
|
// events emitted by app inside iframe to the SDK - Internal use
|
|
5
|
-
var FooterIframeIncomingEvent;
|
|
2
|
+
export var FooterIframeIncomingEvent;
|
|
6
3
|
(function (FooterIframeIncomingEvent) {
|
|
7
4
|
FooterIframeIncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
|
|
8
5
|
FooterIframeIncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
|
|
9
6
|
FooterIframeIncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
|
|
10
7
|
FooterIframeIncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
|
|
11
|
-
})(FooterIframeIncomingEvent || (
|
|
8
|
+
})(FooterIframeIncomingEvent || (FooterIframeIncomingEvent = {}));
|
|
12
9
|
// events emitted by SDK to the app inside iframe- Internal use
|
|
13
|
-
var FooterIframeOutgoingEvent;
|
|
10
|
+
export var FooterIframeOutgoingEvent;
|
|
14
11
|
(function (FooterIframeOutgoingEvent) {
|
|
15
12
|
FooterIframeOutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
|
|
16
13
|
FooterIframeOutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
|
|
17
|
-
})(FooterIframeOutgoingEvent || (
|
|
14
|
+
})(FooterIframeOutgoingEvent || (FooterIframeOutgoingEvent = {}));
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,50 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.WonJackpotWidget = void 0;
|
|
19
|
-
var BaseWidget_1 = require("../BaseWidget");
|
|
20
|
-
var _environment_1 = require("../../environments/environment.prod.js");
|
|
21
|
-
var event_1 = require("./types/event");
|
|
22
|
-
var WonJackpotWidget = /** @class */ (function (_super) {
|
|
23
|
-
__extends(WonJackpotWidget, _super);
|
|
24
|
-
function WonJackpotWidget() {
|
|
25
|
-
var _this = _super.call(this) || this;
|
|
26
|
-
_this.childAppOrigin = _environment_1.environment.jackpotWidgetUrl;
|
|
27
|
-
_this.childMessageHandler = function (event) {
|
|
1
|
+
import { BaseWidget } from '../BaseWidget';
|
|
2
|
+
import { environment } from '../../environments/environment.prod.js';
|
|
3
|
+
import { WonJackpotIframeIncomingEvent } from './types/event';
|
|
4
|
+
export class WonJackpotWidget extends BaseWidget {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.childAppOrigin = environment.jackpotWidgetUrl;
|
|
8
|
+
this.childMessageHandler = (event) => {
|
|
28
9
|
var _a, _b;
|
|
29
|
-
if (!((_a =
|
|
10
|
+
if (!((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.src))
|
|
30
11
|
return;
|
|
31
|
-
if (event.origin !==
|
|
12
|
+
if (event.origin !== this.childAppOrigin)
|
|
32
13
|
return;
|
|
33
14
|
switch ((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) {
|
|
34
|
-
case
|
|
35
|
-
|
|
15
|
+
case WonJackpotIframeIncomingEvent.jackpotWinClose:
|
|
16
|
+
this.emit('close');
|
|
36
17
|
break;
|
|
37
18
|
}
|
|
38
19
|
};
|
|
39
|
-
return _this;
|
|
40
20
|
}
|
|
41
|
-
|
|
21
|
+
static getInstance() {
|
|
42
22
|
if (!WonJackpotWidget.instance) {
|
|
43
23
|
WonJackpotWidget.instance = new WonJackpotWidget();
|
|
44
24
|
}
|
|
45
25
|
return WonJackpotWidget.instance;
|
|
46
|
-
}
|
|
47
|
-
|
|
26
|
+
}
|
|
27
|
+
launchWonJackpot(params) {
|
|
48
28
|
if (this.isWidgetLaunched()) {
|
|
49
29
|
console.warn('Won Jackpot widget is already launched');
|
|
50
30
|
return;
|
|
@@ -56,15 +36,13 @@ var WonJackpotWidget = /** @class */ (function (_super) {
|
|
|
56
36
|
this.iframe.style.height = '100%';
|
|
57
37
|
this.iframe.style.zIndex = '9999999'; // 7
|
|
58
38
|
this.iframe.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
|
59
|
-
this.iframe.src =
|
|
39
|
+
this.iframe.src = `${environment.jackpotWidgetUrl}/win-animation-widget`;
|
|
60
40
|
this.appendIframe(this.iframe, params.container);
|
|
61
41
|
this.setLaunched(true);
|
|
62
42
|
window.addEventListener('message', this.childMessageHandler);
|
|
63
|
-
}
|
|
64
|
-
|
|
43
|
+
}
|
|
44
|
+
destroyWonJackpot() {
|
|
65
45
|
window.removeEventListener('message', this.childMessageHandler);
|
|
66
46
|
this.removeIframe();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}(BaseWidget_1.BaseWidget));
|
|
70
|
-
exports.WonJackpotWidget = WonJackpotWidget;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WonJackpotIframeIncomingEvent = void 0;
|
|
4
1
|
// events emitted by app inside iframe to the SDK - Internal use
|
|
5
|
-
var WonJackpotIframeIncomingEvent;
|
|
2
|
+
export var WonJackpotIframeIncomingEvent;
|
|
6
3
|
(function (WonJackpotIframeIncomingEvent) {
|
|
7
4
|
WonJackpotIframeIncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
|
|
8
5
|
WonJackpotIframeIncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
|
|
9
6
|
WonJackpotIframeIncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
|
|
10
7
|
WonJackpotIframeIncomingEvent["jackpotWinClose"] = "jackpot-win-close";
|
|
11
|
-
})(WonJackpotIframeIncomingEvent || (
|
|
8
|
+
})(WonJackpotIframeIncomingEvent || (WonJackpotIframeIncomingEvent = {}));
|
package/package.json
CHANGED