@kalamba/sdk 0.7.0 → 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-c5948a4a.cjs → errors-358575c3.cjs} +1 -1
- package/dist/{errors-867a013a.js → errors-afd9f527.js} +44 -11
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +24 -19
- package/dist/index.js +18 -15
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.ts +34 -27
- package/dist/plugins.js +408 -409
- package/dist/wrapper.cjs +1 -1
- package/dist/wrapper.d.ts +38 -29
- package/dist/wrapper.js +669 -629
- package/package.json +1 -1
|
@@ -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 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:"CLOSE",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;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* BSD 3-Clause License
|
|
3
3
|
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
5
|
+
var N = Object.defineProperty;
|
|
6
|
+
var S = (_, E, O) => E in _ ? N(_, E, { enumerable: !0, configurable: !0, writable: !0, value: O }) : _[E] = O;
|
|
7
|
+
var R = (_, 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",
|
|
@@ -37,21 +37,54 @@ const I = {
|
|
|
37
37
|
MISSING_GAME_STATE: "MISSING_GAME_STATE",
|
|
38
38
|
DATA_ACCESS_ERROR: "DATA_ACCESS_ERROR",
|
|
39
39
|
UNKNOWN: "UNKNOWN"
|
|
40
|
+
}, C = {
|
|
41
|
+
CONNECTION_ERROR: "RELOAD",
|
|
42
|
+
INVALID_BET_CURRENCY: "CLOSE",
|
|
43
|
+
INVALID_BET: "CONTINUE",
|
|
44
|
+
INVALID_CAGE_CODE: "CLOSE",
|
|
45
|
+
INVALID_CLIENT_TYPE: "CLOSE",
|
|
46
|
+
INVALID_MESSAGE_FORMAT: "CLOSE",
|
|
47
|
+
INVALID_SESSION: "CLOSE",
|
|
48
|
+
TOO_HIGH_BET_FREQUENCY: "CONTINUE",
|
|
49
|
+
TOO_HIGH_ACTION_FREQUENCY: "CONTINUE",
|
|
50
|
+
USER_LOCK_INVALID_PARAMS: "CLOSE",
|
|
51
|
+
USER_ALREADY_LOCKED: "CLOSE",
|
|
52
|
+
GAME_SERVER_ERROR: "RELOAD",
|
|
53
|
+
SESSION_MANAGEMENT_ERROR: "RELOAD",
|
|
54
|
+
MESSAGE_SENDER_ERROR: "RELOAD",
|
|
55
|
+
FREE_ROUNDS_PROCESSING_ERROR: "RELOAD",
|
|
56
|
+
WEB_SESSION_NOT_OPEN: "RELOAD",
|
|
57
|
+
GAMING_LIMITS_REACHED: "CLOSE",
|
|
58
|
+
OUT_OF_MONEY: "CLOSE",
|
|
59
|
+
UNFINISHED_ROUND_IN_PROGRESS: "CLOSE",
|
|
60
|
+
ACCESS_DENIED: "CLOSE",
|
|
61
|
+
CREDENTIALS_NOT_FOUND: "CLOSE",
|
|
62
|
+
ALREADY_LOGGED_IN: "CLOSE",
|
|
63
|
+
GAME_UNAVAILABLE: "CLOSE",
|
|
64
|
+
BONUS_RESTRICTION: "CLOSE",
|
|
65
|
+
TOO_MANY_OPEN_GAMES: "CLOSE",
|
|
66
|
+
GAME_FROZEN: "CLOSE",
|
|
67
|
+
WALLET_PROCESSING_ERROR: "CLOSE",
|
|
68
|
+
FORCED_OUTCOMES_NOT_ALLOWED: "CONTINUE",
|
|
69
|
+
MISSING_GAME_STATE: "RELOAD",
|
|
70
|
+
DATA_ACCESS_ERROR: "RELOAD",
|
|
71
|
+
UNKNOWN: "CLOSE"
|
|
40
72
|
};
|
|
41
|
-
class
|
|
42
|
-
constructor(
|
|
73
|
+
class L extends Error {
|
|
74
|
+
constructor(O) {
|
|
43
75
|
super();
|
|
44
|
-
|
|
45
|
-
this.name = "RgsError", this.data =
|
|
76
|
+
R(this, "data");
|
|
77
|
+
this.name = "RgsError", this.data = O;
|
|
46
78
|
}
|
|
47
79
|
}
|
|
48
|
-
class
|
|
80
|
+
class T extends Error {
|
|
49
81
|
constructor() {
|
|
50
82
|
super(), this.name = "TimeoutError";
|
|
51
83
|
}
|
|
52
84
|
}
|
|
53
85
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
I as a
|
|
86
|
+
L as R,
|
|
87
|
+
T,
|
|
88
|
+
I as a,
|
|
89
|
+
C as b
|
|
57
90
|
};
|
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 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)),a=(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-
|
|
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)),a=(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 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 B(r){const i=I(r);return i.setHours(23,59,59,999),i}function k(){return B(Date.now())}function P(r){const i=I(r);return i.setHours(0,0,0,0),i}function L(){return P(Date.now())}const $=3e4;var F,S;class _{constructor(i){a(this,F,void 0);a(this,S,$);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 O{constructor({config:i}){a(this,s,void 0);a(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:L(),toDateTime:k()},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 G(r,i){return r*i/100}function A(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},"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 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 V(r,i,t){const{maximumFractionDigits:n,minimumFractionDigits:o}=t.resolvedOptions();return A(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 K(r,i,{as:t,from:n}={as:"Currency",from:"Money"},o){if(!["string","number"].includes(typeof i))return"NaN";const{canShowCurrency:e=!0,coinValueInCents:g,currency:x,locales:R}=r;n==="Coins"&&(i=G(+i,g));try{const U=j(x),E=new Intl.NumberFormat(R,{...U,...o,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!e?V(r,i,E):q(i,E,x)}catch{return v(r,i,{as:t})}}var c;class H{constructor({config:i}){a(this,c,void 0);u(this,c,i)}formatNumber(i,t){const n={locales:[m(this,c).ui.language]};return A(n,i,t)}formatCurrency(i,t={as:y.Currency,from:f.Money},n){const o=m(this,c).ui.feature.showCurrency,e=m(this,c).api.coinValueInCents,g=m(this,c).api.currency||w,x=[m(this,c).ui.language];return K({canShowCurrency:o,coinValueInCents:e,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 h,d,p,C;class z{constructor({messagePort:i}){a(this,h,void 0);a(this,d,void 0);a(this,p,void 0);a(this,C,void 0);u(this,C,i),this.on("configured",t=>{u(this,h,t),u(this,p,new H({config:t})),u(this,d,new O({config:t}))}),this.on("playResponse",t=>{this.config.api.lastRoundId=t.contract.roundId})}get config(){if(!m(this,h))throw new Error("config is not initialized, you must open game first");return m(this,h)}get history(){if(!m(this,d))throw new Error("config is not initialized, you must open game first");return m(this,d)}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 e(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",e))};window.addEventListener("message",o)}send(i,...[t]){m(this,C).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},e=await this.request("play",o);if(e.type==="response")return e.response;throw e.error.type==="timeout"?new D.TimeoutError:new D.RgsError(e.error.data)}}h=new WeakMap,d=new WeakMap,p=new WeakMap,C=new WeakMap;exports.RgsError=D.RgsError;exports.RgsErrorCode=D.RgsErrorCode;exports.TimeoutError=D.TimeoutError;exports.History=O;exports.I18n=H;exports.KalambaSdk=z;
|
package/dist/index.d.ts
CHANGED
|
@@ -147,7 +147,8 @@ export declare class KalambaSdk {
|
|
|
147
147
|
protected request<M extends DomainMessage<'sdk'>>(message: M, ...[payload]: DomainMessagePayload<'sdk', M> extends never ? [] : [payload: DomainMessagePayload<'sdk', M>]): Promise<RgsResponse<M>>;
|
|
148
148
|
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;
|
|
149
149
|
send<M extends DomainMessage<'sdk'>>(message: M, ...[payload]: DomainMessagePayload<'sdk', M> extends never ? [] : [DomainMessagePayload<'sdk', M>]): void;
|
|
150
|
-
|
|
150
|
+
configure(payload: DomainMessagePayload<'sdk', 'configure'>): void;
|
|
151
|
+
openGame(): Promise<OpenGameResponse>;
|
|
151
152
|
play(contract: ContractPlayPayload, extra?: unknown, actionType?: string): Promise<PlayResponse>;
|
|
152
153
|
}
|
|
153
154
|
|
|
@@ -162,12 +163,6 @@ export declare type MessageMessageEvent<M extends Message> = MessageEvent<{
|
|
|
162
163
|
|
|
163
164
|
export declare type MessagePayload<M extends Message> = MessageMap[M];
|
|
164
165
|
|
|
165
|
-
export declare type OpenGameRequest = {
|
|
166
|
-
gameName: string;
|
|
167
|
-
/** version of game client */
|
|
168
|
-
version: string;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
166
|
export declare type OpenGameResponse = {
|
|
172
167
|
contract: {
|
|
173
168
|
bet: {
|
|
@@ -284,13 +279,6 @@ export declare class RgsError extends Error {
|
|
|
284
279
|
constructor(data: RgsErrorData);
|
|
285
280
|
}
|
|
286
281
|
|
|
287
|
-
declare type RgsError_2 = {
|
|
288
|
-
type: 'timeout';
|
|
289
|
-
} | {
|
|
290
|
-
type: 'error';
|
|
291
|
-
data: RgsErrorData;
|
|
292
|
-
};
|
|
293
|
-
|
|
294
282
|
export declare const RgsErrorCode: {
|
|
295
283
|
readonly CONNECTION_ERROR: "CONNECTION_ERROR";
|
|
296
284
|
readonly INVALID_BET_CURRENCY: "INVALID_BET_CURRENCY";
|
|
@@ -330,10 +318,17 @@ export declare type RgsErrorData = {
|
|
|
330
318
|
details?: unknown;
|
|
331
319
|
};
|
|
332
320
|
|
|
321
|
+
export declare type RgsErrorWithType = {
|
|
322
|
+
type: 'timeout';
|
|
323
|
+
} | {
|
|
324
|
+
type: 'error';
|
|
325
|
+
data: RgsErrorData;
|
|
326
|
+
};
|
|
327
|
+
|
|
333
328
|
export declare type RgsOnlyMessagePayloadMap = {
|
|
334
|
-
openGameError:
|
|
329
|
+
openGameError: RgsErrorWithType;
|
|
335
330
|
openGameResponse: OpenGameResponse;
|
|
336
|
-
playError:
|
|
331
|
+
playError: RgsErrorWithType;
|
|
337
332
|
playResponse: PlayResponse;
|
|
338
333
|
realityCheck: {
|
|
339
334
|
duration: number;
|
|
@@ -423,6 +418,7 @@ export declare type SdkError = {
|
|
|
423
418
|
});
|
|
424
419
|
|
|
425
420
|
export declare type SdkOnlyMessagePayloadMap = {
|
|
421
|
+
configure: Partial<WrapperConfig>;
|
|
426
422
|
autoplay: {
|
|
427
423
|
action: 'start' | 'stop' | 'pause' | 'resume';
|
|
428
424
|
};
|
|
@@ -449,7 +445,7 @@ export declare type SdkOnlyMessagePayloadMap = {
|
|
|
449
445
|
progress: number;
|
|
450
446
|
};
|
|
451
447
|
loadStart: never;
|
|
452
|
-
openGame:
|
|
448
|
+
openGame: never;
|
|
453
449
|
play: PlayRequest;
|
|
454
450
|
playCycleEnd: PlayResponse;
|
|
455
451
|
playCycleStart: ContractPlayPayload;
|
|
@@ -525,10 +521,21 @@ export declare type ToTelemetryPluginsForwardedMessageMap = {
|
|
|
525
521
|
wrapper: undefined;
|
|
526
522
|
};
|
|
527
523
|
|
|
524
|
+
export declare type WrapperConfig = {
|
|
525
|
+
gameName: string;
|
|
526
|
+
gameVersion: string;
|
|
527
|
+
showFreeRounds: boolean;
|
|
528
|
+
showRealityCheck: boolean;
|
|
529
|
+
showErrors: boolean;
|
|
530
|
+
showBars: boolean;
|
|
531
|
+
skipErrors: ((typeof RgsErrorCode)[keyof typeof RgsErrorCode] | 'TIMEOUT')[];
|
|
532
|
+
};
|
|
533
|
+
|
|
528
534
|
export declare type WrapperOnlyMessagePayloadMap = {
|
|
529
535
|
bet: Bet;
|
|
530
536
|
close: never;
|
|
531
537
|
configured: SdkConfig;
|
|
538
|
+
error: SdkError;
|
|
532
539
|
freeze: never;
|
|
533
540
|
history: History_3;
|
|
534
541
|
resume: never;
|
|
@@ -540,8 +547,6 @@ export declare type WrapperOnlyMessagePayloadMap = {
|
|
|
540
547
|
export declare type WrapperState = {
|
|
541
548
|
balance: number;
|
|
542
549
|
bet: Bet;
|
|
543
|
-
gameName: string;
|
|
544
|
-
version: string;
|
|
545
550
|
};
|
|
546
551
|
|
|
547
552
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,8 @@ var m = (n, i, t) => (N(n, i, "read from private field"), t ? t.call(n) : i.get(
|
|
|
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
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-
|
|
15
|
-
import { a as ii } from "./errors-
|
|
14
|
+
import { T as b, R as E } from "./errors-afd9f527.js";
|
|
15
|
+
import { a as ii } from "./errors-afd9f527.js";
|
|
16
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);
|
|
@@ -307,28 +307,28 @@ class z {
|
|
|
307
307
|
c = new WeakMap();
|
|
308
308
|
const K = () => {
|
|
309
309
|
};
|
|
310
|
-
var
|
|
310
|
+
var h, l, p, d;
|
|
311
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))
|
|
@@ -358,11 +358,14 @@ class Y {
|
|
|
358
358
|
"*"
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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");
|
|
366
|
+
if (t.type === "response")
|
|
367
|
+
return await i, t.response;
|
|
368
|
+
throw t.error.type === "timeout" ? new b() : new E(t.error.data);
|
|
366
369
|
}
|
|
367
370
|
async play(i, t, r = "SPIN") {
|
|
368
371
|
const o = { contract: i, extra: t, actionType: r }, a = await this.request("play", o);
|
|
@@ -371,7 +374,7 @@ class Y {
|
|
|
371
374
|
throw a.error.type === "timeout" ? new b() : new E(a.error.data);
|
|
372
375
|
}
|
|
373
376
|
}
|
|
374
|
-
|
|
377
|
+
h = new WeakMap(), l = new WeakMap(), p = new WeakMap(), d = new WeakMap();
|
|
375
378
|
export {
|
|
376
379
|
_ as History,
|
|
377
380
|
z as I18n,
|