@kalamba/sdk 0.10.1 → 0.13.2
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-afd9f527.js → errors-7cbbda8a.js} +6 -6
- package/dist/{errors-358575c3.cjs → errors-db453887.cjs} +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +167 -118
- package/dist/plugins.cjs +2 -2
- package/dist/plugins.d.ts +25 -17
- package/dist/plugins.js +634 -637
- package/dist/v4-58efbfa1.js +48 -0
- package/dist/v4-bada56b0.cjs +5 -0
- package/dist/wrapper.cjs +2 -2
- package/dist/wrapper.d.ts +2 -0
- package/dist/wrapper.js +923 -915
- package/package.json +12 -7
- package/dist/noop-3336849b.js +0 -18
- package/dist/noop-b3c54b76.cjs +0 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BSD 3-Clause License
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2025, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
var
|
|
6
|
-
var S = (_, E, O) => E in _ ?
|
|
7
|
-
var
|
|
5
|
+
var R = Object.defineProperty;
|
|
6
|
+
var S = (_, E, O) => E in _ ? R(_, E, { enumerable: !0, configurable: !0, writable: !0, value: O }) : _[E] = O;
|
|
7
|
+
var N = (_, E, O) => (S(_, typeof E != "symbol" ? E + "" : E, O), O);
|
|
8
8
|
const I = {
|
|
9
9
|
CONNECTION_ERROR: "CONNECTION_ERROR",
|
|
10
10
|
INVALID_BET_CURRENCY: "INVALID_BET_CURRENCY",
|
|
@@ -55,7 +55,7 @@ const I = {
|
|
|
55
55
|
FREE_ROUNDS_PROCESSING_ERROR: "RELOAD",
|
|
56
56
|
WEB_SESSION_NOT_OPEN: "RELOAD",
|
|
57
57
|
GAMING_LIMITS_REACHED: "CLOSE",
|
|
58
|
-
OUT_OF_MONEY: "
|
|
58
|
+
OUT_OF_MONEY: "CONTINUE",
|
|
59
59
|
UNFINISHED_ROUND_IN_PROGRESS: "CLOSE",
|
|
60
60
|
ACCESS_DENIED: "CLOSE",
|
|
61
61
|
CREDENTIALS_NOT_FOUND: "CLOSE",
|
|
@@ -73,7 +73,7 @@ const I = {
|
|
|
73
73
|
class L extends Error {
|
|
74
74
|
constructor(O) {
|
|
75
75
|
super();
|
|
76
|
-
|
|
76
|
+
N(this, "data");
|
|
77
77
|
this.name = "RgsError", this.data = O;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BSD 3-Clause License
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2025, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
"use strict";var N=Object.defineProperty;var S=(_,E,O)=>E in _?N(_,E,{enumerable:!0,configurable:!0,writable:!0,value:O}):_[E]=O;var R=(_,E,O)=>(S(_,typeof E!="symbol"?E+"":E,O),O);const A={CONNECTION_ERROR:"CONNECTION_ERROR",INVALID_BET_CURRENCY:"INVALID_BET_CURRENCY",INVALID_BET:"INVALID_BET",INVALID_CAGE_CODE:"INVALID_CAGE_CODE",INVALID_CLIENT_TYPE:"INVALID_CLIENT_TYPE",INVALID_MESSAGE_FORMAT:"INVALID_MESSAGE_FORMAT",INVALID_SESSION:"INVALID_SESSION",TOO_HIGH_BET_FREQUENCY:"TOO_HIGH_BET_FREQUENCY",TOO_HIGH_ACTION_FREQUENCY:"TOO_HIGH_ACTION_FREQUENCY",USER_LOCK_INVALID_PARAMS:"USER_LOCK_INVALID_PARAMS",USER_ALREADY_LOCKED:"USER_ALREADY_LOCKED",GAME_SERVER_ERROR:"GAME_SERVER_ERROR",SESSION_MANAGEMENT_ERROR:"SESSION_MANAGEMENT_ERROR",MESSAGE_SENDER_ERROR:"MESSAGE_SENDER_ERROR",FREE_ROUNDS_PROCESSING_ERROR:"FREE_ROUNDS_PROCESSING_ERROR",WEB_SESSION_NOT_OPEN:"WEB_SESSION_NOT_OPEN",GAMING_LIMITS_REACHED:"GAMING_LIMITS_REACHED",OUT_OF_MONEY:"OUT_OF_MONEY",UNFINISHED_ROUND_IN_PROGRESS:"UNFINISHED_ROUND_IN_PROGRESS",ACCESS_DENIED:"ACCESS_DENIED",CREDENTIALS_NOT_FOUND:"CREDENTIALS_NOT_FOUND",ALREADY_LOGGED_IN:"ALREADY_LOGGED_IN",GAME_UNAVAILABLE:"GAME_UNAVAILABLE",BONUS_RESTRICTION:"BONUS_RESTRICTION",TOO_MANY_OPEN_GAMES:"TOO_MANY_OPEN_GAMES",GAME_FROZEN:"GAME_FROZEN",WALLET_PROCESSING_ERROR:"WALLET_PROCESSING_ERROR",FORCED_OUTCOMES_NOT_ALLOWED:"FORCED_OUTCOMES_NOT_ALLOWED",MISSING_GAME_STATE:"MISSING_GAME_STATE",DATA_ACCESS_ERROR:"DATA_ACCESS_ERROR",UNKNOWN:"UNKNOWN"},I={CONNECTION_ERROR:"RELOAD",INVALID_BET_CURRENCY:"CLOSE",INVALID_BET:"CONTINUE",INVALID_CAGE_CODE:"CLOSE",INVALID_CLIENT_TYPE:"CLOSE",INVALID_MESSAGE_FORMAT:"CLOSE",INVALID_SESSION:"CLOSE",TOO_HIGH_BET_FREQUENCY:"CONTINUE",TOO_HIGH_ACTION_FREQUENCY:"CONTINUE",USER_LOCK_INVALID_PARAMS:"CLOSE",USER_ALREADY_LOCKED:"CLOSE",GAME_SERVER_ERROR:"RELOAD",SESSION_MANAGEMENT_ERROR:"RELOAD",MESSAGE_SENDER_ERROR:"RELOAD",FREE_ROUNDS_PROCESSING_ERROR:"RELOAD",WEB_SESSION_NOT_OPEN:"RELOAD",GAMING_LIMITS_REACHED:"CLOSE",OUT_OF_MONEY:"
|
|
5
|
+
"use strict";var N=Object.defineProperty;var S=(_,E,O)=>E in _?N(_,E,{enumerable:!0,configurable:!0,writable:!0,value:O}):_[E]=O;var R=(_,E,O)=>(S(_,typeof E!="symbol"?E+"":E,O),O);const A={CONNECTION_ERROR:"CONNECTION_ERROR",INVALID_BET_CURRENCY:"INVALID_BET_CURRENCY",INVALID_BET:"INVALID_BET",INVALID_CAGE_CODE:"INVALID_CAGE_CODE",INVALID_CLIENT_TYPE:"INVALID_CLIENT_TYPE",INVALID_MESSAGE_FORMAT:"INVALID_MESSAGE_FORMAT",INVALID_SESSION:"INVALID_SESSION",TOO_HIGH_BET_FREQUENCY:"TOO_HIGH_BET_FREQUENCY",TOO_HIGH_ACTION_FREQUENCY:"TOO_HIGH_ACTION_FREQUENCY",USER_LOCK_INVALID_PARAMS:"USER_LOCK_INVALID_PARAMS",USER_ALREADY_LOCKED:"USER_ALREADY_LOCKED",GAME_SERVER_ERROR:"GAME_SERVER_ERROR",SESSION_MANAGEMENT_ERROR:"SESSION_MANAGEMENT_ERROR",MESSAGE_SENDER_ERROR:"MESSAGE_SENDER_ERROR",FREE_ROUNDS_PROCESSING_ERROR:"FREE_ROUNDS_PROCESSING_ERROR",WEB_SESSION_NOT_OPEN:"WEB_SESSION_NOT_OPEN",GAMING_LIMITS_REACHED:"GAMING_LIMITS_REACHED",OUT_OF_MONEY:"OUT_OF_MONEY",UNFINISHED_ROUND_IN_PROGRESS:"UNFINISHED_ROUND_IN_PROGRESS",ACCESS_DENIED:"ACCESS_DENIED",CREDENTIALS_NOT_FOUND:"CREDENTIALS_NOT_FOUND",ALREADY_LOGGED_IN:"ALREADY_LOGGED_IN",GAME_UNAVAILABLE:"GAME_UNAVAILABLE",BONUS_RESTRICTION:"BONUS_RESTRICTION",TOO_MANY_OPEN_GAMES:"TOO_MANY_OPEN_GAMES",GAME_FROZEN:"GAME_FROZEN",WALLET_PROCESSING_ERROR:"WALLET_PROCESSING_ERROR",FORCED_OUTCOMES_NOT_ALLOWED:"FORCED_OUTCOMES_NOT_ALLOWED",MISSING_GAME_STATE:"MISSING_GAME_STATE",DATA_ACCESS_ERROR:"DATA_ACCESS_ERROR",UNKNOWN:"UNKNOWN"},I={CONNECTION_ERROR:"RELOAD",INVALID_BET_CURRENCY:"CLOSE",INVALID_BET:"CONTINUE",INVALID_CAGE_CODE:"CLOSE",INVALID_CLIENT_TYPE:"CLOSE",INVALID_MESSAGE_FORMAT:"CLOSE",INVALID_SESSION:"CLOSE",TOO_HIGH_BET_FREQUENCY:"CONTINUE",TOO_HIGH_ACTION_FREQUENCY:"CONTINUE",USER_LOCK_INVALID_PARAMS:"CLOSE",USER_ALREADY_LOCKED:"CLOSE",GAME_SERVER_ERROR:"RELOAD",SESSION_MANAGEMENT_ERROR:"RELOAD",MESSAGE_SENDER_ERROR:"RELOAD",FREE_ROUNDS_PROCESSING_ERROR:"RELOAD",WEB_SESSION_NOT_OPEN:"RELOAD",GAMING_LIMITS_REACHED:"CLOSE",OUT_OF_MONEY:"CONTINUE",UNFINISHED_ROUND_IN_PROGRESS:"CLOSE",ACCESS_DENIED:"CLOSE",CREDENTIALS_NOT_FOUND:"CLOSE",ALREADY_LOGGED_IN:"CLOSE",GAME_UNAVAILABLE:"CLOSE",BONUS_RESTRICTION:"CLOSE",TOO_MANY_OPEN_GAMES:"CLOSE",GAME_FROZEN:"CLOSE",WALLET_PROCESSING_ERROR:"CLOSE",FORCED_OUTCOMES_NOT_ALLOWED:"CONTINUE",MISSING_GAME_STATE:"RELOAD",DATA_ACCESS_ERROR:"RELOAD",UNKNOWN:"CLOSE"};class C extends Error{constructor(O){super();R(this,"data");this.name="RgsError",this.data=O}}class L extends Error{constructor(){super(),this.name="TimeoutError"}}exports.RgsError=C;exports.RgsErrorAction=I;exports.RgsErrorCode=A;exports.TimeoutError=L;
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BSD 3-Clause License
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2025, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
"use strict";var b=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var m=(r,i,t)=>(b(r,i,"read from private field"),t?t.call(r):i.get(r)),e=(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)},u=(r,i,t,n)=>(b(r,i,"write to private field"),n?n.call(r,t):i.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./errors-358575c3.cjs");function A(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 U(r){const i=A(r);return i.setHours(23,59,59,999),i}function L(){return U(Date.now())}function P(r){const i=A(r);return i.setHours(0,0,0,0),i}function k(){return P(Date.now())}const G=3e4;var F,S;class ${constructor(i){e(this,F,void 0);e(this,S,G);u(this,F,i)}buildHeaders(){const i={};return m(this,F).token&&(i.Authorization=`Bearer ${m(this,F).token}`),i}async request(i,t){const n=new URL(i,m(this,F).apiUrl??window.location.origin);return n.search=new URLSearchParams({...t}).toString(),await(await fetch(n,{signal:AbortSignal.timeout(m(this,S)),headers:this.buildHeaders()})).json()}async getRounds(i){return this.request("/rounds",i)}async getRound(i,t){return this.request(`/rounds/${i}`,t)}}F=new WeakMap,S=new WeakMap;const N={limit:100,page:0};var s,l;class I{constructor({config:i}){e(this,s,void 0);e(this,l,void 0);u(this,s,i),u(this,l,new $({apiUrl:i.api.gameHistoryUrl}))}async getRound(i,{pagination:t=N}={}){return m(this,l).getRound(i,{gameCode:m(this,s).api.game,operatorCode:m(this,s).api.brand,username:m(this,s).api.user,...t})}async getLastRound(){return m(this,s).api.lastRoundId?this.getRound(m(this,s).api.lastRoundId):null}async getRounds({searchPeriod:i={fromDateTime:k(),toDateTime:L()},pagination:t=N}={}){const n=m(this,s).api.user.replace(/^user_/,"").replace(new RegExp(`_${m(this,s).api.integration}$`),"");return m(this,l).getRounds({gameCode:m(this,s).api.game,operatorCode:m(this,s).api.integration,username:n,fromDataTime:i.fromDateTime.toISOString(),toDateTime:i.toDateTime.toISOString(),...t})}}s=new WeakMap,l=new WeakMap;function _(r,i){return r*i/100}function O(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 w="XTS";var y=(r=>(r.Currency="Currency",r.Number="Number",r))(y||{}),f=(r=>(r.Coins="Coins",r.Money="Money",r))(f||{});const T={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},"BK.":{maximumFractionDigits:2,minimumFractionDigits:2},"BT.":{maximumFractionDigits:2,minimumFractionDigits:2},"FC.":{maximumFractionDigits:2,minimumFractionDigits:2},"GC.":{maximumFractionDigits:2,minimumFractionDigits:2},"SC.":{maximumFractionDigits:2,minimumFractionDigits:2},GLD:{displayAs:"GC.",maximumFractionDigits:2,minimumFractionDigits:2},SS1:{displayAs:"SC.",maximumFractionDigits:2,minimumFractionDigits:2},SWEP:{displayAs:"SC.",maximumFractionDigits:2,minimumFractionDigits:2},GCLC:{displayAs:"GC.",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 M(r){return r in T}function j(r){return M(r)?{...T[r],currency:w}:{currency:r}}function q(r,i,t){const n=i.format(+r);return M(t)?n.replace(w,T[t].displayAs??t):n}function K(r,i,t){const{maximumFractionDigits:n,minimumFractionDigits:o}=t.resolvedOptions();return O(r,i,{maximumFractionDigits:n,minimumFractionDigits:o})}function V(r,i,{as:t}={as:"Currency"}){const{canShowCurrency:n,currency:o}=r;return t==="Number"||!n?`${i}`:`${i} ${o}`}function v(r,i,{as:t,from:n}={as:"Currency",from:"Money"},o){if(!["string","number"].includes(typeof i))return"NaN";const{canShowCurrency:a=!0,coinValueInCents:g,currency:x,locales:E}=r;n==="Coins"&&(i=_(+i,g));try{const H=j(x),R=new Intl.NumberFormat(E,{...H,...o,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!a?K(r,i,R):q(i,R,x)}catch{return V(r,i,{as:t})}}var c;class B{constructor({config:i}){e(this,c,void 0);u(this,c,i)}formatNumber(i,t){const n={locales:[m(this,c).ui.language]};return O(n,i,t)}formatCurrency(i,t={as:y.Currency,from:f.Money},n){const o=m(this,c).ui.feature.showCurrency,a=m(this,c).api.coinValueInCents,g=m(this,c).api.currency||w,x=[m(this,c).ui.language];return v({canShowCurrency:o,coinValueInCents:a,currency:g,locales:x},i,t,n)}formatCoins(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Coins},t)}formatCoinsWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Coins},t)}formatMoney(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Money},t)}formatMoneyWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Money},t)}}c=new WeakMap;const X=()=>{};var d,h,C,p;class z{constructor({messagePort:i}){e(this,d,void 0);e(this,h,void 0);e(this,C,void 0);e(this,p,void 0);u(this,p,i),this.on("configured",t=>{u(this,d,t),u(this,C,new B({config:t})),u(this,h,new I({config:t}))}),this.on("playResponse",t=>{this.config.api.lastRoundId=t.contract.roundId})}get config(){if(!m(this,d))throw new Error("config is not initialized, you must open game first");return m(this,d)}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,C))throw new Error("i18n is not initialized, you must open game first");return m(this,C)}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 a(g){g.data.message===`kalamba:wrapper:${i}`&&(X("on",g.data.message.replace(/^kalamba:/,""),g.data.payload),t(g.data.payload),n!=null&&n.once&&window.removeEventListener("message",a))};window.addEventListener("message",o)}send(i,...[t]){m(this,p).postMessage({message:`kalamba:sdk:${i}`,payload:t},"*")}configure(i){this.send("configure",i)}async openGame(){const i=new Promise(n=>this.on("configured",n,{once:!0})),t=await this.request("openGame");if(t.type==="response")return await i,t.response;throw t.error.type==="timeout"?new D.TimeoutError:new D.RgsError(t.error.data)}async play(i,t,n="SPIN"){const o={contract:i,extra:t,actionType:n},a=await this.request("play",o);if(a.type==="response")return a.response;throw a.error.type==="timeout"?new D.TimeoutError:new D.RgsError(a.error.data)}}d=new WeakMap,h=new WeakMap,C=new WeakMap,p=new WeakMap;exports.RgsError=D.RgsError;exports.RgsErrorCode=D.RgsErrorCode;exports.TimeoutError=D.TimeoutError;exports.History=I;exports.I18n=B;exports.KalambaSdk=z;
|
|
5
|
+
"use strict";var N=(m,i,t)=>{if(!i.has(m))throw TypeError("Cannot "+t)};var r=(m,i,t)=>(N(m,i,"read from private field"),t?t.call(m):i.get(m)),e=(m,i,t)=>{if(i.has(m))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(m):i.set(m,t)},u=(m,i,t,n)=>(N(m,i,"write to private field"),n?n.call(m,t):i.set(m,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./errors-db453887.cjs");function b(m){const i=Object.prototype.toString.call(m);return m instanceof Date||typeof m=="object"&&i==="[object Date]"?new m.constructor(+m):typeof m=="number"||i==="[object Number]"||typeof m=="string"||i==="[object String]"?new Date(m):new Date(NaN)}function H(m){const i=b(m);return i.setHours(23,59,59,999),i}function P(){return H(Date.now())}function U(m){const i=b(m);return i.setHours(0,0,0,0),i}function G(){return U(Date.now())}const k=3e4;var F,S;class ${constructor(i){e(this,F,void 0);e(this,S,k);u(this,F,i)}buildHeaders(){const i={};return r(this,F).token&&(i.Authorization=`Bearer ${r(this,F).token}`),i}async request(i,t){const n=new URL(i,r(this,F).apiUrl??window.location.origin);return n.search=new URLSearchParams({...t}).toString(),await(await fetch(n,{signal:AbortSignal.timeout(r(this,S)),headers:this.buildHeaders()})).json()}async getRounds(i){return this.request("/rounds",i)}async getRound(i,t){return this.request(`/rounds/${i}`,t)}}F=new WeakMap,S=new WeakMap;const A={limit:100,page:0};var o,l;class I{constructor({config:i}){e(this,o,void 0);e(this,l,void 0);u(this,o,i),u(this,l,new $({apiUrl:i.api.gameHistoryUrl}))}async getRound(i,{pagination:t=A}={}){return r(this,l).getRound(i,{gameCode:r(this,o).api.game,operatorCode:r(this,o).api.brand,username:r(this,o).api.user,...t})}async getLastRound(){return r(this,o).api.lastRoundId?this.getRound(r(this,o).api.lastRoundId):null}async getRounds({searchPeriod:i={fromDateTime:G(),toDateTime:P()},pagination:t=A}={}){const n=r(this,o).api.user.replace(/^user_/,"").replace(new RegExp(`_${r(this,o).api.integration}$`),"");return r(this,l).getRounds({gameCode:r(this,o).api.game,operatorCode:r(this,o).api.integration,username:n,fromDataTime:i.fromDateTime.toISOString(),toDateTime:i.toDateTime.toISOString(),...t})}}o=new WeakMap,l=new WeakMap;function K(m,i){return m*i/100}function O(m,i,t){if(!["string","number"].includes(typeof i))return"NaN";const{locales:n}=m;try{return new Intl.NumberFormat(n,{...t,numberingSystem:"latn",style:"decimal"}).format(+i)}catch{return`${i}`}}const w="XTS";var y=(m=>(m.Currency="Currency",m.Number="Number",m))(y||{}),f=(m=>(m.Coins="Coins",m.Money="Money",m))(f||{});const T={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},"BK.":{maximumFractionDigits:2,minimumFractionDigits:2},"BT.":{maximumFractionDigits:2,minimumFractionDigits:2},"FC.":{maximumFractionDigits:2,minimumFractionDigits:2},"GC.":{maximumFractionDigits:2,minimumFractionDigits:2},"SC.":{maximumFractionDigits:2,minimumFractionDigits:2},GC:{maximumFractionDigits:2,minimumFractionDigits:2},SC:{maximumFractionDigits:2,minimumFractionDigits:2},GLD:{displayAs:"GC.",maximumFractionDigits:2,minimumFractionDigits:2},SS1:{displayAs:"SC.",maximumFractionDigits:2,minimumFractionDigits:2},SWEP:{displayAs:"SC.",maximumFractionDigits:2,minimumFractionDigits:2},GCLC:{displayAs:"GC.",maximumFractionDigits:2,minimumFractionDigits:2},SWPC:{displayAs:"SC",maximumFractionDigits:2,minimumFractionDigits:2},LUKC:{displayAs:"LC",maximumFractionDigits:2,minimumFractionDigits:2},SVC:{maximumFractionDigits:2,minimumFractionDigits:2},DOT:{maximumFractionDigits:4,minimumFractionDigits:4},SOL:{maximumFractionDigits:4,minimumFractionDigits:4},XRP:{maximumFractionDigits:2,minimumFractionDigits:2},ADA:{maximumFractionDigits:2,minimumFractionDigits:2},TON:{maximumFractionDigits:4,minimumFractionDigits:4},FTN:{maximumFractionDigits:4,minimumFractionDigits:4},OMR:{maximumFractionDigits:2,minimumFractionDigits:2},JOD:{maximumFractionDigits:2,minimumFractionDigits:2},BHD:{maximumFractionDigits:2,minimumFractionDigits:2},KWD:{maximumFractionDigits:2,minimumFractionDigits:2},BNS:{maximumFractionDigits:2,minimumFractionDigits:2},MMK:{maximumFractionDigits:2,minimumFractionDigits:2},XOF:{maximumFractionDigits:2,minimumFractionDigits:2},VND:{maximumFractionDigits:2,minimumFractionDigits:2},BIF:{maximumFractionDigits:2,minimumFractionDigits:2},CLP:{maximumFractionDigits:2,minimumFractionDigits:2},GNF:{maximumFractionDigits:2,minimumFractionDigits:2},IQD:{maximumFractionDigits:2,minimumFractionDigits:2},ISK:{maximumFractionDigits:2,minimumFractionDigits:2},PYG:{maximumFractionDigits:2,minimumFractionDigits:2},XAF:{maximumFractionDigits:2,minimumFractionDigits:2},LAK:{maximumFractionDigits:2,minimumFractionDigits:2},LBP:{maximumFractionDigits:2,minimumFractionDigits:2},MGA:{maximumFractionDigits:2,minimumFractionDigits:2},SOS:{maximumFractionDigits:2,minimumFractionDigits:2},UGX:{maximumFractionDigits:2,minimumFractionDigits:2},ALL:{maximumFractionDigits:2,minimumFractionDigits:2},IRR:{maximumFractionDigits:2,minimumFractionDigits:2}};function M(m){return m in T}function _(m){return M(m)?{...T[m],currency:w}:{currency:m}}function X(m,i,t){const n=i.format(+m);return M(t)?n.replace(w,T[t].displayAs??t):n}function j(m,i,t){const{maximumFractionDigits:n,minimumFractionDigits:a}=t.resolvedOptions();return O(m,i,{maximumFractionDigits:n,minimumFractionDigits:a})}function q(m,i,{as:t}={as:"Currency"}){const{canShowCurrency:n,currency:a}=m;return t==="Number"||!n?`${i}`:`${i} ${a}`}function V(m,i,{as:t,from:n}={as:"Currency",from:"Money"},a){if(!["string","number"].includes(typeof i))return"NaN";const{canShowCurrency:s=!0,coinValueInCents:g,currency:p,locales:R}=m;n==="Coins"&&(i=K(+i,g));try{const L=_(p),E=new Intl.NumberFormat(R,{...L,...a,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!s?j(m,i,E):X(i,E,p)}catch{return q(m,i,{as:t})}}var c;class B{constructor({config:i}){e(this,c,void 0);u(this,c,i)}formatNumber(i,t){const n={locales:[r(this,c).ui.language]};return O(n,i,t)}formatCurrency(i,t={as:y.Currency,from:f.Money},n){const a=r(this,c).ui.feature.showCurrency,s=r(this,c).api.coinValueInCents,g=r(this,c).api.currency||w,p=[r(this,c).ui.language];return V({canShowCurrency:a,coinValueInCents:s,currency:g,locales:p},i,t,n)}formatCoins(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Coins},t)}formatCoinsWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Coins},t)}formatMoney(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Money},t)}formatMoneyWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Money},t)}}c=new WeakMap;const W=()=>{};var x,C,d,h;class v{constructor({messagePort:i}){e(this,x,void 0);e(this,C,void 0);e(this,d,void 0);e(this,h,void 0);u(this,h,i),this.on("configured",t=>{u(this,x,t),u(this,d,new B({config:t})),u(this,C,new I({config:t}))}),this.on("playResponse",t=>{this.config.api.lastRoundId=t.contract.roundId})}get config(){if(!r(this,x))throw new Error("config is not initialized, you must open game first");return r(this,x)}get history(){if(!r(this,C))throw new Error("config is not initialized, you must open game first");return r(this,C)}get i18n(){if(!r(this,d))throw new Error("i18n is not initialized, you must open game first");return r(this,d)}request(i,...[t]){return new Promise(n=>{this.on(`${i}Response`,a=>n({type:"response",response:a}),{once:!0}),this.on(`${i}Error`,a=>n({type:"error",error:a}),{once:!0}),this.send(i,t)})}on(i,t,n){const a=function s(g){g.data.message===`kalamba:wrapper:${i}`&&(W("on",g.data.message.replace(/^kalamba:/,""),g.data.payload),t(g.data.payload),n!=null&&n.once&&window.removeEventListener("message",s))};window.addEventListener("message",a)}send(i,...[t]){r(this,h).postMessage({message:`kalamba:sdk:${i}`,payload:t},"*")}configure(i){this.send("configure",i)}async openGame(){const i=new Promise(n=>this.on("configured",n,{once:!0})),t=await this.request("openGame");if(t.type==="response")return await i,t.response;throw t.error.type==="timeout"?new D.TimeoutError:new D.RgsError(t.error.data)}async play(i,t,n="SPIN"){const a={contract:i,extra:t,actionType:n},s=await this.request("play",a);if(s.type==="response")return s.response;throw s.error.type==="timeout"?new D.TimeoutError:new D.RgsError(s.error.data)}}x=new WeakMap,C=new WeakMap,d=new WeakMap,h=new WeakMap;exports.RgsError=D.RgsError;exports.RgsErrorCode=D.RgsErrorCode;exports.TimeoutError=D.TimeoutError;exports.History=I;exports.I18n=B;exports.KalambaSdk=v;
|
package/dist/index.d.ts
CHANGED
|
@@ -399,6 +399,7 @@ export declare interface SdkConfig {
|
|
|
399
399
|
playMode: 'FUN' | 'REAL';
|
|
400
400
|
user: string;
|
|
401
401
|
sessionId: string;
|
|
402
|
+
backendSessionId?: string;
|
|
402
403
|
lastRoundId?: string;
|
|
403
404
|
};
|
|
404
405
|
ui: {
|
|
@@ -414,6 +415,7 @@ export declare interface SdkConfig {
|
|
|
414
415
|
feature: {
|
|
415
416
|
allowTelemetry: boolean;
|
|
416
417
|
allowFullscreen: boolean;
|
|
418
|
+
allowGamble: boolean;
|
|
417
419
|
allowQuickStop: boolean;
|
|
418
420
|
showCashier: boolean;
|
|
419
421
|
showClock: boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BSD 3-Clause License
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2025, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
var N = (
|
|
6
|
-
if (!i.has(
|
|
5
|
+
var N = (m, i, t) => {
|
|
6
|
+
if (!i.has(m))
|
|
7
7
|
throw TypeError("Cannot " + t);
|
|
8
8
|
};
|
|
9
|
-
var
|
|
10
|
-
if (i.has(
|
|
9
|
+
var r = (m, i, t) => (N(m, i, "read from private field"), t ? t.call(m) : i.get(m)), e = (m, i, t) => {
|
|
10
|
+
if (i.has(m))
|
|
11
11
|
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
i instanceof WeakSet ? i.add(
|
|
13
|
-
}, u = (
|
|
14
|
-
import { T as
|
|
15
|
-
import { a as ii } from "./errors-
|
|
16
|
-
function I(
|
|
17
|
-
const i = Object.prototype.toString.call(
|
|
18
|
-
return
|
|
12
|
+
i instanceof WeakSet ? i.add(m) : i.set(m, t);
|
|
13
|
+
}, u = (m, i, t, n) => (N(m, i, "write to private field"), n ? n.call(m, t) : i.set(m, t), t);
|
|
14
|
+
import { T as A, R as b } from "./errors-7cbbda8a.js";
|
|
15
|
+
import { a as ii } from "./errors-7cbbda8a.js";
|
|
16
|
+
function I(m) {
|
|
17
|
+
const i = Object.prototype.toString.call(m);
|
|
18
|
+
return m instanceof Date || typeof m == "object" && i === "[object Date]" ? new m.constructor(+m) : typeof m == "number" || i === "[object Number]" || typeof m == "string" || i === "[object String]" ? new Date(m) : /* @__PURE__ */ new Date(NaN);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const i = I(
|
|
20
|
+
function M(m) {
|
|
21
|
+
const i = I(m);
|
|
22
22
|
return i.setHours(23, 59, 59, 999), i;
|
|
23
23
|
}
|
|
24
24
|
function U() {
|
|
25
|
-
return
|
|
25
|
+
return M(Date.now());
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const i = I(
|
|
27
|
+
function G(m) {
|
|
28
|
+
const i = I(m);
|
|
29
29
|
return i.setHours(0, 0, 0, 0), i;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
31
|
+
function H() {
|
|
32
|
+
return G(Date.now());
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
var D,
|
|
36
|
-
class
|
|
34
|
+
const P = 3e4;
|
|
35
|
+
var D, h;
|
|
36
|
+
class k {
|
|
37
37
|
constructor(i) {
|
|
38
38
|
e(this, D, void 0);
|
|
39
|
-
e(this,
|
|
39
|
+
e(this, h, P);
|
|
40
40
|
u(this, D, i);
|
|
41
41
|
}
|
|
42
42
|
buildHeaders() {
|
|
43
43
|
const i = {};
|
|
44
|
-
return
|
|
44
|
+
return r(this, D).token && (i.Authorization = `Bearer ${r(this, D).token}`), i;
|
|
45
45
|
}
|
|
46
46
|
async request(i, t) {
|
|
47
|
-
const
|
|
48
|
-
return
|
|
47
|
+
const n = new URL(i, r(this, D).apiUrl ?? window.location.origin);
|
|
48
|
+
return n.search = new URLSearchParams({
|
|
49
49
|
...t
|
|
50
|
-
}).toString(), await (await fetch(
|
|
51
|
-
signal: AbortSignal.timeout(
|
|
50
|
+
}).toString(), await (await fetch(n, {
|
|
51
|
+
signal: AbortSignal.timeout(r(this, h)),
|
|
52
52
|
headers: this.buildHeaders()
|
|
53
53
|
})).json();
|
|
54
54
|
}
|
|
@@ -59,8 +59,8 @@ class G {
|
|
|
59
59
|
return this.request(`/rounds/${i}`, t);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
D = new WeakMap(),
|
|
63
|
-
const
|
|
62
|
+
D = new WeakMap(), h = new WeakMap();
|
|
63
|
+
const E = {
|
|
64
64
|
limit: 100,
|
|
65
65
|
page: 0
|
|
66
66
|
};
|
|
@@ -71,35 +71,35 @@ class $ {
|
|
|
71
71
|
}) {
|
|
72
72
|
e(this, s, void 0);
|
|
73
73
|
e(this, f, void 0);
|
|
74
|
-
u(this, s, i), u(this, f, new
|
|
74
|
+
u(this, s, i), u(this, f, new k({
|
|
75
75
|
apiUrl: i.api.gameHistoryUrl
|
|
76
76
|
}));
|
|
77
77
|
}
|
|
78
78
|
async getRound(i, {
|
|
79
|
-
pagination: t =
|
|
79
|
+
pagination: t = E
|
|
80
80
|
} = {}) {
|
|
81
|
-
return
|
|
82
|
-
gameCode:
|
|
83
|
-
operatorCode:
|
|
84
|
-
username:
|
|
81
|
+
return r(this, f).getRound(i, {
|
|
82
|
+
gameCode: r(this, s).api.game,
|
|
83
|
+
operatorCode: r(this, s).api.brand,
|
|
84
|
+
username: r(this, s).api.user,
|
|
85
85
|
...t
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
async getLastRound() {
|
|
89
|
-
return
|
|
89
|
+
return r(this, s).api.lastRoundId ? this.getRound(r(this, s).api.lastRoundId) : null;
|
|
90
90
|
}
|
|
91
91
|
async getRounds({
|
|
92
92
|
searchPeriod: i = {
|
|
93
|
-
fromDateTime:
|
|
93
|
+
fromDateTime: H(),
|
|
94
94
|
toDateTime: U()
|
|
95
95
|
},
|
|
96
|
-
pagination: t =
|
|
96
|
+
pagination: t = E
|
|
97
97
|
} = {}) {
|
|
98
|
-
const
|
|
99
|
-
return
|
|
100
|
-
gameCode:
|
|
101
|
-
operatorCode:
|
|
102
|
-
username:
|
|
98
|
+
const n = r(this, s).api.user.replace(/^user_/, "").replace(new RegExp(`_${r(this, s).api.integration}$`), "");
|
|
99
|
+
return r(this, f).getRounds({
|
|
100
|
+
gameCode: r(this, s).api.game,
|
|
101
|
+
operatorCode: r(this, s).api.integration,
|
|
102
|
+
username: n,
|
|
103
103
|
fromDataTime: i.fromDateTime.toISOString(),
|
|
104
104
|
toDateTime: i.toDateTime.toISOString(),
|
|
105
105
|
...t
|
|
@@ -107,15 +107,15 @@ class $ {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
s = new WeakMap(), f = new WeakMap();
|
|
110
|
-
function
|
|
111
|
-
return
|
|
110
|
+
function K(m, i) {
|
|
111
|
+
return m * i / 100;
|
|
112
112
|
}
|
|
113
|
-
function O(
|
|
113
|
+
function O(m, i, t) {
|
|
114
114
|
if (!["string", "number"].includes(typeof i))
|
|
115
115
|
return "NaN";
|
|
116
|
-
const { locales:
|
|
116
|
+
const { locales: n } = m;
|
|
117
117
|
try {
|
|
118
|
-
return new Intl.NumberFormat(
|
|
118
|
+
return new Intl.NumberFormat(n, {
|
|
119
119
|
...t,
|
|
120
120
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
121
121
|
// @ts-ignore
|
|
@@ -127,7 +127,7 @@ function O(n, i, t) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
const S = "XTS";
|
|
130
|
-
var F = /* @__PURE__ */ ((
|
|
130
|
+
var F = /* @__PURE__ */ ((m) => (m.Currency = "Currency", m.Number = "Number", m))(F || {}), y = /* @__PURE__ */ ((m) => (m.Coins = "Coins", m.Money = "Money", m))(y || {});
|
|
131
131
|
const w = {
|
|
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
|
|
@@ -208,11 +208,15 @@ const w = {
|
|
|
208
208
|
"FC.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
209
209
|
"GC.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
210
210
|
"SC.": { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
211
|
+
GC: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
212
|
+
SC: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
211
213
|
GLD: { displayAs: "GC.", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
212
214
|
SS1: { displayAs: "SC.", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
213
215
|
// Softswiss
|
|
214
216
|
SWEP: { displayAs: "SC.", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
215
217
|
GCLC: { displayAs: "GC.", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
218
|
+
SWPC: { displayAs: "SC", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
219
|
+
LUKC: { displayAs: "LC", maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
216
220
|
// Silvercash
|
|
217
221
|
SVC: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
218
222
|
// Polkadot
|
|
@@ -220,83 +224,128 @@ const w = {
|
|
|
220
224
|
// Solana
|
|
221
225
|
SOL: { maximumFractionDigits: 4, minimumFractionDigits: 4 },
|
|
222
226
|
// XRP
|
|
223
|
-
XRP: { maximumFractionDigits:
|
|
227
|
+
XRP: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
224
228
|
// Cardano
|
|
225
|
-
ADA: { maximumFractionDigits:
|
|
229
|
+
ADA: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
226
230
|
// Toncoin
|
|
227
231
|
TON: { maximumFractionDigits: 4, minimumFractionDigits: 4 },
|
|
228
232
|
// Fasttoken
|
|
229
|
-
FTN: { maximumFractionDigits: 4, minimumFractionDigits: 4 }
|
|
233
|
+
FTN: { maximumFractionDigits: 4, minimumFractionDigits: 4 },
|
|
234
|
+
// Omani Rial
|
|
235
|
+
OMR: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
236
|
+
// Jordanian Dinar
|
|
237
|
+
JOD: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
238
|
+
// Bahraini Dinar
|
|
239
|
+
BHD: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
240
|
+
// Kuwaiti Dinar
|
|
241
|
+
KWD: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
242
|
+
// MicroGame
|
|
243
|
+
BNS: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
244
|
+
// https://kalamba.atlassian.net/browse/FRAM-1829
|
|
245
|
+
// Myanmar Kyat
|
|
246
|
+
MMK: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
247
|
+
// West African CFA franc
|
|
248
|
+
XOF: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
249
|
+
// Vietnamese dong
|
|
250
|
+
VND: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
251
|
+
// Burundian franc
|
|
252
|
+
BIF: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
253
|
+
// Chilean peso
|
|
254
|
+
CLP: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
255
|
+
// Guinean franc
|
|
256
|
+
GNF: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
257
|
+
// Iraqi dinar
|
|
258
|
+
IQD: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
259
|
+
// Icelandic króna
|
|
260
|
+
ISK: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
261
|
+
// Paraguayan guaraní
|
|
262
|
+
PYG: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
263
|
+
// Central African CFA franc
|
|
264
|
+
XAF: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
265
|
+
// Lao kip
|
|
266
|
+
LAK: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
267
|
+
// Lebanese pound
|
|
268
|
+
LBP: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
269
|
+
// Malagasy ariary
|
|
270
|
+
MGA: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
271
|
+
// Somali shilling
|
|
272
|
+
SOS: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
273
|
+
// Ugandan shilling
|
|
274
|
+
UGX: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
275
|
+
// Albanian lek
|
|
276
|
+
ALL: { maximumFractionDigits: 2, minimumFractionDigits: 2 },
|
|
277
|
+
// Iranian rial
|
|
278
|
+
IRR: { maximumFractionDigits: 2, minimumFractionDigits: 2 }
|
|
230
279
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
231
280
|
};
|
|
232
|
-
function B(
|
|
233
|
-
return
|
|
281
|
+
function B(m) {
|
|
282
|
+
return m in w;
|
|
234
283
|
}
|
|
235
|
-
function
|
|
236
|
-
return B(
|
|
237
|
-
...w[
|
|
284
|
+
function _(m) {
|
|
285
|
+
return B(m) ? {
|
|
286
|
+
...w[m],
|
|
238
287
|
currency: S
|
|
239
288
|
} : {
|
|
240
|
-
currency:
|
|
289
|
+
currency: m
|
|
241
290
|
};
|
|
242
291
|
}
|
|
243
|
-
function
|
|
244
|
-
const
|
|
245
|
-
return B(t) ?
|
|
292
|
+
function X(m, i, t) {
|
|
293
|
+
const n = i.format(+m);
|
|
294
|
+
return B(t) ? n.replace(S, w[t].displayAs ?? t) : n;
|
|
246
295
|
}
|
|
247
|
-
function V(
|
|
248
|
-
const { maximumFractionDigits:
|
|
249
|
-
return O(
|
|
296
|
+
function V(m, i, t) {
|
|
297
|
+
const { maximumFractionDigits: n, minimumFractionDigits: a } = t.resolvedOptions();
|
|
298
|
+
return O(m, i, { maximumFractionDigits: n, minimumFractionDigits: a });
|
|
250
299
|
}
|
|
251
|
-
function
|
|
300
|
+
function j(m, i, { as: t } = {
|
|
252
301
|
as: "Currency"
|
|
253
302
|
/* Currency */
|
|
254
303
|
}) {
|
|
255
|
-
const { canShowCurrency:
|
|
256
|
-
return t === "Number" || !
|
|
304
|
+
const { canShowCurrency: n, currency: a } = m;
|
|
305
|
+
return t === "Number" || !n ? `${i}` : `${i} ${a}`;
|
|
257
306
|
}
|
|
258
|
-
function
|
|
307
|
+
function q(m, i, { as: t, from: n } = {
|
|
259
308
|
as: "Currency",
|
|
260
309
|
from: "Money"
|
|
261
310
|
/* Money */
|
|
262
|
-
},
|
|
311
|
+
}, a) {
|
|
263
312
|
if (!["string", "number"].includes(typeof i))
|
|
264
313
|
return "NaN";
|
|
265
|
-
const { canShowCurrency:
|
|
266
|
-
|
|
314
|
+
const { canShowCurrency: o = !0, coinValueInCents: g, currency: d, locales: T } = m;
|
|
315
|
+
n === "Coins" && (i = K(+i, g));
|
|
267
316
|
try {
|
|
268
|
-
const
|
|
269
|
-
...
|
|
270
|
-
...
|
|
317
|
+
const L = _(d), R = new Intl.NumberFormat(T, {
|
|
318
|
+
...L,
|
|
319
|
+
...a,
|
|
271
320
|
currencyDisplay: "symbol",
|
|
272
321
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
273
322
|
// @ts-ignore
|
|
274
323
|
numberingSystem: "latn",
|
|
275
324
|
style: "currency"
|
|
276
325
|
});
|
|
277
|
-
return t === "Number" || !
|
|
326
|
+
return t === "Number" || !o ? V(m, i, R) : X(i, R, d);
|
|
278
327
|
} catch {
|
|
279
|
-
return
|
|
328
|
+
return j(m, i, { as: t });
|
|
280
329
|
}
|
|
281
330
|
}
|
|
282
331
|
var c;
|
|
283
|
-
class
|
|
332
|
+
class W {
|
|
284
333
|
constructor({ config: i }) {
|
|
285
334
|
e(this, c, void 0);
|
|
286
335
|
u(this, c, i);
|
|
287
336
|
}
|
|
288
337
|
formatNumber(i, t) {
|
|
289
|
-
const
|
|
290
|
-
return O(
|
|
338
|
+
const n = { locales: [r(this, c).ui.language] };
|
|
339
|
+
return O(n, i, t);
|
|
291
340
|
}
|
|
292
|
-
formatCurrency(i, t = { as: F.Currency, from: y.Money },
|
|
293
|
-
const
|
|
294
|
-
return
|
|
295
|
-
canShowCurrency:
|
|
296
|
-
coinValueInCents:
|
|
341
|
+
formatCurrency(i, t = { as: F.Currency, from: y.Money }, n) {
|
|
342
|
+
const a = r(this, c).ui.feature.showCurrency, o = r(this, c).api.coinValueInCents, g = r(this, c).api.currency || S, d = [r(this, c).ui.language];
|
|
343
|
+
return q({
|
|
344
|
+
canShowCurrency: a,
|
|
345
|
+
coinValueInCents: o,
|
|
297
346
|
currency: g,
|
|
298
|
-
locales:
|
|
299
|
-
}, i, t,
|
|
347
|
+
locales: d
|
|
348
|
+
}, i, t, n);
|
|
300
349
|
}
|
|
301
350
|
formatCoins(i, t) {
|
|
302
351
|
return this.formatCurrency(i, { as: F.Number, from: y.Coins }, t);
|
|
@@ -312,52 +361,52 @@ class v {
|
|
|
312
361
|
}
|
|
313
362
|
}
|
|
314
363
|
c = new WeakMap();
|
|
315
|
-
const
|
|
364
|
+
const v = () => {
|
|
316
365
|
};
|
|
317
|
-
var l,
|
|
366
|
+
var x, l, C, p;
|
|
318
367
|
class Y {
|
|
319
368
|
constructor({ messagePort: i }) {
|
|
369
|
+
e(this, x, void 0);
|
|
320
370
|
e(this, l, void 0);
|
|
321
|
-
e(this,
|
|
371
|
+
e(this, C, void 0);
|
|
322
372
|
e(this, p, void 0);
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
u(this, l, t), u(this, p, new v({ config: t })), u(this, h, new $({ config: t }));
|
|
373
|
+
u(this, p, i), this.on("configured", (t) => {
|
|
374
|
+
u(this, x, t), u(this, C, new W({ config: t })), u(this, l, new $({ config: t }));
|
|
326
375
|
}), this.on("playResponse", (t) => {
|
|
327
376
|
this.config.api.lastRoundId = t.contract.roundId;
|
|
328
377
|
});
|
|
329
378
|
}
|
|
330
379
|
get config() {
|
|
331
|
-
if (!
|
|
380
|
+
if (!r(this, x))
|
|
332
381
|
throw new Error("config is not initialized, you must open game first");
|
|
333
|
-
return
|
|
382
|
+
return r(this, x);
|
|
334
383
|
}
|
|
335
384
|
get history() {
|
|
336
|
-
if (!
|
|
385
|
+
if (!r(this, l))
|
|
337
386
|
throw new Error("config is not initialized, you must open game first");
|
|
338
|
-
return
|
|
387
|
+
return r(this, l);
|
|
339
388
|
}
|
|
340
389
|
get i18n() {
|
|
341
|
-
if (!
|
|
390
|
+
if (!r(this, C))
|
|
342
391
|
throw new Error("i18n is not initialized, you must open game first");
|
|
343
|
-
return
|
|
392
|
+
return r(this, C);
|
|
344
393
|
}
|
|
345
394
|
request(i, ...[t]) {
|
|
346
|
-
return new Promise((
|
|
347
|
-
this.on(`${i}Response`, (
|
|
395
|
+
return new Promise((n) => {
|
|
396
|
+
this.on(`${i}Response`, (a) => n({ type: "response", response: a }), {
|
|
348
397
|
once: !0
|
|
349
|
-
}), this.on(`${i}Error`, (
|
|
398
|
+
}), this.on(`${i}Error`, (a) => n({ type: "error", error: a }), { once: !0 }), this.send(i, t);
|
|
350
399
|
});
|
|
351
400
|
}
|
|
352
|
-
on(i, t,
|
|
353
|
-
const
|
|
354
|
-
g.data.message === `kalamba:wrapper:${i}` && (
|
|
401
|
+
on(i, t, n) {
|
|
402
|
+
const a = function o(g) {
|
|
403
|
+
g.data.message === `kalamba:wrapper:${i}` && (v("on", g.data.message.replace(/^kalamba:/, ""), g.data.payload), t(g.data.payload), n != null && n.once && window.removeEventListener("message", o));
|
|
355
404
|
};
|
|
356
|
-
window.addEventListener("message",
|
|
405
|
+
window.addEventListener("message", a);
|
|
357
406
|
}
|
|
358
407
|
// TODO error messages
|
|
359
408
|
send(i, ...[t]) {
|
|
360
|
-
|
|
409
|
+
r(this, p).postMessage(
|
|
361
410
|
{
|
|
362
411
|
message: `kalamba:sdk:${i}`,
|
|
363
412
|
payload: t
|
|
@@ -369,24 +418,24 @@ class Y {
|
|
|
369
418
|
this.send("configure", i);
|
|
370
419
|
}
|
|
371
420
|
async openGame() {
|
|
372
|
-
const i = new Promise((
|
|
421
|
+
const i = new Promise((n) => this.on("configured", n, { once: !0 })), t = await this.request("openGame");
|
|
373
422
|
if (t.type === "response")
|
|
374
423
|
return await i, t.response;
|
|
375
|
-
throw t.error.type === "timeout" ? new
|
|
424
|
+
throw t.error.type === "timeout" ? new A() : new b(t.error.data);
|
|
376
425
|
}
|
|
377
|
-
async play(i, t,
|
|
378
|
-
const
|
|
379
|
-
if (
|
|
380
|
-
return
|
|
381
|
-
throw
|
|
426
|
+
async play(i, t, n = "SPIN") {
|
|
427
|
+
const a = { contract: i, extra: t, actionType: n }, o = await this.request("play", a);
|
|
428
|
+
if (o.type === "response")
|
|
429
|
+
return o.response;
|
|
430
|
+
throw o.error.type === "timeout" ? new A() : new b(o.error.data);
|
|
382
431
|
}
|
|
383
432
|
}
|
|
384
|
-
|
|
433
|
+
x = new WeakMap(), l = new WeakMap(), C = new WeakMap(), p = new WeakMap();
|
|
385
434
|
export {
|
|
386
435
|
$ as History,
|
|
387
|
-
|
|
436
|
+
W as I18n,
|
|
388
437
|
Y as KalambaSdk,
|
|
389
|
-
|
|
438
|
+
b as RgsError,
|
|
390
439
|
ii as RgsErrorCode,
|
|
391
|
-
|
|
440
|
+
A as TimeoutError
|
|
392
441
|
};
|