@splash-tech/jackpot-sdk 3.0.2 → 3.0.4
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 +21 -123
- package/dist/clients/{b2tech/B2TechFooterWidget.d.ts → h4n8w3vt/FooterWidget.d.ts} +2 -3
- package/dist/clients/{b2tech/B2TechFooterWidget.js → h4n8w3vt/FooterWidget.js} +17 -21
- package/dist/clients/h4n8w3vt/types.d.ts +9 -0
- package/dist/clients/registry.d.ts +18 -14
- package/dist/clients/registry.js +14 -16
- package/dist/clients/{defaultClient/DefaultClientFooterWidget.d.ts → x7k2m9qp/FooterWidget.d.ts} +2 -2
- package/dist/clients/{defaultClient/DefaultClientFooterWidget.js → x7k2m9qp/FooterWidget.js} +1 -1
- package/dist/clients/{defaultClient/DefaultClientWinWidget.d.ts → x7k2m9qp/WinWidget.d.ts} +2 -2
- package/dist/clients/{defaultClient/DefaultClientWinWidget.js → x7k2m9qp/WinWidget.js} +1 -1
- package/dist/clients/x7k2m9qp/types.d.ts +14 -0
- package/dist/compat/v2/mapLaunchParams.d.ts +6 -0
- package/dist/compat/v2/mapLaunchParams.js +18 -0
- package/dist/compat/v2/splashJackpot.d.ts +22 -0
- package/dist/compat/v2/splashJackpot.js +100 -0
- package/dist/compat/v2/types.d.ts +16 -0
- package/dist/compat/v3/createSplashJackpot.d.ts +3 -0
- package/dist/compat/v3/createSplashJackpot.js +8 -0
- package/dist/{types.d.ts → compat/v3/types.d.ts} +2 -3
- package/dist/compat/v3/types.js +1 -0
- package/dist/core/types.d.ts +0 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -11
- package/package.json +1 -1
- package/dist/clients/b2tech/types.d.ts +0 -6
- package/dist/clients/defaultClient/types.d.ts +0 -14
- /package/dist/clients/{b2tech → h4n8w3vt}/types.js +0 -0
- /package/dist/clients/{defaultClient → x7k2m9qp}/types.js +0 -0
- /package/dist/{types.js → compat/v2/types.js} +0 -0
package/README.md
CHANGED
|
@@ -22,28 +22,23 @@ npm install @splash-tech/jackpot-sdk
|
|
|
22
22
|
|
|
23
23
|
# Quick Start
|
|
24
24
|
|
|
25
|
-
The SDK is initialized once with your **clientId**. The clientId determines which widget app is loaded, which launch options are available, and which events are emitted — all fully typed.
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import { createSplashJackpot } from '@splash-tech/jackpot-sdk';
|
|
29
|
-
|
|
30
|
-
const splashJackpot = createSplashJackpot({
|
|
31
|
-
client: 'defaultClient',
|
|
32
|
-
env: 'production',
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
25
|
## Launch Footer Widget
|
|
37
26
|
|
|
38
27
|
```ts
|
|
28
|
+
import { splashJackpot } from '@splash-tech/jackpot-sdk';
|
|
29
|
+
|
|
39
30
|
splashJackpot.footerWidget.launch({
|
|
40
31
|
data: widgetData,
|
|
41
32
|
});
|
|
42
33
|
```
|
|
43
34
|
|
|
35
|
+
---
|
|
36
|
+
|
|
44
37
|
## Launch Win Widget
|
|
45
38
|
|
|
46
39
|
```ts
|
|
40
|
+
import { splashJackpot } from '@splash-tech/jackpot-sdk';
|
|
41
|
+
|
|
47
42
|
splashJackpot.winWidget.launch({
|
|
48
43
|
data: winData,
|
|
49
44
|
});
|
|
@@ -51,53 +46,23 @@ splashJackpot.winWidget.launch({
|
|
|
51
46
|
|
|
52
47
|
---
|
|
53
48
|
|
|
54
|
-
# Initialization Options
|
|
55
|
-
|
|
56
|
-
| Option | Type | Default | Description |
|
|
57
|
-
| ------ | ------ | ---------- | ---------------------------------------------------------- |
|
|
58
|
-
| client | string | (required) | Client integration to use (`defaultClient`, `b2tech`) |
|
|
59
|
-
| env | string | production | SDK environment (`local`, `dev`, `staging`, `production`) |
|
|
60
|
-
|
|
61
|
-
An unknown `client` throws at initialization.
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
49
|
# Widget Launch Parameters
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
74
|
-
## Footer Widget `config`
|
|
75
|
-
|
|
76
|
-
| Field | Type | Default | Description |
|
|
77
|
-
| --------- | ----------------- | ------------- | ------------------------------------------ |
|
|
78
|
-
| position | 'top' \| 'bottom' | per client | Where the footer bar is docked |
|
|
79
|
-
| maxWidth | string | per client | Maximum width of the footer widget |
|
|
80
|
-
| container | string | document.body | CSS selector where widget will be injected |
|
|
81
|
-
|
|
82
|
-
## Win Widget `config`
|
|
83
|
-
|
|
84
|
-
| Field | Type | Default | Description |
|
|
85
|
-
| --------- | --------------------- | ------------- | ------------------------------------------------------- |
|
|
86
|
-
| animation | 'wheel' \| 'airplane' | 'wheel' | Win animation to play (`defaultClient` only) |
|
|
87
|
-
| container | string | document.body | CSS selector where widget will be injected |
|
|
88
|
-
|
|
89
|
-
Clients may have additional `config` fields; TypeScript only offers the fields valid for your clientId.
|
|
51
|
+
| Parameter | Type | Default | Description |
|
|
52
|
+
| --------- | ------ | ------------- | --------------------------------------------------------- |
|
|
53
|
+
| data | object | null | Widget data from Splash backend |
|
|
54
|
+
| container | string | document.body | CSS selector where widget will be injected |
|
|
55
|
+
| mode | string | production | SDK environment (`local`, `dev`, `staging`, `production`) |
|
|
56
|
+
| maxWidth | string | '1300px' | Maximum width of the footer widget |
|
|
90
57
|
|
|
91
58
|
Example:
|
|
92
59
|
|
|
93
60
|
```ts
|
|
94
61
|
splashJackpot.footerWidget.launch({
|
|
95
62
|
data: widgetData,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
container: '#game-container',
|
|
100
|
-
},
|
|
63
|
+
container: '#game-container',
|
|
64
|
+
mode: 'production',
|
|
65
|
+
maxWidth: '100%',
|
|
101
66
|
});
|
|
102
67
|
```
|
|
103
68
|
|
|
@@ -105,9 +70,7 @@ splashJackpot.footerWidget.launch({
|
|
|
105
70
|
|
|
106
71
|
# Widget API
|
|
107
72
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## Footer Widget (core, all clients)
|
|
73
|
+
## Footer Widget
|
|
111
74
|
|
|
112
75
|
- `launch()` – launch widget
|
|
113
76
|
- `updateData()` – update jackpot values
|
|
@@ -117,11 +80,7 @@ Every client gets the core API. On top of it, a client may have extra methods de
|
|
|
117
80
|
- `removeAllEventListeners()` – remove all listeners
|
|
118
81
|
- `destroy()` – remove widget from DOM
|
|
119
82
|
|
|
120
|
-
##
|
|
121
|
-
|
|
122
|
-
- `helloWorld()` – placeholder client-specific method
|
|
123
|
-
|
|
124
|
-
## Win Widget (core, all clients)
|
|
83
|
+
## Win Widget
|
|
125
84
|
|
|
126
85
|
- `launch()`
|
|
127
86
|
- `isLaunched()`
|
|
@@ -134,9 +93,7 @@ Every client gets the core API. On top of it, a client may have extra methods de
|
|
|
134
93
|
|
|
135
94
|
# Events
|
|
136
95
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
## Footer Widget (`defaultClient`)
|
|
96
|
+
## Footer Widget
|
|
140
97
|
|
|
141
98
|
| Event | Description |
|
|
142
99
|
| ----------------- | ---------------------------------- |
|
|
@@ -144,14 +101,6 @@ Events are client-specific; TypeScript only offers the event names valid for you
|
|
|
144
101
|
| hidePopup | Footer popup closed |
|
|
145
102
|
| participateChange | User toggled jackpot participation |
|
|
146
103
|
|
|
147
|
-
## Footer Widget (`b2tech` client)
|
|
148
|
-
|
|
149
|
-
| Event | Description |
|
|
150
|
-
| ------------------ | ------------------------------- |
|
|
151
|
-
| panelOpen | Footer panel opened |
|
|
152
|
-
| panelClose | Footer panel closed |
|
|
153
|
-
| subscriptionChange | User toggled their subscription |
|
|
154
|
-
|
|
155
104
|
Example:
|
|
156
105
|
|
|
157
106
|
```ts
|
|
@@ -160,18 +109,14 @@ splashJackpot.footerWidget.addEventListener('showPopup', () => {
|
|
|
160
109
|
});
|
|
161
110
|
```
|
|
162
111
|
|
|
163
|
-
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Win Widget
|
|
164
115
|
|
|
165
116
|
| Event | Description |
|
|
166
117
|
| ----- | ----------------- |
|
|
167
118
|
| close | Win widget closed |
|
|
168
119
|
|
|
169
|
-
## Win Widget (`b2tech` client)
|
|
170
|
-
|
|
171
|
-
| Event | Description |
|
|
172
|
-
| --------- | -------------------- |
|
|
173
|
-
| dismissed | Win widget dismissed |
|
|
174
|
-
|
|
175
120
|
---
|
|
176
121
|
|
|
177
122
|
# Cleanup
|
|
@@ -185,53 +130,6 @@ splashJackpot.footerWidget.destroy();
|
|
|
185
130
|
|
|
186
131
|
---
|
|
187
132
|
|
|
188
|
-
# Migrating from 2.x
|
|
189
|
-
|
|
190
|
-
```ts
|
|
191
|
-
// 2.x
|
|
192
|
-
import { splashJackpot } from '@splash-tech/jackpot-sdk';
|
|
193
|
-
|
|
194
|
-
splashJackpot.footerWidget.launch({
|
|
195
|
-
data: widgetData,
|
|
196
|
-
mode: 'production',
|
|
197
|
-
position: 'bottom',
|
|
198
|
-
maxWidth: '100%',
|
|
199
|
-
container: '#game-container',
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
// 3.x
|
|
203
|
-
import { createSplashJackpot } from '@splash-tech/jackpot-sdk';
|
|
204
|
-
|
|
205
|
-
const splashJackpot = createSplashJackpot({
|
|
206
|
-
client: 'defaultClient',
|
|
207
|
-
env: 'production',
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
splashJackpot.footerWidget.launch({
|
|
211
|
-
data: widgetData,
|
|
212
|
-
config: {
|
|
213
|
-
position: 'bottom',
|
|
214
|
-
maxWidth: '100%',
|
|
215
|
-
container: '#game-container',
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
- `client` and `env` moved from `launch()` to `createSplashJackpot()`.
|
|
221
|
-
- Presentation options (`position`, `maxWidth`, `animation`, `container`) moved under `config`.
|
|
222
|
-
- Everything else (`updateData`, events, `destroy`) is unchanged.
|
|
223
|
-
|
|
224
|
-
---
|
|
225
|
-
|
|
226
|
-
# Adding a New Client (SDK maintainers)
|
|
227
|
-
|
|
228
|
-
1. Create `src/clients/<name>/` with `client.ts`, `FooterWidgetProtocol.ts`, `WinWidgetProtocol.ts`, and `types.ts` (launch `config` shapes, event maps, and host-facing method interfaces — empty interfaces if the client has none).
|
|
229
|
-
2. Implement the client's extra host-facing methods in each protocol's `createMethods(ctx)` factory. `ctx` is a controller exposing `sendToChild`, `expandIframe`/`collapseIframe` (footer), `emit`, `destroy`, and `isLaunched`. Keep the return type annotation on `createMethods` so methods outside the declared interface fail compilation. Core behavior (`launch`, `updateData`, events, `destroy`) lives in the widgets and is not client-definable.
|
|
230
|
-
3. For the win widget, optionally provide `presentation` (`applyLaunchPresentation`/`cleanupPresentation`) on the protocol for a custom enter/exit animation; omit it for a plain iframe.
|
|
231
|
-
4. Register it in `src/clients/registry.ts`: add the id to `ClientId`, the config to `clientRegistry`, and the types to the six type maps. Missing entries fail compilation.
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
133
|
# Documentation
|
|
236
134
|
|
|
237
135
|
For full integration instructions, backend communication flow, and advanced usage, refer to the complete [documentation](https://www.notion.so/Jackpot-Widgets-320975a6f2ab80118284e6165d569843?pvs=25#325975a6f2ab8096be15dfc7eda06028).
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { FooterWidgetBase } from '../../core/FooterWidgetBase';
|
|
2
|
-
import {
|
|
3
|
-
export declare class
|
|
2
|
+
import { FooterWidgetConfig, FooterWidgetEvents } from './types';
|
|
3
|
+
export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, FooterWidgetEvents> {
|
|
4
4
|
protected readonly route = "/footer-widget";
|
|
5
5
|
protected readonly height = "64px";
|
|
6
6
|
protected sendInitialData(): void;
|
|
7
7
|
protected sendDataUpdate(partialData: object): void;
|
|
8
8
|
protected handleChildMessage(type: string | undefined): boolean;
|
|
9
9
|
showWinPopup(data: unknown): void;
|
|
10
|
-
hideWinPopup(): void;
|
|
11
10
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { FooterWidgetBase } from '../../core/FooterWidgetBase';
|
|
2
2
|
var IncomingEvent;
|
|
3
3
|
(function (IncomingEvent) {
|
|
4
|
-
IncomingEvent["footerWidgetLoaded"] = "jackpot-
|
|
5
|
-
IncomingEvent["
|
|
6
|
-
IncomingEvent["
|
|
7
|
-
IncomingEvent["
|
|
4
|
+
IncomingEvent["footerWidgetLoaded"] = "jackpot-footer-widget-loaded";
|
|
5
|
+
IncomingEvent["participateChange"] = "jackpot-footer-widget-participate-change";
|
|
6
|
+
IncomingEvent["showPopup"] = "jackpot-footer-widget-popup-show";
|
|
7
|
+
IncomingEvent["hidePopup"] = "jackpot-footer-widget-popup-hide";
|
|
8
|
+
IncomingEvent["hideWinPopup"] = "jackpot-footer-widget-win-popup-hide";
|
|
8
9
|
})(IncomingEvent || (IncomingEvent = {}));
|
|
9
10
|
var OutgoingEvent;
|
|
10
11
|
(function (OutgoingEvent) {
|
|
11
|
-
OutgoingEvent["footerWidgetDataInitial"] = "jackpot-
|
|
12
|
-
OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-
|
|
13
|
-
OutgoingEvent["
|
|
14
|
-
OutgoingEvent["winPopupHide"] = "jackpot-b2tech-footer-widget-win-popup-hide";
|
|
12
|
+
OutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
|
|
13
|
+
OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
|
|
14
|
+
OutgoingEvent["showWinPopup"] = "jackpot-footer-widget-win-popup-show";
|
|
15
15
|
})(OutgoingEvent || (OutgoingEvent = {}));
|
|
16
|
-
export class
|
|
16
|
+
export class FooterWidget extends FooterWidgetBase {
|
|
17
17
|
constructor() {
|
|
18
18
|
super(...arguments);
|
|
19
19
|
this.route = '/footer-widget';
|
|
@@ -37,15 +37,20 @@ export class B2TechFooterWidget extends FooterWidgetBase {
|
|
|
37
37
|
case IncomingEvent.footerWidgetLoaded:
|
|
38
38
|
this.sendInitialData();
|
|
39
39
|
return true;
|
|
40
|
+
case IncomingEvent.participateChange:
|
|
41
|
+
this.emit('participateChange');
|
|
42
|
+
return true;
|
|
40
43
|
case IncomingEvent.showPopup:
|
|
44
|
+
this.emit('showPopup');
|
|
41
45
|
this.expandIframe();
|
|
42
46
|
return true;
|
|
43
47
|
case IncomingEvent.hidePopup:
|
|
48
|
+
this.emit('hidePopup');
|
|
44
49
|
this.collapseIframe();
|
|
45
50
|
return true;
|
|
46
|
-
case IncomingEvent.
|
|
51
|
+
case IncomingEvent.hideWinPopup:
|
|
52
|
+
this.emit('hideWinPopup');
|
|
47
53
|
this.collapseIframe();
|
|
48
|
-
this.emit('winPopupClosed');
|
|
49
54
|
return true;
|
|
50
55
|
default:
|
|
51
56
|
return false;
|
|
@@ -57,18 +62,9 @@ export class B2TechFooterWidget extends FooterWidgetBase {
|
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
59
64
|
this.sendToChild({
|
|
60
|
-
type: OutgoingEvent.
|
|
65
|
+
type: OutgoingEvent.showWinPopup,
|
|
61
66
|
data,
|
|
62
67
|
});
|
|
63
68
|
this.expandIframe();
|
|
64
69
|
}
|
|
65
|
-
hideWinPopup() {
|
|
66
|
-
if (!this.isLaunched())
|
|
67
|
-
return;
|
|
68
|
-
this.sendToChild({
|
|
69
|
-
type: OutgoingEvent.winPopupHide,
|
|
70
|
-
data: null,
|
|
71
|
-
});
|
|
72
|
-
this.collapseIframe();
|
|
73
|
-
}
|
|
74
70
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FooterWidgetBaseConfig } from '../../core/types';
|
|
2
|
+
export interface FooterWidgetConfig extends FooterWidgetBaseConfig {
|
|
3
|
+
}
|
|
4
|
+
export interface FooterWidgetEvents {
|
|
5
|
+
participateChange: void;
|
|
6
|
+
showPopup: void;
|
|
7
|
+
hidePopup: void;
|
|
8
|
+
hideWinPopup: void;
|
|
9
|
+
}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import { SDKEnv } from '../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { SDKEnv } from '../compat/v2/types';
|
|
2
|
+
import { FooterWidget as FooterWidgetH4 } from './h4n8w3vt/FooterWidget';
|
|
3
|
+
import { FooterWidget as FooterWidgetX7 } from './x7k2m9qp/FooterWidget';
|
|
4
|
+
import { WinWidget as WinWidgetX7 } from './x7k2m9qp/WinWidget';
|
|
5
|
+
export declare const Clients: {
|
|
6
|
+
readonly x7k2m9qp: "x7k2m9qp";
|
|
7
|
+
readonly h4n8w3vt: "h4n8w3vt";
|
|
8
|
+
};
|
|
9
|
+
export type ClientId = (typeof Clients)[keyof typeof Clients];
|
|
10
|
+
export interface X7Widgets {
|
|
11
|
+
footerWidget: FooterWidgetX7;
|
|
12
|
+
winWidget: WinWidgetX7;
|
|
9
13
|
}
|
|
10
|
-
export interface
|
|
11
|
-
footerWidget:
|
|
14
|
+
export interface H4Widgets {
|
|
15
|
+
footerWidget: FooterWidgetH4;
|
|
12
16
|
}
|
|
13
17
|
export interface ClientWidgets {
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
[Clients.x7k2m9qp]: X7Widgets;
|
|
19
|
+
[Clients.h4n8w3vt]: H4Widgets;
|
|
16
20
|
}
|
|
17
21
|
interface ClientDefinition<C extends ClientId> {
|
|
18
|
-
baseUrls
|
|
19
|
-
createWidgets: (
|
|
22
|
+
baseUrls?: Record<SDKEnv, string>;
|
|
23
|
+
createWidgets: (baseUrl: string) => ClientWidgets[C];
|
|
20
24
|
}
|
|
21
25
|
export declare const clientRegistry: {
|
|
22
26
|
[K in ClientId]: ClientDefinition<K>;
|
package/dist/clients/registry.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { FooterWidget as FooterWidgetH4 } from './h4n8w3vt/FooterWidget';
|
|
2
|
+
import { FooterWidget as FooterWidgetX7 } from './x7k2m9qp/FooterWidget';
|
|
3
|
+
import { WinWidget as WinWidgetX7 } from './x7k2m9qp/WinWidget';
|
|
4
|
+
export const Clients = {
|
|
5
|
+
x7k2m9qp: 'x7k2m9qp',
|
|
6
|
+
h4n8w3vt: 'h4n8w3vt',
|
|
7
|
+
};
|
|
4
8
|
export const clientRegistry = {
|
|
5
|
-
|
|
9
|
+
[Clients.x7k2m9qp]: {
|
|
6
10
|
baseUrls: {
|
|
7
11
|
local: 'http://localhost:4741',
|
|
8
12
|
dev: 'https://jackpot-widget-dev.splash.tech',
|
|
9
13
|
staging: 'https://jackpot-widget-staging.splash.tech',
|
|
10
14
|
production: 'https://jackpot-widget.splash.tech',
|
|
11
15
|
},
|
|
12
|
-
createWidgets: (
|
|
13
|
-
footerWidget: new
|
|
14
|
-
winWidget: new
|
|
16
|
+
createWidgets: (baseUrl) => ({
|
|
17
|
+
footerWidget: new FooterWidgetX7(baseUrl),
|
|
18
|
+
winWidget: new WinWidgetX7(baseUrl),
|
|
15
19
|
}),
|
|
16
20
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
dev: 'https://jackpot-widget-b2tech-dev.splash.tech',
|
|
21
|
-
staging: 'https://jackpot-widget-b2tech-staging.splash.tech',
|
|
22
|
-
production: 'https://jackpot-widget-b2tech.splash.tech',
|
|
23
|
-
},
|
|
24
|
-
createWidgets: (origin) => ({
|
|
25
|
-
footerWidget: new B2TechFooterWidget(origin),
|
|
21
|
+
[Clients.h4n8w3vt]: {
|
|
22
|
+
createWidgets: (baseUrl) => ({
|
|
23
|
+
footerWidget: new FooterWidgetH4(baseUrl),
|
|
26
24
|
}),
|
|
27
25
|
},
|
|
28
26
|
};
|
package/dist/clients/{defaultClient/DefaultClientFooterWidget.d.ts → x7k2m9qp/FooterWidget.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FooterWidgetBase } from '../../core/FooterWidgetBase';
|
|
2
|
-
import {
|
|
3
|
-
export declare class
|
|
2
|
+
import { FooterWidgetConfig, FooterWidgetEvents } from './types';
|
|
3
|
+
export declare class FooterWidget extends FooterWidgetBase<FooterWidgetConfig, FooterWidgetEvents> {
|
|
4
4
|
protected readonly route = "/footer-widget";
|
|
5
5
|
protected readonly height = "50px";
|
|
6
6
|
protected sendInitialData(): void;
|
package/dist/clients/{defaultClient/DefaultClientFooterWidget.js → x7k2m9qp/FooterWidget.js}
RENAMED
|
@@ -11,7 +11,7 @@ var OutgoingEvent;
|
|
|
11
11
|
OutgoingEvent["footerWidgetDataInitial"] = "jackpot-footer-widget-data-initial";
|
|
12
12
|
OutgoingEvent["footerWidgetDataUpdated"] = "jackpot-footer-widget-data-updated";
|
|
13
13
|
})(OutgoingEvent || (OutgoingEvent = {}));
|
|
14
|
-
export class
|
|
14
|
+
export class FooterWidget extends FooterWidgetBase {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
17
|
this.route = '/footer-widget';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WinWidgetBase } from '../../core/WinWidgetBase';
|
|
2
|
-
import {
|
|
3
|
-
export declare class
|
|
2
|
+
import { WinWidgetConfig, WinWidgetEvents } from './types';
|
|
3
|
+
export declare class WinWidget extends WinWidgetBase<WinWidgetConfig, WinWidgetEvents> {
|
|
4
4
|
protected get route(): string;
|
|
5
5
|
protected sendInitialData(): void;
|
|
6
6
|
protected handleChildMessage(type: string | undefined): boolean;
|
|
@@ -8,7 +8,7 @@ var OutgoingEvent;
|
|
|
8
8
|
(function (OutgoingEvent) {
|
|
9
9
|
OutgoingEvent["winWidgetDataInitial"] = "jackpot-win-widget-data-initial";
|
|
10
10
|
})(OutgoingEvent || (OutgoingEvent = {}));
|
|
11
|
-
export class
|
|
11
|
+
export class WinWidget extends WinWidgetBase {
|
|
12
12
|
get route() {
|
|
13
13
|
var _a;
|
|
14
14
|
return `/win-animation-widget?animation=${(_a = this.config.animation) !== null && _a !== void 0 ? _a : 'wheel'}`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FooterWidgetBaseConfig, WinWidgetBaseConfig } from '../../core/types';
|
|
2
|
+
export interface FooterWidgetConfig extends FooterWidgetBaseConfig {
|
|
3
|
+
}
|
|
4
|
+
export interface WinWidgetConfig extends WinWidgetBaseConfig {
|
|
5
|
+
animation?: 'wheel' | 'airplane';
|
|
6
|
+
}
|
|
7
|
+
export interface FooterWidgetEvents {
|
|
8
|
+
participateChange: void;
|
|
9
|
+
showPopup: void;
|
|
10
|
+
hidePopup: void;
|
|
11
|
+
}
|
|
12
|
+
export interface WinWidgetEvents {
|
|
13
|
+
close: void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FooterWidgetBaseConfig, WidgetLaunchParams, WinWidgetBaseConfig } from '../../core/types';
|
|
2
|
+
import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
|
|
3
|
+
export declare function mapV2FooterWidgetLaunchParams(params: V2FooterWidgetLaunchParams): WidgetLaunchParams<FooterWidgetBaseConfig>;
|
|
4
|
+
export declare function mapV2WinWidgetLaunchParams(params: V2WinWidgetLaunchParams): WidgetLaunchParams<WinWidgetBaseConfig & {
|
|
5
|
+
animation?: 'wheel' | 'airplane';
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function mapV2FooterWidgetLaunchParams(params) {
|
|
2
|
+
return {
|
|
3
|
+
data: params.data,
|
|
4
|
+
config: Object.assign(Object.assign(Object.assign({}, (params.container !== undefined
|
|
5
|
+
? { container: params.container }
|
|
6
|
+
: {})), (params.position !== undefined ? { position: params.position } : {})), (params.maxWidth !== undefined ? { maxWidth: params.maxWidth } : {})),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function mapV2WinWidgetLaunchParams(params) {
|
|
10
|
+
return {
|
|
11
|
+
data: params.data,
|
|
12
|
+
config: Object.assign(Object.assign({}, (params.container !== undefined
|
|
13
|
+
? { container: params.container }
|
|
14
|
+
: {})), (params.animation !== undefined
|
|
15
|
+
? { animation: params.animation }
|
|
16
|
+
: {})),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FooterWidgetEvents, WinWidgetEvents } from '../../clients/x7k2m9qp/types';
|
|
2
|
+
import { WidgetEventHandler } from '../../core/types';
|
|
3
|
+
import { V2FooterWidgetLaunchParams, V2WinWidgetLaunchParams } from './types';
|
|
4
|
+
export declare const splashJackpot: {
|
|
5
|
+
footerWidget: {
|
|
6
|
+
isLaunched: () => boolean;
|
|
7
|
+
launch: (params: V2FooterWidgetLaunchParams) => void;
|
|
8
|
+
updateData: (partialData: object) => void;
|
|
9
|
+
destroy: () => void;
|
|
10
|
+
addEventListener: (event: keyof FooterWidgetEvents, handler: WidgetEventHandler) => void;
|
|
11
|
+
removeEventListener: (event: keyof FooterWidgetEvents, handler: WidgetEventHandler) => void;
|
|
12
|
+
removeAllEventListeners: () => void;
|
|
13
|
+
};
|
|
14
|
+
winWidget: {
|
|
15
|
+
isLaunched: () => boolean;
|
|
16
|
+
launch: (params: V2WinWidgetLaunchParams) => void;
|
|
17
|
+
destroy: () => void;
|
|
18
|
+
addEventListener: (event: keyof WinWidgetEvents, handler: WidgetEventHandler) => void;
|
|
19
|
+
removeEventListener: (event: keyof WinWidgetEvents, handler: WidgetEventHandler) => void;
|
|
20
|
+
removeAllEventListeners: () => void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Clients, clientRegistry } from '../../clients/registry';
|
|
2
|
+
import { createSplashJackpot } from '../v3/createSplashJackpot';
|
|
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
|
+
function createV2SplashJackpot() {
|
|
9
|
+
let instance = null;
|
|
10
|
+
const footerWidgetListeners = new Map();
|
|
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
|
+
}
|
|
21
|
+
function createInstance(mode) {
|
|
22
|
+
if (instance)
|
|
23
|
+
return instance;
|
|
24
|
+
instance = createSplashJackpot({
|
|
25
|
+
client: Clients.x7k2m9qp,
|
|
26
|
+
baseUrl: resolveBuiltInBaseUrl(mode),
|
|
27
|
+
});
|
|
28
|
+
for (const [event, handlers] of footerWidgetListeners) {
|
|
29
|
+
for (const handler of handlers) {
|
|
30
|
+
instance.footerWidget.addEventListener(event, handler);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const [event, handlers] of winWidgetListeners) {
|
|
34
|
+
for (const handler of handlers) {
|
|
35
|
+
instance.winWidget.addEventListener(event, handler);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return instance;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
footerWidget: {
|
|
42
|
+
isLaunched: () => { var _a; return (_a = instance === null || instance === void 0 ? void 0 : instance.footerWidget.isLaunched()) !== null && _a !== void 0 ? _a : false; },
|
|
43
|
+
launch: (params) => {
|
|
44
|
+
createInstance(params.mode).footerWidget.launch(mapV2FooterWidgetLaunchParams(params));
|
|
45
|
+
},
|
|
46
|
+
updateData: (partialData) => {
|
|
47
|
+
instance === null || instance === void 0 ? void 0 : instance.footerWidget.updateData(partialData);
|
|
48
|
+
},
|
|
49
|
+
destroy: () => {
|
|
50
|
+
instance === null || instance === void 0 ? void 0 : instance.footerWidget.destroy();
|
|
51
|
+
},
|
|
52
|
+
addEventListener: (event, handler) => {
|
|
53
|
+
if (!footerWidgetListeners.has(event)) {
|
|
54
|
+
footerWidgetListeners.set(event, []);
|
|
55
|
+
}
|
|
56
|
+
footerWidgetListeners.get(event).push(handler);
|
|
57
|
+
instance === null || instance === void 0 ? void 0 : instance.footerWidget.addEventListener(event, handler);
|
|
58
|
+
},
|
|
59
|
+
removeEventListener: (event, handler) => {
|
|
60
|
+
const handlers = footerWidgetListeners.get(event);
|
|
61
|
+
if (handlers) {
|
|
62
|
+
footerWidgetListeners.set(event, handlers.filter((h) => h !== handler));
|
|
63
|
+
}
|
|
64
|
+
instance === null || instance === void 0 ? void 0 : instance.footerWidget.removeEventListener(event, handler);
|
|
65
|
+
},
|
|
66
|
+
removeAllEventListeners: () => {
|
|
67
|
+
footerWidgetListeners.clear();
|
|
68
|
+
instance === null || instance === void 0 ? void 0 : instance.footerWidget.removeAllEventListeners();
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
winWidget: {
|
|
72
|
+
isLaunched: () => { var _a; return (_a = instance === null || instance === void 0 ? void 0 : instance.winWidget.isLaunched()) !== null && _a !== void 0 ? _a : false; },
|
|
73
|
+
launch: (params) => {
|
|
74
|
+
createInstance(params.mode).winWidget.launch(mapV2WinWidgetLaunchParams(params));
|
|
75
|
+
},
|
|
76
|
+
destroy: () => {
|
|
77
|
+
instance === null || instance === void 0 ? void 0 : instance.winWidget.destroy();
|
|
78
|
+
},
|
|
79
|
+
addEventListener: (event, handler) => {
|
|
80
|
+
if (!winWidgetListeners.has(event)) {
|
|
81
|
+
winWidgetListeners.set(event, []);
|
|
82
|
+
}
|
|
83
|
+
winWidgetListeners.get(event).push(handler);
|
|
84
|
+
instance === null || instance === void 0 ? void 0 : instance.winWidget.addEventListener(event, handler);
|
|
85
|
+
},
|
|
86
|
+
removeEventListener: (event, handler) => {
|
|
87
|
+
const handlers = winWidgetListeners.get(event);
|
|
88
|
+
if (handlers) {
|
|
89
|
+
winWidgetListeners.set(event, handlers.filter((h) => h !== handler));
|
|
90
|
+
}
|
|
91
|
+
instance === null || instance === void 0 ? void 0 : instance.winWidget.removeEventListener(event, handler);
|
|
92
|
+
},
|
|
93
|
+
removeAllEventListeners: () => {
|
|
94
|
+
winWidgetListeners.clear();
|
|
95
|
+
instance === null || instance === void 0 ? void 0 : instance.winWidget.removeAllEventListeners();
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export const splashJackpot = createV2SplashJackpot();
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
container?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface V2WinWidgetLaunchParams {
|
|
12
|
+
data: unknown;
|
|
13
|
+
mode?: V2Mode;
|
|
14
|
+
animation?: 'wheel' | 'airplane';
|
|
15
|
+
container?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { clientRegistry } from '../../clients/registry';
|
|
2
|
+
export function createSplashJackpot(options) {
|
|
3
|
+
const client = clientRegistry[options.client];
|
|
4
|
+
if (!client) {
|
|
5
|
+
throw new Error(`createSplashJackpot: unknown client "${options.client}".`);
|
|
6
|
+
}
|
|
7
|
+
return client.createWidgets(options.baseUrl);
|
|
8
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ClientId, ClientWidgets } from '
|
|
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
|
-
|
|
4
|
+
baseUrl: string;
|
|
6
5
|
}
|
|
7
6
|
export type SplashJackpotSDK<C extends ClientId> = ClientWidgets[C];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/core/types.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
export { Clients } from './clients/registry';
|
|
2
|
+
export { splashJackpot } from './compat/v2/splashJackpot';
|
|
3
|
+
export { createSplashJackpot } from './compat/v3/createSplashJackpot';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
throw new Error(`createSplashJackpot: unknown client "${options.client}".`);
|
|
7
|
-
}
|
|
8
|
-
const env = (_a = options.env) !== null && _a !== void 0 ? _a : 'production';
|
|
9
|
-
const childAppOrigin = client.baseUrls[env];
|
|
10
|
-
return client.createWidgets(childAppOrigin);
|
|
11
|
-
}
|
|
1
|
+
export { Clients } from './clients/registry';
|
|
2
|
+
// v2
|
|
3
|
+
export { splashJackpot } from './compat/v2/splashJackpot';
|
|
4
|
+
// v3
|
|
5
|
+
export { createSplashJackpot } from './compat/v3/createSplashJackpot';
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FooterWidgetBaseConfig, WinWidgetBaseConfig } from '../../core/types';
|
|
2
|
-
export interface DefaultClientFooterWidgetConfig extends FooterWidgetBaseConfig {
|
|
3
|
-
}
|
|
4
|
-
export interface DefaultClientWinWidgetConfig extends WinWidgetBaseConfig {
|
|
5
|
-
animation?: 'wheel' | 'airplane';
|
|
6
|
-
}
|
|
7
|
-
export interface DefaultClientFooterWidgetEvents {
|
|
8
|
-
participateChange: void;
|
|
9
|
-
showPopup: void;
|
|
10
|
-
hidePopup: void;
|
|
11
|
-
}
|
|
12
|
-
export interface DefaultClientWinWidgetEvents {
|
|
13
|
-
close: void;
|
|
14
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|