@splash-tech/jackpot-sdk 3.1.0 → 3.1.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.
@@ -1,9 +1,18 @@
1
1
  import { WinWidgetBase } from '../../core/WinWidgetBase';
2
2
  import { WinWidgetConfig, WinWidgetEvents } from './types';
3
3
  export declare class WinWidget extends WinWidgetBase<WinWidgetConfig, WinWidgetEvents> {
4
+ private layoutContainer?;
5
+ private circle?;
6
+ private overlay?;
7
+ private resizeObserver?;
8
+ private resizeFrame?;
9
+ private circleExpanded;
10
+ private launchTimers;
4
11
  protected get route(): string;
5
12
  protected sendInitialData(): void;
6
13
  protected handleChildMessage(type: string | undefined): boolean;
7
14
  protected applyLaunchAnimation(iframe: HTMLIFrameElement): void;
8
15
  protected cleanupLaunchAnimation(): void;
16
+ private scheduleLayout;
17
+ private updateLayout;
9
18
  }
@@ -9,6 +9,19 @@ var OutgoingEvent;
9
9
  OutgoingEvent["winWidgetDataInitial"] = "jackpot-win-widget-data-initial";
10
10
  })(OutgoingEvent || (OutgoingEvent = {}));
11
11
  export class WinWidget extends WinWidgetBase {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.circleExpanded = false;
15
+ this.launchTimers = [];
16
+ this.scheduleLayout = () => {
17
+ if (this.resizeFrame !== undefined || !this.layoutContainer)
18
+ return;
19
+ this.resizeFrame = window.requestAnimationFrame(() => {
20
+ this.resizeFrame = undefined;
21
+ this.updateLayout();
22
+ });
23
+ };
24
+ }
12
25
  get route() {
13
26
  var _a;
14
27
  return `/win-animation-widget?animation=${(_a = this.config.animation) !== null && _a !== void 0 ? _a : 'wheel'}`;
@@ -34,6 +47,7 @@ export class WinWidget extends WinWidgetBase {
34
47
  }
35
48
  }
36
49
  applyLaunchAnimation(iframe) {
50
+ var _a, _b;
37
51
  const targetContainer = this.container
38
52
  ? document.querySelector(this.container)
39
53
  : document.body;
@@ -48,7 +62,6 @@ export class WinWidget extends WinWidgetBase {
48
62
  targetContainer.style.position = 'relative';
49
63
  }
50
64
  }
51
- // container
52
65
  const container = document.createElement('div');
53
66
  container.dataset.winWidget = 'container';
