@splash-tech/jackpot-sdk 1.0.0 → 1.0.2

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.
@@ -0,0 +1,4 @@
1
+ export declare const environment: {
2
+ production: boolean;
3
+ jackpotWidgetUrl: string;
4
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SplashJackpotsSDK } from './types';
1
+ import { SplashJackpotSDK } from './types';
2
2
  import { FooterWidgetParams } from './widgets/footerWidget/types/data';
3
3
  import { WonJackpotWidgetParams } from './widgets/wonJackpotWidget/types/data';
4
- export declare const splashJackpots: SplashJackpotsSDK;
5
- export type { SplashJackpotsSDK, FooterWidgetParams, WonJackpotWidgetParams };
4
+ export declare const splashJackpot: SplashJackpotSDK;
5
+ export type { SplashJackpotSDK as SplashJackpot, FooterWidgetParams, WonJackpotWidgetParams, };
package/dist/index.js CHANGED
@@ -1,38 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splashJackpots = void 0;
4
- var FooterWidget_1 = require("./widgets/footerWidget/FooterWidget");
5
- var WonJackpotWidget_1 = require("./widgets/wonJackpotWidget/WonJackpotWidget");
6
- exports.splashJackpots = {
7
- footer: {
8
- isLaunched: function () { return FooterWidget_1.FooterWidget.getInstance().isWidgetLaunched(); },
9
- launch: function (params) {
10
- return FooterWidget_1.FooterWidget.getInstance().launchFooter(params);
11
- },
12
- updateData: function (partialData) {
13
- return FooterWidget_1.FooterWidget.getInstance().updateData(partialData);
14
- },
15
- showPopup: function () { return FooterWidget_1.FooterWidget.getInstance().showPopup(); },
16
- hidePopup: function () { return FooterWidget_1.FooterWidget.getInstance().hidePopup(); },
17
- destroy: function () { return FooterWidget_1.FooterWidget.getInstance().destroyFooter(); },
18
- addEventListener: function (event, handler) {
19
- return FooterWidget_1.FooterWidget.getInstance().addEventListener(event, handler);
20
- },
21
- removeEventListener: function (event, handler) {
22
- return FooterWidget_1.FooterWidget.getInstance().removeEventListener(event, handler);
23
- },
24
- },
25
- wonJackpot: {
26
- isLaunched: function () { return WonJackpotWidget_1.WonJackpotWidget.getInstance().isWidgetLaunched(); },
27
- launch: function (params) {
28
- return WonJackpotWidget_1.WonJackpotWidget.getInstance().launchWonJackpot(params);
29
- },
30
- destroy: function () { return WonJackpotWidget_1.WonJackpotWidget.getInstance().destroyWonJackpot(); },
31
- addEventListener: function (event, handler) {
32
- return WonJackpotWidget_1.WonJackpotWidget.getInstance().addEventListener(event, handler);
33
- },
34
- removeEventListener: function (event, handler) {
35
- return WonJackpotWidget_1.WonJackpotWidget.getInstance().removeEventListener(event, handler);
36
- },
37
- },
38
- };
1
+ var e={283(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.environment=void 0,t.environment={production:!0,jackpotWidgetUrl:"https://jackpot-widget.splash.tech"}},529(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BaseWidget=void 0;var o=function(){function e(){this.iframe=null,this.isLaunched=!1,this.listeners=new Map}return e.prototype.emit=function(e,t){var o=this.listeners.get(e);null==o||o.forEach(function(e){return e()})},e.prototype.addEventListener=function(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)},e.prototype.removeEventListener=function(e,t){var o=this.listeners.get(e);o&&this.listeners.set(e,o.filter(function(e){return e!==t}))},e.prototype.createIframe=function(){var e=document.createElement("iframe");return e.style.border="none",e.style.position="fixed",e.style.zIndex="999999",e},e.prototype.appendIframe=function(e,t){var o=t?document.querySelector(t):document.body;o?(t&&(e.style.position="absolute",o.style.position="relative"),o.appendChild(e)):(console.error('Container "'.concat(t,'" not found')),document.body.appendChild(e))},e.prototype.removeIframe=function(){this.iframe&&this.iframe.parentNode&&(this.iframe.parentNode.removeChild(this.iframe),this.iframe=null,this.isLaunched=!1)},e.prototype.setLaunched=function(e){this.isLaunched=e},e.prototype.isWidgetLaunched=function(){return this.isLaunched},e}();t.BaseWidget=o},489(e,t,o){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)});Object.defineProperty(t,"__esModule",{value:!0}),t.FooterWidget=void 0;var r=o(529),a=o(283),s=o(978),c=function(e){function t(){var t=e.call(this)||this;return t.childAppOrigin=a.environment.jackpotWidgetUrl,t.childMessageHandler=function(e){var o,n;if((null===(o=t.iframe)||void 0===o?void 0:o.src)&&e.origin===t.childAppOrigin)switch(null===(n=e.data)||void 0===n?void 0:n.type){case s.FooterIframeIncomingEvent.footerWidgetLoaded:t.sendDataToChild(s.FooterIframeOutgoingEvent.footerWidgetDataInitial,t.data);break;case s.FooterIframeIncomingEvent.showPopup:t.emit("showPopup"),t.showPopup();break;case s.FooterIframeIncomingEvent.hidePopup:t.emit("hidePopup"),t.hidePopup();break;case s.FooterIframeIncomingEvent.participateChange:t.emit("participateChange")}},t}return i(t,e),t.getInstance=function(){return t.instance||(t.instance=new t),t.instance},t.prototype.sendDataToChild=function(e,t){var o;(null===(o=this.iframe)||void 0===o?void 0:o.contentWindow)&&void 0!==t&&this.iframe.contentWindow.postMessage({type:e,payload:t},this.childAppOrigin)},t.prototype.launchFooter=function(e){this.isWidgetLaunched()?console.warn("Footer widget is already launched"):(this.data=e.data,this.iframe=this.createIframe(),this.iframe.style.bottom="0",this.iframe.style.left="0",this.iframe.style.width="100%",this.iframe.style.height="50px",this.iframe.style.zIndex="999999",this.iframe.src="".concat(a.environment.jackpotWidgetUrl,"/footer-widget"),this.appendIframe(this.iframe,e.container),this.setLaunched(!0),window.addEventListener("message",this.childMessageHandler))},t.prototype.updateData=function(e){e&&"object"==typeof e?0!==Object.keys(e).length?this.sendDataToChild(s.FooterIframeOutgoingEvent.footerWidgetDataUpdated,e):console.error("FooterWidget.updateData: empty object provided"):console.error("FooterWidget.updateData: invalid payload",e)},t.prototype.showPopup=function(){this.iframe&&(this.iframe.style.height="100%")},t.prototype.hidePopup=function(){this.iframe&&(this.iframe.style.height="50px")},t.prototype.destroyFooter=function(){window.removeEventListener("message",this.childMessageHandler),this.removeIframe()},t}(r.BaseWidget);t.FooterWidget=c},978(e,t){var o,n;Object.defineProperty(t,"__esModule",{value:!0}),t.FooterIframeOutgoingEvent=t.FooterIframeIncomingEvent=void 0,function(e){e.footerWidgetLoaded="jackpot-footer-widget-loaded",e.participateChange="jackpot-footer-widget-participate-change",e.showPopup="jackpot-footer-widget-popup-show",e.hidePopup="jackpot-footer-widget-popup-hide"}(o||(t.FooterIframeIncomingEvent=o={})),function(e){e.footerWidgetDataInitial="jackpot-footer-widget-data-initial",e.footerWidgetDataUpdated="jackpot-footer-widget-data-updated"}(n||(t.FooterIframeOutgoingEvent=n={}))},79(e,t,o){var n,i=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)});Object.defineProperty(t,"__esModule",{value:!0}),t.WonJackpotWidget=void 0;var r=o(529),a=o(283),s=o(95),c=function(e){function t(){var t=e.call(this)||this;return t.childAppOrigin=a.environment.jackpotWidgetUrl,t.childMessageHandler=function(e){var o,n;(null===(o=t.iframe)||void 0===o?void 0:o.src)&&e.origin===t.childAppOrigin&&(null===(n=e.data)||void 0===n?void 0:n.type)===s.WonJackpotIframeIncomingEvent.jackpotWinClose&&t.emit("close")},t}return i(t,e),t.getInstance=function(){return t.instance||(t.instance=new t),t.instance},t.prototype.launchWonJackpot=function(e){this.isWidgetLaunched()?console.warn("Won Jackpot widget is already launched"):(this.iframe=this.createIframe(),this.iframe.style.top="0",this.iframe.style.left="0",this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.zIndex="9999999",this.iframe.style.backgroundColor="rgba(0, 0, 0, 0.5)",this.iframe.src="".concat(a.environment.jackpotWidgetUrl,"/win-animation-widget"),this.appendIframe(this.iframe,e.container),this.setLaunched(!0),window.addEventListener("message",this.childMessageHandler))},t.prototype.destroyWonJackpot=function(){window.removeEventListener("message",this.childMessageHandler),this.removeIframe()},t}(r.BaseWidget);t.WonJackpotWidget=c},95(e,t){var o;Object.defineProperty(t,"__esModule",{value:!0}),t.WonJackpotIframeIncomingEvent=void 0,function(e){e.footerWidgetLoaded="jackpot-footer-widget-loaded",e.participateChange="jackpot-footer-widget-participate-change",e.showPopup="jackpot-footer-widget-popup-show",e.jackpotWinClose="jackpot-win-close"}(o||(t.WonJackpotIframeIncomingEvent=o={}))}},t={};function o(n){var i=t[n];if(void 0!==i)return i.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,o),r.exports}var n={};(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.splashJackpot=void 0;var t=o(489),i=o(79),r=t.FooterWidget.getInstance(),a=i.WonJackpotWidget.getInstance();e.splashJackpot={footer:{isLaunched:function(){return r.isWidgetLaunched()},launch:function(e){return r.launchFooter(e)},updateData:function(e){return r.updateData(e)},showPopup:function(){return r.showPopup()},hidePopup:function(){return r.hidePopup()},destroy:function(){return r.destroyFooter()},addEventListener:function(e,t){return r.addEventListener(e,t)},removeEventListener:function(e,t){return r.removeEventListener(e,t)}},wonJackpot:{isLaunched:function(){return a.isWidgetLaunched()},launch:function(e){return a.launchWonJackpot(e)},destroy:function(){return a.destroyWonJackpot()},addEventListener:function(e,t){return a.addEventListener(e,t)},removeEventListener:function(e,t){return a.removeEventListener(e,t)}}}})();const i=n.__esModule,r=n.splashJackpot;export{i as __esModule,r as splashJackpot,n as default};
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ 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
5
  import { WonJackpotWidgetEvents } from './widgets/wonJackpotWidget/types/event';
