@kalamba/sdk 0.4.1 → 0.5.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/index.cjs +1 -1
- package/dist/index.d.ts +48 -12
- package/dist/index.js +196 -93
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.ts +4 -5
- package/dist/plugins.js +106 -103
- package/dist/wrapper.d.ts +3 -5
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* BSD 3-Clause License
|
|
3
3
|
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
"use strict";var
|
|
5
|
+
"use strict";var G=Object.defineProperty;var L=(r,i,t)=>i in r?G(r,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[i]=t;var S=(r,i,t)=>(L(r,typeof i!="symbol"?i+"":i,t),t),R=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var m=(r,i,t)=>(R(r,i,"read from private field"),t?t.call(r):i.get(r)),u=(r,i,t)=>{if(i.has(r))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(r):i.set(r,t)},c=(r,i,t,n)=>(R(r,i,"write to private field"),n?n.call(r,t):i.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function I(r){const i=Object.prototype.toString.call(r);return r instanceof Date||typeof r=="object"&&i==="[object Date]"?new r.constructor(+r):typeof r=="number"||i==="[object Number]"||typeof r=="string"||i==="[object String]"?new Date(r):new Date(NaN)}function $(r){const i=I(r);return i.setHours(23,59,59,999),i}function _(){return $(Date.now())}function j(r){const i=I(r);return i.setHours(0,0,0,0),i}function q(){return j(Date.now())}const V=3e4;var D,x;class v{constructor(i){u(this,D,void 0);u(this,x,V);c(this,D,i)}buildHeaders(){const i={};return m(this,D).token&&(i.Authorization=`Bearer ${m(this,D).token}`),i}async request(i,t){const n=new URL(i,m(this,D).apiUrl??window.location.origin);return n.search=new URLSearchParams({...t}).toString(),await(await fetch(n,{signal:AbortSignal.timeout(m(this,x)),headers:this.buildHeaders()})).json()}async getRounds(i){return this.request("/rounds",i)}async getRound(i,t){return this.request(`/rounds/${i}`,t)}}D=new WeakMap,x=new WeakMap;const O={limit:100,page:0};var e,l;class A{constructor({config:i}){u(this,e,void 0);u(this,l,void 0);c(this,e,i),c(this,l,new v({apiUrl:i.api.gameHistoryUrl}))}async getRound(i,{pagination:t=O}={}){return m(this,l).getRound(i,{gameCode:m(this,e).api.game,operatorCode:m(this,e).api.brand,username:m(this,e).api.user,...t})}async getLastRound(){return m(this,e).api.lastRoundId?this.getRound(m(this,e).api.lastRoundId):null}async getRounds({searchPeriod:i={fromDateTime:q(),toDateTime:_()},pagination:t=O}={}){const n=m(this,e).api.user.replace(/^user_/,"").replace(new RegExp(`_${m(this,e).api.integration}$`),"");return m(this,l).getRounds({gameCode:m(this,e).api.game,operatorCode:m(this,e).api.integration,username:n,fromDataTime:i.fromDateTime.toISOString(),toDateTime:i.toDateTime.toISOString(),...t})}}e=new WeakMap,l=new WeakMap;function K(r,i){return r*i/100}function M(r,i,t){if(!["string","number"].includes(typeof i))return"NaN";const{locales:n}=r;try{return new Intl.NumberFormat(n,{...t,numberingSystem:"latn",style:"decimal"}).format(+i)}catch{return`${i}`}}const T="XTS";var F=(r=>(r.Currency="Currency",r.Number="Number",r))(F||{}),y=(r=>(r.Coins="Coins",r.Money="Money",r))(y||{});const E={ARSB:{displayAs:"ARS",maximumFractionDigits:2,minimumFractionDigits:2},CHIPS:{maximumFractionDigits:0,minimumFractionDigits:0},BNB:{maximumFractionDigits:6,minimumFractionDigits:6},BUSD:{maximumFractionDigits:4,minimumFractionDigits:4},BTC:{maximumFractionDigits:8,minimumFractionDigits:2},mBTC:{maximumFractionDigits:5,minimumFractionDigits:2},uBTC:{maximumFractionDigits:2,minimumFractionDigits:2},BCH:{maximumFractionDigits:8,minimumFractionDigits:2},mBCH:{maximumFractionDigits:2,minimumFractionDigits:2},ETH:{maximumFractionDigits:8,minimumFractionDigits:2},mETH:{maximumFractionDigits:5,minimumFractionDigits:2},uETH:{maximumFractionDigits:2,minimumFractionDigits:2},SOC:{maximumFractionDigits:8,minimumFractionDigits:2},LTC:{maximumFractionDigits:8,minimumFractionDigits:2},mLTC:{maximumFractionDigits:5,minimumFractionDigits:2},uLTC:{maximumFractionDigits:2,minimumFractionDigits:2},DOG:{maximumFractionDigits:4,minimumFractionDigits:2},USDC:{maximumFractionDigits:4,minimumFractionDigits:4},USDT:{maximumFractionDigits:4,minimumFractionDigits:2},TRX:{maximumFractionDigits:2,minimumFractionDigits:2},TUSD:{maximumFractionDigits:2,minimumFractionDigits:2},DAI:{maximumFractionDigits:2,minimumFractionDigits:2},XMR:{maximumFractionDigits:4,minimumFractionDigits:4},CBET:{maximumFractionDigits:0,minimumFractionDigits:0},kCBET:{maximumFractionDigits:2,minimumFractionDigits:2},SHIB:{maximumFractionDigits:0,minimumFractionDigits:0},kSHIB:{maximumFractionDigits:4,minimumFractionDigits:2},NEO:{maximumFractionDigits:4,minimumFractionDigits:4},BSV:{maximumFractionDigits:4,minimumFractionDigits:4},EOS:{maximumFractionDigits:4,minimumFractionDigits:4},DASH:{maximumFractionDigits:4,minimumFractionDigits:4},XLM:{maximumFractionDigits:2,minimumFractionDigits:2},KRW:{maximumFractionDigits:2,minimumFractionDigits:2},kVND:{maximumFractionDigits:4,minimumFractionDigits:2},kIDR:{maximumFractionDigits:4,minimumFractionDigits:2},RSD:{maximumFractionDigits:2,minimumFractionDigits:2},STAKEGC:{displayAs:"GC",maximumFractionDigits:0,minimumFractionDigits:0},STAKESC:{displayAs:"SC",maximumFractionDigits:2,minimumFractionDigits:2},"FC.":{maximumFractionDigits:2,minimumFractionDigits:2},"GC.":{maximumFractionDigits:2,minimumFractionDigits:2},"SC.":{maximumFractionDigits:2,minimumFractionDigits:2},SVC:{maximumFractionDigits:2,minimumFractionDigits:2},DOT:{maximumFractionDigits:4,minimumFractionDigits:4},SOL:{maximumFractionDigits:4,minimumFractionDigits:4},XRP:{maximumFractionDigits:4,minimumFractionDigits:4},ADA:{maximumFractionDigits:4,minimumFractionDigits:4},TON:{maximumFractionDigits:4,minimumFractionDigits:4},FTN:{maximumFractionDigits:4,minimumFractionDigits:4}};function H(r){return r in E}function X(r){return H(r)?{...E[r],currency:T}:{currency:r}}function z(r,i,t){const n=i.format(+r);return H(t)?n.replace(T,E[t].displayAs??t):n}function W(r,i,t){const{maximumFractionDigits:n,minimumFractionDigits:o}=t.resolvedOptions();return M(r,i,{maximumFractionDigits:n,minimumFractionDigits:o})}function J(r,i,{as:t}={as:"Currency"}){const{canShowCurrency:n,currency:o}=r;return t==="Number"||!n?`${i}`:`${i} ${o}`}function Y(r,i,{as:t,from:n}={as:"Currency",from:"Money"},o){if(!["string","number"].includes(typeof i))return"NaN";const{canShowCurrency:s=!0,coinValueInCents:a,currency:C,locales:b}=r;n==="Coins"&&(i=K(+i,a));try{const k=X(C),N=new Intl.NumberFormat(b,{...k,...o,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!s?W(r,i,N):z(i,N,C)}catch{return J(r,i,{as:t})}}var g;class P{constructor({config:i}){u(this,g,void 0);c(this,g,i)}formatNumber(i,t){const n={locales:[m(this,g).ui.language]};return M(n,i,t)}formatCurrency(i,t={as:F.Currency,from:y.Money},n){const o=m(this,g).ui.feature.showCurrency,s=m(this,g).api.coinValueInCents,a=m(this,g).api.currency||T,C=[m(this,g).ui.language];return Y({canShowCurrency:o,coinValueInCents:s,currency:a,locales:C},i,t,n)}formatCoins(i,t){return this.formatCurrency(i,{as:F.Number,from:y.Coins},t)}formatCoinsWithCurrency(i,t){return this.formatCurrency(i,{as:F.Currency,from:y.Coins},t)}formatMoney(i,t){return this.formatCurrency(i,{as:F.Number,from:y.Money},t)}formatMoneyWithCurrency(i,t){return this.formatCurrency(i,{as:F.Currency,from:y.Money},t)}}g=new WeakMap;const Q=()=>{};class U extends Error{constructor(t){super("OpenGameError");S(this,"error");this.name="OpenGameError",this.error=t}}class B extends Error{constructor(t){super("PlayError");S(this,"error");this.name="PlayError",this.error=t}}class w extends Error{constructor(){super("TimeoutError"),this.name="TimeoutError"}}var f,h,p,d;class Z{constructor({messagePort:i}){u(this,f,void 0);u(this,h,void 0);u(this,p,void 0);u(this,d,void 0);c(this,d,i),this.on("configured",t=>{c(this,f,t),c(this,p,new P({config:t})),c(this,h,new A({config:t}))}),this.on("playResponse",t=>{this.config.api.lastRoundId=t.contract.roundId})}get config(){if(!m(this,f))throw new Error("config is not initialized, you must open game first");return m(this,f)}get history(){if(!m(this,h))throw new Error("config is not initialized, you must open game first");return m(this,h)}get i18n(){if(!m(this,p))throw new Error("i18n is not initialized, you must open game first");return m(this,p)}request(i,...[t]){return new Promise(n=>{this.on(`${i}Response`,o=>n({type:"response",response:o}),{once:!0}),this.on(`${i}Error`,o=>n({type:"error",error:o}),{once:!0}),this.send(i,t)})}on(i,t,n){const o=function s(a){a.data.message===`kalamba:wrapper:${i}`&&(Q("on",a.data.message.replace(/^kalamba:/,""),a.data.payload),t(a.data.payload),n!=null&&n.once&&window.removeEventListener("message",s))};window.addEventListener("message",o)}send(i,...[t]){m(this,d).postMessage({message:`kalamba:sdk:${i}`,payload:t},"*")}async openGame(i){var n;const[,t]=await Promise.all([new Promise(o=>this.on("configured",o,{once:!0})),this.request("openGame",i)]);if(t.type==="response")return t.response;throw((n=t.error)==null?void 0:n.type)==="timeout"?new w:new U(t.error)}async play(i,t,n="SPIN"){var a;const o={contract:i,extra:t,actionType:n},s=await this.request("play",o);if(s.type==="response")return s.response;throw((a=s.error)==null?void 0:a.type)==="timeout"?new w:new B(s.error)}}f=new WeakMap,h=new WeakMap,p=new WeakMap,d=new WeakMap;exports.History=A;exports.I18n=P;exports.KalambaSdk=Z;exports.OpenGameError=U;exports.PlayError=B;exports.TimeoutError=w;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CurrencyFormat } from '@kalamba/common/src/utils/format/currency';
|
|
2
|
+
import { CurrencyNumber } from '@kalamba/common/src/utils/format/currency';
|
|
1
3
|
import { FormatCurrencyOptions } from '@kalamba/common/src/utils/format/currency';
|
|
2
4
|
|
|
3
5
|
declare interface AddEventListenerOptions_2 {
|
|
@@ -39,7 +41,7 @@ export declare type CasinoOnlyMessagePayloadMap = {
|
|
|
39
41
|
help: {
|
|
40
42
|
show?: boolean;
|
|
41
43
|
};
|
|
42
|
-
history:
|
|
44
|
+
history: History_3;
|
|
43
45
|
paytable: {
|
|
44
46
|
show?: boolean;
|
|
45
47
|
};
|
|
@@ -55,6 +57,10 @@ export declare type ContractPlayPayload = {
|
|
|
55
57
|
bet: Bet | null;
|
|
56
58
|
};
|
|
57
59
|
|
|
60
|
+
export { CurrencyFormat }
|
|
61
|
+
|
|
62
|
+
export { CurrencyNumber }
|
|
63
|
+
|
|
58
64
|
export declare type DomainAllowedPayloadMap<P extends DomainPrefix> = DomainToMessagePayloadMap[P];
|
|
59
65
|
|
|
60
66
|
export declare type DomainMessage<P extends DomainPrefix> = keyof DomainAllowedPayloadMap<P>;
|
|
@@ -83,6 +89,8 @@ declare type Error_2 = {
|
|
|
83
89
|
};
|
|
84
90
|
export { Error_2 as Error }
|
|
85
91
|
|
|
92
|
+
export { FormatCurrencyOptions }
|
|
93
|
+
|
|
86
94
|
export declare type ForwardToPluginsMessage<P extends PluginDomain> = keyof ForwardToPluginsMessageMap<'sdk'>[P] | keyof ForwardToPluginsMessageMap<'rgs'>[P] | keyof ForwardToPluginsMessageMap<'casino'>[P] | keyof ForwardToPluginsMessageMap<'telemetry'>[P];
|
|
87
95
|
|
|
88
96
|
export declare interface ForwardToPluginsMessageMap<SourceDomain extends DomainPrefix> {
|
|
@@ -97,12 +105,31 @@ export declare type ForwardToSdkMessage = keyof ToSdkForwardedMessageMap;
|
|
|
97
105
|
|
|
98
106
|
export declare type ForwardToSdkMessagePayload<M extends ForwardToSdkMessage> = ToSdkForwardedMessageMap[M];
|
|
99
107
|
|
|
100
|
-
declare
|
|
108
|
+
export declare interface GetRoundOptions {
|
|
109
|
+
pagination?: Pagination;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export declare interface GetRoundsOptions {
|
|
113
|
+
searchPeriod?: SearchPeriod;
|
|
114
|
+
pagination?: Pagination;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare class History_2 {
|
|
118
|
+
#private;
|
|
119
|
+
constructor({ config }: {
|
|
120
|
+
config: SdkConfig;
|
|
121
|
+
});
|
|
122
|
+
getRound(roundId: string, { pagination }?: GetRoundOptions): Promise<unknown>;
|
|
123
|
+
getLastRound(): Promise<unknown>;
|
|
124
|
+
getRounds({ searchPeriod, pagination, }?: GetRoundsOptions): Promise<unknown>;
|
|
125
|
+
}
|
|
126
|
+
export { History_2 as History }
|
|
127
|
+
|
|
128
|
+
declare type History_3 = {
|
|
101
129
|
source: 'realityCheck' | 'settings' | 'casino';
|
|
102
130
|
};
|
|
103
|
-
export { History_2 as History }
|
|
104
131
|
|
|
105
|
-
export declare class
|
|
132
|
+
export declare class I18n {
|
|
106
133
|
#private;
|
|
107
134
|
constructor({ config }: {
|
|
108
135
|
config: SdkConfig;
|
|
@@ -121,7 +148,8 @@ export declare class KalambaSdk {
|
|
|
121
148
|
messagePort: Window;
|
|
122
149
|
});
|
|
123
150
|
get config(): SdkConfig;
|
|
124
|
-
get
|
|
151
|
+
get history(): History_2;
|
|
152
|
+
get i18n(): I18n;
|
|
125
153
|
protected request<M extends DomainMessage<'sdk'>>(message: M, ...[payload]: DomainMessagePayload<'sdk', M> extends never ? [] : [payload: DomainMessagePayload<'sdk', M>]): Promise<RgsResponse<M>>;
|
|
126
154
|
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;
|
|
127
155
|
send<M extends DomainMessage<'sdk'>>(message: M, ...[payload]: DomainMessagePayload<'sdk', M> extends never ? [] : [DomainMessagePayload<'sdk', M>]): void;
|
|
@@ -160,10 +188,7 @@ export declare type OpenGameResponse = {
|
|
|
160
188
|
contract: {
|
|
161
189
|
bet: {
|
|
162
190
|
available: Record<number, number[]>;
|
|
163
|
-
default:
|
|
164
|
-
base: number;
|
|
165
|
-
multiplier: number;
|
|
166
|
-
};
|
|
191
|
+
default: Bet;
|
|
167
192
|
max: number;
|
|
168
193
|
last: Bet | null;
|
|
169
194
|
lastPaid: Bet | null;
|
|
@@ -185,6 +210,7 @@ export declare type OpenGameResponse = {
|
|
|
185
210
|
}[];
|
|
186
211
|
version: string;
|
|
187
212
|
};
|
|
213
|
+
roundId?: string;
|
|
188
214
|
serverTime: number;
|
|
189
215
|
sessionId: string;
|
|
190
216
|
stateType: {
|
|
@@ -200,6 +226,11 @@ export declare type OpenGameResponse = {
|
|
|
200
226
|
data: unknown;
|
|
201
227
|
};
|
|
202
228
|
|
|
229
|
+
export declare interface Pagination {
|
|
230
|
+
limit: number;
|
|
231
|
+
page: number;
|
|
232
|
+
}
|
|
233
|
+
|
|
203
234
|
export declare class PlayError extends Error {
|
|
204
235
|
error: any;
|
|
205
236
|
constructor(error: any);
|
|
@@ -226,8 +257,8 @@ export declare type PlayResponse = {
|
|
|
226
257
|
coins: number;
|
|
227
258
|
version: number;
|
|
228
259
|
};
|
|
229
|
-
serverTime: number;
|
|
230
260
|
roundId: string;
|
|
261
|
+
serverTime: number;
|
|
231
262
|
stateType: {
|
|
232
263
|
thisRound: string;
|
|
233
264
|
nextRound: string;
|
|
@@ -378,7 +409,7 @@ export declare type SdkOnlyMessagePayloadMap = {
|
|
|
378
409
|
fullscreen: {
|
|
379
410
|
lock?: OrientationLockType;
|
|
380
411
|
};
|
|
381
|
-
history:
|
|
412
|
+
history: History_3;
|
|
382
413
|
loadEnd: never;
|
|
383
414
|
loadProgress: {
|
|
384
415
|
progress: number;
|
|
@@ -402,6 +433,11 @@ export declare type SdkOnlyMessagePayloadMap = {
|
|
|
402
433
|
'telemetry.orientationChange': never;
|
|
403
434
|
};
|
|
404
435
|
|
|
436
|
+
export declare interface SearchPeriod {
|
|
437
|
+
fromDateTime: Date;
|
|
438
|
+
toDateTime: Date;
|
|
439
|
+
}
|
|
440
|
+
|
|
405
441
|
export declare type Settings = {
|
|
406
442
|
fastPlay?: boolean;
|
|
407
443
|
fastPlaySpeed?: number;
|
|
@@ -448,7 +484,7 @@ export declare type WrapperOnlyMessagePayloadMap = {
|
|
|
448
484
|
close: never;
|
|
449
485
|
configured: SdkConfig;
|
|
450
486
|
freeze: never;
|
|
451
|
-
history:
|
|
487
|
+
history: History_3;
|
|
452
488
|
resume: never;
|
|
453
489
|
state: WrapperState;
|
|
454
490
|
suspend: never;
|
package/dist/index.js
CHANGED
|
@@ -2,26 +2,120 @@
|
|
|
2
2
|
* BSD 3-Clause License
|
|
3
3
|
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var U = Object.defineProperty;
|
|
6
|
+
var B = (r, i, t) => i in r ? U(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
|
|
7
|
+
var w = (r, i, t) => (B(r, typeof i != "symbol" ? i + "" : i, t), t), R = (r, i, t) => {
|
|
8
8
|
if (!i.has(r))
|
|
9
9
|
throw TypeError("Cannot " + t);
|
|
10
10
|
};
|
|
11
|
-
var
|
|
11
|
+
var m = (r, i, t) => (R(r, i, "read from private field"), t ? t.call(r) : i.get(r)), u = (r, i, t) => {
|
|
12
12
|
if (i.has(r))
|
|
13
13
|
throw TypeError("Cannot add the same private member more than once");
|
|
14
14
|
i instanceof WeakSet ? i.add(r) : i.set(r, t);
|
|
15
|
-
},
|
|
16
|
-
function
|
|
15
|
+
}, c = (r, i, t, n) => (R(r, i, "write to private field"), n ? n.call(r, t) : i.set(r, t), t);
|
|
16
|
+
function I(r) {
|
|
17
|
+
const i = Object.prototype.toString.call(r);
|
|
18
|
+
return r instanceof Date || typeof r == "object" && i === "[object Date]" ? new r.constructor(+r) : typeof r == "number" || i === "[object Number]" || typeof r == "string" || i === "[object String]" ? new Date(r) : /* @__PURE__ */ new Date(NaN);
|
|
19
|
+
}
|
|
20
|
+
function P(r) {
|
|
21
|
+
const i = I(r);
|
|
22
|
+
return i.setHours(23, 59, 59, 999), i;
|
|
23
|
+
}
|
|
24
|
+
function k() {
|
|
25
|
+
return P(Date.now());
|
|
26
|
+
}
|
|
27
|
+
function L(r) {
|
|
28
|
+
const i = I(r);
|
|
29
|
+
return i.setHours(0, 0, 0, 0), i;
|
|
30
|
+
}
|
|
31
|
+
function $() {
|
|
32
|
+
return L(Date.now());
|
|
33
|
+
}
|
|
34
|
+
const G = 3e4;
|
|
35
|
+
var D, x;
|
|
36
|
+
class _ {
|
|
37
|
+
constructor(i) {
|
|
38
|
+
u(this, D, void 0);
|
|
39
|
+
u(this, x, G);
|
|
40
|
+
c(this, D, i);
|
|
41
|
+
}
|
|
42
|
+
buildHeaders() {
|
|
43
|
+
const i = {};
|
|
44
|
+
return m(this, D).token && (i.Authorization = `Bearer ${m(this, D).token}`), i;
|
|
45
|
+
}
|
|
46
|
+
async request(i, t) {
|
|
47
|
+
const n = new URL(i, m(this, D).apiUrl ?? window.location.origin);
|
|
48
|
+
return n.search = new URLSearchParams({
|
|
49
|
+
...t
|
|
50
|
+
}).toString(), await (await fetch(n, {
|
|
51
|
+
signal: AbortSignal.timeout(m(this, x)),
|
|
52
|
+
headers: this.buildHeaders()
|
|
53
|
+
})).json();
|
|
54
|
+
}
|
|
55
|
+
async getRounds(i) {
|
|
56
|
+
return this.request("/rounds", i);
|
|
57
|
+
}
|
|
58
|
+
async getRound(i, t) {
|
|
59
|
+
return this.request(`/rounds/${i}`, t);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
D = new WeakMap(), x = new WeakMap();
|
|
63
|
+
const b = {
|
|
64
|
+
limit: 100,
|
|
65
|
+
page: 0
|
|
66
|
+
};
|
|
67
|
+
var s, f;
|
|
68
|
+
class j {
|
|
69
|
+
constructor({
|
|
70
|
+
config: i
|
|
71
|
+
}) {
|
|
72
|
+
u(this, s, void 0);
|
|
73
|
+
u(this, f, void 0);
|
|
74
|
+
c(this, s, i), c(this, f, new _({
|
|
75
|
+
apiUrl: i.api.gameHistoryUrl
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
async getRound(i, {
|
|
79
|
+
pagination: t = b
|
|
80
|
+
} = {}) {
|
|
81
|
+
return m(this, f).getRound(i, {
|
|
82
|
+
gameCode: m(this, s).api.game,
|
|
83
|
+
operatorCode: m(this, s).api.brand,
|
|
84
|
+
username: m(this, s).api.user,
|
|
85
|
+
...t
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async getLastRound() {
|
|
89
|
+
return m(this, s).api.lastRoundId ? this.getRound(m(this, s).api.lastRoundId) : null;
|
|
90
|
+
}
|
|
91
|
+
async getRounds({
|
|
92
|
+
searchPeriod: i = {
|
|
93
|
+
fromDateTime: $(),
|
|
94
|
+
toDateTime: k()
|
|
95
|
+
},
|
|
96
|
+
pagination: t = b
|
|
97
|
+
} = {}) {
|
|
98
|
+
const n = m(this, s).api.user.replace(/^user_/, "").replace(new RegExp(`_${m(this, s).api.integration}$`), "");
|
|
99
|
+
return m(this, f).getRounds({
|
|
100
|
+
gameCode: m(this, s).api.game,
|
|
101
|
+
operatorCode: m(this, s).api.integration,
|
|
102
|
+
username: n,
|
|
103
|
+
fromDataTime: i.fromDateTime.toISOString(),
|
|
104
|
+
toDateTime: i.toDateTime.toISOString(),
|
|
105
|
+
...t
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
s = new WeakMap(), f = new WeakMap();
|
|
110
|
+
function q(r, i) {
|
|
17
111
|
return r * i / 100;
|
|
18
112
|
}
|
|
19
|
-
function
|
|
113
|
+
function A(r, i, t) {
|
|
20
114
|
if (!["string", "number"].includes(typeof i))
|
|
21
115
|
return "NaN";
|
|
22
|
-
const { locales:
|
|
116
|
+
const { locales: n } = r;
|
|
23
117
|
try {
|
|
24
|
-
return new Intl.NumberFormat(
|
|
118
|
+
return new Intl.NumberFormat(n, {
|
|
25
119
|
...t,
|
|
26
120
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
121
|
// @ts-ignore
|
|
@@ -32,9 +126,9 @@ function w(r, i, t) {
|
|
|
32
126
|
return `${i}`;
|
|
33
127
|
}
|
|
34
128
|
}
|
|
35
|
-
const
|
|
36
|
-
var
|
|
37
|
-
const
|
|
129
|
+
const S = "XTS";
|
|
130
|
+
var F = /* @__PURE__ */ ((r) => (r.Currency = "Currency", r.Number = "Number", r))(F || {}), y = /* @__PURE__ */ ((r) => (r.Coins = "Coins", r.Money = "Money", r))(y || {});
|
|
131
|
+
const T = {
|
|
38
132
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
39
133
|
// ARSB is the internal currency relevant for invoicing purposes, players should see it as ARS
|
|
40
134
|
ARSB: { displayAs: "ARS", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
@@ -128,146 +222,154 @@ const h = {
|
|
|
128
222
|
FTN: { maximumFractionDigits: 4, minimumFractionDigits: 4 }
|
|
129
223
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
130
224
|
};
|
|
131
|
-
function
|
|
132
|
-
return r in
|
|
225
|
+
function M(r) {
|
|
226
|
+
return r in T;
|
|
133
227
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
136
|
-
...
|
|
137
|
-
currency:
|
|
228
|
+
function V(r) {
|
|
229
|
+
return M(r) ? {
|
|
230
|
+
...T[r],
|
|
231
|
+
currency: S
|
|
138
232
|
} : {
|
|
139
233
|
currency: r
|
|
140
234
|
};
|
|
141
235
|
}
|
|
142
|
-
function
|
|
143
|
-
const
|
|
144
|
-
return
|
|
236
|
+
function X(r, i, t) {
|
|
237
|
+
const n = i.format(+r);
|
|
238
|
+
return M(t) ? n.replace(S, T[t].displayAs ?? t) : n;
|
|
145
239
|
}
|
|
146
|
-
function
|
|
147
|
-
const { maximumFractionDigits:
|
|
148
|
-
return
|
|
240
|
+
function v(r, i, t) {
|
|
241
|
+
const { maximumFractionDigits: n, minimumFractionDigits: o } = t.resolvedOptions();
|
|
242
|
+
return A(r, i, { maximumFractionDigits: n, minimumFractionDigits: o });
|
|
149
243
|
}
|
|
150
|
-
function
|
|
244
|
+
function z(r, i, { as: t } = {
|
|
151
245
|
as: "Currency"
|
|
152
246
|
/* Currency */
|
|
153
247
|
}) {
|
|
154
|
-
const { canShowCurrency:
|
|
155
|
-
return t === "Number" || !
|
|
248
|
+
const { canShowCurrency: n, currency: o } = r;
|
|
249
|
+
return t === "Number" || !n ? `${i}` : `${i} ${o}`;
|
|
156
250
|
}
|
|
157
|
-
function
|
|
251
|
+
function K(r, i, { as: t, from: n } = {
|
|
158
252
|
as: "Currency",
|
|
159
253
|
from: "Money"
|
|
160
254
|
/* Money */
|
|
161
|
-
},
|
|
255
|
+
}, o) {
|
|
162
256
|
if (!["string", "number"].includes(typeof i))
|
|
163
257
|
return "NaN";
|
|
164
|
-
const { canShowCurrency:
|
|
165
|
-
|
|
258
|
+
const { canShowCurrency: e = !0, coinValueInCents: a, currency: C, locales: E } = r;
|
|
259
|
+
n === "Coins" && (i = q(+i, a));
|
|
166
260
|
try {
|
|
167
|
-
const
|
|
168
|
-
...
|
|
169
|
-
...
|
|
261
|
+
const H = V(C), N = new Intl.NumberFormat(E, {
|
|
262
|
+
...H,
|
|
263
|
+
...o,
|
|
170
264
|
currencyDisplay: "symbol",
|
|
171
265
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
172
266
|
// @ts-ignore
|
|
173
267
|
numberingSystem: "latn",
|
|
174
268
|
style: "currency"
|
|
175
269
|
});
|
|
176
|
-
return t === "Number" || !
|
|
270
|
+
return t === "Number" || !e ? v(r, i, N) : X(i, N, C);
|
|
177
271
|
} catch {
|
|
178
|
-
return
|
|
272
|
+
return z(r, i, { as: t });
|
|
179
273
|
}
|
|
180
274
|
}
|
|
181
|
-
var
|
|
182
|
-
class
|
|
275
|
+
var g;
|
|
276
|
+
class W {
|
|
183
277
|
constructor({ config: i }) {
|
|
184
|
-
|
|
185
|
-
|
|
278
|
+
u(this, g, void 0);
|
|
279
|
+
c(this, g, i);
|
|
186
280
|
}
|
|
187
281
|
formatNumber(i, t) {
|
|
188
|
-
const
|
|
189
|
-
return
|
|
282
|
+
const n = { locales: [m(this, g).ui.language] };
|
|
283
|
+
return A(n, i, t);
|
|
190
284
|
}
|
|
191
|
-
formatCurrency(i, t = { as:
|
|
192
|
-
const
|
|
193
|
-
return
|
|
194
|
-
canShowCurrency:
|
|
195
|
-
coinValueInCents:
|
|
285
|
+
formatCurrency(i, t = { as: F.Currency, from: y.Money }, n) {
|
|
286
|
+
const o = m(this, g).ui.feature.showCurrency, e = m(this, g).api.coinValueInCents, a = m(this, g).api.currency || S, C = [m(this, g).ui.language];
|
|
287
|
+
return K({
|
|
288
|
+
canShowCurrency: o,
|
|
289
|
+
coinValueInCents: e,
|
|
196
290
|
currency: a,
|
|
197
|
-
locales:
|
|
198
|
-
}, i, t,
|
|
291
|
+
locales: C
|
|
292
|
+
}, i, t, n);
|
|
199
293
|
}
|
|
200
294
|
formatCoins(i, t) {
|
|
201
|
-
return this.formatCurrency(i, { as:
|
|
295
|
+
return this.formatCurrency(i, { as: F.Number, from: y.Coins }, t);
|
|
202
296
|
}
|
|
203
297
|
formatCoinsWithCurrency(i, t) {
|
|
204
|
-
return this.formatCurrency(i, { as:
|
|
298
|
+
return this.formatCurrency(i, { as: F.Currency, from: y.Coins }, t);
|
|
205
299
|
}
|
|
206
300
|
formatMoney(i, t) {
|
|
207
|
-
return this.formatCurrency(i, { as:
|
|
301
|
+
return this.formatCurrency(i, { as: F.Number, from: y.Money }, t);
|
|
208
302
|
}
|
|
209
303
|
formatMoneyWithCurrency(i, t) {
|
|
210
|
-
return this.formatCurrency(i, { as:
|
|
304
|
+
return this.formatCurrency(i, { as: F.Currency, from: y.Money }, t);
|
|
211
305
|
}
|
|
212
306
|
}
|
|
213
|
-
|
|
214
|
-
const
|
|
307
|
+
g = new WeakMap();
|
|
308
|
+
const J = () => {
|
|
215
309
|
};
|
|
216
|
-
class
|
|
310
|
+
class Y extends Error {
|
|
217
311
|
constructor(t) {
|
|
218
312
|
super("OpenGameError");
|
|
219
|
-
|
|
313
|
+
w(this, "error");
|
|
220
314
|
this.name = "OpenGameError", this.error = t;
|
|
221
315
|
}
|
|
222
316
|
}
|
|
223
|
-
class
|
|
317
|
+
class Q extends Error {
|
|
224
318
|
constructor(t) {
|
|
225
319
|
super("PlayError");
|
|
226
|
-
|
|
320
|
+
w(this, "error");
|
|
227
321
|
this.name = "PlayError", this.error = t;
|
|
228
322
|
}
|
|
229
323
|
}
|
|
230
|
-
class
|
|
324
|
+
class O extends Error {
|
|
231
325
|
constructor() {
|
|
232
326
|
super("TimeoutError"), this.name = "TimeoutError";
|
|
233
327
|
}
|
|
234
328
|
}
|
|
235
|
-
var
|
|
236
|
-
class
|
|
329
|
+
var l, h, p, d;
|
|
330
|
+
class ii {
|
|
237
331
|
constructor({ messagePort: i }) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
332
|
+
u(this, l, void 0);
|
|
333
|
+
u(this, h, void 0);
|
|
334
|
+
u(this, p, void 0);
|
|
335
|
+
u(this, d, void 0);
|
|
336
|
+
c(this, d, i), this.on("configured", (t) => {
|
|
337
|
+
c(this, l, t), c(this, p, new W({ config: t })), c(this, h, new j({ config: t }));
|
|
338
|
+
}), this.on("playResponse", (t) => {
|
|
339
|
+
this.config.api.lastRoundId = t.contract.roundId;
|
|
243
340
|
});
|
|
244
341
|
}
|
|
245
342
|
get config() {
|
|
246
|
-
if (!
|
|
343
|
+
if (!m(this, l))
|
|
344
|
+
throw new Error("config is not initialized, you must open game first");
|
|
345
|
+
return m(this, l);
|
|
346
|
+
}
|
|
347
|
+
get history() {
|
|
348
|
+
if (!m(this, h))
|
|
247
349
|
throw new Error("config is not initialized, you must open game first");
|
|
248
|
-
return
|
|
350
|
+
return m(this, h);
|
|
249
351
|
}
|
|
250
352
|
get i18n() {
|
|
251
|
-
if (!
|
|
353
|
+
if (!m(this, p))
|
|
252
354
|
throw new Error("i18n is not initialized, you must open game first");
|
|
253
|
-
return
|
|
355
|
+
return m(this, p);
|
|
254
356
|
}
|
|
255
357
|
request(i, ...[t]) {
|
|
256
|
-
return new Promise((
|
|
257
|
-
this.on(`${i}Response`, (
|
|
358
|
+
return new Promise((n) => {
|
|
359
|
+
this.on(`${i}Response`, (o) => n({ type: "response", response: o }), {
|
|
258
360
|
once: !0
|
|
259
|
-
}), this.on(`${i}Error`, (
|
|
361
|
+
}), this.on(`${i}Error`, (o) => n({ type: "error", error: o }), { once: !0 }), this.send(i, t);
|
|
260
362
|
});
|
|
261
363
|
}
|
|
262
|
-
on(i, t,
|
|
263
|
-
const
|
|
264
|
-
a.data.message === `kalamba:wrapper:${i}` && (
|
|
364
|
+
on(i, t, n) {
|
|
365
|
+
const o = function e(a) {
|
|
366
|
+
a.data.message === `kalamba:wrapper:${i}` && (J("on", a.data.message.replace(/^kalamba:/, ""), a.data.payload), t(a.data.payload), n != null && n.once && window.removeEventListener("message", e));
|
|
265
367
|
};
|
|
266
|
-
window.addEventListener("message",
|
|
368
|
+
window.addEventListener("message", o);
|
|
267
369
|
}
|
|
268
370
|
// TODO error messages
|
|
269
371
|
send(i, ...[t]) {
|
|
270
|
-
|
|
372
|
+
m(this, d).postMessage(
|
|
271
373
|
{
|
|
272
374
|
message: `kalamba:sdk:${i}`,
|
|
273
375
|
payload: t
|
|
@@ -276,29 +378,30 @@ class L {
|
|
|
276
378
|
);
|
|
277
379
|
}
|
|
278
380
|
async openGame(i) {
|
|
279
|
-
var
|
|
381
|
+
var n;
|
|
280
382
|
const [, t] = await Promise.all([
|
|
281
383
|
// TODO: return promise from call to this.on if listener is not provided
|
|
282
|
-
new Promise((
|
|
384
|
+
new Promise((o) => this.on("configured", o, { once: !0 })),
|
|
283
385
|
this.request("openGame", i)
|
|
284
386
|
]);
|
|
285
387
|
if (t.type === "response")
|
|
286
388
|
return t.response;
|
|
287
|
-
throw ((
|
|
389
|
+
throw ((n = t.error) == null ? void 0 : n.type) === "timeout" ? new O() : new Y(t.error);
|
|
288
390
|
}
|
|
289
|
-
async play(i, t,
|
|
391
|
+
async play(i, t, n = "SPIN") {
|
|
290
392
|
var a;
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
return
|
|
294
|
-
throw ((a =
|
|
393
|
+
const o = { contract: i, extra: t, actionType: n }, e = await this.request("play", o);
|
|
394
|
+
if (e.type === "response")
|
|
395
|
+
return e.response;
|
|
396
|
+
throw ((a = e.error) == null ? void 0 : a.type) === "timeout" ? new O() : new Q(e.error);
|
|
295
397
|
}
|
|
296
398
|
}
|
|
297
|
-
|
|
399
|
+
l = new WeakMap(), h = new WeakMap(), p = new WeakMap(), d = new WeakMap();
|
|
298
400
|
export {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
401
|
+
j as History,
|
|
402
|
+
W as I18n,
|
|
403
|
+
ii as KalambaSdk,
|
|
404
|
+
Y as OpenGameError,
|
|
405
|
+
Q as PlayError,
|
|
406
|
+
O as TimeoutError
|
|
304
407
|
};
|