54
67
  Object.assign(container.style, {
@@ -57,9 +70,8 @@ export class WinWidget extends WinWidgetBase {
57
70
  width: '100%',
58
71
  height: '100%',
59
72
  overflow: 'hidden',
60
- zIndex: '99999999', // 8
73
+ zIndex: '99999999',
61
74
  });
62
- // circle
63
75
  const circle = document.createElement('div');
64
76
  circle.dataset.winWidget = 'circle';
65
77
  Object.assign(circle.style, {
@@ -73,23 +85,16 @@ export class WinWidget extends WinWidgetBase {
73
85
  transform: 'translate(-50%, -50%)',
74
86
  transition: 'width 1.2s cubic-bezier(0.22, 1, 0.36, 1), height 1.2s cubic-bezier(0.22, 1, 0.36, 1)',
75
87
  });
76
- // iframe
77
- const viewportW = `${window.innerWidth}px`;
78
- const viewportH = `${window.innerHeight}px`;
79
88
  Object.assign(iframe.style, {
80
89
  position: 'absolute',
81
90
  left: '50%',
82
91
  top: '50%',
83
- width: viewportW,
84
- height: viewportH,
85
92
  transform: 'translate(-50%, -50%)',
86
93
  border: 'none',
87
94
  backgroundColor: 'rgba(0, 0, 0, 0.5)',
88
95
  });
89
- // append iframe into the circle, then circle into the container
90
96
  circle.appendChild(iframe);
91
97
  container.appendChild(circle);
92
- // blur overlay
93
98
  const overlay = document.createElement('div');
94
99
  overlay.dataset.winWidget = 'overlay';
95
100
  Object.assign(overlay.style, {
@@ -98,35 +103,79 @@ export class WinWidget extends WinWidgetBase {
98
103
  width: '100%',
99
104
  height: '100%',
100
105
  background: 'rgba(0,0,0,0)',
101
- zIndex: '9999999', // 7
106
+ zIndex: '9999999',
102
107
  backdropFilter: 'blur(0px)',
103
108
  transition: 'background 0.8s ease, backdrop-filter 0.8s ease',
104
109
  });
105
- // append overlay and container into the targetContainer
106
110
  targetContainer.appendChild(overlay);
107
111
  targetContainer.appendChild(container);
108
- // blur animation
109
- setTimeout(() => {
110
- overlay.style.background = 'rgba(0,0,0,0.4)';
111
- overlay.style.backdropFilter = 'blur(8px)';
112
- }, 200);
113
- // circle grow animation
114
- requestAnimationFrame(() => {
112
+ this.layoutContainer = container;
113
+ this.circle = circle;
114
+ this.overlay = overlay;
115
+ this.circleExpanded = false;
116
+ this.updateLayout();
117
+ this.resizeObserver = new ResizeObserver(this.scheduleLayout);
118
+ this.resizeObserver.observe(container);
119
+ window.addEventListener('resize', this.scheduleLayout);
120
+ window.addEventListener('orientationchange', this.scheduleLayout);
121
+ (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.addEventListener('resize', this.scheduleLayout);
122
+ (_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.addEventListener('scroll', this.scheduleLayout);
123
+ this.launchTimers = [
115
124
  setTimeout(() => {
116
- const size = Math.ceil(Math.sqrt(window.innerWidth * window.innerWidth +
117
- window.innerHeight * window.innerHeight) * 2);
118
- circle.style.width = `${size}px`;
119
- circle.style.height = `${size}px`;
120
- }, 1000);
121
- });
125
+ overlay.style.background = 'rgba(0,0,0,0.4)';
126
+ overlay.style.backdropFilter = 'blur(8px)';
127
+ }, 200),
128
+ setTimeout(() => {
129
+ this.circleExpanded = true;
130
+ this.updateLayout();
131
+ }, 1000),
132
+ ];
122
133
  this.setLaunched(true);
123
134
  }
124
135
  cleanupLaunchAnimation() {
125
- var _a, _b;
126
- const root = this.container
127
- ? document.querySelector(this.container) || document
128
- : document;
129
- (_a = root.querySelector('[data-win-widget="overlay"]')) === null || _a === void 0 ? void 0 : _a.remove();
130
- (_b = root.querySelector('[data-win-widget="container"]')) === null || _b === void 0 ? void 0 : _b.remove();
136
+ var _a, _b, _c, _d, _e;
137
+ this.launchTimers.forEach(clearTimeout);
138
+ this.launchTimers = [];
139
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
140
+ this.resizeObserver = undefined;
141
+ if (this.resizeFrame !== undefined)
142
+ window.cancelAnimationFrame(this.resizeFrame);
143
+ this.resizeFrame = undefined;
144
+ window.removeEventListener('resize', this.scheduleLayout);
145
+ window.removeEventListener('orientationchange', this.scheduleLayout);
146
+ (_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.removeEventListener('resize', this.scheduleLayout);
147
+ (_c = window.visualViewport) === null || _c === void 0 ? void 0 : _c.removeEventListener('scroll', this.scheduleLayout);
148
+ (_d = this.overlay) === null || _d === void 0 ? void 0 : _d.remove();
149
+ (_e = this.layoutContainer) === null || _e === void 0 ? void 0 : _e.remove();
150
+ this.overlay = undefined;
151
+ this.layoutContainer = undefined;
152
+ this.circle = undefined;
153
+ this.circleExpanded = false;
154
+ }
155
+ updateLayout() {
156
+ var _a, _b, _c, _d;
157
+ if (!this.layoutContainer || !this.iframe || !this.circle)
158
+ return;
159
+ if (!this.container) {
160
+ const viewport = window.visualViewport;
161
+ const bounds = {
162
+ left: `${(_a = viewport === null || viewport === void 0 ? void 0 : viewport.offsetLeft) !== null && _a !== void 0 ? _a : 0}px`,
163
+ top: `${(_b = viewport === null || viewport === void 0 ? void 0 : viewport.offsetTop) !== null && _b !== void 0 ? _b : 0}px`,
164
+ width: `${(_c = viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _c !== void 0 ? _c : window.innerWidth}px`,
165
+ height: `${(_d = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _d !== void 0 ? _d : window.innerHeight}px`,
166
+ };
167
+ Object.assign(this.layoutContainer.style, bounds);
168
+ if (this.overlay)
169
+ Object.assign(this.overlay.style, bounds);
170
+ }
171
+ const width = this.layoutContainer.clientWidth;
172
+ const height = this.layoutContainer.clientHeight;
173
+ this.iframe.style.width = `${width}px`;
174
+ this.iframe.style.height = `${height}px`;
175
+ if (this.circleExpanded) {
176
+ const size = Math.ceil(Math.hypot(width, height) * 2);
177
+ this.circle.style.width = `${size}px`;
178
+ this.circle.style.height = `${size}px`;
179
+ }
131
180
  }
132
181
  }
@@ -16,6 +16,7 @@ export interface LobbyWidgetConfig {
16
16
  container: string;
17
17
  maxWidth?: string;
18
18
  showOptInButton?: boolean;
19
+ showBanner?: boolean;
19
20
  }
20
21
  export interface LobbyWidgetData {
21
22
  themeUrl: string;
@@ -2,10 +2,12 @@ export function mapV2FooterWidgetLaunchParams(params) {
2
2
  return {
3
3
  data: params.data,
4
4
  onLoad: params.onLoad,
5
- config: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
5
+ config: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
6
6
  ? { container: params.container }
7
7
  : {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})), (params.height !== undefined ? { height: params.height } : {})), (params.showLevelIcons !== undefined
8
8
  ? { showLevelIcons: params.showLevelIcons }
9
+ : {})), (params.popupTopOffset !== undefined
10
+ ? { popupTopOffset: params.popupTopOffset }
9
11
  : {})),
