@kalamba/sdk 0.6.1 → 0.8.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/errors-358575c3.cjs +5 -0
- package/dist/errors-afd9f527.js +90 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +90 -78
- package/dist/index.js +88 -91
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.ts +97 -69
- package/dist/plugins.js +1002 -1043
- package/dist/wrapper.cjs +1 -1
- package/dist/wrapper.d.ts +99 -69
- package/dist/wrapper.js +669 -629
- package/package.json +1 -1
- package/dist/errors-66b5612a.cjs +0 -5
- package/dist/errors-96eb18f7.js +0 -52
package/dist/index.js
CHANGED
|
@@ -2,41 +2,41 @@
|
|
|
2
2
|
* BSD 3-Clause License
|
|
3
3
|
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
var
|
|
5
|
+
var N = (n, i, t) => {
|
|
6
6
|
if (!i.has(n))
|
|
7
7
|
throw TypeError("Cannot " + t);
|
|
8
8
|
};
|
|
9
|
-
var m = (n, i, t) => (
|
|
9
|
+
var m = (n, i, t) => (N(n, i, "read from private field"), t ? t.call(n) : i.get(n)), e = (n, i, t) => {
|
|
10
10
|
if (i.has(n))
|
|
11
11
|
throw TypeError("Cannot add the same private member more than once");
|
|
12
12
|
i instanceof WeakSet ? i.add(n) : i.set(n, t);
|
|
13
|
-
}, u = (n, i, t, r) => (
|
|
14
|
-
import { T as
|
|
15
|
-
import { a as
|
|
16
|
-
function
|
|
13
|
+
}, u = (n, i, t, r) => (N(n, i, "write to private field"), r ? r.call(n, t) : i.set(n, t), t);
|
|
14
|
+
import { T as b, R as E } from "./errors-afd9f527.js";
|
|
15
|
+
import { a as ii } from "./errors-afd9f527.js";
|
|
16
|
+
function A(n) {
|
|
17
17
|
const i = Object.prototype.toString.call(n);
|
|
18
18
|
return n instanceof Date || typeof n == "object" && i === "[object Date]" ? new n.constructor(+n) : typeof n == "number" || i === "[object Number]" || typeof n == "string" || i === "[object String]" ? new Date(n) : /* @__PURE__ */ new Date(NaN);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const i =
|
|
20
|
+
function U(n) {
|
|
21
|
+
const i = A(n);
|
|
22
22
|
return i.setHours(23, 59, 59, 999), i;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
24
|
+
function B() {
|
|
25
|
+
return U(Date.now());
|
|
26
26
|
}
|
|
27
27
|
function k(n) {
|
|
28
|
-
const i =
|
|
28
|
+
const i = A(n);
|
|
29
29
|
return i.setHours(0, 0, 0, 0), i;
|
|
30
30
|
}
|
|
31
31
|
function L() {
|
|
32
32
|
return k(Date.now());
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const P = 3e4;
|
|
35
35
|
var D, x;
|
|
36
|
-
class
|
|
36
|
+
class $ {
|
|
37
37
|
constructor(i) {
|
|
38
38
|
e(this, D, void 0);
|
|
39
|
-
e(this, x,
|
|
39
|
+
e(this, x, P);
|
|
40
40
|
u(this, D, i);
|
|
41
41
|
}
|
|
42
42
|
buildHeaders() {
|
|
@@ -60,45 +60,45 @@ class G {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
D = new WeakMap(), x = new WeakMap();
|
|
63
|
-
const
|
|
63
|
+
const I = {
|
|
64
64
|
limit: 100,
|
|
65
65
|
page: 0
|
|
66
66
|
};
|
|
67
|
-
var
|
|
67
|
+
var s, y;
|
|
68
68
|
class _ {
|
|
69
69
|
constructor({
|
|
70
70
|
config: i
|
|
71
71
|
}) {
|
|
72
|
-
e(this,
|
|
73
|
-
e(this,
|
|
74
|
-
u(this,
|
|
72
|
+
e(this, s, void 0);
|
|
73
|
+
e(this, y, void 0);
|
|
74
|
+
u(this, s, i), u(this, y, new $({
|
|
75
75
|
apiUrl: i.api.gameHistoryUrl
|
|
76
76
|
}));
|
|
77
77
|
}
|
|
78
78
|
async getRound(i, {
|
|
79
|
-
pagination: t =
|
|
79
|
+
pagination: t = I
|
|
80
80
|
} = {}) {
|
|
81
|
-
return m(this,
|
|
82
|
-
gameCode: m(this,
|
|
83
|
-
operatorCode: m(this,
|
|
84
|
-
username: m(this,
|
|
81
|
+
return m(this, y).getRound(i, {
|
|
82
|
+
gameCode: m(this, s).api.game,
|
|
83
|
+
operatorCode: m(this, s).api.brand,
|
|
84
|
+
username: m(this, s).api.user,
|
|
85
85
|
...t
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
async getLastRound() {
|
|
89
|
-
return m(this,
|
|
89
|
+
return m(this, s).api.lastRoundId ? this.getRound(m(this, s).api.lastRoundId) : null;
|
|
90
90
|
}
|
|
91
91
|
async getRounds({
|
|
92
92
|
searchPeriod: i = {
|
|
93
93
|
fromDateTime: L(),
|
|
94
|
-
toDateTime:
|
|
94
|
+
toDateTime: B()
|
|
95
95
|
},
|
|
96
|
-
pagination: t =
|
|
96
|
+
pagination: t = I
|
|
97
97
|
} = {}) {
|
|
98
|
-
const r = m(this,
|
|
99
|
-
return m(this,
|
|
100
|
-
gameCode: m(this,
|
|
101
|
-
operatorCode: m(this,
|
|
98
|
+
const r = m(this, s).api.user.replace(/^user_/, "").replace(new RegExp(`_${m(this, s).api.integration}$`), "");
|
|
99
|
+
return m(this, y).getRounds({
|
|
100
|
+
gameCode: m(this, s).api.game,
|
|
101
|
+
operatorCode: m(this, s).api.integration,
|
|
102
102
|
username: r,
|
|
103
103
|
fromDataTime: i.fromDateTime.toISOString(),
|
|
104
104
|
toDateTime: i.toDateTime.toISOString(),
|
|
@@ -106,11 +106,11 @@ class _ {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
function
|
|
109
|
+
s = new WeakMap(), y = new WeakMap();
|
|
110
|
+
function G(n, i) {
|
|
111
111
|
return n * i / 100;
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function O(n, i, t) {
|
|
114
114
|
if (!["string", "number"].includes(typeof i))
|
|
115
115
|
return "NaN";
|
|
116
116
|
const { locales: r } = n;
|
|
@@ -127,7 +127,7 @@ function I(n, i, t) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
const w = "XTS";
|
|
130
|
-
var F = /* @__PURE__ */ ((n) => (n.Currency = "Currency", n.Number = "Number", n))(F || {}),
|
|
130
|
+
var F = /* @__PURE__ */ ((n) => (n.Currency = "Currency", n.Number = "Number", n))(F || {}), f = /* @__PURE__ */ ((n) => (n.Coins = "Coins", n.Money = "Money", n))(f || {});
|
|
131
131
|
const S = {
|
|
132
132
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
133
133
|
// ARSB is the internal currency relevant for invoicing purposes, players should see it as ARS
|
|
@@ -222,44 +222,44 @@ const S = {
|
|
|
222
222
|
FTN: { maximumFractionDigits: 4, minimumFractionDigits: 4 }
|
|
223
223
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
224
224
|
};
|
|
225
|
-
function
|
|
225
|
+
function M(n) {
|
|
226
226
|
return n in S;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
228
|
+
function j(n) {
|
|
229
|
+
return M(n) ? {
|
|
230
230
|
...S[n],
|
|
231
231
|
currency: w
|
|
232
232
|
} : {
|
|
233
233
|
currency: n
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function q(n, i, t) {
|
|
237
237
|
const r = i.format(+n);
|
|
238
|
-
return
|
|
238
|
+
return M(t) ? r.replace(w, S[t].displayAs ?? t) : r;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function V(n, i, t) {
|
|
241
241
|
const { maximumFractionDigits: r, minimumFractionDigits: o } = t.resolvedOptions();
|
|
242
|
-
return
|
|
242
|
+
return O(n, i, { maximumFractionDigits: r, minimumFractionDigits: o });
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function X(n, i, { as: t } = {
|
|
245
245
|
as: "Currency"
|
|
246
246
|
/* Currency */
|
|
247
247
|
}) {
|
|
248
248
|
const { canShowCurrency: r, currency: o } = n;
|
|
249
249
|
return t === "Number" || !r ? `${i}` : `${i} ${o}`;
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function v(n, i, { as: t, from: r } = {
|
|
252
252
|
as: "Currency",
|
|
253
253
|
from: "Money"
|
|
254
254
|
/* Money */
|
|
255
255
|
}, o) {
|
|
256
256
|
if (!["string", "number"].includes(typeof i))
|
|
257
257
|
return "NaN";
|
|
258
|
-
const { canShowCurrency:
|
|
259
|
-
r === "Coins" && (i =
|
|
258
|
+
const { canShowCurrency: a = !0, coinValueInCents: g, currency: C, locales: T } = n;
|
|
259
|
+
r === "Coins" && (i = G(+i, g));
|
|
260
260
|
try {
|
|
261
|
-
const
|
|
262
|
-
...
|
|
261
|
+
const H = j(C), R = new Intl.NumberFormat(T, {
|
|
262
|
+
...H,
|
|
263
263
|
...o,
|
|
264
264
|
currencyDisplay: "symbol",
|
|
265
265
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -267,68 +267,68 @@ function z(n, i, { as: t, from: r } = {
|
|
|
267
267
|
numberingSystem: "latn",
|
|
268
268
|
style: "currency"
|
|
269
269
|
});
|
|
270
|
-
return t === "Number" || !
|
|
270
|
+
return t === "Number" || !a ? V(n, i, R) : q(i, R, C);
|
|
271
271
|
} catch {
|
|
272
|
-
return
|
|
272
|
+
return X(n, i, { as: t });
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
var c;
|
|
276
|
-
class
|
|
276
|
+
class z {
|
|
277
277
|
constructor({ config: i }) {
|
|
278
278
|
e(this, c, void 0);
|
|
279
279
|
u(this, c, i);
|
|
280
280
|
}
|
|
281
281
|
formatNumber(i, t) {
|
|
282
282
|
const r = { locales: [m(this, c).ui.language] };
|
|
283
|
-
return
|
|
283
|
+
return O(r, i, t);
|
|
284
284
|
}
|
|
285
|
-
formatCurrency(i, t = { as: F.Currency, from:
|
|
286
|
-
const o = m(this, c).ui.feature.showCurrency,
|
|
287
|
-
return
|
|
285
|
+
formatCurrency(i, t = { as: F.Currency, from: f.Money }, r) {
|
|
286
|
+
const o = m(this, c).ui.feature.showCurrency, a = m(this, c).api.coinValueInCents, g = m(this, c).api.currency || w, C = [m(this, c).ui.language];
|
|
287
|
+
return v({
|
|
288
288
|
canShowCurrency: o,
|
|
289
|
-
coinValueInCents:
|
|
289
|
+
coinValueInCents: a,
|
|
290
290
|
currency: g,
|
|
291
291
|
locales: C
|
|
292
292
|
}, i, t, r);
|
|
293
293
|
}
|
|
294
294
|
formatCoins(i, t) {
|
|
295
|
-
return this.formatCurrency(i, { as: F.Number, from:
|
|
295
|
+
return this.formatCurrency(i, { as: F.Number, from: f.Coins }, t);
|
|
296
296
|
}
|
|
297
297
|
formatCoinsWithCurrency(i, t) {
|
|
298
|
-
return this.formatCurrency(i, { as: F.Currency, from:
|
|
298
|
+
return this.formatCurrency(i, { as: F.Currency, from: f.Coins }, t);
|
|
299
299
|
}
|
|
300
300
|
formatMoney(i, t) {
|
|
301
|
-
return this.formatCurrency(i, { as: F.Number, from:
|
|
301
|
+
return this.formatCurrency(i, { as: F.Number, from: f.Money }, t);
|
|
302
302
|
}
|
|
303
303
|
formatMoneyWithCurrency(i, t) {
|
|
304
|
-
return this.formatCurrency(i, { as: F.Currency, from:
|
|
304
|
+
return this.formatCurrency(i, { as: F.Currency, from: f.Money }, t);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
c = new WeakMap();
|
|
308
|
-
const
|
|
308
|
+
const K = () => {
|
|
309
309
|
};
|
|
310
|
-
var
|
|
311
|
-
class
|
|
310
|
+
var h, l, p, d;
|
|
311
|
+
class Y {
|
|
312
312
|
constructor({ messagePort: i }) {
|
|
313
|
-
e(this, l, void 0);
|
|
314
313
|
e(this, h, void 0);
|
|
314
|
+
e(this, l, void 0);
|
|
315
315
|
e(this, p, void 0);
|
|
316
316
|
e(this, d, void 0);
|
|
317
317
|
u(this, d, i), this.on("configured", (t) => {
|
|
318
|
-
u(this,
|
|
318
|
+
u(this, h, t), u(this, p, new z({ config: t })), u(this, l, new _({ config: t }));
|
|
319
319
|
}), this.on("playResponse", (t) => {
|
|
320
320
|
this.config.api.lastRoundId = t.contract.roundId;
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
323
|
get config() {
|
|
324
|
-
if (!m(this,
|
|
324
|
+
if (!m(this, h))
|
|
325
325
|
throw new Error("config is not initialized, you must open game first");
|
|
326
|
-
return m(this,
|
|
326
|
+
return m(this, h);
|
|
327
327
|
}
|
|
328
328
|
get history() {
|
|
329
|
-
if (!m(this,
|
|
329
|
+
if (!m(this, l))
|
|
330
330
|
throw new Error("config is not initialized, you must open game first");
|
|
331
|
-
return m(this,
|
|
331
|
+
return m(this, l);
|
|
332
332
|
}
|
|
333
333
|
get i18n() {
|
|
334
334
|
if (!m(this, p))
|
|
@@ -343,8 +343,8 @@ class Q {
|
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
on(i, t, r) {
|
|
346
|
-
const o = function
|
|
347
|
-
g.data.message === `kalamba:wrapper:${i}` && (
|
|
346
|
+
const o = function a(g) {
|
|
347
|
+
g.data.message === `kalamba:wrapper:${i}` && (K("on", g.data.message.replace(/^kalamba:/, ""), g.data.payload), t(g.data.payload), r != null && r.once && window.removeEventListener("message", a));
|
|
348
348
|
};
|
|
349
349
|
window.addEventListener("message", o);
|
|
350
350
|
}
|
|
@@ -358,31 +358,28 @@ class Q {
|
|
|
358
358
|
"*"
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
]);
|
|
361
|
+
configure(i) {
|
|
362
|
+
this.send("configure", i);
|
|
363
|
+
}
|
|
364
|
+
async openGame() {
|
|
365
|
+
const i = new Promise((r) => this.on("configured", r, { once: !0 })), t = await this.request("openGame");
|
|
367
366
|
if (t.type === "response")
|
|
368
|
-
return t.response;
|
|
369
|
-
throw t.error.type === "timeout" ? new
|
|
367
|
+
return await i, t.response;
|
|
368
|
+
throw t.error.type === "timeout" ? new b() : new E(t.error.data);
|
|
370
369
|
}
|
|
371
370
|
async play(i, t, r = "SPIN") {
|
|
372
|
-
const o = { contract: i, extra: t, actionType: r },
|
|
373
|
-
if (
|
|
374
|
-
return
|
|
375
|
-
throw
|
|
371
|
+
const o = { contract: i, extra: t, actionType: r }, a = await this.request("play", o);
|
|
372
|
+
if (a.type === "response")
|
|
373
|
+
return a.response;
|
|
374
|
+
throw a.error.type === "timeout" ? new b() : new E(a.error.data);
|
|
376
375
|
}
|
|
377
376
|
}
|
|
378
|
-
|
|
377
|
+
h = new WeakMap(), l = new WeakMap(), p = new WeakMap(), d = new WeakMap();
|
|
379
378
|
export {
|
|
380
379
|
_ as History,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
ni as PlayErrorCode,
|
|
387
|
-
E as TimeoutError
|
|
380
|
+
z as I18n,
|
|
381
|
+
Y as KalambaSdk,
|
|
382
|
+
E as RgsError,
|
|
383
|
+
ii as RgsErrorCode,
|
|
384
|
+
b as TimeoutError
|
|
388
385
|
};
|