@kalamba/sdk 0.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/LICENSE +28 -0
- package/README.md +28 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +98 -0
- package/dist/noop-3336849b.js +18 -0
- package/dist/noop-b3c54b76.cjs +5 -0
- package/dist/plugins.cjs +5 -0
- package/dist/plugins.d.ts +550 -0
- package/dist/plugins.js +2563 -0
- package/dist/wrapper.cjs +5 -0
- package/dist/wrapper.d.ts +389 -0
- package/dist/wrapper.js +1746 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Kalamba Games Limited
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Kalamba SDK
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
Kalamba SDK is a toolkit designed to handle frontend communication between the Game Client, the Casino Frontend, the Telemetry Service, and the RGS.
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
|
|
11
|
+
#### NPM
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @kalamba/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### Requirements
|
|
18
|
+
|
|
19
|
+
Kalamba SDK uses the following APIs:
|
|
20
|
+
|
|
21
|
+
- [Promises](https://caniuse.com/promises)
|
|
22
|
+
- [postMessage](https://caniuse.com/x-doc-messaging)
|
|
23
|
+
|
|
24
|
+
Click above links to check Browser compatibility.
|
|
25
|
+
|
|
26
|
+
### Documentation
|
|
27
|
+
|
|
28
|
+
Documentation can be found [here](https://docs.kalamba.games/sdk/)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSD 3-Clause License
|
|
3
|
+
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
|
+
*/
|
|
5
|
+
"use strict";var E=Object.defineProperty;var w=(s,e,r)=>e in s?E(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var i=(s,e,r)=>(w(s,typeof e!="symbol"?e+"":e,r),r),m=(s,e,r)=>{if(!e.has(s))throw TypeError("Cannot "+r)};var u=(s,e,r)=>(m(s,e,"read from private field"),r?r.call(s):e.get(s)),p=(s,e,r)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,r)},l=(s,e,r,o)=>(m(s,e,"write to private field"),o?o.call(s,r):e.set(s,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=()=>{};class d extends Error{constructor(r){super("OpenGameError");i(this,"error");this.name="OpenGameError",this.error=r}}class h extends Error{constructor(r){super("PlayError");i(this,"error");this.name="PlayError",this.error=r}}class c extends Error{constructor(){super("TimeoutError"),this.name="TimeoutError"}}var a;class f{constructor({messagePort:e}){i(this,"config");p(this,a,void 0);l(this,a,e),this.on("configured",r=>{this.config=r})}request(e,...[r]){return new Promise(o=>{this.on(`${e}Response`,t=>o({type:"response",response:t}),{once:!0}),this.on(`${e}Error`,t=>o({type:"error",error:t}),{once:!0}),this.send(e,r)})}on(e,r,o){const t=function y(n){n.data.message===`kalamba:wrapper:${e}`&&(g("on",n.data.message.replace(/^kalamba:/,""),n.data.payload),r(n.data.payload),o!=null&&o.once&&window.removeEventListener("message",y))};window.addEventListener("message",t)}send(e,...[r]){u(this,a).postMessage({message:`kalamba:sdk:${e}`,payload:r},"*")}async openGame(e){var o;const[,r]=await Promise.all([new Promise(t=>this.on("configured",t,{once:!0})),this.request("openGame",e)]);if(r.type==="response")return r.response;throw((o=r.error)==null?void 0:o.type)==="timeout"?new c:new d(r.error)}async play(e){var o;const r=await this.request("play",e);if(r.type==="response")return r.response;throw((o=r.error)==null?void 0:o.type)==="timeout"?new c:new h(r.error)}}a=new WeakMap;exports.KalambaSdk=f;exports.OpenGameError=d;exports.PlayError=h;exports.TimeoutError=c;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
declare interface AddEventListenerOptions_2 {
|
|
2
|
+
once: boolean;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export declare type AutoplayLimit = {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
showNoLimit: boolean;
|
|
8
|
+
showCustomLimit: boolean;
|
|
9
|
+
options: number[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export declare type Bet = {
|
|
13
|
+
base: number;
|
|
14
|
+
multiplier: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export declare type Cashier = {
|
|
18
|
+
type: 'ON_DEMAND' | 'BALANCE_LOW' | 'BALANCE_INSUFFICIENT';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export declare type CashierConfig = {
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
balanceThreshold: number[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export declare type CasinoOnlyMessagePayloadMap = {
|
|
27
|
+
balance: {
|
|
28
|
+
balance: number;
|
|
29
|
+
};
|
|
30
|
+
bet: Bet;
|
|
31
|
+
cashier: Cashier;
|
|
32
|
+
choice: {
|
|
33
|
+
id: string;
|
|
34
|
+
};
|
|
35
|
+
close: never;
|
|
36
|
+
freeze: never;
|
|
37
|
+
help: {
|
|
38
|
+
show?: boolean;
|
|
39
|
+
};
|
|
40
|
+
history: History_2;
|
|
41
|
+
paytable: {
|
|
42
|
+
show?: boolean;
|
|
43
|
+
};
|
|
44
|
+
play: PlayRequest;
|
|
45
|
+
resume: never;
|
|
46
|
+
settings: Settings;
|
|
47
|
+
suspend: never;
|
|
48
|
+
unfreeze: never;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export declare type DomainAllowedPayloadMap<P extends DomainPrefix> = DomainToMessagePayloadMap[P];
|
|
52
|
+
|
|
53
|
+
export declare type DomainMessage<P extends DomainPrefix> = keyof DomainAllowedPayloadMap<P>;
|
|
54
|
+
|
|
55
|
+
export declare type DomainMessageMessageEvent<P extends DomainPrefix, M extends DomainMessage<P>> = MessageEvent<{
|
|
56
|
+
message: M;
|
|
57
|
+
payload: DomainMessagePayload<P, M>;
|
|
58
|
+
}>;
|
|
59
|
+
|
|
60
|
+
export declare type DomainMessagePayload<P extends DomainPrefix, M extends DomainMessage<P>> = DomainAllowedPayloadMap<P>[M];
|
|
61
|
+
|
|
62
|
+
export declare type DomainPrefix = keyof DomainToMessagePayloadMap & string;
|
|
63
|
+
|
|
64
|
+
export declare type DomainToMessagePayloadMap = {
|
|
65
|
+
sdk: SdkOnlyMessagePayloadMap;
|
|
66
|
+
wrapper: WrapperOnlyMessagePayloadMap;
|
|
67
|
+
casino: CasinoOnlyMessagePayloadMap;
|
|
68
|
+
rgs: RgsOnlyMessagePayloadMap;
|
|
69
|
+
telemetry: TelemetryOnlyMessagePayloadMap;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
declare type Error_2 = {
|
|
73
|
+
message: string;
|
|
74
|
+
messageKey: string;
|
|
75
|
+
type: 'CLOSE' | 'RELOAD' | 'CONTINUE';
|
|
76
|
+
};
|
|
77
|
+
export { Error_2 as Error }
|
|
78
|
+
|
|
79
|
+
export declare type ForwardToPluginsMessage<P extends PluginDomain> = keyof ForwardToPluginsMessageMap<'sdk'>[P] | keyof ForwardToPluginsMessageMap<'rgs'>[P] | keyof ForwardToPluginsMessageMap<'casino'>[P] | keyof ForwardToPluginsMessageMap<'telemetry'>[P];
|
|
80
|
+
|
|
81
|
+
export declare interface ForwardToPluginsMessageMap<SourceDomain extends DomainPrefix> {
|
|
82
|
+
casino: ToCasinoPluginsForwardedMessageMap[SourceDomain];
|
|
83
|
+
rgs: ToRgsPluginsForwardedMessageMap[SourceDomain];
|
|
84
|
+
telemetry: ToTelemetryPluginsForwardedMessageMap[SourceDomain];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare type ForwardToPluginsMessagePayload<P extends PluginDomain, M extends ForwardToPluginsMessage<P>> = ForwardToPluginsMessageMap<'sdk'>[P][M] & ForwardToPluginsMessageMap<'rgs'>[P][M] & ForwardToPluginsMessageMap<'casino'>[P][M] & ForwardToPluginsMessageMap<'telemetry'>[P][M];
|
|
88
|
+
|
|
89
|
+
export declare type ForwardToSdkMessage = keyof ToSdkForwardedMessageMap;
|
|
90
|
+
|
|
91
|
+
export declare type ForwardToSdkMessagePayload<M extends ForwardToSdkMessage> = ToSdkForwardedMessageMap[M];
|
|
92
|
+
|
|
93
|
+
declare type History_2 = {
|
|
94
|
+
source: 'realityCheck' | 'settings' | 'casino';
|
|
95
|
+
};
|
|
96
|
+
export { History_2 as History }
|
|
97
|
+
|
|
98
|
+
export declare class KalambaSdk {
|
|
99
|
+
#private;
|
|
100
|
+
config: SdkConfig;
|
|
101
|
+
constructor({ messagePort }: {
|
|
102
|
+
messagePort: Window;
|
|
103
|
+
});
|
|
104
|
+
protected request<M extends DomainMessage<'sdk'>>(message: M, ...[payload]: DomainMessagePayload<'sdk', M> extends never ? [] : [payload: DomainMessagePayload<'sdk', M>]): Promise<RgsResponse<M>>;
|
|
105
|
+
on<M extends DomainMessage<'wrapper'> | ForwardToSdkMessage>(message: M, listener: (payload: M extends DomainMessage<'wrapper'> ? DomainMessagePayload<'wrapper', M> : M extends ForwardToSdkMessage ? ForwardToSdkMessagePayload<M> : never) => void, options?: AddEventListenerOptions_2): void;
|
|
106
|
+
send<M extends DomainMessage<'sdk'>>(message: M, ...[payload]: DomainMessagePayload<'sdk', M> extends never ? [] : [DomainMessagePayload<'sdk', M>]): void;
|
|
107
|
+
openGame(payload: DomainMessagePayload<'sdk', 'openGame'>): Promise<OpenGameResponse>;
|
|
108
|
+
play(payload: DomainMessagePayload<'sdk', 'play'>): Promise<PlayResponse>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export declare type Message = keyof MessageMap;
|
|
112
|
+
|
|
113
|
+
export declare type MessageMap = DomainAllowedPayloadMap<'sdk'> & DomainAllowedPayloadMap<'wrapper'> & DomainAllowedPayloadMap<'casino'> & DomainAllowedPayloadMap<'rgs'> & DomainAllowedPayloadMap<'telemetry'> & PrefixedMessageMap;
|
|
114
|
+
|
|
115
|
+
export declare type MessageMessageEvent<M extends Message> = MessageEvent<{
|
|
116
|
+
message: M;
|
|
117
|
+
payload: MessagePayload<M>;
|
|
118
|
+
}>;
|
|
119
|
+
|
|
120
|
+
export declare type MessagePayload<M extends Message> = MessageMap[M];
|
|
121
|
+
|
|
122
|
+
export declare class OpenGameError extends Error {
|
|
123
|
+
error: any;
|
|
124
|
+
constructor(error: any);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare type OpenGameError_2 = {
|
|
128
|
+
data: any;
|
|
129
|
+
type?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export declare type OpenGameRequest = {
|
|
133
|
+
gameName: string;
|
|
134
|
+
version: string;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export declare type OpenGameResponse = {
|
|
138
|
+
balance: number;
|
|
139
|
+
data: any;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export declare class PlayError extends Error {
|
|
143
|
+
error: any;
|
|
144
|
+
constructor(error: any);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare type PlayError_2 = {
|
|
148
|
+
data: any;
|
|
149
|
+
type?: string;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export declare type PlayRequest = {
|
|
153
|
+
bet: Bet;
|
|
154
|
+
} | {
|
|
155
|
+
userInput: unknown;
|
|
156
|
+
} | {
|
|
157
|
+
opaqueGameAttributes: unknown;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export declare type PlayResponse = {
|
|
161
|
+
balance: number;
|
|
162
|
+
data: any;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export declare type PluginDomain = keyof ForwardToPluginsMessageMap<any>;
|
|
166
|
+
|
|
167
|
+
export declare type PrefixedForwardToPluginsMessage<P extends PluginDomain> = PrefixTypes<keyof ForwardToPluginsMessageMap<'sdk'>[P], 'sdk'> | PrefixTypes<keyof ForwardToPluginsMessageMap<'rgs'>[P], 'rgs'> | PrefixTypes<keyof ForwardToPluginsMessageMap<'casino'>[P], 'casino'> | PrefixTypes<keyof ForwardToPluginsMessageMap<'telemetry'>[P], 'telemetry'>;
|
|
168
|
+
|
|
169
|
+
export declare type PrefixedMessage = keyof PrefixedMessageMap;
|
|
170
|
+
|
|
171
|
+
export declare type PrefixedMessageMap = PrefixedMessagePayloadMap<'sdk'> & PrefixedMessagePayloadMap<'wrapper'> & PrefixedMessagePayloadMap<'casino'> & PrefixedMessagePayloadMap<'rgs'> & PrefixedMessagePayloadMap<'telemetry'>;
|
|
172
|
+
|
|
173
|
+
export declare type PrefixedMessageMessageEvent<M extends PrefixedMessage> = MessageEvent<{
|
|
174
|
+
message: M;
|
|
175
|
+
payload: PrefixedMessagePayload<M>;
|
|
176
|
+
}>;
|
|
177
|
+
|
|
178
|
+
export declare type PrefixedMessagePayload<M extends PrefixedMessage> = PrefixedMessageMap[M];
|
|
179
|
+
|
|
180
|
+
export declare type PrefixedMessagePayloadMap<P extends DomainPrefix> = PrefixKeys<DomainToMessagePayloadMap[P], P>;
|
|
181
|
+
|
|
182
|
+
declare type PrefixKeys<Base, Prefix extends string> = {
|
|
183
|
+
[Key in keyof Base as `${Prefix}:${string & Key}`]: Base[Key];
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
declare type PrefixTypes<Types, Prefix extends string> = `${Prefix}:${Types}`;
|
|
187
|
+
|
|
188
|
+
export declare type RealityCheckConfig = {
|
|
189
|
+
sessionDurationPeriodFormat: 'seconds' | 'minutes' | 'hours';
|
|
190
|
+
showCloseGame: boolean;
|
|
191
|
+
showHistory: boolean;
|
|
192
|
+
showNetPosition: boolean;
|
|
193
|
+
showSessionDuration: boolean;
|
|
194
|
+
showSumBets: boolean;
|
|
195
|
+
showSumWins: boolean;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export declare type RgsOnlyMessagePayloadMap = {
|
|
199
|
+
openGameError: OpenGameError_2;
|
|
200
|
+
openGameResponse: OpenGameResponse;
|
|
201
|
+
playError: PlayError_2;
|
|
202
|
+
playResponse: PlayResponse;
|
|
203
|
+
realityCheck: {
|
|
204
|
+
duration: number;
|
|
205
|
+
sumBetAmount: number;
|
|
206
|
+
sumWinAmount: number;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export declare type RgsResponse<M extends DomainMessage<'sdk'>> = `${M}Response` extends DomainMessage<'rgs'> ? {
|
|
211
|
+
type: 'response';
|
|
212
|
+
response: DomainMessagePayload<'rgs', `${M}Response`>;
|
|
213
|
+
} | {
|
|
214
|
+
type: 'error';
|
|
215
|
+
error: DomainMessagePayload<'rgs', `${M}Error`>;
|
|
216
|
+
} : never;
|
|
217
|
+
|
|
218
|
+
export declare interface SdkConfig {
|
|
219
|
+
api: {
|
|
220
|
+
brand: string;
|
|
221
|
+
cashierUrl?: string;
|
|
222
|
+
coinValueInCents: number;
|
|
223
|
+
country: string;
|
|
224
|
+
currency: string;
|
|
225
|
+
game: string;
|
|
226
|
+
gameHistoryUrl: string;
|
|
227
|
+
homeUrl?: string;
|
|
228
|
+
integration: string;
|
|
229
|
+
integrationData?: unknown;
|
|
230
|
+
jurisdiction: string;
|
|
231
|
+
playMode: 'FUN' | 'REAL';
|
|
232
|
+
user: string;
|
|
233
|
+
};
|
|
234
|
+
ui: {
|
|
235
|
+
autoplay: {
|
|
236
|
+
enabled: boolean;
|
|
237
|
+
rounds: AutoplayLimit;
|
|
238
|
+
lossLimit: AutoplayLimit;
|
|
239
|
+
winLimit: AutoplayLimit;
|
|
240
|
+
simple: boolean;
|
|
241
|
+
stopOnFeature: boolean;
|
|
242
|
+
};
|
|
243
|
+
cashier: CashierConfig;
|
|
244
|
+
feature: {
|
|
245
|
+
allowTelemetry: boolean;
|
|
246
|
+
allowFullscreen: boolean;
|
|
247
|
+
allowQuickStop: boolean;
|
|
248
|
+
showCashier: boolean;
|
|
249
|
+
showClock: boolean;
|
|
250
|
+
showCloseGame: boolean;
|
|
251
|
+
showCurrency: boolean;
|
|
252
|
+
showFastPlay: boolean;
|
|
253
|
+
showFeatureBuy: boolean;
|
|
254
|
+
showFeatureIntro: boolean;
|
|
255
|
+
showFeatureOutro: boolean;
|
|
256
|
+
showFunModeBanner: boolean;
|
|
257
|
+
showHistory: boolean;
|
|
258
|
+
showLowWinCelebration: boolean;
|
|
259
|
+
showMaximumWin: boolean;
|
|
260
|
+
showNetPosition: boolean;
|
|
261
|
+
showPaylineLines: boolean;
|
|
262
|
+
showPaytable: boolean;
|
|
263
|
+
showRoundId: boolean;
|
|
264
|
+
showRtp: boolean;
|
|
265
|
+
showRules: boolean;
|
|
266
|
+
showSessionDuration: boolean;
|
|
267
|
+
showUi: boolean;
|
|
268
|
+
};
|
|
269
|
+
language: string;
|
|
270
|
+
maximumBet?: number;
|
|
271
|
+
minimumSpinDuration: number;
|
|
272
|
+
requestTimeoutMs: number;
|
|
273
|
+
realityCheck: RealityCheckConfig;
|
|
274
|
+
skipInsufficientFundsCheck: boolean;
|
|
275
|
+
skipSplash: boolean;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export declare type SdkOnlyMessagePayloadMap = {
|
|
280
|
+
autoplay: {
|
|
281
|
+
action: 'start' | 'stop' | 'pause' | 'resume';
|
|
282
|
+
};
|
|
283
|
+
balance: {
|
|
284
|
+
balance: number;
|
|
285
|
+
};
|
|
286
|
+
bet: Bet;
|
|
287
|
+
cashier: Cashier;
|
|
288
|
+
choice: {
|
|
289
|
+
message: string;
|
|
290
|
+
options: {
|
|
291
|
+
id: string;
|
|
292
|
+
label: string;
|
|
293
|
+
}[];
|
|
294
|
+
};
|
|
295
|
+
close: never;
|
|
296
|
+
error: Error_2;
|
|
297
|
+
fullscreen: {
|
|
298
|
+
lock?: OrientationLockType;
|
|
299
|
+
};
|
|
300
|
+
history: History_2;
|
|
301
|
+
loadEnd: never;
|
|
302
|
+
loadProgress: {
|
|
303
|
+
progress: number;
|
|
304
|
+
};
|
|
305
|
+
loadStart: never;
|
|
306
|
+
openGame: OpenGameRequest;
|
|
307
|
+
play: PlayRequest;
|
|
308
|
+
playCycleEnd: PlayResponse;
|
|
309
|
+
playCycleStart: PlayRequest;
|
|
310
|
+
playEnd: PlayResponse;
|
|
311
|
+
playReady: {
|
|
312
|
+
ready: boolean;
|
|
313
|
+
};
|
|
314
|
+
playStart: PlayRequest;
|
|
315
|
+
translations: Record<string, Record<string, string>>;
|
|
316
|
+
settings: Settings;
|
|
317
|
+
'telemetry.click': {
|
|
318
|
+
location: string;
|
|
319
|
+
name: string;
|
|
320
|
+
};
|
|
321
|
+
'telemetry.orientationChange': never;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export declare type Settings = {
|
|
325
|
+
fastPlay?: boolean;
|
|
326
|
+
fastPlaySpeed?: number;
|
|
327
|
+
sounds?: boolean;
|
|
328
|
+
music?: boolean;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export declare type TelemetryOnlyMessagePayloadMap = {
|
|
332
|
+
[key: string]: unknown;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export declare class TimeoutError extends Error {
|
|
336
|
+
constructor();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export declare type ToCasinoPluginsForwardedMessageMap = {
|
|
340
|
+
sdk: Pick<SdkOnlyMessagePayloadMap, 'autoplay' | 'balance' | 'bet' | 'cashier' | 'choice' | 'close' | 'error' | 'history' | 'loadEnd' | 'loadProgress' | 'loadStart' | 'openGame' | 'play' | 'playCycleEnd' | 'playCycleStart' | 'playEnd' | 'playReady' | 'playStart' | 'settings'>;
|
|
341
|
+
casino: undefined;
|
|
342
|
+
rgs: Pick<RgsOnlyMessagePayloadMap, 'playResponse' | 'playError' | 'openGameResponse'>;
|
|
343
|
+
telemetry: undefined;
|
|
344
|
+
wrapper: undefined;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export declare type ToRgsPluginsForwardedMessageMap = {
|
|
348
|
+
sdk: Pick<SdkOnlyMessagePayloadMap, 'history' | 'openGame' | 'play'>;
|
|
349
|
+
casino: Pick<CasinoOnlyMessagePayloadMap, 'play' | 'cashier' | 'close' | 'history'>;
|
|
350
|
+
rgs: undefined;
|
|
351
|
+
telemetry: undefined;
|
|
352
|
+
wrapper: undefined;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export declare type ToSdkForwardedMessageMap = Pick<CasinoOnlyMessagePayloadMap, 'balance' | 'bet' | 'choice' | 'freeze' | 'help' | 'paytable' | 'resume' | 'settings' | 'suspend' | 'unfreeze'> & Pick<RgsOnlyMessagePayloadMap, 'realityCheck' | 'openGameError' | 'openGameResponse' | 'playError' | 'playResponse'>;
|
|
356
|
+
|
|
357
|
+
export declare type ToTelemetryPluginsForwardedMessageMap = {
|
|
358
|
+
sdk: Pick<SdkOnlyMessagePayloadMap, 'autoplay' | 'error' | 'loadStart' | 'loadProgress' | 'loadEnd' | 'playCycleStart' | 'playCycleEnd' | 'settings' | 'telemetry.click' | 'telemetry.orientationChange'>;
|
|
359
|
+
casino: undefined;
|
|
360
|
+
rgs: Pick<RgsOnlyMessagePayloadMap, 'openGameResponse' | 'openGameError' | 'playResponse' | 'playError'>;
|
|
361
|
+
telemetry: undefined;
|
|
362
|
+
wrapper: undefined;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export declare type WrapperOnlyMessagePayloadMap = {
|
|
366
|
+
bet: Bet;
|
|
367
|
+
close: never;
|
|
368
|
+
configured: SdkConfig;
|
|
369
|
+
freeze: never;
|
|
370
|
+
history: History_2;
|
|
371
|
+
resume: never;
|
|
372
|
+
state: WrapperState;
|
|
373
|
+
suspend: never;
|
|
374
|
+
unfreeze: never;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export declare type WrapperState = {
|
|
378
|
+
balance: number;
|
|
379
|
+
bet: Bet;
|
|
380
|
+
gameName: string;
|
|
381
|
+
version: string;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSD 3-Clause License
|
|
3
|
+
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
|
+
*/
|
|
5
|
+
var h = Object.defineProperty;
|
|
6
|
+
var w = (s, r, e) => r in s ? h(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
7
|
+
var i = (s, r, e) => (w(s, typeof r != "symbol" ? r + "" : r, e), e), c = (s, r, e) => {
|
|
8
|
+
if (!r.has(s))
|
|
9
|
+
throw TypeError("Cannot " + e);
|
|
10
|
+
};
|
|
11
|
+
var p = (s, r, e) => (c(s, r, "read from private field"), e ? e.call(s) : r.get(s)), m = (s, r, e) => {
|
|
12
|
+
if (r.has(s))
|
|
13
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
14
|
+
r instanceof WeakSet ? r.add(s) : r.set(s, e);
|
|
15
|
+
}, u = (s, r, e, o) => (c(s, r, "write to private field"), o ? o.call(s, e) : r.set(s, e), e);
|
|
16
|
+
const y = () => {
|
|
17
|
+
};
|
|
18
|
+
class E extends Error {
|
|
19
|
+
constructor(e) {
|
|
20
|
+
super("OpenGameError");
|
|
21
|
+
i(this, "error");
|
|
22
|
+
this.name = "OpenGameError", this.error = e;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class g extends Error {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
super("PlayError");
|
|
28
|
+
i(this, "error");
|
|
29
|
+
this.name = "PlayError", this.error = e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class l extends Error {
|
|
33
|
+
constructor() {
|
|
34
|
+
super("TimeoutError"), this.name = "TimeoutError";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var a;
|
|
38
|
+
class P {
|
|
39
|
+
constructor({ messagePort: r }) {
|
|
40
|
+
// after open game we can be sure that config is set
|
|
41
|
+
// it's much easier to use it with type `SdkConfig` instead of `SdkConfig | undefined`
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
i(this, "config");
|
|
45
|
+
m(this, a, void 0);
|
|
46
|
+
u(this, a, r), this.on("configured", (e) => {
|
|
47
|
+
this.config = e;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
request(r, ...[e]) {
|
|
51
|
+
return new Promise((o) => {
|
|
52
|
+
this.on(`${r}Response`, (t) => o({ type: "response", response: t }), {
|
|
53
|
+
once: !0
|
|
54
|
+
}), this.on(`${r}Error`, (t) => o({ type: "error", error: t }), { once: !0 }), this.send(r, e);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
on(r, e, o) {
|
|
58
|
+
const t = function d(n) {
|
|
59
|
+
n.data.message === `kalamba:wrapper:${r}` && (y("on", n.data.message.replace(/^kalamba:/, ""), n.data.payload), e(n.data.payload), o != null && o.once && window.removeEventListener("message", d));
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener("message", t);
|
|
62
|
+
}
|
|
63
|
+
// TODO error messages
|
|
64
|
+
send(r, ...[e]) {
|
|
65
|
+
p(this, a).postMessage(
|
|
66
|
+
{
|
|
67
|
+
message: `kalamba:sdk:${r}`,
|
|
68
|
+
payload: e
|
|
69
|
+
},
|
|
70
|
+
"*"
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
async openGame(r) {
|
|
74
|
+
var o;
|
|
75
|
+
const [, e] = await Promise.all([
|
|
76
|
+
// TODO: return promise from call to this.on if listener is not provided
|
|
77
|
+
new Promise((t) => this.on("configured", t, { once: !0 })),
|
|
78
|
+
this.request("openGame", r)
|
|
79
|
+
]);
|
|
80
|
+
if (e.type === "response")
|
|
81
|
+
return e.response;
|
|
82
|
+
throw ((o = e.error) == null ? void 0 : o.type) === "timeout" ? new l() : new E(e.error);
|
|
83
|
+
}
|
|
84
|
+
async play(r) {
|
|
85
|
+
var o;
|
|
86
|
+
const e = await this.request("play", r);
|
|
87
|
+
if (e.type === "response")
|
|
88
|
+
return e.response;
|
|
89
|
+
throw ((o = e.error) == null ? void 0 : o.type) === "timeout" ? new l() : new g(e.error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
a = new WeakMap();
|
|
93
|
+
export {
|
|
94
|
+
P as KalambaSdk,
|
|
95
|
+
E as OpenGameError,
|
|
96
|
+
g as PlayError,
|
|
97
|
+
l as TimeoutError
|
|
98
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSD 3-Clause License
|
|
3
|
+
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
|
+
*/
|
|
5
|
+
var t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
6
|
+
function e(o) {
|
|
7
|
+
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
8
|
+
}
|
|
9
|
+
function n() {
|
|
10
|
+
}
|
|
11
|
+
var l = n;
|
|
12
|
+
const a = /* @__PURE__ */ e(l);
|
|
13
|
+
export {
|
|
14
|
+
a,
|
|
15
|
+
t as c,
|
|
16
|
+
e as g,
|
|
17
|
+
l as n
|
|
18
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSD 3-Clause License
|
|
3
|
+
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
|
+
*/
|
|
5
|
+
"use strict";var t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function e(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function l(){}var n=l;const f=e(n);exports.commonjsGlobal=t;exports.getDefaultExportFromCjs=e;exports.noop=f;exports.noop_1=n;
|