@splash-tech/jackpot-sdk 1.0.0

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 ADDED
@@ -0,0 +1,94 @@
1
+ # Splash Jackpot SDK
2
+
3
+ A TypeScript library for managing jackpot widgets
4
+
5
+ ### SDK Initialization
6
+
7
+ You can include the SDK directly in your HTML file:
8
+
9
+ ```html
10
+ <script src="http://jackpot-lib.splash.tech/splash-jackpots.js"></script>
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ The SDK allows you to specify a target container for the widgets:
16
+
17
+ - Use any valid CSS selector (e.g., '#my-container', '.my-class')
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
23
+
24
+ ```typescript
25
+ // Launch footer widget in default container (body)
26
+ SplashJackpots.footer.launch({
27
+ data: 'your-data', // pass data to footer widget
28
+ });
29
+
30
+ // Launch footer widget inside a specific container
31
+ SplashJackpots.footer.launch({
32
+ container: '#footer-container', // CSS selector for the container
33
+ data: 'your-data', // pass data to footer widget
34
+ });
35
+
36
+ // Destroy footer widget
37
+ SplashJackpots.footer.destroy();
38
+ ```
39
+
40
+ In order to avoid typescript errors, you need to add the following jackpot-widget.d.ts file to your project:
41
+
42
+ _NOTE: Name of the file could be different_
43
+
44
+ ```typescript
45
+ export interface WidgetParams {
46
+ container?: string; // Optional container ID/selector
47
+ data: unknown;
48
+ }
49
+
50
+ export interface SplashJackpotsSDK {
51
+ footer: {
52
+ isLaunched: () => boolean;
53
+ launch: (params: WidgetParams) => void;
54
+ destroy: () => void;
55
+ };
56
+ wonJackpot: {
57
+ isLaunched: () => boolean;
58
+ launch: (params: WidgetParams) => void;
59
+ destroy: () => void;
60
+ };
61
+ }
62
+
63
+ declare global {
64
+ const SplashJackpots: SplashJackpotsSDK;
65
+
66
+ interface Window {
67
+ SplashJackpots: SplashJackpotsSDK;
68
+ }
69
+ }
70
+ ```
71
+
72
+ ## Development
73
+
74
+ ```bash
75
+ # Install dependencies
76
+ npm install
77
+
78
+ # Build the library
79
+ npm run build # Local build
80
+ npm run build:dev # Development build
81
+ npm run build:staging # Staging build
82
+ npm run build:prod # Production build
83
+
84
+ # Run server
85
+ npm run serve # Local environment
86
+ npm run serve:dev # Development environment
87
+ npm run serve:staging # Staging environment
88
+ npm run serve:prod # Production environment
89
+ ```
90
+
91
+ Build script will create a `dist` folder containing:
92
+
93
+ - `splash-jackpots.js` - The bundled library
94
+ - `splash-jackpots.d.ts` - TypeScript type definitions
@@ -0,0 +1,4 @@
1
+ export declare const environment: {
2
+ production: boolean;
3
+ jackpotWidgetUrl: string;
4
+ };
@@ -0,0 +1,7 @@
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
+ };
@@ -0,0 +1,5 @@
1
+ import { SplashJackpotsSDK } from './types';
2
+ import { FooterWidgetParams } from './widgets/footerWidget/types/data';
3
+ import { WonJackpotWidgetParams } from './widgets/wonJackpotWidget/types/data';
4
+ export declare const splashJackpots: SplashJackpotsSDK;
5
+ export type { SplashJackpotsSDK, FooterWidgetParams, WonJackpotWidgetParams };
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
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
+ };
@@ -0,0 +1,24 @@
1
+ import { FooterWidgetParams } from './widgets/footerWidget/types/data';
2
+ import { FooterWidgetEvents } from './widgets/footerWidget/types/event';
3
+ import { WidgetEventHandler } from './widgets/shared/types';
4
+ import { WonJackpotWidgetParams } from './widgets/wonJackpotWidget/types/data';
5
+ import { WonJackpotWidgetEvents } from './widgets/wonJackpotWidget/types/event';
6
+ export interface SplashJackpotsSDK {
7
+ footer: {
8
+ isLaunched: () => boolean;
9
+ launch: (params: FooterWidgetParams) => void;
10
+ updateData: (partialData: unknown) => void;
11
+ showPopup: () => void;
12
+ hidePopup: () => void;
13
+ destroy: () => void;
14
+ addEventListener(event: keyof FooterWidgetEvents, handler: WidgetEventHandler): void;
15
+ removeEventListener(event: keyof FooterWidgetEvents, handler: WidgetEventHandler): void;
16
+ };
17
+ wonJackpot: {
18
+ isLaunched: () => boolean;
19
+ launch: (params: WonJackpotWidgetParams) => void;
20
+ destroy: () => void;
21
+ addEventListener(event: keyof WonJackpotWidgetEvents, handler: WidgetEventHandler): void;
22
+ removeEventListener(event: keyof WonJackpotWidgetEvents, handler: WidgetEventHandler): void;
23
+ };
24
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import { WidgetEventHandler } from './shared/types';
2
+ export declare abstract class BaseWidget {
3
+ protected iframe: HTMLIFrameElement | null;
4
+ protected isLaunched: boolean;
5
+ private listeners;
6
+ protected emit(event: string, payload?: unknown): void;
7
+ addEventListener(event: string, handler: WidgetEventHandler): void;
8
+ removeEventListener(event: string, handler: WidgetEventHandler): void;
9
+ protected createIframe(): HTMLIFrameElement;
10
+ protected appendIframe(iframe: HTMLIFrameElement, container?: string): void;
11
+ protected removeIframe(): void;
12
+ protected setLaunched(launched: boolean): void;
13
+ isWidgetLaunched(): boolean;
14
+ }
@@ -0,0 +1,64 @@
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;
@@ -0,0 +1,16 @@
1
+ import { BaseWidget } from '../BaseWidget';
2
+ import { FooterWidgetParams } from './types/data';
3
+ export declare class FooterWidget extends BaseWidget {
4
+ private static instance;
5
+ private childAppOrigin;
6
+ private data;
7
+ private constructor();
8
+ static getInstance(): FooterWidget;
9
+ private childMessageHandler;
10
+ private sendDataToChild;
11
+ launchFooter(params: FooterWidgetParams): void;
12
+ updateData(partialData: unknown): void;
13
+ showPopup(): void;
14
+ hidePopup(): void;
15
+ destroyFooter(): void;
16
+ }
@@ -0,0 +1,117 @@
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;
@@ -0,0 +1,152 @@
1
+ export interface FooterWidgetParams {
2
+ container?: string;
3
+ data: unknown;
4
+ }
5
+ export interface FooterWidgetData {
6
+ group: JackpotGroupResponse;
7
+ newGroup: JackpotGroupResponseNew;
8
+ theme: JackpotThemeResponse;
9
+ participate: JackpotParticipation;
10
+ }
11
+ export interface JackpotGroup {
12
+ uuid: string;
13
+ name: string;
14
+ brands: string[];
15
+ tags: {
16
+ tag: string;
17
+ }[];
18
+ deleted: boolean;
19
+ }
20
+ export interface JackpotGroupResponse {
21
+ jackpotGroup: JackpotGroup | null;
22
+ theme: Theme | null;
23
+ jackpotLevels: JackpotLevel[];
24
+ }
25
+ export interface JackpotLevel {
26
+ uuid: string;
27
+ name: string;
28
+ currency: string;
29
+ values: {
30
+ [key: string]: number;
31
+ };
32
+ won: boolean;
33
+ paused: boolean;
34
+ prizeLabel: string | null;
35
+ iconAsset: Asset | null;
36
+ }
37
+ export interface JackpotLevelWithColor extends JackpotLevel {
38
+ filter: string;
39
+ background: string;
40
+ }
41
+ export interface WonJackpotLevel extends JackpotLevelWithColor {
42
+ winAmount: number;
43
+ }
44
+ export interface JackpotSegment {
45
+ icon: string;
46
+ backgroundColor: string;
47
+ label: string;
48
+ index: number;
49
+ isWon: boolean;
50
+ filter: string;
51
+ }
52
+ export interface Theme extends BaseTheme {
53
+ clientLogoAsset: Asset | null;
54
+ jackpotLogoAsset: Asset | null;
55
+ jackpotPopupImageAsset: Asset | null;
56
+ lockingSymbolSoundAsset: Asset | null;
57
+ resultNoPrizeSoundAsset: Asset | null;
58
+ resultPrizeRevealSoundAsset: Asset | null;
59
+ spinSoundAsset: Asset | null;
60
+ }
61
+ export interface JackpotGroupResponseNew {
62
+ uuid: string;
63
+ noOfWins: number;
64
+ totalWinAmount: number;
65
+ currentCounters: JackpotCounter[];
66
+ }
67
+ export interface JackpotCounter {
68
+ uuid: string;
69
+ name: string;
70
+ currency: string;
71
+ currentValue: number;
72
+ totalUserLevelContributionPerSpin: number;
73
+ }
74
+ export interface JackpotThemeResponse {
75
+ theme: Theme;
76
+ }
77
+ export interface JackpotParticipation {
78
+ jackpotId: string;
79
+ participate: boolean;
80
+ tag: string | null;
81
+ }
82
+ export interface Asset {
83
+ uuid: string;
84
+ createdTs: string;
85
+ name: string;
86
+ label: string;
87
+ comment: string;
88
+ url: string;
89
+ tags: string[];
90
+ type: AssetType;
91
+ sportType: SportType;
92
+ }
93
+ export declare enum AssetType {
94
+ GAME = "GAME",
95
+ REPORT = "REPORT",
96
+ FONT = "FONT",
97
+ CLIENT = "CLIENT",
98
+ AUDIO = "AUDIO"
99
+ }
100
+ export declare enum SportType {
101
+ SOCCER = "SOCCER",
102
+ CRICKET = "CRICKET",
103
+ BASKETBALL = "BASKETBALL",
104
+ ICE_HOCKEY = "ICE HOCKEY",
105
+ RUGBY = "RUGBY",
106
+ MMA = "MMA",
107
+ BOXING = "BOXING",
108
+ BASEBALL = "BASEBALL",
109
+ GOLF = "GOLF",
110
+ TENNIS = "TENNIS",
111
+ E_SPORTS = "E-SPORTS",
112
+ FORMULA_1 = "FORMULA 1",
113
+ OTHER = "OTHER",
114
+ DARTS = "DARTS",
115
+ OLYMPICS = "OLYMPICS",
116
+ VOLLEYBALL = "VOLLEYBALL",
117
+ AMERICAN_FOOTBALL = "AMERICAN FOOTBALL"
118
+ }
119
+ export interface BaseTheme {
120
+ uuid: string;
121
+ createdTs: string;
122
+ updatedTs: string;
123
+ name: string;
124
+ cssVariables: ConfigValue[];
125
+ primaryFontRegularAsset: Asset;
126
+ primaryFontMediumAsset: Asset;
127
+ primaryFontBoldAsset: Asset;
128
+ jackpotFontAsset: Asset;
129
+ darkMode: boolean;
130
+ backgroundAnimation: BackgroundAnimationType | null;
131
+ labels: ConfigValue[];
132
+ cornerRadiusCta: number;
133
+ termsAndConditions: string | null;
134
+ rules: string | null;
135
+ faq: string | null;
136
+ secondaryCtaStyle: CTAStyles | null;
137
+ }
138
+ export declare enum CTAStyles {
139
+ Outline = "OUTLINE",
140
+ Solid = "SOLID"
141
+ }
142
+ export interface ConfigValue {
143
+ uuid: string;
144
+ key: string;
145
+ description: string;
146
+ value: string;
147
+ hint: string;
148
+ }
149
+ export declare enum BackgroundAnimationType {
150
+ SNOW = "SNOW",
151
+ SPARKLE = "SPARKLE"
152
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ export declare enum FooterIframeIncomingEvent {
2
+ footerWidgetLoaded = "jackpot-footer-widget-loaded",
3
+ participateChange = "jackpot-footer-widget-participate-change",
4
+ showPopup = "jackpot-footer-widget-popup-show",
5
+ hidePopup = "jackpot-footer-widget-popup-hide"
6
+ }
7
+ export declare enum FooterIframeOutgoingEvent {
8
+ footerWidgetDataInitial = "jackpot-footer-widget-data-initial",
9
+ footerWidgetDataUpdated = "jackpot-footer-widget-data-updated"
10
+ }
11
+ export type FooterWidgetEvents = {
12
+ participateChange: void;
13
+ showPopup: void;
14
+ hidePopup: void;
15
+ };
@@ -0,0 +1,17 @@
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 = {}));
@@ -0,0 +1 @@
1
+ export type WidgetEventHandler = () => void;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { BaseWidget } from '../BaseWidget';
2
+ import { WonJackpotWidgetParams } from './types/data';
3
+ export declare class WonJackpotWidget extends BaseWidget {
4
+ private static instance;
5
+ private childAppOrigin;
6
+ private constructor();
7
+ static getInstance(): WonJackpotWidget;
8
+ private childMessageHandler;
9
+ launchWonJackpot(params: WonJackpotWidgetParams): void;
10
+ destroyWonJackpot(): void;
11
+ }
@@ -0,0 +1,70 @@
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;
@@ -0,0 +1,4 @@
1
+ export interface WonJackpotWidgetParams {
2
+ container?: string;
3
+ data: unknown;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export declare enum WonJackpotIframeIncomingEvent {
2
+ footerWidgetLoaded = "jackpot-footer-widget-loaded",
3
+ participateChange = "jackpot-footer-widget-participate-change",
4
+ showPopup = "jackpot-footer-widget-popup-show",
5
+ jackpotWinClose = "jackpot-win-close"
6
+ }
7
+ export type WonJackpotWidgetEvents = {
8
+ close: void;
9
+ };
@@ -0,0 +1,11 @@
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 = {}));
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@splash-tech/jackpot-sdk",
3
+ "version": "1.0.0",
4
+ "description": "SDK for managing jackpot widgets in iframes",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "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"
18
+ },
19
+ "keywords": [
20
+ "jackpot",
21
+ "widget",
22
+ "iframe",
23
+ "splash"
24
+ ],
25
+ "author": "Splash Tech",
26
+ "license": "MIT",
27
+ "devDependencies": {
28
+ "@types/node": "^20.11.19",
29
+ "typescript": "^5.8.2"
30
+ }
31
+ }