6
- export interface SplashJackpotsSDK {
6
+ export interface SplashJackpotSDK {
7
7
  footer: {
8
8
  isLaunched: () => boolean;
9
9
  launch: (params: FooterWidgetParams) => void;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@splash-tech/jackpot-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "SDK for managing jackpot widgets in iframes",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "files": [
@@ -9,12 +10,16 @@
9
10
  "README.md"
10
11
  ],
11
12
  "scripts": {
12
- "clean": "rm -rf dist",
13
- "build:local": "npm run clean && tsc -p tsconfig.build.local.json",
14
- "build:dev": "npm run clean && tsc -p tsconfig.build.dev.json",
15
- "build:staging": "npm run clean && tsc -p tsconfig.build.staging.json",
16
- "build:prod": "npm run clean && tsc -p tsconfig.build.prod.json",
17
- "prepublishOnly": "npm run build:prod"
13
+ "build": "webpack --env local --mode development",
14
+ "build:dev": "webpack --env dev --mode development",
15
+ "build:staging": "webpack --env staging --mode production",
16
+ "build:prod": "webpack --env production --mode production",
17
+ "serve": "webpack serve --env local --mode development",
18
+ "serve:dev": "webpack serve --env dev --mode development",
19
+ "serve:staging": "webpack serve --env staging --mode production",
20
+ "serve:prod": "webpack serve --env production --mode production",
21
+ "prepublishOnly": "npm run build:prod",
22
+ "test": "echo \"Error: no test specified\" && exit 1"
18
23
  },
19
24
  "keywords": [
20
25
  "jackpot",
@@ -26,6 +31,10 @@
26
31
  "license": "MIT",
27
32
  "devDependencies": {
28
33
  "@types/node": "^20.11.19",
29
- "typescript": "^5.8.2"
34
+ "ts-loader": "^9.5.4",
35
+ "tsc-alias": "^1.8.16",
36
+ "typescript": "^5.8.2",
37
+ "webpack": "^5.105.3",
38
+ "webpack-cli": "^6.0.1"
30
39
  }
31
40
  }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.environment = void 0;
4
- exports.environment = {
5
- production: true,
6
- jackpotWidgetUrl: 'https://jackpot-widget.splash.tech',
7
- };
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseWidget = void 0;
4
- var BaseWidget = /** @class */ (function () {
5
- function BaseWidget() {
6
- this.iframe = null;
7
- this.isLaunched = false;
8
- this.listeners = new Map();
9
- }
10
- BaseWidget.prototype.emit = function (event, payload) {
11
- var handlers = this.listeners.get(event);
12
- handlers === null || handlers === void 0 ? void 0 : handlers.forEach(function (handler) { return handler(); });
13
- };
14
- BaseWidget.prototype.addEventListener = function (event, handler) {
15
- if (!this.listeners.has(event)) {
16
- this.listeners.set(event, []);
17
- }
18
- this.listeners.get(event).push(handler);
19
- };
20
- BaseWidget.prototype.removeEventListener = function (event, handler) {
21
- var handlers = this.listeners.get(event);
22
- if (!handlers)
23
- return;
24
- this.listeners.set(event, handlers.filter(function (h) { return h !== handler; }));
25
- };
26
- BaseWidget.prototype.createIframe = function () {
27
- var iframe = document.createElement('iframe');
28
- iframe.style.border = 'none';
29
- iframe.style.position = 'fixed';
30
- iframe.style.zIndex = '999999';
31
- return iframe;
32
- };
33
- BaseWidget.prototype.appendIframe = function (iframe, container) {
34
- var targetContainer = container
35
- ? document.querySelector(container)
36
- : document.body;
37
- if (!targetContainer) {
38
- console.error("Container \"".concat(container, "\" not found"));
39
- document.body.appendChild(iframe);
40
- }
41
- else {
42
- if (container) {
43
- iframe.style.position = 'absolute';
44
- targetContainer.style.position = 'relative';
45
- }
46
- targetContainer.appendChild(iframe);
47
- }
48
- };
49
- BaseWidget.prototype.removeIframe = function () {
50
- if (this.iframe && this.iframe.parentNode) {
51
- this.iframe.parentNode.removeChild(this.iframe);
52
- this.iframe = null;
53
- this.isLaunched = false;
54
- }
55
- };
56
- BaseWidget.prototype.setLaunched = function (launched) {
57
- this.isLaunched = launched;
58
- };
59
- BaseWidget.prototype.isWidgetLaunched = function () {
60
- return this.isLaunched;
61
- };
62
- return BaseWidget;
63
- }());
64
- exports.BaseWidget = BaseWidget;
@@ -1,117 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
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("@environment");
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;
27
- // listen for messages of an app that is inside iframe
28
- _this.childMessageHandler = function (event) {
29
- var _a, _b;
30
- if (!((_a = _this.iframe) === null || _a === void 0 ? void 0 : _a.src))
31
- return;
32
- if (event.origin !== _this.childAppOrigin)
33
- return;
34
- switch ((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) {
35
- case event_1.FooterIframeIncomingEvent.footerWidgetLoaded:
36
- _this.sendDataToChild(event_1.FooterIframeOutgoingEvent.footerWidgetDataInitial, _this.data);
37
- break;
38
- case event_1.FooterIframeIncomingEvent.showPopup: {
39
- _this.emit('showPopup');
40
- _this.showPopup();
41
- break;
42
- }
43
- case event_1.FooterIframeIncomingEvent.hidePopup: {
44
- _this.emit('hidePopup');
45
- _this.hidePopup();
46
- break;
47
- }
48
- case event_1.FooterIframeIncomingEvent.participateChange: {
49
- _this.emit('participateChange');
50
- break;
51
- }
52
- }
53
- };
54
- return _this;
55
- }
56
- FooterWidget.getInstance = function () {
57
- if (!FooterWidget.instance) {
58
- FooterWidget.instance = new FooterWidget();
59
- }
60
- return FooterWidget.instance;
61
- };
62
- FooterWidget.prototype.sendDataToChild = function (type, data) {
63
- var _a;
64
- if (((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) && data !== undefined) {
65
- this.iframe.contentWindow.postMessage({
66
- type: type,
67
- payload: data,
68
- }, this.childAppOrigin);
69
- }
70
- };
71
- FooterWidget.prototype.launchFooter = function (params) {
72
- if (this.isWidgetLaunched()) {
73
- console.warn('Footer widget is already launched');
74
- return;
75
- }
76
- this.data = params.data;
77
- this.iframe = this.createIframe();
78
- this.iframe.style.bottom = '0';
79
- this.iframe.style.left = '0';
80
- this.iframe.style.width = '100%';
81
- this.iframe.style.height = '50px';
82
- this.iframe.style.zIndex = '999999'; // 6
83
- this.iframe.src = "".concat(_environment_1.environment.jackpotWidgetUrl, "/footer-widget");
84
- this.appendIframe(this.iframe, params.container);
85
- this.setLaunched(true);
86
- window.addEventListener('message', this.childMessageHandler);
87
- };
88
- FooterWidget.prototype.updateData = function (partialData) {
89
- // must be a non-null object
90
- if (!partialData || typeof partialData !== 'object') {
91
- console.error('FooterWidget.updateData: invalid payload', partialData);
92
- return;
93
- }
94
- // ignore empty object {}
95
- if (Object.keys(partialData).length === 0) {
96
- console.error('FooterWidget.updateData: empty object provided');
97
- return;
98
- }
99
- this.sendDataToChild(event_1.FooterIframeOutgoingEvent.footerWidgetDataUpdated, partialData);
100
- };
101
- FooterWidget.prototype.showPopup = function () {
102
- if (this.iframe) {
103
- this.iframe.style.height = '100%';
104
- }
105
- };
106
- FooterWidget.prototype.hidePopup = function () {
107
- if (this.iframe) {
108
- this.iframe.style.height = '50px';
109
- }
110
- };
111
- FooterWidget.prototype.destroyFooter = function () {
112
- window.removeEventListener('message', this.childMessageHandler);
113
- this.removeIframe();
114
- };
115
- return FooterWidget;
116
- }(BaseWidget_1.BaseWidget));
117
- exports.FooterWidget = FooterWidget;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FooterIframeOutgoingEvent = exports.FooterIframeIncomingEvent = void 0;
4
- // events emitted by app inside iframe to the SDK - Internal use
5
- var FooterIframeIncomingEvent;
6
- (function (FooterIframeIncomingEvent) {
7
- FooterIframeIncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
8
- FooterIframeIncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
9
- FooterIframeIncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
10
- FooterIframeIncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
11
- })(FooterIframeIncomingEvent || (exports.FooterIframeIncomingEvent = FooterIframeIncomingEvent = {}));
12
- // events emitted by SDK to the app inside iframe- Internal use
13
- var FooterIframeOutgoingEvent;
14
- (function (FooterIframeOutgoingEvent) {
15
- FooterIframeOutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
16
- FooterIframeOutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
17
- })(FooterIframeOutgoingEvent || (exports.FooterIframeOutgoingEvent = FooterIframeOutgoingEvent = {}));
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
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("@environment");
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) {
28
- var _a, _b;
29
- if (!((_a = _this.iframe) === null || _a === void 0 ? void 0 : _a.src))
30
- return;
31
- if (event.origin !== _this.childAppOrigin)
32
- return;
33
- switch ((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) {
34
- case event_1.WonJackpotIframeIncomingEvent.jackpotWinClose:
35
- _this.emit('close');
36
- break;
37
- }
38
- };
39
- return _this;
40
- }
41
- WonJackpotWidget.getInstance = function () {
42
- if (!WonJackpotWidget.instance) {
43
- WonJackpotWidget.instance = new WonJackpotWidget();
44
- }
45
- return WonJackpotWidget.instance;
46
- };
47
- WonJackpotWidget.prototype.launchWonJackpot = function (params) {
48
- if (this.isWidgetLaunched()) {
49
- console.warn('Won Jackpot widget is already launched');
50
- return;
51
- }
52
- this.iframe = this.createIframe();
53
- this.iframe.style.top = '0';
54
- this.iframe.style.left = '0';
55
- this.iframe.style.width = '100%';
56
- this.iframe.style.height = '100%';
57
- this.iframe.style.zIndex = '9999999'; // 7
58
- this.iframe.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
59
- this.iframe.src = "".concat(_environment_1.environment.jackpotWidgetUrl, "/win-animation-widget");
60
- this.appendIframe(this.iframe, params.container);
61
- this.setLaunched(true);
62
- window.addEventListener('message', this.childMessageHandler);
63
- };
64
- WonJackpotWidget.prototype.destroyWonJackpot = function () {
65
- window.removeEventListener('message', this.childMessageHandler);
66
- this.removeIframe();
67
- };
68
- return WonJackpotWidget;
69
- }(BaseWidget_1.BaseWidget));
70
- exports.WonJackpotWidget = WonJackpotWidget;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WonJackpotIframeIncomingEvent = void 0;
4
- // events emitted by app inside iframe to the SDK - Internal use
5
- var WonJackpotIframeIncomingEvent;
6
- (function (WonJackpotIframeIncomingEvent) {
7
- WonJackpotIframeIncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
8
- WonJackpotIframeIncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
9
- WonJackpotIframeIncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
10
- WonJackpotIframeIncomingEvent["jackpotWinClose"] = "jackpot-win-close";
11
- })(WonJackpotIframeIncomingEvent || (exports.WonJackpotIframeIncomingEvent = WonJackpotIframeIncomingEvent = {}));