10
12
  };
11
13
  }
@@ -1,10 +1,6 @@
1
1
  import { Clients, clientRegistry } from '../../clients/registry';
2
2
  import { createSplashJackpot } from '../v3/createSplashJackpot';
3
3
  import { mapV2FooterWidgetLaunchParams, mapV2WinWidgetLaunchParams, } from './mapLaunchParams';
4
- // Facade for legacy v2.
5
- // v2 way of using sdk gets mapped into v3.
6
- // Internally, widgets do everything in v3 way.
7
- // When all clients update to v3, this can be removed without touching existing widgets.
8
4
  function createV2SplashJackpot() {
9
5
  let instance = null;
10
6
  const footerWidgetListeners = new Map();
@@ -54,6 +50,7 @@ function createV2SplashJackpot() {
54
50
  container: params.container,
55
51
  maxWidth: params.maxWidth,
56
52
  showOptInButton: params.showOptInButton,
53
+ showBanner: params.showBanner,
57
54
  },
58
55
  });
59
56
  },
@@ -9,6 +9,7 @@ export interface V2FooterWidgetLaunchParams {
9
9
  maxWidth?: string;
10
10
  height?: string;
11
11
  showLevelIcons?: boolean;
12
+ popupTopOffset?: number;
12
13
  container?: string;
13
14
  onLoad?: () => void;
14
15
  }
@@ -24,5 +25,6 @@ export interface V2LobbyWidgetLaunchParams {
24
25
  container: string;
25
26
  maxWidth?: string;
26
27
  showOptInButton?: boolean;
28
+ showBanner?: boolean;
27
29
  onLoad?: () => void;
28
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splash-tech/jackpot-sdk",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "SDK for managing jackpot widgets in iframes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,6 +23,7 @@
23
23
  "test": "echo \"Error: no test specified\" && exit 1",
24
24
  "test:lobby": "node --test tests/lobby-widget.cjs",
25
25
  "test:footer": "node --test tests/footer-widget.cjs",
26
+ "test:win": "node --test tests/win-widget.cjs",
26
27
  "preview:lobby": "tsc && node examples/serve.cjs"
27
28
  },
28
29
  "keywords": [