@splash-tech/jackpot-sdk 2.0.1 → 3.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.
Files changed (42) hide show
  1. package/README.md +123 -25
  2. package/dist/clients/b2tech/B2TechFooterWidget.d.ts +11 -0
  3. package/dist/clients/b2tech/B2TechFooterWidget.js +74 -0
  4. package/dist/clients/b2tech/types.d.ts +6 -0
  5. package/dist/clients/defaultClient/DefaultClientFooterWidget.d.ts +9 -0
  6. package/dist/clients/defaultClient/DefaultClientFooterWidget.js +53 -0
  7. package/dist/clients/defaultClient/DefaultClientWinWidget.d.ts +9 -0
  8. package/dist/clients/defaultClient/DefaultClientWinWidget.js +95 -0
  9. package/dist/clients/defaultClient/types.d.ts +14 -0
  10. package/dist/clients/registry.d.ts +24 -0
  11. package/dist/clients/registry.js +28 -0
  12. package/dist/core/BaseWidget.d.ts +24 -0
  13. package/dist/core/BaseWidget.js +96 -0
  14. package/dist/core/FooterWidgetBase.d.ts +18 -0
  15. package/dist/core/FooterWidgetBase.js +71 -0
  16. package/dist/core/WinWidgetBase.d.ts +12 -0
  17. package/dist/core/WinWidgetBase.js +47 -0
  18. package/dist/core/types.d.ts +21 -0
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +11 -25
  21. package/dist/shared/validation.d.ts +1 -0
  22. package/dist/shared/validation.js +11 -0
  23. package/dist/types.d.ts +6 -23
  24. package/package.json +9 -1
  25. package/dist/widgets/BaseWidget.d.ts +0 -28
  26. package/dist/widgets/BaseWidget.js +0 -104
  27. package/dist/widgets/footerWidget/FooterWidget.d.ts +0 -16
  28. package/dist/widgets/footerWidget/FooterWidget.js +0 -110
  29. package/dist/widgets/footerWidget/types/data.d.ts +0 -12
  30. package/dist/widgets/footerWidget/types/events.d.ts +0 -15
  31. package/dist/widgets/footerWidget/types/events.js +0 -14
  32. package/dist/widgets/shared/types.d.ts +0 -18
  33. package/dist/widgets/winWidget/WinWidget copy.d.ts +0 -13
  34. package/dist/widgets/winWidget/WinWidget copy.js +0 -131
  35. package/dist/widgets/winWidget/WinWidget.d.ts +0 -14
  36. package/dist/widgets/winWidget/WinWidget.js +0 -134
  37. package/dist/widgets/winWidget/types/data.d.ts +0 -12
  38. package/dist/widgets/winWidget/types/events.d.ts +0 -10
  39. package/dist/widgets/winWidget/types/events.js +0 -11
  40. /package/dist/{widgets/shared → clients/b2tech}/types.js +0 -0
  41. /package/dist/{widgets/footerWidget/types/data.js → clients/defaultClient/types.js} +0 -0
  42. /package/dist/{widgets/winWidget/types/data.js → core/types.js} +0 -0
