@kalamba/sdk 0.42.0 → 0.43.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.
@@ -68,7 +68,6 @@ type NestedRecord<K extends string | number | symbol, V> = { [k in K]: V | Neste
68
68
  type WrapperConfig = {
69
69
  gameName: string;
70
70
  gameVersion: string;
71
- gameHistoryUrl?: string;
72
71
  showFreeRounds: boolean;
73
72
  showPromoPanel: boolean;
74
73
  showRealityCheck: boolean;
@@ -84,6 +83,7 @@ type WrapperState = {
84
83
  openGameResponse?: OpenGameResponse['contract'];
85
84
  lastPlayResponse?: PlayResponse['contract'];
86
85
  freeRoundId?: string;
86
+ playBlockers: Promise<void>[];
87
87
  };
88
88
  type AutoplayLimit = {
89
89
  enabled: boolean;
@@ -377,6 +377,9 @@ type SdkOnlyMessagePayloadMap = {
377
377
  freeRoundsPopup: never;
378
378
  };
379
379
  type WrapperOnlyMessagePayloadMap = {
380
+ balance: {
381
+ balance: number;
382
+ };
380
383
  bet: Bet;
381
384
  cashier: Cashier;
382
385
  close: never;
@@ -385,11 +388,11 @@ type WrapperOnlyMessagePayloadMap = {
385
388
  freeze: never;
386
389
  history: History;
387
390
  resume: never;
388
- state: WrapperState;
389
391
  suspend: never;
390
392
  unfreeze: never;
391
393
  legalBets: Record<number, number[]>;
392
394
  play: PlayRequestEnhanced;
395
+ playReady: never;
393
396
  freeRounds: FreeRoundsAction;
394
397
  freeRoundsOffer: FreeRound;
395
398
  freeRoundsInfo: FreeRound;
@@ -68,7 +68,6 @@ type NestedRecord<K extends string | number | symbol, V> = { [k in K]: V | Neste
68
68
  type WrapperConfig = {
69
69
  gameName: string;
70
70
  gameVersion: string;
71
- gameHistoryUrl?: string;
72
71
  showFreeRounds: boolean;
73
72
  showPromoPanel: boolean;
74
73
  showRealityCheck: boolean;
@@ -84,6 +83,7 @@ type WrapperState = {
84
83
  openGameResponse?: OpenGameResponse['contract'];
85
84
  lastPlayResponse?: PlayResponse['contract'];
86
85
  freeRoundId?: string;
86
+ playBlockers: Promise<void>[];
87
87
  };
88
88
  type AutoplayLimit = {
89
89
  enabled: boolean;
@@ -377,6 +377,9 @@ type SdkOnlyMessagePayloadMap = {
377
377
  freeRoundsPopup: never;
378
378
  };
379
379
  type WrapperOnlyMessagePayloadMap = {
380
+ balance: {
381
+ balance: number;
382
+ };
380
383
  bet: Bet;
381
384
  cashier: Cashier;
382
385
  close: never;
@@ -385,11 +388,11 @@ type WrapperOnlyMessagePayloadMap = {
385
388
  freeze: never;
386
389
  history: History;
387
390
  resume: never;
388
- state: WrapperState;
389
391
  suspend: never;
390
392
  unfreeze: never;
391
393
  legalBets: Record<number, number[]>;
392
394
  play: PlayRequestEnhanced;
395
+ playReady: never;
393
396
  freeRounds: FreeRoundsAction;
394
397
  freeRoundsOffer: FreeRound;
395
398
  freeRoundsInfo: FreeRound;
@@ -2,7 +2,7 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { A as OpenGameRequest, C as FreeRoundsResponse, N as PlayRequestEnhanced, P as PlayResponse, S as FreeRoundsRequest, W as RgsErrorWithType, _ as ForwardToPluginsMessagePayload, c as ContractPlayPayload, f as DomainMessagePayload, h as ForwardToPluginsMessage, it as WrapperState, j as OpenGameResponse, nt as WrapperConfig, q as SdkConfig, t as I18n, u as DomainMessage, w as GetBalanceResponse } from "./i18n-C9qVulRQ.cjs";
5
+ import { A as OpenGameRequest, C as FreeRoundsResponse, N as PlayRequestEnhanced, P as PlayResponse, S as FreeRoundsRequest, W as RgsErrorWithType, _ as ForwardToPluginsMessagePayload, c as ContractPlayPayload, f as DomainMessagePayload, h as ForwardToPluginsMessage, it as WrapperState, j as OpenGameResponse, nt as WrapperConfig, q as SdkConfig, t as I18n, u as DomainMessage, w as GetBalanceResponse } from "./i18n-DK-Smr79.cjs";
6
6
 
7
7
  //#region src/common/logger.d.ts
8
8
  declare function createLogger(prefix: string, style: string): (message: string, ...args: any[]) => void;
@@ -2,7 +2,7 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { A as OpenGameRequest, C as FreeRoundsResponse, N as PlayRequestEnhanced, P as PlayResponse, S as FreeRoundsRequest, W as RgsErrorWithType, _ as ForwardToPluginsMessagePayload, c as ContractPlayPayload, f as DomainMessagePayload, h as ForwardToPluginsMessage, it as WrapperState, j as OpenGameResponse, nt as WrapperConfig, q as SdkConfig, t as I18n, u as DomainMessage, w as GetBalanceResponse } from "./i18n-40l1CUXq.js";
5
+ import { A as OpenGameRequest, C as FreeRoundsResponse, N as PlayRequestEnhanced, P as PlayResponse, S as FreeRoundsRequest, W as RgsErrorWithType, _ as ForwardToPluginsMessagePayload, c as ContractPlayPayload, f as DomainMessagePayload, h as ForwardToPluginsMessage, it as WrapperState, j as OpenGameResponse, nt as WrapperConfig, q as SdkConfig, t as I18n, u as DomainMessage, w as GetBalanceResponse } from "./i18n-BtKlSq1-.js";
6
6
 
7
7
  //#region src/common/logger.d.ts
8
8
  declare function createLogger(prefix: string, style: string): (message: string, ...args: any[]) => void;
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { $ as ToRgsPluginsForwardedMessageMap, A as OpenGameRequest, B as PrefixedMessagePayload, C as FreeRoundsResponse, D as MessageMap, E as Message, F as PluginDomain, G as RgsOnlyMessagePayloadMap, H as RealityCheckConfig, I as PrefixedForwardToPluginsMessage, J as SdkError, K as RgsResponse, L as PrefixedMessage, M as PlayRequest, N as PlayRequestEnhanced, O as MessageMessageEvent, P as PlayResponse, Q as ToCasinoPluginsForwardedMessageMap, R as PrefixedMessageMap, S as FreeRoundsRequest, T as History, U as RgsErrorData, V as PrefixedMessagePayloadMap, W as RgsErrorWithType, X as Settings, Y as SdkOnlyMessagePayloadMap, Z as TelemetryOnlyMessagePayloadMap, _ as ForwardToPluginsMessagePayload, a as CashierConfig, b as FreeRound, c as ContractPlayPayload, ct as TimeoutError, d as DomainMessageMessageEvent, dt as FormatCurrencyOptions, et as ToSdkForwardedMessageMap, f as DomainMessagePayload, g as ForwardToPluginsMessageMap, h as ForwardToPluginsMessage, i as Cashier, it as WrapperState, j as OpenGameResponse, k as MessagePayload, l as DomainAllowedPayloadMap, lt as CurrencyFormat, m as DomainToMessagePayloadMap, n as AutoplayLimit, nt as WrapperConfig, o as CasinoOnlyMessagePayloadMap, ot as RgsError, p as DomainPrefix, q as SdkConfig, r as Bet, rt as WrapperOnlyMessagePayloadMap, s as ContractOpenGamePayload, st as RgsErrorCode, t as I18n, tt as ToTelemetryPluginsForwardedMessageMap, u as DomainMessage, ut as CurrencyNumber, v as ForwardToSdkMessage, w as GetBalanceResponse, x as FreeRoundsAction, y as ForwardToSdkMessagePayload, z as PrefixedMessageMessageEvent } from "./i18n-C9qVulRQ.cjs";
5
+ import { $ as ToRgsPluginsForwardedMessageMap, A as OpenGameRequest, B as PrefixedMessagePayload, C as FreeRoundsResponse, D as MessageMap, E as Message, F as PluginDomain, G as RgsOnlyMessagePayloadMap, H as RealityCheckConfig, I as PrefixedForwardToPluginsMessage, J as SdkError, K as RgsResponse, L as PrefixedMessage, M as PlayRequest, N as PlayRequestEnhanced, O as MessageMessageEvent, P as PlayResponse, Q as ToCasinoPluginsForwardedMessageMap, R as PrefixedMessageMap, S as FreeRoundsRequest, T as History, U as RgsErrorData, V as PrefixedMessagePayloadMap, W as RgsErrorWithType, X as Settings, Y as SdkOnlyMessagePayloadMap, Z as TelemetryOnlyMessagePayloadMap, _ as ForwardToPluginsMessagePayload, a as CashierConfig, b as FreeRound, c as ContractPlayPayload, ct as TimeoutError, d as DomainMessageMessageEvent, dt as FormatCurrencyOptions, et as ToSdkForwardedMessageMap, f as DomainMessagePayload, g as ForwardToPluginsMessageMap, h as ForwardToPluginsMessage, i as Cashier, it as WrapperState, j as OpenGameResponse, k as MessagePayload, l as DomainAllowedPayloadMap, lt as CurrencyFormat, m as DomainToMessagePayloadMap, n as AutoplayLimit, nt as WrapperConfig, o as CasinoOnlyMessagePayloadMap, ot as RgsError, p as DomainPrefix, q as SdkConfig, r as Bet, rt as WrapperOnlyMessagePayloadMap, s as ContractOpenGamePayload, st as RgsErrorCode, t as I18n, tt as ToTelemetryPluginsForwardedMessageMap, u as DomainMessage, ut as CurrencyNumber, v as ForwardToSdkMessage, w as GetBalanceResponse, x as FreeRoundsAction, y as ForwardToSdkMessagePayload, z as PrefixedMessageMessageEvent } from "./i18n-DK-Smr79.cjs";
6
6
 
7
7
  //#region src/sdk/KalambaSdk.d.ts
8
8
  type MessageType = 'openGame' | 'play';
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { $ as ToRgsPluginsForwardedMessageMap, A as OpenGameRequest, B as PrefixedMessagePayload, C as FreeRoundsResponse, D as MessageMap, E as Message, F as PluginDomain, G as RgsOnlyMessagePayloadMap, H as RealityCheckConfig, I as PrefixedForwardToPluginsMessage, J as SdkError, K as RgsResponse, L as PrefixedMessage, M as PlayRequest, N as PlayRequestEnhanced, O as MessageMessageEvent, P as PlayResponse, Q as ToCasinoPluginsForwardedMessageMap, R as PrefixedMessageMap, S as FreeRoundsRequest, T as History, U as RgsErrorData, V as PrefixedMessagePayloadMap, W as RgsErrorWithType, X as Settings, Y as SdkOnlyMessagePayloadMap, Z as TelemetryOnlyMessagePayloadMap, _ as ForwardToPluginsMessagePayload, a as CashierConfig, b as FreeRound, c as ContractPlayPayload, ct as TimeoutError, d as DomainMessageMessageEvent, dt as FormatCurrencyOptions, et as ToSdkForwardedMessageMap, f as DomainMessagePayload, g as ForwardToPluginsMessageMap, h as ForwardToPluginsMessage, i as Cashier, it as WrapperState, j as OpenGameResponse, k as MessagePayload, l as DomainAllowedPayloadMap, lt as CurrencyFormat, m as DomainToMessagePayloadMap, n as AutoplayLimit, nt as WrapperConfig, o as CasinoOnlyMessagePayloadMap, ot as RgsError, p as DomainPrefix, q as SdkConfig, r as Bet, rt as WrapperOnlyMessagePayloadMap, s as ContractOpenGamePayload, st as RgsErrorCode, t as I18n, tt as ToTelemetryPluginsForwardedMessageMap, u as DomainMessage, ut as CurrencyNumber, v as ForwardToSdkMessage, w as GetBalanceResponse, x as FreeRoundsAction, y as ForwardToSdkMessagePayload, z as PrefixedMessageMessageEvent } from "./i18n-40l1CUXq.js";
5
+ import { $ as ToRgsPluginsForwardedMessageMap, A as OpenGameRequest, B as PrefixedMessagePayload, C as FreeRoundsResponse, D as MessageMap, E as Message, F as PluginDomain, G as RgsOnlyMessagePayloadMap, H as RealityCheckConfig, I as PrefixedForwardToPluginsMessage, J as SdkError, K as RgsResponse, L as PrefixedMessage, M as PlayRequest, N as PlayRequestEnhanced, O as MessageMessageEvent, P as PlayResponse, Q as ToCasinoPluginsForwardedMessageMap, R as PrefixedMessageMap, S as FreeRoundsRequest, T as History, U as RgsErrorData, V as PrefixedMessagePayloadMap, W as RgsErrorWithType, X as Settings, Y as SdkOnlyMessagePayloadMap, Z as TelemetryOnlyMessagePayloadMap, _ as ForwardToPluginsMessagePayload, a as CashierConfig, b as FreeRound, c as ContractPlayPayload, ct as TimeoutError, d as DomainMessageMessageEvent, dt as FormatCurrencyOptions, et as ToSdkForwardedMessageMap, f as DomainMessagePayload, g as ForwardToPluginsMessageMap, h as ForwardToPluginsMessage, i as Cashier, it as WrapperState, j as OpenGameResponse, k as MessagePayload, l as DomainAllowedPayloadMap, lt as CurrencyFormat, m as DomainToMessagePayloadMap, n as AutoplayLimit, nt as WrapperConfig, o as CasinoOnlyMessagePayloadMap, ot as RgsError, p as DomainPrefix, q as SdkConfig, r as Bet, rt as WrapperOnlyMessagePayloadMap, s as ContractOpenGamePayload, st as RgsErrorCode, t as I18n, tt as ToTelemetryPluginsForwardedMessageMap, u as DomainMessage, ut as CurrencyNumber, v as ForwardToSdkMessage, w as GetBalanceResponse, x as FreeRoundsAction, y as ForwardToSdkMessagePayload, z as PrefixedMessageMessageEvent } from "./i18n-BtKlSq1-.js";
6
6
 
7
7
  //#region src/sdk/KalambaSdk.d.ts
8
8
  type MessageType = 'openGame' | 'play';
@@ -2,5 +2,5 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-18Ae87g0.cjs";
5
+ import { i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-COZddK-N.cjs";
6
6
  export { CasinoPlugin, RgsPlugin, TelemetryPlugin, Tracker };
package/dist/plugins.d.ts CHANGED
@@ -2,5 +2,5 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-DbbkVIkz.js";
5
+ import { i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-Ddzn0JlB.js";
6
6
  export { CasinoPlugin, RgsPlugin, TelemetryPlugin, Tracker };
package/dist/wrapper.cjs CHANGED
@@ -5,6 +5,7 @@
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
6
6
  const require_errors = require('./errors-BUjKnbx5.cjs');
7
7
  let lodash_es = require("lodash-es");
8
+ let zustand_vanilla = require("zustand/vanilla");
8
9
  let uuid = require("uuid");
9
10
 
10
11
  //#region src/common/PayloadInjectionManager.ts
@@ -59,7 +60,7 @@ var KalambaSdkWrapper = class {
59
60
  showBars: true,
60
61
  skipErrors: []
61
62
  };
62
- #state = {
63
+ #store = (0, zustand_vanilla.createStore)(() => ({
63
64
  isSdkConfigured: false,
64
65
  balance: 0,
65
66
  bet: {
@@ -69,8 +70,9 @@ var KalambaSdkWrapper = class {
69
70
  updateBalance: true,
70
71
  openGameResponse: void 0,
71
72
  lastPlayResponse: void 0,
72
- freeRoundId: void 0
73
- };
73
+ freeRoundId: void 0,
74
+ playBlockers: []
75
+ }));
74
76
  #sdkConfigManager;
75
77
  #payloadInjectionManager;
76
78
  #wakeLock;
@@ -99,12 +101,13 @@ var KalambaSdkWrapper = class {
99
101
  this.on("sdk:playCycleStart", async () => {
100
102
  await this.requestWakeLock();
101
103
  if (this.state.freeRoundId) return;
104
+ this.send("balance", { balance: this.state.balance - this.state.bet.base * this.state.bet.multiplier });
105
+ });
106
+ this.on("sdk:play", async (payload) => {
102
107
  this.setState((state) => ({
103
108
  ...state,
104
- balance: state.balance - state.bet.base * state.bet.multiplier
109
+ playBlockers: []
105
110
  }));
106
- });
107
- this.on("sdk:play", async (payload) => {
108
111
  const payloadToInject = await this.#payloadInjectionManager.getPayload(payload.contract);
109
112
  this.send("play", {
110
113
  ...payload,
@@ -134,10 +137,7 @@ var KalambaSdkWrapper = class {
134
137
  ...state,
135
138
  openGameResponse: response.contract
136
139
  }));
137
- if (this.state.updateBalance) this.setState((state) => ({
138
- ...state,
139
- balance: response.contract.balance.coins
140
- }));
140
+ if (this.state.updateBalance) this.send("balance", { balance: response.contract.balance.coins });
141
141
  });
142
142
  this.on("rgs:openGameError", async (error) => {
143
143
  if (error.type === "timeout" && !this.config.skipErrors.includes("TIMEOUT")) this.send("error", {
@@ -157,12 +157,13 @@ var KalambaSdkWrapper = class {
157
157
  lastPlayResponse: response.contract
158
158
  }));
159
159
  });
160
+ this.on("playEnd", async () => {
161
+ await Promise.all(this.state.playBlockers);
162
+ this.send("playReady");
163
+ });
160
164
  this.on("playCycleEnd", () => {
161
165
  this.releaseWakeLock();
162
- if (this.state.updateBalance) this.setState((state) => ({
163
- ...state,
164
- balance: this.state.lastPlayResponse.balance.coins
165
- }));
166
+ if (this.state.updateBalance) this.send("balance", { balance: this.state.lastPlayResponse.balance.coins });
166
167
  this.handleFreeRounds(this.state.lastPlayResponse.freeRounds[0]);
167
168
  });
168
169
  this.on("rgs:playError", async (error) => {
@@ -204,7 +205,7 @@ var KalambaSdkWrapper = class {
204
205
  const that = this;
205
206
  return new Proxy({}, {
206
207
  get(_target, prop) {
207
- return Reflect.get(that.#state, prop);
208
+ return Reflect.get(that.#store.getState(), prop);
208
209
  },
209
210
  set(_target, prop, value) {
210
211
  that.setState((state) => ({
@@ -216,8 +217,10 @@ var KalambaSdkWrapper = class {
216
217
  });
217
218
  }
218
219
  setState(setter) {
219
- this.#state = setter(this.#state);
220
- this.send("state", this.#state);
220
+ this.#store.setState(setter(this.#store.getState()));
221
+ }
222
+ subscribe(listener) {
223
+ return this.#store.subscribe(listener);
221
224
  }
222
225
  forwardMessages() {
223
226
  this.forwardToPlugins("casino", [
@@ -2,8 +2,8 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { E as Message, at as DeepPartial, b as FreeRound, f as DomainMessagePayload, it as WrapperState, k as MessagePayload, nt as WrapperConfig, q as SdkConfig, u as DomainMessage } from "./i18n-C9qVulRQ.cjs";
6
- import { a as PayloadInjectionManager, i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-18Ae87g0.cjs";
5
+ import { E as Message, at as DeepPartial, b as FreeRound, f as DomainMessagePayload, it as WrapperState, k as MessagePayload, nt as WrapperConfig, q as SdkConfig, u as DomainMessage } from "./i18n-DK-Smr79.cjs";
6
+ import { a as PayloadInjectionManager, i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-COZddK-N.cjs";
7
7
 
8
8
  //#region src/common/config/SdkConfigManager.d.ts
9
9
  declare abstract class SdkConfigManager {
@@ -37,6 +37,7 @@ declare class KalambaSdkWrapper {
37
37
  });
38
38
  get state(): WrapperState;
39
39
  setState(setter: (currentState: WrapperState) => WrapperState): void;
40
+ subscribe(listener: (state: WrapperState) => void): () => void;
40
41
  forwardMessages(): void;
41
42
  get config(): WrapperConfig;
42
43
  get sdkConfig(): SdkConfig;
package/dist/wrapper.d.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2026, Kalamba Games Limited
4
4
  */
5
- import { E as Message, at as DeepPartial, b as FreeRound, f as DomainMessagePayload, it as WrapperState, k as MessagePayload, nt as WrapperConfig, q as SdkConfig, u as DomainMessage } from "./i18n-40l1CUXq.js";
6
- import { a as PayloadInjectionManager, i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-DbbkVIkz.js";
5
+ import { E as Message, at as DeepPartial, b as FreeRound, f as DomainMessagePayload, it as WrapperState, k as MessagePayload, nt as WrapperConfig, q as SdkConfig, u as DomainMessage } from "./i18n-BtKlSq1-.js";
6
+ import { a as PayloadInjectionManager, i as CasinoPlugin, n as Tracker, r as RgsPlugin, t as TelemetryPlugin } from "./index-Ddzn0JlB.js";
7
7
 
8
8
  //#region src/common/config/SdkConfigManager.d.ts
9
9
  declare abstract class SdkConfigManager {
@@ -37,6 +37,7 @@ declare class KalambaSdkWrapper {
37
37
  });
38
38
  get state(): WrapperState;
39
39
  setState(setter: (currentState: WrapperState) => WrapperState): void;
40
+ subscribe(listener: (state: WrapperState) => void): () => void;
40
41
  forwardMessages(): void;
41
42
  get config(): WrapperConfig;
42
43
  get sdkConfig(): SdkConfig;
package/dist/wrapper.js CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { n as RgsErrorAction } from "./errors-CakYyMwc.js";
6
6
  import { flow, merge, sortBy, sortedUniq } from "lodash-es";
7
+ import { createStore } from "zustand/vanilla";
7
8
  import { v4 } from "uuid";
8
9
 
9
10
  //#region src/common/PayloadInjectionManager.ts
@@ -58,7 +59,7 @@ var KalambaSdkWrapper = class {
58
59
  showBars: true,
59
60
  skipErrors: []
60
61
  };
61
- #state = {
62
+ #store = createStore(() => ({
62
63
  isSdkConfigured: false,
63
64
  balance: 0,
64
65
  bet: {
@@ -68,8 +69,9 @@ var KalambaSdkWrapper = class {
68
69
  updateBalance: true,
69
70
  openGameResponse: void 0,
70
71
  lastPlayResponse: void 0,
71
- freeRoundId: void 0
72
- };
72
+ freeRoundId: void 0,
73
+ playBlockers: []
74
+ }));
73
75
  #sdkConfigManager;
74
76
  #payloadInjectionManager;
75
77
  #wakeLock;
@@ -98,12 +100,13 @@ var KalambaSdkWrapper = class {
98
100
  this.on("sdk:playCycleStart", async () => {
99
101
  await this.requestWakeLock();
100
102
  if (this.state.freeRoundId) return;
103
+ this.send("balance", { balance: this.state.balance - this.state.bet.base * this.state.bet.multiplier });
104
+ });
105
+ this.on("sdk:play", async (payload) => {
101
106
  this.setState((state) => ({
102
107
  ...state,
103
- balance: state.balance - state.bet.base * state.bet.multiplier
108
+ playBlockers: []
104
109
  }));
105
- });
106
- this.on("sdk:play", async (payload) => {
107
110
  const payloadToInject = await this.#payloadInjectionManager.getPayload(payload.contract);
108
111
  this.send("play", {
109
112
  ...payload,
@@ -133,10 +136,7 @@ var KalambaSdkWrapper = class {
133
136
  ...state,
134
137
  openGameResponse: response.contract
135
138
  }));
136
- if (this.state.updateBalance) this.setState((state) => ({
137
- ...state,
138
- balance: response.contract.balance.coins
139
- }));
139
+ if (this.state.updateBalance) this.send("balance", { balance: response.contract.balance.coins });
140
140
  });
141
141
  this.on("rgs:openGameError", async (error) => {
142
142
  if (error.type === "timeout" && !this.config.skipErrors.includes("TIMEOUT")) this.send("error", {
@@ -156,12 +156,13 @@ var KalambaSdkWrapper = class {
156
156
  lastPlayResponse: response.contract
157
157
  }));
158
158
  });
159
+ this.on("playEnd", async () => {
160
+ await Promise.all(this.state.playBlockers);
161
+ this.send("playReady");
162
+ });
159
163
  this.on("playCycleEnd", () => {
160
164
  this.releaseWakeLock();
161
- if (this.state.updateBalance) this.setState((state) => ({
162
- ...state,
163
- balance: this.state.lastPlayResponse.balance.coins
164
- }));
165
+ if (this.state.updateBalance) this.send("balance", { balance: this.state.lastPlayResponse.balance.coins });
165
166
  this.handleFreeRounds(this.state.lastPlayResponse.freeRounds[0]);
166
167
  });
167
168
  this.on("rgs:playError", async (error) => {
@@ -203,7 +204,7 @@ var KalambaSdkWrapper = class {
203
204
  const that = this;
204
205
  return new Proxy({}, {
205
206
  get(_target, prop) {
206
- return Reflect.get(that.#state, prop);
207
+ return Reflect.get(that.#store.getState(), prop);
207
208
  },
208
209
  set(_target, prop, value) {
209
210
  that.setState((state) => ({
@@ -215,8 +216,10 @@ var KalambaSdkWrapper = class {
215
216
  });
216
217
  }
217
218
  setState(setter) {
218
- this.#state = setter(this.#state);
219
- this.send("state", this.#state);
219
+ this.#store.setState(setter(this.#store.getState()));
220
+ }
221
+ subscribe(listener) {
222
+ return this.#store.subscribe(listener);
220
223
  }
221
224
  forwardMessages() {
222
225
  this.forwardToPlugins("casino", [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalamba/sdk",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "type": "module",
6
6
  "files": [