@kalamba/sdk 0.27.0 → 0.35.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/plugins.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ import { FormatCurrencyOptions } from '@kalamba/common/src/utils/format/currency';
2
+ import { StoreApi } from 'zustand';
3
+
4
+ declare interface Actions {
5
+ switchPlayMode: () => void;
6
+ }
7
+
1
8
  declare type AuthenticateResponse = WebSocketResponse<'Authenticate', {
2
9
  code: (typeof AuthenticateResponseCode)[keyof typeof AuthenticateResponseCode];
3
10
  }, Record<string, unknown> & {
@@ -54,6 +61,13 @@ declare type Bet = {
54
61
  multiplier: number;
55
62
  };
56
63
 
64
+ export declare class BspotPlugin extends CasinoPlugin {
65
+ #private;
66
+ static store: StoreApi<Store>;
67
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
68
+ registerFromSdkEvents(): void;
69
+ }
70
+
57
71
  declare type Cashier = {
58
72
  type: 'ON_DEMAND' | 'BALANCE_LOW' | 'BALANCE_INSUFFICIENT';
59
73
  };
@@ -87,12 +101,16 @@ declare type CasinoOnlyMessagePayloadMap = {
87
101
  settings: Settings;
88
102
  suspend: never;
89
103
  unfreeze: never;
104
+ translations: NestedRecord<string, string>;
90
105
  };
91
106
 
92
107
  export declare abstract class CasinoPlugin {
93
108
  config: WrapperConfig;
94
109
  sdkConfig: SdkConfig;
95
- constructor(config: WrapperConfig, sdkConfig: SdkConfig);
110
+ state: WrapperState;
111
+ i18n: I18n;
112
+ injectPayload: (...[source, payload]: Parameters<PayloadInjectionManager['register']>) => () => void;
113
+ constructor(config: WrapperConfig, sdkConfig: SdkConfig, state: WrapperState, injectPayload: (...[source, payload]: Parameters<PayloadInjectionManager['register']>) => () => void);
96
114
  protected on<M extends DomainMessage<'wrapper'> | ForwardToPluginsMessage<'casino'>>(message: M, listener: (payload: M extends DomainMessage<'wrapper'> ? DomainMessagePayload<'wrapper', M> : M extends ForwardToPluginsMessage<'casino'> ? ForwardToPluginsMessagePayload<'casino', M> : never) => void, options?: AddEventListenerOptions): void;
97
115
  protected send<M extends DomainMessage<'casino'>>(message: M, ...[payload]: DomainMessagePayload<'casino', M> extends never ? [] : undefined extends DomainMessagePayload<'casino', M> ? [] | [DomainMessagePayload<'casino', M>] : [DomainMessagePayload<'casino', M>]): void;
98
116
  }
@@ -104,10 +122,9 @@ declare type ContractPlayPayload = {
104
122
  };
105
123
 
106
124
  export declare class DebuggingPlugin extends CasinoPlugin {
125
+ #private;
107
126
  constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
108
- registerDebugToSdkEvents(): void;
109
127
  registerSdkToDebugEvents(): void;
110
- _send(...args: Parameters<typeof DebuggingPlugin.prototype.send>): ReturnType<typeof DebuggingPlugin.prototype.send>;
111
128
  }
112
129
 
113
130
  declare type Decoder = (data: any) => unknown;
@@ -150,7 +167,7 @@ export declare class EveryMatrixPlugin extends CasinoPlugin {
150
167
  registerFromSdkEvents(): void;
151
168
  }
152
169
 
153
- declare type ForwardToPluginsMessage<P extends PluginDomain> = keyof ForwardToPluginsMessageMap<'sdk'>[P] | keyof ForwardToPluginsMessageMap<'rgs'>[P] | keyof ForwardToPluginsMessageMap<'casino'>[P] | keyof ForwardToPluginsMessageMap<'telemetry'>[P];
170
+ declare type ForwardToPluginsMessage<P extends PluginDomain> = keyof ForwardToPluginsMessageMap<'sdk'>[P] | keyof ForwardToPluginsMessageMap<'rgs'>[P] | keyof ForwardToPluginsMessageMap<'casino'>[P] | keyof ForwardToPluginsMessageMap<'telemetry'>[P] | keyof ForwardToPluginsMessageMap<'wrapper'>[P];
154
171
 
155
172
  declare interface ForwardToPluginsMessageMap<SourceDomain extends DomainPrefix> {
156
173
  casino: ToCasinoPluginsForwardedMessageMap[SourceDomain];
@@ -158,7 +175,7 @@ declare interface ForwardToPluginsMessageMap<SourceDomain extends DomainPrefix>
158
175
  telemetry: ToTelemetryPluginsForwardedMessageMap[SourceDomain];
159
176
  }
160
177
 
161
- declare type ForwardToPluginsMessagePayload<P extends PluginDomain, M extends ForwardToPluginsMessage<P>> = ForwardToPluginsMessageMap<'sdk'>[P][M] & ForwardToPluginsMessageMap<'rgs'>[P][M] & ForwardToPluginsMessageMap<'casino'>[P][M] & ForwardToPluginsMessageMap<'telemetry'>[P][M];
178
+ declare type ForwardToPluginsMessagePayload<P extends PluginDomain, M extends ForwardToPluginsMessage<P>> = ForwardToPluginsMessageMap<'sdk'>[P][M] & ForwardToPluginsMessageMap<'rgs'>[P][M] & ForwardToPluginsMessageMap<'casino'>[P][M] & ForwardToPluginsMessageMap<'telemetry'>[P][M] & ForwardToPluginsMessageMap<'wrapper'>[P][M];
162
179
 
163
180
  declare type FreeRound = {
164
181
  conf: {
@@ -242,6 +259,19 @@ declare type History_2 = {
242
259
  source: 'realityCheck' | 'settings' | 'casino';
243
260
  };
244
261
 
262
+ declare class I18n {
263
+ #private;
264
+ constructor({ config }: {
265
+ config: SdkConfig;
266
+ });
267
+ formatNumber(number: string | number, formatOptions?: Intl.NumberFormatOptions): string;
268
+ formatCurrency(number: string | number, options?: FormatCurrencyOptions, formatOptions?: Intl.NumberFormatOptions): string;
269
+ formatCoins(amount: number | string, formatOptions?: Intl.NumberFormatOptions): string;
270
+ formatCoinsWithCurrency(amount: number | string, formatOptions?: Intl.NumberFormatOptions): string;
271
+ formatMoney(amount: number | string, formatOptions?: Intl.NumberFormatOptions): string;
272
+ formatMoneyWithCurrency(amount: number | string, formatOptions?: Intl.NumberFormatOptions): string;
273
+ }
274
+
245
275
  export declare const KalambaBullseyeParsers: {
246
276
  parseAuthenticateResponse: typeof parseAuthenticateResponse;
247
277
  parseAuthenticateError: typeof parseAuthenticateError;
@@ -573,6 +603,37 @@ declare function parsePlayError(errorResponse: any): RgsErrorData;
573
603
 
574
604
  declare function parsePlayResponse(playResponse: ResultGameEvent['body'], dataDecoder?: Decoder): PlayResponse;
575
605
 
606
+ declare type PayloadData = Record<string, unknown>;
607
+
608
+ /**
609
+ * PayloadInjectionManager manages payload injection from multiple sources.
610
+ * Each source can register either static payload data or async functions that will be merged together when creating the final payload for injection.
611
+ */
612
+ declare class PayloadInjectionManager {
613
+ #private;
614
+ /**
615
+ * Register or update payload injector from a specific source
616
+ * @param source - Unique identifier for the payload source (e.g., 'bspot', 'freeRounds')
617
+ * @param payload - Payload data or async function that receives playPayload and returns payload data
618
+ */
619
+ register(source: PayloadSource, payloadProvider: PayloadProvider): void;
620
+ /**
621
+ * Remove payload injector from a specific source
622
+ * @param source - Source identifier to remove
623
+ */
624
+ unregister(source: PayloadSource): void;
625
+ /**
626
+ * Get merged payload from all registered injectors
627
+ * @param playPayload - The play payload that will be passed to registered functions
628
+ * @returns Promise resolving to merged payload object or undefined if no injectors registered
629
+ */
630
+ getPayload(playPayload: ContractPlayPayload): Promise<PayloadData | undefined>;
631
+ }
632
+
633
+ declare type PayloadProvider = PayloadData | ((playPayload: ContractPlayPayload) => PayloadData | Promise<PayloadData>);
634
+
635
+ declare type PayloadSource = string;
636
+
576
637
  declare type PlayRequest = {
577
638
  contract: ContractPlayPayload;
578
639
  extra?: unknown;
@@ -837,9 +898,6 @@ declare type SdkOnlyMessagePayloadMap = {
837
898
  autoplay: {
838
899
  action: 'start' | 'stop' | 'pause' | 'resume';
839
900
  };
840
- balance: {
841
- balance: number;
842
- };
843
901
  bet: Bet;
844
902
  cashier: Cashier;
845
903
  choice: {
@@ -890,7 +948,6 @@ declare type SdkOnlyMessagePayloadMap = {
890
948
 
891
949
  declare type Settings = {
892
950
  fastPlay?: boolean;
893
- fastPlaySpeed?: number;
894
951
  sounds?: boolean;
895
952
  music?: boolean;
896
953
  };
@@ -901,6 +958,11 @@ export declare class SoftSwissPlugin extends CasinoPlugin {
901
958
  registerFromSdkEvents(): void;
902
959
  }
903
960
 
961
+ declare interface State {
962
+ }
963
+
964
+ declare type Store = State & Actions;
965
+
904
966
  declare type TelemetryOnlyMessagePayloadMap = {
905
967
  [key: string]: unknown;
906
968
  };
@@ -915,9 +977,9 @@ export declare abstract class TelemetryPlugin {
915
977
  }
916
978
 
917
979
  declare type ToCasinoPluginsForwardedMessageMap = {
918
- sdk: Pick<SdkOnlyMessagePayloadMap, 'autoplay' | 'balance' | 'bet' | 'cashier' | 'choice' | 'close' | 'error' | 'history' | 'loadEnd' | 'loadProgress' | 'loadStart' | 'openGame' | 'play' | 'playCycleEnd' | 'playCycleStart' | 'playEnd' | 'playReady' | 'playStart' | 'settings'>;
980
+ sdk: Pick<SdkOnlyMessagePayloadMap, 'autoplay' | 'bet' | 'cashier' | 'choice' | 'close' | 'configure' | 'error' | 'history' | 'loadEnd' | 'loadProgress' | 'loadStart' | 'openGame' | 'play' | 'playCycleEnd' | 'playCycleStart' | 'playEnd' | 'playReady' | 'playStart' | 'settings' | 'fullscreen'>;
919
981
  casino: undefined;
920
- rgs: Pick<RgsOnlyMessagePayloadMap, 'playResponse' | 'playError' | 'openGameResponse'>;
982
+ rgs: Pick<RgsOnlyMessagePayloadMap, 'balance' | 'playResponse' | 'playError' | 'openGameResponse'>;
921
983
  telemetry: undefined;
922
984
  wrapper: undefined;
923
985
  };
@@ -1004,6 +1066,7 @@ declare type WrapperConfig = {
1004
1066
 
1005
1067
  declare type WrapperOnlyMessagePayloadMap = {
1006
1068
  bet: Bet;
1069
+ cashier: Cashier;
1007
1070
  close: never;
1008
1071
  configured: SdkConfig;
1009
1072
  error: SdkError;
@@ -1026,8 +1089,8 @@ declare type WrapperState = {
1026
1089
  isSdkConfigured: boolean;
1027
1090
  balance: number;
1028
1091
  bet: Bet;
1029
- openGameResponse?: OpenGameResponse;
1030
- lastPlayResponse?: PlayResponse;
1092
+ openGameResponse?: OpenGameResponse['contract'];
1093
+ lastPlayResponse?: PlayResponse['contract'];
1031
1094
  freeRoundId?: string;
1032
1095
  };
1033
1096