@@ -1,15 +0,0 @@
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
- };
@@ -1,14 +0,0 @@
1
- // events emitted by app inside iframe to the SDK - Internal use
2
- export var FooterIframeIncomingEvent;
3
- (function (FooterIframeIncomingEvent) {
4
- FooterIframeIncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
5
- FooterIframeIncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
6
- FooterIframeIncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
7
- FooterIframeIncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
8
- })(FooterIframeIncomingEvent || (FooterIframeIncomingEvent = {}));
9
- // events emitted by SDK to the app inside iframe - Internal use
10
- export var FooterIframeOutgoingEvent;
11
- (function (FooterIframeOutgoingEvent) {
12
- FooterIframeOutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
13
- FooterIframeOutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
14
- })(FooterIframeOutgoingEvent || (FooterIframeOutgoingEvent = {}));
@@ -1,18 +0,0 @@
1
- import { FooterWidgetParams } from '../footerWidget/types/data';
2
- import { FooterIframeOutgoingEvent } from '../footerWidget/types/events';
3
- import { WinWidgetParams } from '../winWidget/types/data';
4
- import { WinWidgetIframeOutgoingEvent } from '../winWidget/types/events';
5
- export type SDKMode = 'local' | 'dev' | 'staging' | 'production';
6
- export type WidgetParams = FooterWidgetParams | WinWidgetParams;
7
- export type IframeOutgoingEvent = FooterIframeOutgoingEvent | WinWidgetIframeOutgoingEvent;
8
- export type WidgetEventHandler = () => void;
9
- export interface ChildMessage {
10
- type: IframeOutgoingEvent;
11
- data: unknown;
12
- position?: FooterWidgetParams['position'];
13
- animation?: WinWidgetParams['animation'];
14
- maxWidth?: string;
15
- jackpotId?: string | null;
16
- tag?: string | null;
17
- brand?: string | null;
18
- }
@@ -1,13 +0,0 @@
1
- import { BaseWidget } from '../BaseWidget';
2
- import { WinWidgetParams } from './types/data';
3
- export declare class WinWidget extends BaseWidget {
4
- private static instance;
5
- private constructor();
6
- static getInstance(): WinWidget;
7
- private childMessageHandler;
8
- launch(params: WinWidgetParams): void;
9
- private animateEnter;
10
- private cleanupAnimation;
11
- removeAllEventListeners(): void;
12
- destroy(): void;
13
- }
@@ -1,131 +0,0 @@
1
- import { BaseWidget } from '../BaseWidget';
2
- import { WinWidgetIframeIncomingEvent, WinWidgetIframeOutgoingEvent, } from './types/events';
3
- export class WinWidget extends BaseWidget {
4
- constructor() {
5
- super();
6
- this.childMessageHandler = (event) => {
7
- var _a, _b;
8
- if (!((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.src))
9
- return;
10
- if (event.origin !== this.childAppOrigin)
11
- return;
12
- switch ((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) {
13
- case WinWidgetIframeIncomingEvent.winWidgetLoaded:
14
- this.sendDataToChild({
15
- type: WinWidgetIframeOutgoingEvent.winWidgetDataInitial,
16
- data: this.data,
17
- jackpotId: this.jackpotId,
18
- tag: this.tag,
19
- brand: this.brand,
20
- });
21
- break;
22
- case WinWidgetIframeIncomingEvent.winWidgetClose:
23
- this.destroy();
24
- this.emit('close');
25
- break;
26
- }
27
- };
28
- }
29
- static getInstance() {
30
- if (!WinWidget.instance) {
31
- WinWidget.instance = new WinWidget();
32
- }
33
- return WinWidget.instance;
34
- }
35
- launch(params) {
36
- if (this.isWidgetLaunched()) {
37
- console.warn('Won Jackpot widget is already launched');
38
- return;
39
- }
40
- this.setParamsData(params);
41
- this.iframe = this.createIframe();
42
- // TODO: move to set styles
43
- console.log('RUNNING 1');
44
- this.iframe.style.top = '0';
45
- this.iframe.style.left = '0';
46
- this.iframe.style.width = '100%';
47
- this.iframe.style.height = '100%';
48
- this.iframe.style.zIndex = '9999999'; // 7
49
- this.iframe.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
50
- this.iframe.src = `${this.childAppOrigin}/win-animation-widget`;
51
- this.animateEnter(this.iframe, params.container);
52
- window.addEventListener('message', this.childMessageHandler);
53
- }
54
- animateEnter(iframe, containerSelector) {
55
- if (!iframe) {
56
- console.error('Failed to show win widget. Iframe not found.');
57
- return;
58
- }
59
- const targetContainer = containerSelector
60
- ? document.querySelector(containerSelector)
61
- : document.body;
62
- if (!targetContainer) {
63
- console.error(`Failed to show win widget. Container "${containerSelector}" not found`);
64
- return;
65
- }
66
- const isCustomContainer = !!containerSelector;
67
- if (isCustomContainer) {
68
- const style = window.getComputedStyle(targetContainer);
69
- if (style.position === 'static') {
70
- targetContainer.style.position = 'relative';
71
- }
72
- }
73
- // create circular container
74
- const container = document.createElement('div');
75
- container.dataset.winWidget = 'container';
76
- Object.assign(container.style, {
77
- position: isCustomContainer ? 'absolute' : 'fixed',
78
- inset: '0',
79
- width: '100%',
80
- height: '100%',
81
- overflow: 'hidden',
82
- zIndex: '99999999', // 8
83
- clipPath: 'circle(0% at 50% 50%)',
84
- transition: 'clip-path 1.2s cubic-bezier(0.22, 1, 0.36, 1)',
85
- });
86
- // append circular container into targetContainer, and iframe into circular container
87
- targetContainer.appendChild(container);
88
- container.appendChild(iframe);
89
- // create overlay
90
- const overlay = document.createElement('div');
91
- overlay.dataset.winWidget = 'overlay';
92
- Object.assign(overlay.style, {
93
- position: isCustomContainer ? 'absolute' : 'fixed',
94
- inset: '0',
95
- width: '100%',
96
- height: '100%',
97
- background: 'rgba(0,0,0,0)',
98
- zIndex: '9999999', // 7
99
- backdropFilter: 'blur(0px)',
100
- transition: 'background 0.8s ease, backdrop-filter 0.8s ease',
101
- });
102
- // append overlay
103
- targetContainer.appendChild(overlay);
104
- // animate overlay blur
105
- setTimeout(() => {
106
- overlay.style.background = 'rgba(0,0,0,0.4)';
107
- overlay.style.backdropFilter = 'blur(8px)';
108
- }, 200);
109
- // animate circular container growth
110
- setTimeout(() => {
111
- container.style.clipPath = 'circle(150% at 50% 50%)';
112
- }, 1000);
113
- this.setLaunched(true);
114
- }
115
- cleanupAnimation(containerSelector) {
116
- var _a, _b;
117
- const container = containerSelector
118
- ? document.querySelector(containerSelector) || document
119
- : document;
120
- (_a = container.querySelector('[data-win-widget="overlay"]')) === null || _a === void 0 ? void 0 : _a.remove();
121
- (_b = container.querySelector('[data-win-widget="container"]')) === null || _b === void 0 ? void 0 : _b.remove();
122
- }
123
- removeAllEventListeners() {
124
- super.removeAllEventListeners();
125
- }
126
- destroy() {
127
- window.removeEventListener('message', this.childMessageHandler);
128
- this.cleanupAnimation();
129
- this.removeIframe();
130
- }
131
- }
@@ -1,14 +0,0 @@
1
- import { BaseWidget } from '../BaseWidget';
2
- import { WinWidgetParams } from './types/data';
3
- export declare class WinWidget extends BaseWidget {
4
- private static instance;
5
- private constructor();
6
- static getInstance(): WinWidget;
7
- private childMessageHandler;
8
- launch(params: WinWidgetParams): void;
9
- private setIframeStyles;
10
- private animateEnter;
11
- private cleanupAnimation;
12
- removeAllEventListeners(): void;
13
- destroy(): void;
14
- }
@@ -1,134 +0,0 @@
1
- import { BaseWidget } from '../BaseWidget';
2
- import { WinWidgetIframeIncomingEvent, WinWidgetIframeOutgoingEvent, } from './types/events';
3
- export class WinWidget extends BaseWidget {
4
- constructor() {
5
- super();
6
- this.childMessageHandler = (event) => {
7
- var _a, _b;
8
- if (!((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.src))
9
- return;
10
- if (event.origin !== this.childAppOrigin)
11
- return;
12
- switch ((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) {
13
- case WinWidgetIframeIncomingEvent.winWidgetLoaded:
14
- this.sendDataToChild({
15
- type: WinWidgetIframeOutgoingEvent.winWidgetDataInitial,
16
- data: this.data,
17
- jackpotId: this.jackpotId,
18
- tag: this.tag,
19
- brand: this.brand,
20
- animation: this.animation,
21
- });
22
- break;
23
- case WinWidgetIframeIncomingEvent.winWidgetClose:
24
- this.destroy();
25
- this.emit('close');
26
- break;
27
- }
28
- };
29
- }
30
- static getInstance() {
31
- if (!WinWidget.instance) {
32
- WinWidget.instance = new WinWidget();
33
- }
34
- return WinWidget.instance;
35
- }
36
- launch(params) {
37
- if (this.isWidgetLaunched()) {
38
- console.warn('Won Jackpot widget is already launched');
39
- return;
40
- }
41
- this.setParamsData(params);
42
- this.iframe = this.createIframe();
43
- this.iframe = this.setIframeStyles(this.iframe);
44
- this.iframe.src = `${this.childAppOrigin}/win-animation-widget?animation=${this.animation}`;
45
- this.animateEnter(this.iframe, params.container);
46
- window.addEventListener('message', this.childMessageHandler);
47
- }
48
- setIframeStyles(iframe) {
49
- iframe.style.top = '0';
50
- iframe.style.left = '0';
51
- iframe.style.width = '100%';
52
- iframe.style.height = '100%';
53
- iframe.style.zIndex = '9999999'; // 7
54
- iframe.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
55
- return iframe;
56
- }
57
- animateEnter(iframe, containerSelector) {
58
- if (!iframe) {
59
- console.error('Failed to show win widget. Iframe not found.');
60
- return;
61
- }
62
- const targetContainer = containerSelector
63
- ? document.querySelector(containerSelector)
64
- : document.body;
65
- if (!targetContainer) {
66
- console.error(`Failed to show win widget. Container "${containerSelector}" not found`);
67
- return;
68
- }
69
- const isCustomContainer = !!containerSelector;
70
- if (isCustomContainer) {
71
- const style = window.getComputedStyle(targetContainer);
72
- if (style.position === 'static') {
73
- targetContainer.style.position = 'relative';
74
- }
75
- }
76
- // create circular container
77
- const container = document.createElement('div');
78
- container.dataset.winWidget = 'container';
79
- Object.assign(container.style, {
80
- position: isCustomContainer ? 'absolute' : 'fixed',
81
- inset: '0',
82
- width: '100%',
83
- height: '100%',
84
- overflow: 'hidden',
85
- zIndex: '99999999', // 8
86
- clipPath: 'circle(0% at 50% 50%)',
87
- transition: 'clip-path 1.2s cubic-bezier(0.22, 1, 0.36, 1)',
88
- });
89
- // append circular container into targetContainer, and iframe into circular container
90
- targetContainer.appendChild(container);
91
- container.appendChild(iframe);
92
- // create overlay
93
- const overlay = document.createElement('div');
94
- overlay.dataset.winWidget = 'overlay';
95
- Object.assign(overlay.style, {
96
- position: isCustomContainer ? 'absolute' : 'fixed',
97
- inset: '0',
98
- width: '100%',
99
- height: '100%',
100
- background: 'rgba(0,0,0,0)',
101
- zIndex: '9999999', // 7
102
- backdropFilter: 'blur(0px)',
103
- transition: 'background 0.8s ease, backdrop-filter 0.8s ease',
104
- });
105
- // append overlay
106
- targetContainer.appendChild(overlay);
107
- // animate overlay blur
108
- setTimeout(() => {
109
- overlay.style.background = 'rgba(0,0,0,0.4)';
110
- overlay.style.backdropFilter = 'blur(8px)';
111
- }, 200);
112
- // animate circular container growth
113
- setTimeout(() => {
114
- container.style.clipPath = 'circle(150% at 50% 50%)';
115
- }, 1000);
116
- this.setLaunched(true);
117
- }
118
- cleanupAnimation(containerSelector) {
119
- var _a, _b;
120
- const container = containerSelector
121
- ? document.querySelector(containerSelector) || document
122
- : document;
123
- (_a = container.querySelector('[data-win-widget="overlay"]')) === null || _a === void 0 ? void 0 : _a.remove();
124
- (_b = container.querySelector('[data-win-widget="container"]')) === null || _b === void 0 ? void 0 : _b.remove();
125
- }
126
- removeAllEventListeners() {
127
- super.removeAllEventListeners();
128
- }
129
- destroy() {
130
- window.removeEventListener('message', this.childMessageHandler);
131
- this.cleanupAnimation();
132
- this.removeIframe();
133
- }
134
- }
@@ -1,12 +0,0 @@
1
- import { SDKMode } from 'src/widgets/shared/types';
2
- export interface WinWidgetParams {
3
- data: unknown;
4
- mode?: SDKMode;
5
- position?: 'top' | 'bottom';
6
- animation?: 'wheel' | 'airplane';
7
- maxWidth?: string;
8
- container?: string;
9
- jackpotId?: string;
10
- tag?: string;
11
- brand?: string;
12
- }
@@ -1,10 +0,0 @@
1
- export declare enum WinWidgetIframeIncomingEvent {
2
- winWidgetLoaded = "jackpot-win-widget-loaded",
3
- winWidgetClose = "jackpot-win-widget-close"
4
- }
5
- export declare enum WinWidgetIframeOutgoingEvent {
6
- winWidgetDataInitial = "jackpot-win-widget-data-initial"
7
- }
8
- export type WinWidgetWidgetEvents = {
9
- close: void;
10
- };
@@ -1,11 +0,0 @@
1
- // events emitted by app inside iframe to the SDK - Internal use
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["winWidgetDataInitial"] = "jackpot-win-widget-data-initial";
11
- })(WinWidgetIframeOutgoingEvent || (WinWidgetIframeOutgoingEvent = {}));