@splash-tech/jackpot-sdk 3.0.9 → 3.1.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/dist/clients/registry.d.ts +2 -0
- package/dist/clients/registry.js +2 -0
- package/dist/clients/x7k2m9qp/LobbyWidget.d.ts +15 -0
- package/dist/clients/x7k2m9qp/LobbyWidget.js +106 -0
- package/dist/clients/x7k2m9qp/types.d.ts +42 -0
- package/dist/compat/v2/splashJackpot.d.ts +11 -2
- package/dist/compat/v2/splashJackpot.js +38 -0
- package/dist/compat/v2/types.d.ts +9 -0
- package/dist/core/FooterWidgetBase.d.ts +9 -1
- package/dist/core/FooterWidgetBase.js +97 -25
- package/dist/core/types.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +5 -2
|
@@ -2,6 +2,7 @@ import { SDKEnv } from '../compat/v2/types';
|
|
|
2
2
|
import { FooterWidget as FooterWidgetH4 } from './h4n8w3vt/FooterWidget';
|
|
3
3
|
import { FooterWidget as FooterWidgetX7 } from './x7k2m9qp/FooterWidget';
|
|
4
4
|
import { WinWidget as WinWidgetX7 } from './x7k2m9qp/WinWidget';
|
|
5
|
+
import { LobbyWidget as LobbyWidgetX7 } from './x7k2m9qp/LobbyWidget';
|
|
5
6
|
export declare const Clients: {
|
|
6
7
|
readonly x7k2m9qp: "x7k2m9qp";
|
|
7
8
|
readonly h4n8w3vt: "h4n8w3vt";
|
|
@@ -10,6 +11,7 @@ export type ClientId = (typeof Clients)[keyof typeof Clients];
|
|
|
10
11
|
export interface X7Widgets {
|
|
11
12
|
footerWidget: FooterWidgetX7;
|
|
12
13
|
winWidget: WinWidgetX7;
|
|
14
|
+
lobbyWidget: LobbyWidgetX7;
|
|
13
15
|
}
|
|
14
16
|
export interface H4Widgets {
|
|
15
17
|
footerWidget: FooterWidgetH4;
|
package/dist/clients/registry.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FooterWidget as FooterWidgetH4 } from './h4n8w3vt/FooterWidget';
|
|
2
2
|
import { FooterWidget as FooterWidgetX7 } from './x7k2m9qp/FooterWidget';
|
|
3
3
|
import { WinWidget as WinWidgetX7 } from './x7k2m9qp/WinWidget';
|
|
4
|
+
import { LobbyWidget as LobbyWidgetX7 } from './x7k2m9qp/LobbyWidget';
|
|
4
5
|
export const Clients = {
|
|
5
6
|
x7k2m9qp: 'x7k2m9qp',
|
|
6
7
|
h4n8w3vt: 'h4n8w3vt',
|
|
@@ -16,6 +17,7 @@ export const clientRegistry = {
|
|
|
16
17
|
createWidgets: (baseUrl) => ({
|
|
17
18
|
footerWidget: new FooterWidgetX7(baseUrl),
|
|
18
19
|
winWidget: new WinWidgetX7(baseUrl),
|
|
20
|
+
lobbyWidget: new LobbyWidgetX7(baseUrl),
|
|
19
21
|
}),
|
|
20
22
|
},
|
|
21
23
|
[Clients.h4n8w3vt]: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseWidget } from '../../core/BaseWidget';
|
|
2
|
+
import { LobbyWidgetConfig, LobbyWidgetData, LobbyWidgetEvents, LobbyWidgetLaunchParams } from './types';
|
|
3
|
+
export declare class LobbyWidget extends BaseWidget<LobbyWidgetConfig, LobbyWidgetEvents> {
|
|
4
|
+
private readonly baseUrl;
|
|
5
|
+
private onLoad?;
|
|
6
|
+
private ready;
|
|
7
|
+
constructor(baseUrl: string);
|
|
8
|
+
launch(params: LobbyWidgetLaunchParams): void;
|
|
9
|
+
updateData(partialData: Partial<LobbyWidgetData>): void;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
protected startListening(): void;
|
|
12
|
+
protected stopListening(): void;
|
|
13
|
+
protected handleChildMessage(type: string | undefined): boolean;
|
|
14
|
+
private receive;
|
|
15
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BaseWidget } from '../../core/BaseWidget';
|
|
2
|
+
import { validateNonEmptyObject } from '../../shared/validation';
|
|
3
|
+
export class LobbyWidget extends BaseWidget {
|
|
4
|
+
constructor(baseUrl) {
|
|
5
|
+
super(new URL(baseUrl).origin);
|
|
6
|
+
this.baseUrl = baseUrl;
|
|
7
|
+
this.ready = false;
|
|
8
|
+
this.receive = (event) => {
|
|
9
|
+
var _a, _b, _c;
|
|
10
|
+
if (!this.iframe ||
|
|
11
|
+
event.source !== this.iframe.contentWindow ||
|
|
12
|
+
event.origin !== this.childAppOrigin)
|
|
13
|
+
return;
|
|
14
|
+
if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'jackpot-lobby-widget-resize') {
|
|
15
|
+
const height = (_b = event.data.payload) === null || _b === void 0 ? void 0 : _b.height;
|
|
16
|
+
if (typeof height === 'number' &&
|
|
17
|
+
Number.isFinite(height) &&
|
|
18
|
+
height >= 0 &&
|
|
19
|
+
height <= 100000) {
|
|
20
|
+
this.iframe.style.height = `${Math.ceil(height)}px`;
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.handleChildMessage((_c = event.data) === null || _c === void 0 ? void 0 : _c.type);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
launch(params) {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (!validateNonEmptyObject(params === null || params === void 0 ? void 0 : params.data, 'LobbyWidget.launch'))
|
|
30
|
+
return;
|
|
31
|
+
const container = (_a = params.config) === null || _a === void 0 ? void 0 : _a.container;
|
|
32
|
+
const target = container ? document.querySelector(container) : null;
|
|
33
|
+
if (!target) {
|
|
34
|
+
throw new Error(`LobbyWidget.launch: container "${container !== null && container !== void 0 ? container : ''}" not found.`);
|
|
35
|
+
}
|
|
36
|
+
this.destroy();
|
|
37
|
+
this.config = Object.assign({}, params.config);
|
|
38
|
+
this.data = params.data;
|
|
39
|
+
this.onLoad = params.onLoad;
|
|
40
|
+
const iframe = document.createElement('iframe');
|
|
41
|
+
iframe.title = 'Yay slots jackpot';
|
|
42
|
+
iframe.src = `${this.baseUrl.replace(/\/$/, '')}/lobby-widget`;
|
|
43
|
+
iframe.style.display = 'block';
|
|
44
|
+
iframe.style.border = '0';
|
|
45
|
+
iframe.style.width = '100%';
|
|
46
|
+
iframe.style.maxWidth = (_b = this.config.maxWidth) !== null && _b !== void 0 ? _b : '100%';
|
|
47
|
+
iframe.style.height = '1px';
|
|
48
|
+
iframe.style.marginInline = 'auto';
|
|
49
|
+
this.iframe = iframe;
|
|
50
|
+
this.startListening();
|
|
51
|
+
this.setLaunched(true);
|
|
52
|
+
target.appendChild(iframe);
|
|
53
|
+
}
|
|
54
|
+
updateData(partialData) {
|
|
55
|
+
if (!this.isLaunched() ||
|
|
56
|
+
!validateNonEmptyObject(partialData, 'LobbyWidget.updateData'))
|
|
57
|
+
return;
|
|
58
|
+
const { levels, stats, participate } = partialData;
|
|
59
|
+
const updated = Object.assign(Object.assign(Object.assign({}, (levels !== undefined ? { levels } : {})), (stats !== undefined ? { stats } : {})), (participate !== undefined ? { participate } : {}));
|
|
60
|
+
this.data = Object.assign(Object.assign({}, this.data), updated);
|
|
61
|
+
this.sendToChild({
|
|
62
|
+
type: 'jackpot-lobby-widget-data-updated',
|
|
63
|
+
data: updated,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
destroy() {
|
|
67
|
+
this.stopListening();
|
|
68
|
+
this.removeIframe();
|
|
69
|
+
this.ready = false;
|
|
70
|
+
this.onLoad = undefined;
|
|
71
|
+
this.data = undefined;
|
|
72
|
+
}
|
|
73
|
+
startListening() {
|
|
74
|
+
window.addEventListener('message', this.receive);
|
|
75
|
+
}
|
|
76
|
+
stopListening() {
|
|
77
|
+
window.removeEventListener('message', this.receive);
|
|
78
|
+
}
|
|
79
|
+
handleChildMessage(type) {
|
|
80
|
+
var _a;
|
|
81
|
+
switch (type) {
|
|
82
|
+
case 'jackpot-lobby-widget-loaded':
|
|
83
|
+
this.sendToChild({
|
|
84
|
+
type: 'jackpot-lobby-widget-data-initial',
|
|
85
|
+
data: this.data,
|
|
86
|
+
config: this.config,
|
|
87
|
+
});
|
|
88
|
+
return true;
|
|
89
|
+
case 'jackpot-lobby-widget-ready':
|
|
90
|
+
if (!this.ready) {
|
|
91
|
+
this.ready = true;
|
|
92
|
+
(_a = this.onLoad) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
93
|
+
this.emit('ready');
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
case 'jackpot-lobby-widget-participate-change':
|
|
97
|
+
this.emit('participateChange');
|
|
98
|
+
return true;
|
|
99
|
+
case 'jackpot-lobby-widget-error':
|
|
100
|
+
this.emit('error');
|
|
101
|
+
return true;
|
|
102
|
+
default:
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -12,3 +12,45 @@ export interface FooterWidgetEvents {
|
|
|
12
12
|
export interface WinWidgetEvents {
|
|
13
13
|
close: void;
|
|
14
14
|
}
|
|
15
|
+
export interface LobbyWidgetConfig {
|
|
16
|
+
container: string;
|
|
17
|
+
maxWidth?: string;
|
|
18
|
+
showOptInButton?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface LobbyWidgetData {
|
|
21
|
+
themeUrl: string;
|
|
22
|
+
termsAndConditionsUrl: string;
|
|
23
|
+
levels: {
|
|
24
|
+
uuid: string;
|
|
25
|
+
name: string;
|
|
26
|
+
imageUrl: string;
|
|
27
|
+
currentValue: {
|
|
28
|
+
amount: number;
|
|
29
|
+
currency: string;
|
|
30
|
+
};
|
|
31
|
+
}[];
|
|
32
|
+
stats: {
|
|
33
|
+
wins: number;
|
|
34
|
+
totalWinAmount: {
|
|
35
|
+
amount: number;
|
|
36
|
+
currency: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
participate: {
|
|
40
|
+
optedIn: boolean;
|
|
41
|
+
participateAmount: {
|
|
42
|
+
amount: number;
|
|
43
|
+
currency: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface LobbyWidgetLaunchParams {
|
|
48
|
+
config: LobbyWidgetConfig;
|
|
49
|
+
data: LobbyWidgetData;
|
|
50
|
+
onLoad?: () => void;
|
|
51
|
+
}
|
|
52
|
+
export interface LobbyWidgetEvents {
|
|
53
|
+
participateChange: void;
|
|
54
|
+
ready: void;
|
|
55
|
+
error: void;
|
|
56
|
+
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { FooterWidgetEvents, WinWidgetEvents } from '../../clients/x7k2m9qp/types';
|
|
1
|
+
import { FooterWidgetEvents, LobbyWidgetData, LobbyWidgetEvents, WinWidgetEvents } from '../../clients/x7k2m9qp/types';
|
|
2
2
|
import { WidgetEventHandler } from '../../core/types';
|
|
3
|
-
import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
|
|
3
|
+
import { V2FooterWidgetLaunchParams, V2LobbyWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
|
|
4
4
|
export declare const splashJackpot: {
|
|
5
|
+
lobbyWidget: {
|
|
6
|
+
isLaunched: () => boolean;
|
|
7
|
+
launch: (params: V2LobbyWidgetLaunchParams) => void;
|
|
8
|
+
updateData: (data: Partial<LobbyWidgetData>) => void | undefined;
|
|
9
|
+
destroy: () => void | undefined;
|
|
10
|
+
addEventListener: (event: keyof LobbyWidgetEvents, handler: WidgetEventHandler) => void;
|
|
11
|
+
removeEventListener: (event: keyof LobbyWidgetEvents, handler: WidgetEventHandler) => void;
|
|
12
|
+
removeAllEventListeners: () => void;
|
|
13
|
+
};
|
|
5
14
|
footerWidget: {
|
|
6
15
|
isLaunched: () => boolean;
|
|
7
16
|
launch: (params: V2FooterWidgetLaunchParams) => void;
|
|
@@ -9,6 +9,7 @@ function createV2SplashJackpot() {
|
|
|
9
9
|
let instance = null;
|
|
10
10
|
const footerWidgetListeners = new Map();
|
|
11
11
|
const winWidgetListeners = new Map();
|
|
12
|
+
const lobbyWidgetListeners = new Map();
|
|
12
13
|
function resolveBuiltInBaseUrl(mode) {
|
|
13
14
|
var _a;
|
|
14
15
|
const env = mode !== null && mode !== void 0 ? mode : 'production';
|
|
@@ -35,9 +36,46 @@ function createV2SplashJackpot() {
|
|
|
35
36
|
instance.winWidget.addEventListener(event, handler);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
for (const [event, handlers] of lobbyWidgetListeners) {
|
|
40
|
+
for (const handler of handlers) {
|
|
41
|
+
instance.lobbyWidget.addEventListener(event, handler);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
38
44
|
return instance;
|
|
39
45
|
}
|
|
40
46
|
return {
|
|
47
|
+
lobbyWidget: {
|
|
48
|
+
isLaunched: () => { var _a; return (_a = instance === null || instance === void 0 ? void 0 : instance.lobbyWidget.isLaunched()) !== null && _a !== void 0 ? _a : false; },
|
|
49
|
+
launch: (params) => {
|
|
50
|
+
createInstance(params.mode).lobbyWidget.launch({
|
|
51
|
+
data: params.data,
|
|
52
|
+
onLoad: params.onLoad,
|
|
53
|
+
config: {
|
|
54
|
+
container: params.container,
|
|
55
|
+
maxWidth: params.maxWidth,
|
|
56
|
+
showOptInButton: params.showOptInButton,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
updateData: (data) => instance === null || instance === void 0 ? void 0 : instance.lobbyWidget.updateData(data),
|
|
61
|
+
destroy: () => instance === null || instance === void 0 ? void 0 : instance.lobbyWidget.destroy(),
|
|
62
|
+
addEventListener: (event, handler) => {
|
|
63
|
+
if (!lobbyWidgetListeners.has(event))
|
|
64
|
+
lobbyWidgetListeners.set(event, []);
|
|
65
|
+
lobbyWidgetListeners.get(event).push(handler);
|
|
66
|
+
instance === null || instance === void 0 ? void 0 : instance.lobbyWidget.addEventListener(event, handler);
|
|
67
|
+
},
|
|
68
|
+
removeEventListener: (event, handler) => {
|
|
69
|
+
const handlers = lobbyWidgetListeners.get(event);
|
|
70
|
+
if (handlers)
|
|
71
|
+
lobbyWidgetListeners.set(event, handlers.filter((h) => h !== handler));
|
|
72
|
+
instance === null || instance === void 0 ? void 0 : instance.lobbyWidget.removeEventListener(event, handler);
|
|
73
|
+
},
|
|
74
|
+
removeAllEventListeners: () => {
|
|
75
|
+
lobbyWidgetListeners.clear();
|
|
76
|
+
instance === null || instance === void 0 ? void 0 : instance.lobbyWidget.removeAllEventListeners();
|
|
77
|
+
},
|
|
78
|
+
},
|
|
41
79
|
footerWidget: {
|
|
42
80
|
isLaunched: () => { var _a; return (_a = instance === null || instance === void 0 ? void 0 : instance.footerWidget.isLaunched()) !== null && _a !== void 0 ? _a : false; },
|
|
43
81
|
launch: (params) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FooterWidgetBaseConfig } from '../../core/types';
|
|
2
|
+
import { LobbyWidgetData } from '../../clients/x7k2m9qp/types';
|
|
2
3
|
export type SDKEnv = 'local' | 'dev' | 'staging' | 'production';
|
|
3
4
|
export type V2Mode = SDKEnv;
|
|
4
5
|
export interface V2FooterWidgetLaunchParams {
|
|
@@ -17,3 +18,11 @@ export interface V2WinWidgetLaunchParams {
|
|
|
17
18
|
animation?: 'wheel' | 'airplane';
|
|
18
19
|
container?: string;
|
|
19
20
|
}
|
|
21
|
+
export interface V2LobbyWidgetLaunchParams {
|
|
22
|
+
data: LobbyWidgetData;
|
|
23
|
+
mode?: V2Mode;
|
|
24
|
+
container: string;
|
|
25
|
+
maxWidth?: string;
|
|
26
|
+
showOptInButton?: boolean;
|
|
27
|
+
onLoad?: () => void;
|
|
28
|
+
}
|
|
@@ -9,6 +9,11 @@ export declare abstract class FooterWidgetBase<TConfig extends FooterWidgetBaseC
|
|
|
9
9
|
protected showLevelIcons: boolean;
|
|
10
10
|
private onLoadHandler?;
|
|
11
11
|
private onLoadCalled;
|
|
12
|
+
private popupTopOffset;
|
|
13
|
+
private popupExpanded;
|
|
14
|
+
private popupAnchor;
|
|
15
|
+
private popupResizeObserver?;
|
|
16
|
+
private popupLayoutFrame?;
|
|
12
17
|
protected abstract sendInitialData(): void;
|
|
13
18
|
protected abstract sendDataUpdate(partialData: object): void;
|
|
14
19
|
launch(params: FooterWidgetLaunchParams<TConfig>): void;
|
|
@@ -16,7 +21,10 @@ export declare abstract class FooterWidgetBase<TConfig extends FooterWidgetBaseC
|
|
|
16
21
|
destroy(): void;
|
|
17
22
|
protected styleIframe(iframe: HTMLIFrameElement): HTMLIFrameElement;
|
|
18
23
|
protected expandIframe(iframeRect?: DOMRect): void;
|
|
24
|
+
private updatePopupBounds;
|
|
25
|
+
private schedulePopupLayout;
|
|
26
|
+
private startPopupLayoutTracking;
|
|
27
|
+
private stopPopupLayoutTracking;
|
|
19
28
|
protected collapseIframe(): void;
|
|
20
|
-
private setIframeHeight;
|
|
21
29
|
protected onChildAppLoaded(): void;
|
|
22
30
|
}
|
|
@@ -6,6 +6,7 @@ const defaults = {
|
|
|
6
6
|
maxWidth: '1300px',
|
|
7
7
|
height: '50px',
|
|
8
8
|
showLevelIcons: true,
|
|
9
|
+
popupTopOffset: 0,
|
|
9
10
|
};
|
|
10
11
|
export class FooterWidgetBase extends BaseWidget {
|
|
11
12
|
constructor() {
|
|
@@ -16,9 +17,20 @@ export class FooterWidgetBase extends BaseWidget {
|
|
|
16
17
|
this.height = defaults.height;
|
|
17
18
|
this.showLevelIcons = defaults.showLevelIcons;
|
|
18
19
|
this.onLoadCalled = false;
|
|
20
|
+
this.popupTopOffset = defaults.popupTopOffset;
|
|
21
|
+
this.popupExpanded = false;
|
|
22
|
+
this.popupAnchor = null;
|
|
23
|
+
this.schedulePopupLayout = () => {
|
|
24
|
+
if (!this.popupExpanded || this.popupLayoutFrame !== undefined)
|
|
25
|
+
return;
|
|
26
|
+
this.popupLayoutFrame = window.requestAnimationFrame(() => {
|
|
27
|
+
this.popupLayoutFrame = undefined;
|
|
28
|
+
this.updatePopupBounds();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
19
31
|
}
|
|
20
32
|
launch(params) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
22
34
|
if (this.isLaunched()) {
|
|
23
35
|
console.warn('Footer widget is already launched');
|
|
24
36
|
return;
|
|
@@ -32,6 +44,10 @@ export class FooterWidgetBase extends BaseWidget {
|
|
|
32
44
|
this.maxWidth = (_d = this.config.maxWidth) !== null && _d !== void 0 ? _d : defaults.maxWidth;
|
|
33
45
|
this.height = (_e = this.config.height) !== null && _e !== void 0 ? _e : defaults.height;
|
|
34
46
|
this.showLevelIcons = (_f = this.config.showLevelIcons) !== null && _f !== void 0 ? _f : defaults.showLevelIcons;
|
|
47
|
+
const popupTopOffset = (_g = this.config.popupTopOffset) !== null && _g !== void 0 ? _g : defaults.popupTopOffset;
|
|
48
|
+
this.popupTopOffset = Number.isFinite(popupTopOffset)
|
|
49
|
+
? Math.max(0, popupTopOffset)
|
|
50
|
+
: defaults.popupTopOffset;
|
|
35
51
|
this.iframe = this.createIframe();
|
|
36
52
|
this.iframe = this.styleIframe(this.iframe);
|
|
37
53
|
this.iframe.src = `${this.childAppOrigin}${this.route}`;
|
|
@@ -45,6 +61,7 @@ export class FooterWidgetBase extends BaseWidget {
|
|
|
45
61
|
this.sendDataUpdate(partialData);
|
|
46
62
|
}
|
|
47
63
|
destroy() {
|
|
64
|
+
this.stopPopupLayoutTracking();
|
|
48
65
|
this.onLoadHandler = undefined;
|
|
49
66
|
this.onLoadCalled = false;
|
|
50
67
|
this.container = defaults.container;
|
|
@@ -74,39 +91,94 @@ export class FooterWidgetBase extends BaseWidget {
|
|
|
74
91
|
expandIframe(iframeRect) {
|
|
75
92
|
if (!this.iframe)
|
|
76
93
|
return;
|
|
77
|
-
if (
|
|
78
|
-
this.
|
|
94
|
+
if (this.popupExpanded) {
|
|
95
|
+
this.updatePopupBounds();
|
|
79
96
|
return;
|
|
80
97
|
}
|
|
81
98
|
const rect = iframeRect !== null && iframeRect !== void 0 ? iframeRect : this.iframe.getBoundingClientRect();
|
|
82
|
-
this.iframe.
|
|
83
|
-
this.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
const parent = this.iframe.parentElement;
|
|
100
|
+
if (this.container && parent === document.querySelector(this.container)) {
|
|
101
|
+
this.popupAnchor = document.createElement('div');
|
|
102
|
+
this.popupAnchor.setAttribute('aria-hidden', 'true');
|
|
103
|
+
Object.assign(this.popupAnchor.style, {
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
left: '0',
|
|
106
|
+
width: '100%',
|
|
107
|
+
height: this.height,
|
|
108
|
+
[this.position]: '0',
|
|
109
|
+
visibility: 'hidden',
|
|
110
|
+
pointerEvents: 'none',
|
|
111
|
+
});
|
|
112
|
+
parent === null || parent === void 0 ? void 0 : parent.appendChild(this.popupAnchor);
|
|
91
113
|
}
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
114
|
+
this.popupExpanded = true;
|
|
115
|
+
this.updatePopupBounds(this.popupAnchor ? rect : undefined);
|
|
116
|
+
this.startPopupLayoutTracking();
|
|
95
117
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (this.
|
|
100
|
-
this.iframe.style.position = 'absolute';
|
|
101
|
-
this.styleIframe(this.iframe);
|
|
118
|
+
updatePopupBounds(rect) {
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
120
|
+
if (rect === void 0) { rect = (_a = this.popupAnchor) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(); }
|
|
121
|
+
if (!this.iframe || !this.popupExpanded)
|
|
102
122
|
return;
|
|
123
|
+
const viewport = window.visualViewport;
|
|
124
|
+
const viewportLeft = (_b = viewport === null || viewport === void 0 ? void 0 : viewport.offsetLeft) !== null && _b !== void 0 ? _b : 0;
|
|
125
|
+
const viewportTop = (_c = viewport === null || viewport === void 0 ? void 0 : viewport.offsetTop) !== null && _c !== void 0 ? _c : 0;
|
|
126
|
+
const viewportRight = viewportLeft + ((_d = viewport === null || viewport === void 0 ? void 0 : viewport.width) !== null && _d !== void 0 ? _d : window.innerWidth);
|
|
127
|
+
const viewportBottom = viewportTop + ((_e = viewport === null || viewport === void 0 ? void 0 : viewport.height) !== null && _e !== void 0 ? _e : window.innerHeight);
|
|
128
|
+
const left = Math.max(viewportLeft, (_f = rect === null || rect === void 0 ? void 0 : rect.left) !== null && _f !== void 0 ? _f : viewportLeft);
|
|
129
|
+
const right = Math.min(viewportRight, (_g = rect === null || rect === void 0 ? void 0 : rect.right) !== null && _g !== void 0 ? _g : viewportRight);
|
|
130
|
+
const top = Math.min(viewportBottom, Math.max(viewportTop + this.popupTopOffset, this.position === 'top' ? ((_h = rect === null || rect === void 0 ? void 0 : rect.top) !== null && _h !== void 0 ? _h : viewportTop) : viewportTop));
|
|
131
|
+
const bottom = Math.min(viewportBottom, this.position === 'bottom'
|
|
132
|
+
? ((_j = rect === null || rect === void 0 ? void 0 : rect.bottom) !== null && _j !== void 0 ? _j : viewportBottom)
|
|
133
|
+
: viewportBottom);
|
|
134
|
+
Object.assign(this.iframe.style, {
|
|
135
|
+
position: 'fixed',
|
|
136
|
+
left: `${left}px`,
|
|
137
|
+
right: 'auto',
|
|
138
|
+
top: `${top}px`,
|
|
139
|
+
bottom: 'auto',
|
|
140
|
+
width: `${Math.max(0, right - left)}px`,
|
|
141
|
+
height: `${Math.max(0, bottom - top)}px`,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
startPopupLayoutTracking() {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
window.addEventListener('resize', this.schedulePopupLayout);
|
|
147
|
+
window.addEventListener('orientationchange', this.schedulePopupLayout);
|
|
148
|
+
window.addEventListener('scroll', this.schedulePopupLayout, true);
|
|
149
|
+
(_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.addEventListener('resize', this.schedulePopupLayout);
|
|
150
|
+
(_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.addEventListener('scroll', this.schedulePopupLayout);
|
|
151
|
+
if (this.popupAnchor && typeof ResizeObserver !== 'undefined') {
|
|
152
|
+
this.popupResizeObserver = new ResizeObserver(this.schedulePopupLayout);
|
|
153
|
+
this.popupResizeObserver.observe(this.popupAnchor);
|
|
154
|
+
if (this.popupAnchor.parentElement) {
|
|
155
|
+
this.popupResizeObserver.observe(this.popupAnchor.parentElement);
|
|
156
|
+
}
|
|
103
157
|
}
|
|
104
|
-
this.setIframeHeight(this.height);
|
|
105
158
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
159
|
+
stopPopupLayoutTracking() {
|
|
160
|
+
var _a, _b, _c, _d;
|
|
161
|
+
this.popupExpanded = false;
|
|
162
|
+
window.removeEventListener('resize', this.schedulePopupLayout);
|
|
163
|
+
window.removeEventListener('orientationchange', this.schedulePopupLayout);
|
|
164
|
+
window.removeEventListener('scroll', this.schedulePopupLayout, true);
|
|
165
|
+
(_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.removeEventListener('resize', this.schedulePopupLayout);
|
|
166
|
+
(_b = window.visualViewport) === null || _b === void 0 ? void 0 : _b.removeEventListener('scroll', this.schedulePopupLayout);
|
|
167
|
+
(_c = this.popupResizeObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
168
|
+
this.popupResizeObserver = undefined;
|
|
169
|
+
if (this.popupLayoutFrame !== undefined) {
|
|
170
|
+
window.cancelAnimationFrame(this.popupLayoutFrame);
|
|
171
|
+
this.popupLayoutFrame = undefined;
|
|
109
172
|
}
|
|
173
|
+
(_d = this.popupAnchor) === null || _d === void 0 ? void 0 : _d.remove();
|
|
174
|
+
this.popupAnchor = null;
|
|
175
|
+
}
|
|
176
|
+
collapseIframe() {
|
|
177
|
+
this.stopPopupLayoutTracking();
|
|
178
|
+
if (!this.iframe)
|
|
179
|
+
return;
|
|
180
|
+
this.iframe.style.position = this.container ? 'absolute' : 'fixed';
|
|
181
|
+
this.styleIframe(this.iframe);
|
|
110
182
|
}
|
|
111
183
|
onChildAppLoaded() {
|
|
112
184
|
var _a;
|
package/dist/core/types.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Clients } from './clients/registry';
|
|
2
2
|
export { splashJackpot } from './compat/v2/splashJackpot';
|
|
3
3
|
export { createSplashJackpot } from './compat/v3/createSplashJackpot';
|
|
4
|
+
export type { LobbyWidgetConfig, LobbyWidgetData, LobbyWidgetEvents, LobbyWidgetLaunchParams, } from './clients/x7k2m9qp/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splash-tech/jackpot-sdk",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "SDK for managing jackpot widgets in iframes",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
"build": "npm run clean && tsc",
|
|
21
21
|
"build:watch": "npm run clean && tsc --watch",
|
|
22
22
|
"publish:npm": "npm run build && npm publish --access public",
|
|
23
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
23
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
24
|
+
"test:lobby": "node --test tests/lobby-widget.cjs",
|
|
25
|
+
"test:footer": "node --test tests/footer-widget.cjs",
|
|
26
|
+
"preview:lobby": "tsc && node examples/serve.cjs"
|
|
24
27
|
},
|
|
25
28
|
"keywords": [
|
|
26
29
|
"jackpot",
|