@splash-tech/jackpot-sdk 3.0.5 → 3.0.6

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.
@@ -5,5 +5,6 @@ export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, F
5
5
  protected sendInitialData(): void;
6
6
  protected sendDataUpdate(partialData: object): void;
7
7
  protected handleChildMessage(type: string | undefined): boolean;
8
+ showPopup(): void;
8
9
  showWinPopup(data: unknown): void;
9
10
  }
@@ -2,6 +2,7 @@ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
2
  var IncomingEvent;
3
3
  (function (IncomingEvent) {
4
4
  IncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
5
+ IncomingEvent["ready"] = "jackpot-footer-widget-ready";
5
6
  IncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
6
7
  IncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
7
8
  IncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
@@ -12,6 +13,7 @@ var OutgoingEvent;
12
13
  OutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
13
14
  OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
14
15
  OutgoingEvent["showWinPopup"] = "jackpot-footer-widget-win-popup-show";
16
+ OutgoingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
15
17
  })(OutgoingEvent || (OutgoingEvent = {}));
16
18
  export class FooterWidget extends FooterWidgetBase {
17
19
  constructor() {
@@ -36,6 +38,9 @@ export class FooterWidget extends FooterWidgetBase {
36
38
  case IncomingEvent.footerWidgetLoaded:
37
39
  this.sendInitialData();
38
40
  return true;
41
+ case IncomingEvent.ready:
42
+ this.onChildAppLoaded();
43
+ return true;
39
44
  case IncomingEvent.participateChange:
40
45
  this.emit('participateChange');
41
46
  return true;
@@ -55,6 +60,16 @@ export class FooterWidget extends FooterWidgetBase {
55
60
  return false;
56
61
  }
57
62
  }
63
+ showPopup() {
64
+ if (!this.isLaunched()) {
65
+ console.warn('Footer widget must be launched before showPopup');
66
+ return;
67
+ }
68
+ this.sendToChild({
69
+ type: OutgoingEvent.showPopup,
70
+ data: null,
71
+ });
72
+ }
58
73
  showWinPopup(data) {
59
74
  if (!this.isLaunched()) {
60
75
  console.warn('Footer widget must be launched before showWinPopup');
@@ -2,6 +2,7 @@ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
2
  var IncomingEvent;
3
3
  (function (IncomingEvent) {
4
4
  IncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
5
+ IncomingEvent["ready"] = "jackpot-footer-widget-ready";
5
6
  IncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
6
7
  IncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
7
8
  IncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
@@ -34,6 +35,9 @@ export class FooterWidget extends FooterWidgetBase {
34
35
  case IncomingEvent.footerWidgetLoaded:
35
36
  this.sendInitialData();
36
37
  return true;
38
+ case IncomingEvent.ready:
39
+ this.onChildAppLoaded();
40
+ return true;
37
41
  case IncomingEvent.showPopup:
38
42
  this.emit('showPopup');
39
43
  this.expandIframe();
@@ -1,6 +1,6 @@
1
- import { FooterWidgetBaseConfig, WidgetLaunchParams, WinWidgetBaseConfig } from '../../core/types';
1
+ import { FooterWidgetLaunchParams, WidgetLaunchParams, WinWidgetBaseConfig } from '../../core/types';
2
2
  import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
3
- export declare function mapV2FooterWidgetLaunchParams(params: V2FooterWidgetLaunchParams): WidgetLaunchParams<FooterWidgetBaseConfig>;
3
+ export declare function mapV2FooterWidgetLaunchParams(params: V2FooterWidgetLaunchParams): FooterWidgetLaunchParams;
4
4
  export declare function mapV2WinWidgetLaunchParams(params: V2WinWidgetLaunchParams): WidgetLaunchParams<WinWidgetBaseConfig & {
5
5
  animation?: 'wheel' | 'airplane';
6
6
  }>;
@@ -1,6 +1,7 @@
1
1
  export function mapV2FooterWidgetLaunchParams(params) {
2
2
  return {
3
3
  data: params.data,
4
+ onLoad: params.onLoad,
4
5
  config: Object.assign(Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
5
6
  ? { container: params.container }
6
7
  : {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})), (params.height !== undefined ? { height: params.height } : {})),
@@ -8,6 +8,7 @@ export interface V2FooterWidgetLaunchParams {
8
8
  maxWidth?: string;
9
9
  height?: string;
10
10
  container?: string;
11
+ onLoad?: () => void;
11
12
  }
12
13
  export interface V2WinWidgetLaunchParams {
13
14
  data: unknown;
@@ -1,18 +1,21 @@
1
1
  import { BaseWidget } from './BaseWidget';
2
- import { FooterWidgetBaseConfig, WidgetLaunchParams } from './types';
2
+ import { FooterWidgetBaseConfig, FooterWidgetLaunchParams } from './types';
3
3
  export declare abstract class FooterWidgetBase<TConfig extends FooterWidgetBaseConfig, TEvents> extends BaseWidget<TConfig, TEvents> {
4
4
  protected abstract readonly route: string;
5
5
  protected container: string;
6
6
  protected position: "top" | "bottom";
7
7
  protected maxWidth: string;
8
8
  protected height: string;
9
+ private onLoadHandler?;
10
+ private onLoadCalled;
9
11
  protected abstract sendInitialData(): void;
10
12
  protected abstract sendDataUpdate(partialData: object): void;
11
- launch(params: WidgetLaunchParams<TConfig>): void;
13
+ launch(params: FooterWidgetLaunchParams<TConfig>): void;
12
14
  updateData(partialData: object): void;
13
15
  destroy(): void;
14
16
  protected styleIframe(iframe: HTMLIFrameElement): HTMLIFrameElement;
15
17
  protected expandIframe(): void;
16
18
  protected collapseIframe(): void;
17
19
  private setIframeHeight;
20
+ protected onChildAppLoaded(): void;
18
21
  }
@@ -13,6 +13,7 @@ export class FooterWidgetBase extends BaseWidget {
13
13
  this.position = defaults.position;
14
14
  this.maxWidth = defaults.maxWidth;
15
15
  this.height = defaults.height;
16
+ this.onLoadCalled = false;
16
17
  }
17
18
  launch(params) {
18
19
  var _a, _b, _c, _d, _e;
@@ -22,6 +23,8 @@ export class FooterWidgetBase extends BaseWidget {
22
23
  }
23
24
  this.config = (_a = params.config) !== null && _a !== void 0 ? _a : {};
24
25
  this.data = params.data;
26
+ this.onLoadHandler = params.onLoad;
27
+ this.onLoadCalled = false;
25
28
  this.container = (_b = this.config.container) !== null && _b !== void 0 ? _b : defaults.container;
26
29
  this.position = (_c = this.config.position) !== null && _c !== void 0 ? _c : defaults.position;
27
30
  this.maxWidth = (_d = this.config.maxWidth) !== null && _d !== void 0 ? _d : defaults.maxWidth;
@@ -39,6 +42,8 @@ export class FooterWidgetBase extends BaseWidget {
39
42
  this.sendDataUpdate(partialData);
40
43
  }
41
44
  destroy() {
45
+ this.onLoadHandler = undefined;
46
+ this.onLoadCalled = false;
42
47
  this.container = defaults.container;
43
48
  this.position = defaults.position;
44
49
  this.maxWidth = defaults.maxWidth;
@@ -72,4 +77,11 @@ export class FooterWidgetBase extends BaseWidget {
72
77
  this.iframe.style.height = height;
73
78
  }
74
79
  }
80
+ onChildAppLoaded() {
81
+ var _a;
82
+ if (this.onLoadCalled)
83
+ return;
84
+ this.onLoadCalled = true;
85
+ (_a = this.onLoadHandler) === null || _a === void 0 ? void 0 : _a.call(this);
86
+ }
75
87
  }
@@ -2,6 +2,9 @@ export interface WidgetLaunchParams<TConfig> {
2
2
  config?: TConfig;
3
3
  data: unknown;
4
4
  }
5
+ export interface FooterWidgetLaunchParams<TConfig extends FooterWidgetBaseConfig = FooterWidgetBaseConfig> extends WidgetLaunchParams<TConfig> {
6
+ onLoad?: () => void;
7
+ }
5
8
  export interface FooterWidgetBaseConfig {
6
9
  container?: string;
7
10
  position?: 'top' | 'bottom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splash-tech/jackpot-sdk",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "SDK for managing jackpot widgets in iframes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",