@splash-tech/jackpot-sdk 3.0.3 → 3.0.5

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 CHANGED
@@ -54,6 +54,7 @@ splashJackpot.winWidget.launch({
54
54
  | container | string | document.body | CSS selector where widget will be injected |
55
55
  | mode | string | production | SDK environment (`local`, `dev`, `staging`, `production`) |
56
56
  | maxWidth | string | '1300px' | Maximum width of the footer widget |
57
+ | height | string | '50px' | Height of the footer widget |
57
58
 
58
59
  Example:
59
60
 
@@ -63,6 +64,7 @@ splashJackpot.footerWidget.launch({
63
64
  container: '#game-container',
64
65
  mode: 'production',
65
66
  maxWidth: '100%',
67
+ height: '80px',
66
68
  });
67
69
  ```
68
70
 
@@ -2,7 +2,6 @@ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
2
  import { FooterWidgetConfig, FooterWidgetEvents } from './types';
3
3
  export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, FooterWidgetEvents> {
4
4
  protected readonly route = "/footer-widget";
5
- protected readonly height = "64px";
6
5
  protected sendInitialData(): void;
7
6
  protected sendDataUpdate(partialData: object): void;
8
7
  protected handleChildMessage(type: string | undefined): boolean;
@@ -17,7 +17,6 @@ export class FooterWidget extends FooterWidgetBase {
17
17
  constructor() {
18
18
  super(...arguments);
19
19
  this.route = '/footer-widget';
20
- this.height = '64px';
21
20
  }
22
21
  sendInitialData() {
23
22
  this.sendToChild({
File without changes
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ // import { LobbyWidgetBase } from '../../core/LobbyWidgetBase';
3
+ // import { InitialChildMessage } from '../../core/types';
4
+ // import { LobbyWidgetConfig, LobbyWidgetEvents } from './types';
5
+ // enum IncomingEvent {
6
+ // lobbyWidgetLoaded = 'jackpot-lobby-widget-loaded',
7
+ // optInToggle = 'jackpot-lobby-widget-opt-in-toggle',
8
+ // showAll = 'jackpot-lobby-widget-show-all',
9
+ // toggleFavorite = 'jackpot-lobby-widget-toggle-favorite',
10
+ // infoClick = 'jackpot-lobby-widget-info-click',
11
+ // gameClick = 'jackpot-lobby-widget-game-click',
12
+ // resize = 'jackpot-lobby-widget-resize',
13
+ // }
14
+ // enum OutgoingEvent {
15
+ // lobbyWidgetDataInitial = 'jackpot-lobby-widget-data-initial',
16
+ // lobbyWidgetDataUpdated = 'jackpot-lobby-widget-data-updated',
17
+ // }
18
+ // export class LobbyWidget extends LobbyWidgetBase<
19
+ // LobbyWidgetConfig,
20
+ // LobbyWidgetEvents
21
+ // > {
22
+ // protected readonly route = '/lobby-widget';
23
+ // protected sendInitialData(): void {
24
+ // this.sendToChild({
25
+ // type: OutgoingEvent.lobbyWidgetDataInitial,
26
+ // data: this.data,
27
+ // config: this.config,
28
+ // } satisfies InitialChildMessage<LobbyWidgetConfig>);
29
+ // }
30
+ // protected sendDataUpdate(partialData: object): void {
31
+ // this.sendToChild({
32
+ // type: OutgoingEvent.lobbyWidgetDataUpdated,
33
+ // data: partialData,
34
+ // });
35
+ // }
36
+ // protected handleChildMessage(
37
+ // type: string | undefined,
38
+ // payload?: unknown,
39
+ // ): boolean {
40
+ // switch (type) {
41
+ // case IncomingEvent.lobbyWidgetLoaded:
42
+ // this.sendInitialData();
43
+ // return true;
44
+ // case IncomingEvent.optInToggle:
45
+ // this.emit('optInToggle');
46
+ // return true;
47
+ // case IncomingEvent.showAll:
48
+ // this.emit('showAll');
49
+ // return true;
50
+ // case IncomingEvent.toggleFavorite:
51
+ // this.emit('toggleFavorite', payload);
52
+ // return true;
53
+ // case IncomingEvent.infoClick:
54
+ // this.emit('infoClick');
55
+ // return true;
56
+ // case IncomingEvent.gameClick:
57
+ // this.emit('gameClick', payload);
58
+ // return true;
59
+ // case IncomingEvent.resize: {
60
+ // const height = (payload as { height?: number } | undefined)?.height;
61
+ // if (this.iframe && typeof height === 'number' && height > 0) {
62
+ // this.iframe.style.height = `${height}px`;
63
+ // }
64
+ // return true;
65
+ // }
66
+ // default:
67
+ // return false;
68
+ // }
69
+ // }
70
+ // }
@@ -1,4 +1,4 @@
1
- import { SDKEnv } from '../core/types';
1
+ 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';
@@ -19,8 +19,8 @@ export interface ClientWidgets {
19
19
  [Clients.h4n8w3vt]: H4Widgets;
20
20
  }
21
21
  interface ClientDefinition<C extends ClientId> {
22
- baseUrls: Record<SDKEnv, string>;
23
- createWidgets: (origin: string) => ClientWidgets[C];
22
+ baseUrls?: Record<SDKEnv, string>;
23
+ createWidgets: (baseUrl: string) => ClientWidgets[C];
24
24
  }
25
25
  export declare const clientRegistry: {
26
26
  [K in ClientId]: ClientDefinition<K>;
@@ -13,20 +13,14 @@ export const clientRegistry = {
13
13
  staging: 'https://jackpot-widget-staging.splash.tech',
14
14
  production: 'https://jackpot-widget.splash.tech',
15
15
  },
16
- createWidgets: (origin) => ({
17
- footerWidget: new FooterWidgetX7(origin),
18
- winWidget: new WinWidgetX7(origin),
16
+ createWidgets: (baseUrl) => ({
17
+ footerWidget: new FooterWidgetX7(baseUrl),
18
+ winWidget: new WinWidgetX7(baseUrl),
19
19
  }),
20
20
  },
21
21
  [Clients.h4n8w3vt]: {
22
- baseUrls: {
23
- local: 'http://localhost:4742',
24
- dev: 'https://jackpot-widget-b2tech-dev.splash.tech',
25
- staging: 'https://jackpot-widget-b2tech-staging.splash.tech',
26
- production: 'https://jackpot-widget-b2tech.splash.tech',
27
- },
28
- createWidgets: (origin) => ({
29
- footerWidget: new FooterWidgetH4(origin),
22
+ createWidgets: (baseUrl) => ({
23
+ footerWidget: new FooterWidgetH4(baseUrl),
30
24
  }),
31
25
  },
32
26
  };
@@ -2,7 +2,6 @@ import { FooterWidgetBase } from '../../core/FooterWidgetBase';
2
2
  import { FooterWidgetConfig, FooterWidgetEvents } from './types';
3
3
  export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, FooterWidgetEvents> {
4
4
  protected readonly route = "/footer-widget";
5
- protected readonly height = "50px";
6
5
  protected sendInitialData(): void;
7
6
  protected sendDataUpdate(partialData: object): void;
8
7
  protected handleChildMessage(type: string | undefined): boolean;
@@ -15,7 +15,6 @@ export class FooterWidget extends FooterWidgetBase {
15
15
  constructor() {
16
16
  super(...arguments);
17
17
  this.route = '/footer-widget';
18
- this.height = '50px';
19
18
  }
20
19
  sendInitialData() {
21
20
  this.sendToChild({
@@ -1,17 +1,5 @@
1
- import { FooterWidgetBaseConfig, SDKEnv, WidgetLaunchParams, WinWidgetBaseConfig } from '../../core/types';
2
- export interface V2FooterWidgetLaunchParams {
3
- data: unknown;
4
- mode?: SDKEnv;
5
- position?: FooterWidgetBaseConfig['position'];
6
- maxWidth?: string;
7
- container?: string;
8
- }
9
- export interface V2WinWidgetLaunchParams {
10
- data: unknown;
11
- mode?: SDKEnv;
12
- animation?: 'wheel' | 'airplane';
13
- container?: string;
14
- }
1
+ import { FooterWidgetBaseConfig, WidgetLaunchParams, WinWidgetBaseConfig } from '../../core/types';
2
+ import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
15
3
  export declare function mapV2FooterWidgetLaunchParams(params: V2FooterWidgetLaunchParams): WidgetLaunchParams<FooterWidgetBaseConfig>;
16
4
  export declare function mapV2WinWidgetLaunchParams(params: V2WinWidgetLaunchParams): WidgetLaunchParams<WinWidgetBaseConfig & {
17
5
  animation?: 'wheel' | 'airplane';
@@ -1,9 +1,9 @@
1
1
  export function mapV2FooterWidgetLaunchParams(params) {
2
2
  return {
3
3
  data: params.data,
4
- config: Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
4
+ config: Object.assign(Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
5
5
  ? { container: params.container }
6
- : {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})),
6
+ : {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})), (params.height !== undefined ? { height: params.height } : {})),
7
7
  };
8
8
  }
9
9
  export function mapV2WinWidgetLaunchParams(params) {
@@ -1,6 +1,6 @@
1
1
  import { FooterWidgetEvents, WinWidgetEvents } from '../../clients/x7k2m9qp/types';
2
2
  import { WidgetEventHandler } from '../../core/types';
3
- import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './mapLaunchParams';
3
+ import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
4
4
  export declare const splashJackpot: {
5
5
  footerWidget: {
6
6
  isLaunched: () => boolean;
@@ -1,4 +1,4 @@
1
- import { Clients } from '../../clients/registry';
1
+ import { Clients, clientRegistry } from '../../clients/registry';
2
2
  import { createSplashJackpot } from '../v3/createSplashJackpot';
3
3
  import { mapV2FooterWidgetLaunchParams, mapV2WinWidgetLaunchParams, } from './mapLaunchParams';
4
4
  // Facade for legacy v2.
@@ -9,12 +9,21 @@ function createV2SplashJackpot() {
9
9
  let instance = null;
10
10
  const footerWidgetListeners = new Map();
11
11
  const winWidgetListeners = new Map();
12
+ function resolveBuiltInBaseUrl(mode) {
13
+ var _a;
14
+ const env = mode !== null && mode !== void 0 ? mode : 'production';
15
+ const baseUrl = (_a = clientRegistry[Clients.x7k2m9qp].baseUrls) === null || _a === void 0 ? void 0 : _a[env];
16
+ if (!baseUrl) {
17
+ throw new Error(`splashJackpot: no widget URL for mode "${env}".`);
18
+ }
19
+ return baseUrl;
20
+ }
12
21
  function createInstance(mode) {
13
22
  if (instance)
14
23
  return instance;
15
24
  instance = createSplashJackpot({
16
25
  client: Clients.x7k2m9qp,
17
- env: mode !== null && mode !== void 0 ? mode : 'production',
26
+ baseUrl: resolveBuiltInBaseUrl(mode),
18
27
  });
19
28
  for (const [event, handlers] of footerWidgetListeners) {
20
29
  for (const handler of handlers) {
@@ -0,0 +1,17 @@
1
+ import { FooterWidgetBaseConfig } from '../../core/types';
2
+ export type SDKEnv = 'local' | 'dev' | 'staging' | 'production';
3
+ export type V2Mode = SDKEnv;
4
+ export interface V2FooterWidgetLaunchParams {
5
+ data: unknown;
6
+ mode?: V2Mode;
7
+ position?: FooterWidgetBaseConfig['position'];
8
+ maxWidth?: string;
9
+ height?: string;
10
+ container?: string;
11
+ }
12
+ export interface V2WinWidgetLaunchParams {
13
+ data: unknown;
14
+ mode?: V2Mode;
15
+ animation?: 'wheel' | 'airplane';
16
+ container?: string;
17
+ }
@@ -1,3 +1,3 @@
1
1
  import { ClientId } from '../../clients/registry';
2
- import { SplashJackpotInitOptions, SplashJackpotSDK } from '../../types';
2
+ import { SplashJackpotSDK, SplashJackpotInitOptions } from './types';
3
3
  export declare function createSplashJackpot<C extends ClientId>(options: SplashJackpotInitOptions<C>): SplashJackpotSDK<C>;
@@ -1,11 +1,8 @@
1
1
  import { clientRegistry } from '../../clients/registry';
2
2
  export function createSplashJackpot(options) {
3
- var _a;
4
3
  const client = clientRegistry[options.client];
5
4
  if (!client) {
6
5
  throw new Error(`createSplashJackpot: unknown client "${options.client}".`);
7
6
  }
8
- const env = (_a = options.env) !== null && _a !== void 0 ? _a : 'production';
9
- const childAppOrigin = client.baseUrls[env];
10
- return client.createWidgets(childAppOrigin);
7
+ return client.createWidgets(options.baseUrl);
11
8
  }
@@ -1,7 +1,6 @@
1
- import { ClientId, ClientWidgets } from './clients/registry';
2
- import { SDKEnv } from './core/types';
1
+ import { ClientId, ClientWidgets } from '../../clients/registry';
3
2
  export interface SplashJackpotInitOptions<C extends ClientId> {
4
3
  client: C;
5
- env?: SDKEnv;
4
+ baseUrl: string;
6
5
  }
7
6
  export type SplashJackpotSDK<C extends ClientId> = ClientWidgets[C];
@@ -0,0 +1 @@
1
+ export {};
@@ -2,10 +2,10 @@ import { BaseWidget } from './BaseWidget';
2
2
  import { FooterWidgetBaseConfig, WidgetLaunchParams } 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
- protected abstract readonly height: string;
6
5
  protected container: string;
7
6
  protected position: "top" | "bottom";
8
7
  protected maxWidth: string;
8
+ protected height: string;
9
9
  protected abstract sendInitialData(): void;
10
10
  protected abstract sendDataUpdate(partialData: object): void;
11
11
  launch(params: WidgetLaunchParams<TConfig>): void;
@@ -4,6 +4,7 @@ const defaults = {
4
4
  container: '',
5
5
  position: 'bottom',
6
6
  maxWidth: '1300px',
7
+ height: '50px',
7
8
  };
8
9
  export class FooterWidgetBase extends BaseWidget {
9
10
  constructor() {
@@ -11,9 +12,10 @@ export class FooterWidgetBase extends BaseWidget {
11
12
  this.container = defaults.container;
12
13
  this.position = defaults.position;
13
14
  this.maxWidth = defaults.maxWidth;
15
+ this.height = defaults.height;
14
16
  }
15
17
  launch(params) {
16
- var _a, _b, _c, _d;
18
+ var _a, _b, _c, _d, _e;
17
19
  if (this.isLaunched()) {
18
20
  console.warn('Footer widget is already launched');
19
21
  return;
@@ -23,6 +25,7 @@ export class FooterWidgetBase extends BaseWidget {
23
25
  this.container = (_b = this.config.container) !== null && _b !== void 0 ? _b : defaults.container;
24
26
  this.position = (_c = this.config.position) !== null && _c !== void 0 ? _c : defaults.position;
25
27
  this.maxWidth = (_d = this.config.maxWidth) !== null && _d !== void 0 ? _d : defaults.maxWidth;
28
+ this.height = (_e = this.config.height) !== null && _e !== void 0 ? _e : defaults.height;
26
29
  this.iframe = this.createIframe();
27
30
  this.iframe = this.styleIframe(this.iframe);
28
31
  this.iframe.src = `${this.childAppOrigin}${this.route}`;
@@ -39,6 +42,7 @@ export class FooterWidgetBase extends BaseWidget {
39
42
  this.container = defaults.container;
40
43
  this.position = defaults.position;
41
44
  this.maxWidth = defaults.maxWidth;
45
+ this.height = defaults.height;
42
46
  this.stopListening();
43
47
  this.removeIframe();
44
48
  }
File without changes
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ // import { validateNonEmptyObject } from '../shared/validation';
3
+ // import { BaseWidget } from './BaseWidget';
4
+ // import { LobbyWidgetBaseConfig, LobbyWidgetLaunchParams } from './types';
5
+ // const LOBBY_IFRAME_ATTR = 'data-splash-lobby-widget';
6
+ // const defaults = {
7
+ // container: '',
8
+ // showHero: false,
9
+ // };
10
+ // export abstract class LobbyWidgetBase<
11
+ // TConfig extends LobbyWidgetBaseConfig,
12
+ // TEvents,
13
+ // > extends BaseWidget<TConfig, TEvents> {
14
+ // protected abstract readonly route: string;
15
+ // protected container = defaults.container;
16
+ // protected showHero = defaults.showHero;
17
+ // protected abstract sendInitialData(): void;
18
+ // protected abstract sendDataUpdate(partialData: object): void;
19
+ // public launch(params: LobbyWidgetLaunchParams<TConfig>): this {
20
+ // if (this.isLaunched()) {
21
+ // console.warn('Lobby widget is already launched');
22
+ // return this;
23
+ // }
24
+ // this.config = params.config ?? ({} as TConfig);
25
+ // this.data = params.data;
26
+ // this.container = this.config.container ?? defaults.container;
27
+ // this.showHero = this.config.showHero ?? defaults.showHero;
28
+ // if (!this.container) {
29
+ // console.error('Lobby widget: config.container is required.');
30
+ // return this;
31
+ // }
32
+ // const targetContainer = document.querySelector(this.container);
33
+ // if (!targetContainer) {
34
+ // console.error(`Lobby widget: container "${this.container}" not found`);
35
+ // return this;
36
+ // }
37
+ // if (targetContainer.querySelector(`iframe[${LOBBY_IFRAME_ATTR}]`)) {
38
+ // console.error(
39
+ // `Lobby widget: container "${this.container}" already has a lobby widget. Use a separate container per widget.`,
40
+ // );
41
+ // return this;
42
+ // }
43
+ // this.iframe = this.createIframe();
44
+ // this.iframe = this.styleIframe(this.iframe);
45
+ // this.iframe.setAttribute(LOBBY_IFRAME_ATTR, '');
46
+ // this.iframe.src = `${this.childAppOrigin}${this.route}`;
47
+ // this.iframe.style.position = 'relative';
48
+ // targetContainer.appendChild(this.iframe);
49
+ // this.setLaunched(true);
50
+ // this.startListening();
51
+ // return this;
52
+ // }
53
+ // public updateData(partialData: object): void {
54
+ // if (!validateNonEmptyObject(partialData, 'lobbyWidget.updateData')) return;
55
+ // this.sendDataUpdate(partialData);
56
+ // }
57
+ // public destroy(): void {
58
+ // this.container = defaults.container;
59
+ // this.showHero = defaults.showHero;
60
+ // this.stopListening();
61
+ // this.removeIframe();
62
+ // }
63
+ // protected styleIframe(iframe: HTMLIFrameElement): HTMLIFrameElement {
64
+ // iframe.style.display = 'block';
65
+ // iframe.style.width = '100%';
66
+ // iframe.style.border = 'none';
67
+ // iframe.style.backgroundColor = 'transparent';
68
+ // iframe.style.zIndex = '1';
69
+ // return iframe;
70
+ // }
71
+ // }
@@ -1,4 +1,3 @@
1
- export type SDKEnv = 'local' | 'dev' | 'staging' | 'production';
2
1
  export interface WidgetLaunchParams<TConfig> {
3
2
  config?: TConfig;
4
3
  data: unknown;
@@ -7,6 +6,7 @@ export interface FooterWidgetBaseConfig {
7
6
  container?: string;
8
7
  position?: 'top' | 'bottom';
9
8
  maxWidth?: string;
9
+ height?: string;
10
10
  }
11
11
  export interface WinWidgetBaseConfig {
12
12
  container?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splash-tech/jackpot-sdk",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "SDK for managing jackpot widgets in iframes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
File without changes