@clovnet/casino-sdk 1.0.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.
@@ -0,0 +1,382 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+
5
+ // src/react/CasinoProvider.tsx
6
+ var CasinoContext = react.createContext(null);
7
+ function useCasino() {
8
+ const client = react.useContext(CasinoContext);
9
+ if (!client) {
10
+ throw new Error("useCasino must be used within a <CasinoProvider>.");
11
+ }
12
+ return client;
13
+ }
14
+
15
+ // src/react/CasinoProvider.tsx
16
+ function CasinoProvider({ client, children }) {
17
+ return react.createElement(CasinoContext.Provider, { value: client }, children);
18
+ }
19
+ var idle = () => ({ data: null, loading: false, error: null });
20
+ function useAuth() {
21
+ const sdk = useCasino();
22
+ const [state, setState] = react.useState(idle);
23
+ const load = react.useCallback(async () => {
24
+ setState((s) => ({ ...s, loading: true, error: null }));
25
+ try {
26
+ const me = await sdk.auth.me();
27
+ setState({ data: me, loading: false, error: null });
28
+ } catch (error) {
29
+ setState({ data: null, loading: false, error });
30
+ }
31
+ }, [sdk]);
32
+ react.useEffect(() => {
33
+ void load();
34
+ }, [load]);
35
+ const login = react.useCallback(
36
+ async (input) => {
37
+ setState((s) => ({ ...s, loading: true, error: null }));
38
+ try {
39
+ await sdk.auth.login(input);
40
+ } catch (error) {
41
+ setState((s) => ({ ...s, loading: false, error }));
42
+ return;
43
+ }
44
+ await load();
45
+ },
46
+ [sdk, load]
47
+ );
48
+ const logout = react.useCallback(async () => {
49
+ await sdk.auth.logout();
50
+ setState(idle());
51
+ }, [sdk]);
52
+ return {
53
+ player: state.data?.player ?? null,
54
+ profile: state.data?.profile ?? null,
55
+ loading: state.loading,
56
+ error: state.error,
57
+ login,
58
+ logout,
59
+ refresh: load
60
+ };
61
+ }
62
+ function useBalance(options) {
63
+ const sdk = useCasino();
64
+ const live = options?.live ?? true;
65
+ const currency = options?.currency?.toUpperCase();
66
+ const [state, setState] = react.useState(idle);
67
+ const [connection, setConnection] = react.useState("idle");
68
+ const currentRef = react.useRef(null);
69
+ const mountedRef = react.useRef(true);
70
+ react.useEffect(() => {
71
+ mountedRef.current = true;
72
+ return () => {
73
+ mountedRef.current = false;
74
+ };
75
+ }, []);
76
+ const epochRef = react.useRef(0);
77
+ const reload = react.useCallback(async () => {
78
+ const seq = ++epochRef.current;
79
+ const current = () => mountedRef.current && seq === epochRef.current;
80
+ try {
81
+ const bal = await sdk.wallet.getBalance(currency ? { currency } : void 0);
82
+ if (!current()) return;
83
+ currentRef.current = bal;
84
+ setState({ data: bal, loading: false, error: null });
85
+ } catch (error) {
86
+ if (current()) setState((s) => ({ ...s, loading: false, error }));
87
+ }
88
+ }, [sdk, currency]);
89
+ react.useEffect(() => {
90
+ let mounted = true;
91
+ setState((s) => ({ ...s, loading: true }));
92
+ void reload();
93
+ if (!live) return;
94
+ const offState = sdk.realtime.onStateChange((s) => {
95
+ if (mounted) setConnection(s);
96
+ });
97
+ const offBalance = sdk.realtime.on("wallet.balance", (event) => {
98
+ if (!mounted) return;
99
+ if (currency && event.data.currency.toUpperCase() !== currency) return;
100
+ const prev = currentRef.current;
101
+ const sameWallet = prev?.currency === event.data.currency;
102
+ const next = {
103
+ playerId: prev?.playerId ?? sdk.getSession().player?.id ?? "",
104
+ currency: event.data.currency,
105
+ cash: event.data.balances.cash,
106
+ bonus: event.data.balances.bonus,
107
+ locked: event.data.balances.locked,
108
+ total: event.data.balances.cash + event.data.balances.bonus + event.data.balances.locked,
109
+ status: sameWallet ? prev?.status ?? "active" : "active",
110
+ walletId: sameWallet ? prev?.walletId ?? null : null
111
+ };
112
+ currentRef.current = next;
113
+ setState({ data: next, loading: false, error: null });
114
+ });
115
+ void sdk.realtime.connect().catch(() => {
116
+ });
117
+ return () => {
118
+ mounted = false;
119
+ offState();
120
+ offBalance();
121
+ };
122
+ }, [sdk, reload, live, currency]);
123
+ return { ...state, connection, reload };
124
+ }
125
+ function useLobby(query = {}) {
126
+ const sdk = useCasino();
127
+ const [state, setState] = react.useState(() => ({ ...idle(), loading: true }));
128
+ const key = JSON.stringify(query);
129
+ const mountedRef = react.useRef(true);
130
+ react.useEffect(() => {
131
+ mountedRef.current = true;
132
+ return () => {
133
+ mountedRef.current = false;
134
+ };
135
+ }, []);
136
+ const epochRef = react.useRef(0);
137
+ const reload = react.useCallback(async () => {
138
+ const seq = ++epochRef.current;
139
+ const current = () => mountedRef.current && seq === epochRef.current;
140
+ setState((s) => ({ ...s, loading: true, error: null }));
141
+ try {
142
+ const page = await sdk.catalog.lobby(JSON.parse(key));
143
+ if (current()) setState({ data: page, loading: false, error: null });
144
+ } catch (error) {
145
+ if (current()) setState({ data: null, loading: false, error });
146
+ }
147
+ }, [sdk, key]);
148
+ react.useEffect(() => {
149
+ void reload();
150
+ }, [reload]);
151
+ return { ...state, reload };
152
+ }
153
+ function useGame(idOrSlug) {
154
+ const sdk = useCasino();
155
+ const [state, setState] = react.useState(idle);
156
+ react.useEffect(() => {
157
+ if (!idOrSlug) {
158
+ setState(idle());
159
+ return;
160
+ }
161
+ let mounted = true;
162
+ setState((s) => ({ ...s, loading: true, error: null }));
163
+ sdk.catalog.game(idOrSlug).then((game) => mounted && setState({ data: game, loading: false, error: null })).catch((error) => mounted && setState({ data: null, loading: false, error }));
164
+ return () => {
165
+ mounted = false;
166
+ };
167
+ }, [sdk, idOrSlug]);
168
+ return state;
169
+ }
170
+ function useGameLaunch() {
171
+ const sdk = useCasino();
172
+ const [state, setState] = react.useState(idle);
173
+ const launch = react.useCallback(
174
+ async (provider, gameId, options) => {
175
+ setState((s) => ({ ...s, loading: true, error: null }));
176
+ try {
177
+ const result = await sdk.games.providerSession(provider, gameId, options);
178
+ setState({ data: result, loading: false, error: null });
179
+ return result;
180
+ } catch (error) {
181
+ setState({ data: null, loading: false, error });
182
+ throw error;
183
+ }
184
+ },
185
+ [sdk]
186
+ );
187
+ return { ...state, launch, reset: () => setState(idle()) };
188
+ }
189
+ function useCashier() {
190
+ const sdk = useCasino();
191
+ const [loading, setLoading] = react.useState(false);
192
+ const [error, setError] = react.useState(null);
193
+ const run = react.useCallback(async (op) => {
194
+ setLoading(true);
195
+ setError(null);
196
+ try {
197
+ return await op();
198
+ } catch (e) {
199
+ setError(e);
200
+ throw e;
201
+ } finally {
202
+ setLoading(false);
203
+ }
204
+ }, []);
205
+ return {
206
+ deposit: (input) => run(() => sdk.cashier.deposit(input)),
207
+ withdraw: (input) => run(() => sdk.cashier.withdraw(input)),
208
+ loading,
209
+ error
210
+ };
211
+ }
212
+
213
+ // src/core/env.ts
214
+ function isDevEnvironment() {
215
+ try {
216
+ return typeof process === "undefined" || process.env.NODE_ENV !== "production";
217
+ } catch {
218
+ return true;
219
+ }
220
+ }
221
+
222
+ // src/react/ext-hooks.ts
223
+ var ExtKindMismatchError = class extends Error {
224
+ constructor(message) {
225
+ super(message);
226
+ this.name = "ExtKindMismatchError";
227
+ }
228
+ };
229
+ async function assertActionKind(sdk, pluginKey, actionKey, expected, hook, alternative) {
230
+ if (!isDevEnvironment()) return;
231
+ let kind;
232
+ try {
233
+ const catalog = await sdk.ext.catalog();
234
+ kind = catalog.plugins.find((p) => p.pluginKey === pluginKey)?.actions.find((a) => a.key === actionKey)?.kind;
235
+ } catch {
236
+ return;
237
+ }
238
+ if (kind !== void 0 && kind !== expected) {
239
+ throw new ExtKindMismatchError(
240
+ `${hook}("${pluginKey}", "${actionKey}") resolved a ${kind} action; use ${alternative} instead.`
241
+ );
242
+ }
243
+ }
244
+ function useExtCatalog() {
245
+ const sdk = useCasino();
246
+ const [state, setState] = react.useState({
247
+ catalog: void 0,
248
+ status: "idle",
249
+ error: null
250
+ });
251
+ const mountedRef = react.useRef(true);
252
+ react.useEffect(() => {
253
+ mountedRef.current = true;
254
+ return () => {
255
+ mountedRef.current = false;
256
+ };
257
+ }, []);
258
+ const load = react.useCallback(
259
+ async (force) => {
260
+ setState((s) => ({ ...s, status: "loading", error: null }));
261
+ try {
262
+ const catalog = await sdk.ext.catalog(force ? { force: true } : void 0);
263
+ if (mountedRef.current) setState({ catalog, status: "success", error: null });
264
+ } catch (error) {
265
+ if (mountedRef.current) {
266
+ setState((s) => ({ catalog: s.catalog, status: "error", error }));
267
+ }
268
+ }
269
+ },
270
+ [sdk]
271
+ );
272
+ react.useEffect(() => {
273
+ void load(false);
274
+ }, [load]);
275
+ const refresh = react.useCallback(() => load(true), [load]);
276
+ return { ...state, refresh };
277
+ }
278
+ function useExtQuery(pluginKey, actionKey, input, opts) {
279
+ const sdk = useCasino();
280
+ const enabled = opts?.enabled ?? true;
281
+ const [state, setState] = react.useState({ data: void 0, status: "idle", error: null, guard: null });
282
+ if (state.guard) throw state.guard;
283
+ const mountedRef = react.useRef(true);
284
+ react.useEffect(() => {
285
+ mountedRef.current = true;
286
+ return () => {
287
+ mountedRef.current = false;
288
+ };
289
+ }, []);
290
+ const inputRef = react.useRef(input);
291
+ inputRef.current = input;
292
+ const inputKey = JSON.stringify(input === void 0 ? null : input);
293
+ const epochRef = react.useRef(0);
294
+ const refetch = react.useCallback(async () => {
295
+ const seq = ++epochRef.current;
296
+ const current = () => mountedRef.current && seq === epochRef.current;
297
+ setState((s) => ({ ...s, status: "loading", error: null }));
298
+ try {
299
+ await assertActionKind(sdk, pluginKey, actionKey, "query", "useExtQuery", "useExtAction");
300
+ const data = await sdk.ext(pluginKey).call(actionKey, inputRef.current);
301
+ if (current()) setState({ data, status: "success", error: null, guard: null });
302
+ } catch (error) {
303
+ if (!current()) return;
304
+ setState((s) => ({
305
+ data: s.data,
306
+ status: "error",
307
+ error,
308
+ guard: error instanceof ExtKindMismatchError ? error : null
309
+ }));
310
+ }
311
+ }, [sdk, pluginKey, actionKey, inputKey]);
312
+ react.useEffect(() => {
313
+ if (!enabled) return;
314
+ void refetch();
315
+ }, [refetch, enabled]);
316
+ const refetchOnKey = JSON.stringify(opts?.refetchOn ?? []);
317
+ react.useEffect(() => {
318
+ const triggers = JSON.parse(refetchOnKey);
319
+ if (!enabled || triggers.length === 0) return;
320
+ const offs = triggers.map((spec) => {
321
+ const colon = spec.indexOf(":");
322
+ const channel = colon === -1 ? spec : spec.slice(0, colon);
323
+ const eventType = colon === -1 ? void 0 : spec.slice(colon + 1);
324
+ return sdk.realtime.on(channel, (event) => {
325
+ if (!mountedRef.current) return;
326
+ const type = event.data?.type;
327
+ if (eventType === void 0 || type === eventType) void refetch();
328
+ });
329
+ });
330
+ return () => {
331
+ for (const off of offs) off();
332
+ };
333
+ }, [sdk, refetchOnKey, refetch, enabled]);
334
+ return { data: state.data, status: state.status, error: state.error, refetch };
335
+ }
336
+ function useExtAction(pluginKey, actionKey) {
337
+ const sdk = useCasino();
338
+ const [state, setState] = react.useState({ result: void 0, status: "idle", error: null, guard: null });
339
+ if (state.guard) throw state.guard;
340
+ const mutate = react.useCallback(
341
+ async (input, opts) => {
342
+ setState((s) => ({ ...s, status: "loading", error: null }));
343
+ try {
344
+ await assertActionKind(
345
+ sdk,
346
+ pluginKey,
347
+ actionKey,
348
+ "mutation",
349
+ "useExtAction",
350
+ "useExtQuery"
351
+ );
352
+ const result = await sdk.ext(pluginKey).call(actionKey, input, opts);
353
+ setState({ result, status: "success", error: null, guard: null });
354
+ return result;
355
+ } catch (error) {
356
+ setState((s) => ({
357
+ result: s.result,
358
+ status: "error",
359
+ error,
360
+ guard: error instanceof ExtKindMismatchError ? error : null
361
+ }));
362
+ throw error;
363
+ }
364
+ },
365
+ [sdk, pluginKey, actionKey]
366
+ );
367
+ return { mutate, status: state.status, error: state.error, result: state.result };
368
+ }
369
+
370
+ exports.CasinoProvider = CasinoProvider;
371
+ exports.useAuth = useAuth;
372
+ exports.useBalance = useBalance;
373
+ exports.useCashier = useCashier;
374
+ exports.useCasino = useCasino;
375
+ exports.useExtAction = useExtAction;
376
+ exports.useExtCatalog = useExtCatalog;
377
+ exports.useExtQuery = useExtQuery;
378
+ exports.useGame = useGame;
379
+ exports.useGameLaunch = useGameLaunch;
380
+ exports.useLobby = useLobby;
381
+ //# sourceMappingURL=index.cjs.map
382
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/react/context.ts","../../src/react/CasinoProvider.tsx","../../src/react/hooks.ts","../../src/core/env.ts","../../src/react/ext-hooks.ts"],"names":["createContext","useContext","createElement","useState","useCallback","useEffect","useRef"],"mappings":";;;;;AAMO,IAAM,aAAA,GAAgBA,oBAAmC,IAAI,CAAA;AAG7D,SAAS,SAAA,GAA0B;AACxC,EAAA,MAAM,MAAA,GAASC,iBAAW,aAAa,CAAA;AACvC,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,mDAAmD,CAAA;AAAA,EACrE;AACA,EAAA,OAAO,MAAA;AACT;;;ACEO,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,QAAA,EAAS,EAAwB;AACxE,EAAA,OAAOC,oBAAc,aAAA,CAAc,QAAA,EAAU,EAAE,KAAA,EAAO,MAAA,IAAU,QAAQ,CAAA;AAC1E;ACQA,IAAM,IAAA,GAAO,OAAyB,EAAE,IAAA,EAAM,MAAM,OAAA,EAAS,KAAA,EAAO,OAAO,IAAA,EAAK,CAAA;AAezE,SAAS,OAAA,GAAmB;AACjC,EAAA,MAAM,MAAM,SAAA,EAAU;AACtB,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIC,eAAiC,IAAI,CAAA;AAE/D,EAAA,MAAM,IAAA,GAAOC,kBAAY,YAAY;AACnC,IAAA,QAAA,CAAS,CAAC,OAAO,EAAE,GAAG,GAAG,OAAA,EAAS,IAAA,EAAM,KAAA,EAAO,IAAA,EAAK,CAAE,CAAA;AACtD,IAAA,IAAI;AACF,MAAA,MAAM,EAAA,GAAK,MAAM,GAAA,CAAI,IAAA,CAAK,EAAA,EAAG;AAC7B,MAAA,QAAA,CAAS,EAAE,IAAA,EAAM,EAAA,EAAI,SAAS,KAAA,EAAO,KAAA,EAAO,MAAM,CAAA;AAAA,IACpD,SAAS,KAAA,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,OAAO,KAAA,CAAM,KAAA,EAAO,MAAA,EAAQ,KAAA,CAAM,MAAA,EAAO;AAClF","file":"index.cjs","sourcesContent":["/**\n * React context carrying the shared {@link CasinoClient}.\n */\nimport { createContext, useContext } from \"react\";\nimport type { CasinoClient } from \"../client.js\";\n\nexport const CasinoContext = createContext<CasinoClient | null>(null);\n\n/** Access the SDK client provided by {@link CasinoProvider}. Throws if missing. */\nexport function useCasino(): CasinoClient {\n const client = useContext(CasinoContext);\n if (!client) {\n throw new Error(\"useCasino must be used within a <CasinoProvider>.\");\n }\n return client;\n}\n","/**\n * `<CasinoProvider>` — makes a {@link CasinoClient} available to the hooks.\n *\n * Construct the client once (e.g. in a module scope or a client component) and pass\n * it in. The provider itself renders nothing platform-specific, so it is safe in\n * Next.js client components. Keep it in a `\"use client\"` boundary because the hooks\n * use state/effects.\n */\nimport { createElement, type ReactNode } from \"react\";\nimport { CasinoContext } from \"./context.js\";\nimport type { CasinoClient } from \"../client.js\";\n\nexport interface CasinoProviderProps {\n client: CasinoClient;\n children: ReactNode;\n}\n\nexport function CasinoProvider({ client, children }: CasinoProviderProps) {\n return createElement(CasinoContext.Provider, { value: client }, children);\n}\n","/**\n * React hooks over the SDK. All HTTP hooks are SSR-safe (they fetch in effects and\n * render a stable initial state on the server). {@link useBalance} additionally\n * mounts the realtime client, which is client-only by construction (effects never\n * run during SSR/RSC).\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useCasino } from \"./context.js\";\nimport type {\n BalanceResponse,\n GamePage,\n Game,\n LaunchResult,\n LobbyQuery,\n LoginInput,\n MeResponse,\n DepositInput,\n WithdrawalInput,\n} from \"../types/http.js\";\nimport type { ConnectionState } from \"../realtime/contract.js\";\n\nexport interface AsyncState<T> {\n data: T | null;\n loading: boolean;\n error: Error | null;\n}\n\nconst idle = <T>(): AsyncState<T> => ({ data: null, loading: false, error: null });\n\n// ── useAuth ────────────────────────────────────────────────────────────────────\n\nexport interface UseAuth {\n player: MeResponse[\"player\"] | null;\n profile: MeResponse[\"profile\"] | null;\n loading: boolean;\n error: Error | null;\n login: (input: LoginInput) => Promise<void>;\n logout: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\n/** Auth state + actions. Loads `me()` once on mount to hydrate an existing session. */\nexport function useAuth(): UseAuth {\n const sdk = useCasino();\n const [state, setState] = useState<AsyncState<MeResponse>>(idle);\n\n const load = useCallback(async () => {\n setState((s) => ({ ...s, loading: true, error: null }));\n try {\n const me = await sdk.auth.me();\n setState({ data: me, loading: false, error: null });\n } catch (error) {\n setState({ data: null, loading: false, error: error as Error });\n }\n }, [sdk]);\n\n useEffect(() => {\n void load();\n }, [load]);\n\n // Mirrors load(): a rejected login (wrong password — the most common auth event)\n // must land in { error, loading:false }, never leave the hook stuck loading.\n const login = useCallback(\n async (input: LoginInput) => {\n setState((s) => ({ ...s, loading: true, error: null }));\n try {\n await sdk.auth.login(input);\n } catch (error) {\n setState((s) => ({ ...s, loading: false, error: error as Error }));\n return;\n }\n await load();\n },\n [sdk, load],\n );\n\n const logout = useCallback(async () => {\n await sdk.auth.logout();\n setState(idle());\n }, [sdk]);\n\n return {\n player: state.data?.player ?? null,\n profile: state.data?.profile ?? null,\n loading: state.loading,\n error: state.error,\n login,\n logout,\n refresh: load,\n };\n}\n\n// ── useBalance (live) ────────────────────────────────────────────────────────────\n\nexport interface UseBalance extends AsyncState<BalanceResponse> {\n connection: ConnectionState;\n reload: () => Promise<void>;\n}\n\n/**\n * Live balance: seeds from `wallet.getBalance()`, then subscribes to the realtime\n * `wallet.balance` channel and applies authoritative pushes. Reconnect re-sync\n * re-reads the balance so the UI never shows stale money. Pass `{ live: false }`\n * to skip the socket and just fetch once.\n */\nexport function useBalance(options?: { currency?: string; live?: boolean }): UseBalance {\n const sdk = useCasino();\n const live = options?.live ?? true;\n // Normalize once: the REST path uppercases via Session.resolveCurrency and\n // realtime events carry uppercase ISO codes — a lowercase option must not\n // silently kill the push filter below.\n const currency = options?.currency?.toUpperCase();\n const [state, setState] = useState<AsyncState<BalanceResponse>>(idle);\n const [connection, setConnection] = useState<ConnectionState>(\"idle\");\n const currentRef = useRef<BalanceResponse | null>(null);\n\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n // Monotonic epoch (same mechanism as useLobby/useExtQuery): a currency switch\n // fires overlapping getBalance calls — only the latest may write.\n const epochRef = useRef(0);\n\n const reload = useCallback(async () => {\n const seq = ++epochRef.current;\n const current = () => mountedRef.current && seq === epochRef.current;\n try {\n const bal = await sdk.wallet.getBalance(currency ? { currency } : undefined);\n if (!current()) return;\n currentRef.current = bal;\n setState({ data: bal, loading: false, error: null });\n } catch (error) {\n if (current()) setState((s) => ({ ...s, loading: false, error: error as Error }));\n }\n }, [sdk, currency]);\n\n useEffect(() => {\n let mounted = true;\n setState((s) => ({ ...s, loading: true }));\n void reload();\n if (!live) return;\n\n const offState = sdk.realtime.onStateChange((s) => {\n if (mounted) setConnection(s);\n });\n const offBalance = sdk.realtime.on(\"wallet.balance\", (event) => {\n if (!mounted) return;\n // A currency-scoped hook must ignore pushes for other currencies —\n // multi-currency wallets push one event per currency on the same channel.\n if (currency && event.data.currency.toUpperCase() !== currency) return;\n const prev = currentRef.current;\n // walletId/status are per-currency: never carry them across a currency\n // change (the unscoped hook tracks whichever currency pushed last).\n const sameWallet = prev?.currency === event.data.currency;\n const next: BalanceResponse = {\n playerId: prev?.playerId ?? sdk.getSession().player?.id ?? \"\",\n currency: event.data.currency,\n cash: event.data.balances.cash,\n bonus: event.data.balances.bonus,\n locked: event.data.balances.locked,\n total: event.data.balances.cash + event.data.balances.bonus + event.data.balances.locked,\n status: sameWallet ? (prev?.status ?? \"active\") : \"active\",\n walletId: sameWallet ? (prev?.walletId ?? null) : null,\n };\n currentRef.current = next;\n setState({ data: next, loading: false, error: null });\n });\n void sdk.realtime.connect().catch(() => {\n /* surfaced via onError; balance still works via reload() */\n });\n\n return () => {\n mounted = false;\n offState();\n offBalance();\n };\n }, [sdk, reload, live, currency]);\n\n return { ...state, connection, reload };\n}\n\n// ── useLobby ─────────────────────────────────────────────────────────────────────\n\nexport interface UseLobby extends AsyncState<GamePage> {\n reload: () => Promise<void>;\n}\n\n/** Fetch the lobby (geo/currency-aware) and re-fetch when the query changes. */\nexport function useLobby(query: LobbyQuery = {}): UseLobby {\n const sdk = useCasino();\n const [state, setState] = useState<AsyncState<GamePage>>(() => ({ ...idle(), loading: true }));\n const key = JSON.stringify(query);\n\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n // Monotonic epoch (same mechanism as useExtQuery): a query change or manual\n // reload fires overlapping requests, and network jitter can resolve them out of\n // order — only the latest may write, and never after unmount.\n const epochRef = useRef(0);\n\n const reload = useCallback(async () => {\n const seq = ++epochRef.current;\n const current = () => mountedRef.current && seq === epochRef.current;\n setState((s) => ({ ...s, loading: true, error: null }));\n try {\n const page = await sdk.catalog.lobby(JSON.parse(key) as LobbyQuery);\n if (current()) setState({ data: page, loading: false, error: null });\n } catch (error) {\n if (current()) setState({ data: null, loading: false, error: error as Error });\n }\n }, [sdk, key]);\n\n useEffect(() => {\n void reload();\n }, [reload]);\n\n return { ...state, reload };\n}\n\n// ── useGame ──────────────────────────────────────────────────────────────────────\n\nexport type UseGame = AsyncState<Game>;\n\n/** Fetch a single game's detail by id or slug. */\nexport function useGame(idOrSlug: string | null | undefined): UseGame {\n const sdk = useCasino();\n const [state, setState] = useState<AsyncState<Game>>(idle);\n\n useEffect(() => {\n if (!idOrSlug) {\n setState(idle());\n return;\n }\n let mounted = true;\n setState((s) => ({ ...s, loading: true, error: null }));\n sdk.catalog\n .game(idOrSlug)\n .then((game) => mounted && setState({ data: game, loading: false, error: null }))\n .catch((error) => mounted && setState({ data: null, loading: false, error: error as Error }));\n return () => {\n mounted = false;\n };\n }, [sdk, idOrSlug]);\n\n return state;\n}\n\n// ── useGameLaunch ────────────────────────────────────────────────────────────────\n\nexport interface UseGameLaunch extends AsyncState<LaunchResult> {\n launch: (\n provider: string,\n gameId: string,\n options?: { playerId?: string; currency?: string },\n ) => Promise<LaunchResult>;\n reset: () => void;\n}\n\n/**\n * Imperatively open a game session with a provider adapter\n * (`sdk.games.providerSession`); exposes the resulting `launchUrl` to render.\n * Provider adapters are registered per tenant in the runtime (built-in `\"fake\"`\n * for dev, or plugin-contributed).\n */\nexport function useGameLaunch(): UseGameLaunch {\n const sdk = useCasino();\n const [state, setState] = useState<AsyncState<LaunchResult>>(idle);\n\n const launch = useCallback(\n async (\n provider: string,\n gameId: string,\n options?: { playerId?: string; currency?: string },\n ) => {\n setState((s) => ({ ...s, loading: true, error: null }));\n try {\n const result = await sdk.games.providerSession(provider, gameId, options);\n setState({ data: result, loading: false, error: null });\n return result;\n } catch (error) {\n setState({ data: null, loading: false, error: error as Error });\n throw error;\n }\n },\n [sdk],\n );\n\n return { ...state, launch, reset: () => setState(idle()) };\n}\n\n// ── useCashier ───────────────────────────────────────────────────────────────────\n\nexport interface UseCashier {\n deposit: (input: DepositInput) => Promise<Awaited<ReturnType<CashierDeposit>>>;\n withdraw: (input: WithdrawalInput) => Promise<Awaited<ReturnType<CashierWithdraw>>>;\n loading: boolean;\n error: Error | null;\n}\ntype CashierDeposit = ReturnType<typeof useCasino>[\"cashier\"][\"deposit\"];\ntype CashierWithdraw = ReturnType<typeof useCasino>[\"cashier\"][\"withdraw\"];\n\n/** Deposit/withdraw actions with shared loading/error state. */\nexport function useCashier(): UseCashier {\n const sdk = useCasino();\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const run = useCallback(async <T>(op: () => Promise<T>): Promise<T> => {\n setLoading(true);\n setError(null);\n try {\n return await op();\n } catch (e) {\n setError(e as Error);\n throw e;\n } finally {\n setLoading(false);\n }\n }, []);\n\n return {\n deposit: (input) => run(() => sdk.cashier.deposit(input)),\n withdraw: (input) => run(() => sdk.cashier.withdraw(input)),\n loading,\n error,\n };\n}\n","/**\n * Build-environment detection for dev-only diagnostics (schema warnings,\n * deprecation notices, hook misuse guards).\n */\n\n/**\n * True outside production builds (`process.env.NODE_ENV !== \"production\"`).\n * Bundlers statically replace the env read; where no `process` global exists we\n * err on the dev side, matching React's convention.\n */\nexport function isDevEnvironment(): boolean {\n try {\n return typeof process === \"undefined\" || process.env.NODE_ENV !== \"production\";\n } catch {\n return true;\n }\n}\n","/**\n * React hooks over `sdk.ext` (plugin actions). SSR/RSC-safe like the core hooks:\n * they fetch in effects and render a stable initial state on the server; the\n * `refetchOn` realtime triggers register handlers only (client-side) and never\n * open the socket themselves — they are silently inactive until the app connects\n * `sdk.realtime`.\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useCasino } from \"./context.js\";\nimport { isDevEnvironment } from \"../core/env.js\";\nimport type { CasinoClient } from \"../client.js\";\nimport type { ExtCallOpts, ExtCatalog } from \"../types/ext.js\";\nimport type { RealtimeChannel } from \"../realtime/contract.js\";\n\n/** Lifecycle of an ext hook's request. */\nexport type ExtHookStatus = \"idle\" | \"loading\" | \"success\" | \"error\";\n\n/**\n * Dev-mode misuse guard: `useExtQuery` got a mutation action (or `useExtAction`\n * a query). Thrown during render so it surfaces loudly in development.\n */\nclass ExtKindMismatchError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ExtKindMismatchError\";\n }\n}\n\n/**\n * In dev, resolve the action's `kind` from the (cached) catalog and throw on a\n * hook/kind mismatch. A failed catalog lookup stays silent — the actual call\n * surfaces the real error.\n */\nasync function assertActionKind(\n sdk: CasinoClient,\n pluginKey: string,\n actionKey: string,\n expected: \"query\" | \"mutation\",\n hook: string,\n alternative: string,\n): Promise<void> {\n if (!isDevEnvironment()) return;\n let kind: \"query\" | \"mutation\" | undefined;\n try {\n const catalog = await sdk.ext.catalog();\n kind = catalog.plugins\n .find((p) => p.pluginKey === pluginKey)\n ?.actions.find((a) => a.key === actionKey)?.kind;\n } catch {\n return;\n }\n if (kind !== undefined && kind !== expected) {\n throw new ExtKindMismatchError(\n `${hook}(\"${pluginKey}\", \"${actionKey}\") resolved a ${kind} action; use ${alternative} instead.`,\n );\n }\n}\n\n// ── useExtCatalog ────────────────────────────────────────────────────────────────\n\nexport interface UseExtCatalog {\n catalog: ExtCatalog | undefined;\n status: ExtHookStatus;\n error: Error | null;\n /** Refetch the catalog unconditionally (`{ force: true }`). */\n refresh: () => Promise<void>;\n}\n\n/** The tenant's plugin catalog (cached by the SDK; see `sdk.ext.catalog`). */\nexport function useExtCatalog(): UseExtCatalog {\n const sdk = useCasino();\n const [state, setState] = useState<Omit<UseExtCatalog, \"refresh\">>({\n catalog: undefined,\n status: \"idle\",\n error: null,\n });\n\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n const load = useCallback(\n async (force: boolean) => {\n setState((s) => ({ ...s, status: \"loading\", error: null }));\n try {\n const catalog = await sdk.ext.catalog(force ? { force: true } : undefined);\n if (mountedRef.current) setState({ catalog, status: \"success\", error: null });\n } catch (error) {\n if (mountedRef.current) {\n setState((s) => ({ catalog: s.catalog, status: \"error\", error: error as Error }));\n }\n }\n },\n [sdk],\n );\n\n useEffect(() => {\n void load(false);\n }, [load]);\n\n const refresh = useCallback(() => load(true), [load]);\n\n return { ...state, refresh };\n}\n\n// ── useExtQuery ──────────────────────────────────────────────────────────────────\n\nexport interface UseExtQueryOptions {\n /** Skip fetching while false (default true). */\n enabled?: boolean;\n /**\n * Realtime triggers as `\"<channel>:<eventType>\"`\n * (e.g. `\"ext.cashback:cashback.accrued\"`); omit the `:<eventType>` part to\n * refetch on every event of the channel. Silently inactive while\n * `sdk.realtime` is not connected.\n */\n refetchOn?: string[];\n}\n\nexport interface UseExtQuery<T> {\n data: T | undefined;\n status: ExtHookStatus;\n error: Error | null;\n refetch: () => Promise<void>;\n}\n\n/** Run a `kind: \"query\"` plugin action and hold its result. */\nexport function useExtQuery<T = unknown>(\n pluginKey: string,\n actionKey: string,\n input?: unknown,\n opts?: UseExtQueryOptions,\n): UseExtQuery<T> {\n const sdk = useCasino();\n const enabled = opts?.enabled ?? true;\n const [state, setState] = useState<{\n data: T | undefined;\n status: ExtHookStatus;\n error: Error | null;\n guard: Error | null;\n }>({ data: undefined, status: \"idle\", error: null, guard: null });\n\n // Dev misuse (query hook on a mutation action) crashes the render, not the log.\n if (state.guard) throw state.guard;\n\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n // Track the input by value (JSON identity), not by reference, so inline\n // object literals don't refetch every render.\n const inputRef = useRef(input);\n inputRef.current = input;\n const inputKey = JSON.stringify(input === undefined ? null : input);\n\n // Monotonic epoch so an earlier-but-slower refetch can't overwrite the result\n // of a later one. `refetchOn` fires overlapping calls by design, and plain\n // network jitter can resolve them out of order; only the latest wins.\n const epochRef = useRef(0);\n\n const refetch = useCallback(async () => {\n const seq = ++epochRef.current;\n const current = () => mountedRef.current && seq === epochRef.current;\n setState((s) => ({ ...s, status: \"loading\", error: null }));\n try {\n await assertActionKind(sdk, pluginKey, actionKey, \"query\", \"useExtQuery\", \"useExtAction\");\n const data = await sdk.ext(pluginKey).call<T>(actionKey, inputRef.current);\n if (current()) setState({ data, status: \"success\", error: null, guard: null });\n } catch (error) {\n if (!current()) return;\n setState((s) => ({\n data: s.data,\n status: \"error\",\n error: error as Error,\n guard: error instanceof ExtKindMismatchError ? error : null,\n }));\n }\n // `inputKey` stands in for `input` by value (read via inputRef).\n }, [sdk, pluginKey, actionKey, inputKey]);\n\n useEffect(() => {\n if (!enabled) return;\n void refetch();\n }, [refetch, enabled]);\n\n const refetchOnKey = JSON.stringify(opts?.refetchOn ?? []);\n useEffect(() => {\n const triggers = JSON.parse(refetchOnKey) as string[];\n if (!enabled || triggers.length === 0) return;\n const offs = triggers.map((spec) => {\n const colon = spec.indexOf(\":\");\n const channel = (colon === -1 ? spec : spec.slice(0, colon)) as RealtimeChannel;\n const eventType = colon === -1 ? undefined : spec.slice(colon + 1);\n return sdk.realtime.on(channel, (event) => {\n if (!mountedRef.current) return;\n const type = (event as { data?: { type?: unknown } }).data?.type;\n if (eventType === undefined || type === eventType) void refetch();\n });\n });\n return () => {\n for (const off of offs) off();\n };\n }, [sdk, refetchOnKey, refetch, enabled]);\n\n return { data: state.data, status: state.status, error: state.error, refetch };\n}\n\n// ── useExtAction ─────────────────────────────────────────────────────────────────\n\nexport interface UseExtAction<T> {\n /** Run the mutation. Resolves with the action result; rejects and records the error on failure. */\n mutate: (input?: unknown, opts?: ExtCallOpts) => Promise<T>;\n status: ExtHookStatus;\n error: Error | null;\n result: T | undefined;\n}\n\n/** Imperatively run a `kind: \"mutation\"` plugin action. */\nexport function useExtAction<T = unknown>(pluginKey: string, actionKey: string): UseExtAction<T> {\n const sdk = useCasino();\n const [state, setState] = useState<{\n result: T | undefined;\n status: ExtHookStatus;\n error: Error | null;\n guard: Error | null;\n }>({ result: undefined, status: \"idle\", error: null, guard: null });\n\n // Dev misuse (action hook on a query action) crashes the render, not the log.\n if (state.guard) throw state.guard;\n\n const mutate = useCallback(\n async (input?: unknown, opts?: ExtCallOpts): Promise<T> => {\n setState((s) => ({ ...s, status: \"loading\", error: null }));\n try {\n await assertActionKind(\n sdk,\n pluginKey,\n actionKey,\n \"mutation\",\n \"useExtAction\",\n \"useExtQuery\",\n );\n const result = await sdk.ext(pluginKey).call<T>(actionKey, input, opts);\n setState({ result, status: \"success\", error: null, guard: null });\n return result;\n } catch (error) {\n setState((s) => ({\n result: s.result,\n status: \"error\",\n error: error as Error,\n guard: error instanceof ExtKindMismatchError ? error : null,\n }));\n throw error;\n }\n },\n [sdk, pluginKey, actionKey],\n );\n\n return { mutate, status: state.status, error: state.error, result: state.result };\n}\n"]}
@@ -0,0 +1,118 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { i as CasinoClient, an as MeResponse, al as LoginInput, B as BalanceResponse, v as DepositInput, bj as WithdrawalInput, T as Game, ac as LaunchResult, V as GamePage, ai as LobbyQuery, H as ExtCallOpts, I as ExtCatalog } from '../client-B3-Y0Xan.cjs';
4
+ import { a as ConnectionState } from '../contract-DtFe4bRy.cjs';
5
+
6
+ interface CasinoProviderProps {
7
+ client: CasinoClient;
8
+ children: ReactNode;
9
+ }
10
+ declare function CasinoProvider({ client, children }: CasinoProviderProps): react.FunctionComponentElement<react.ProviderProps<CasinoClient | null>>;
11
+
12
+ /** Access the SDK client provided by {@link CasinoProvider}. Throws if missing. */
13
+ declare function useCasino(): CasinoClient;
14
+
15
+ interface AsyncState<T> {
16
+ data: T | null;
17
+ loading: boolean;
18
+ error: Error | null;
19
+ }
20
+ interface UseAuth {
21
+ player: MeResponse["player"] | null;
22
+ profile: MeResponse["profile"] | null;
23
+ loading: boolean;
24
+ error: Error | null;
25
+ login: (input: LoginInput) => Promise<void>;
26
+ logout: () => Promise<void>;
27
+ refresh: () => Promise<void>;
28
+ }
29
+ /** Auth state + actions. Loads `me()` once on mount to hydrate an existing session. */
30
+ declare function useAuth(): UseAuth;
31
+ interface UseBalance extends AsyncState<BalanceResponse> {
32
+ connection: ConnectionState;
33
+ reload: () => Promise<void>;
34
+ }
35
+ /**
36
+ * Live balance: seeds from `wallet.getBalance()`, then subscribes to the realtime
37
+ * `wallet.balance` channel and applies authoritative pushes. Reconnect re-sync
38
+ * re-reads the balance so the UI never shows stale money. Pass `{ live: false }`
39
+ * to skip the socket and just fetch once.
40
+ */
41
+ declare function useBalance(options?: {
42
+ currency?: string;
43
+ live?: boolean;
44
+ }): UseBalance;
45
+ interface UseLobby extends AsyncState<GamePage> {
46
+ reload: () => Promise<void>;
47
+ }
48
+ /** Fetch the lobby (geo/currency-aware) and re-fetch when the query changes. */
49
+ declare function useLobby(query?: LobbyQuery): UseLobby;
50
+ type UseGame = AsyncState<Game>;
51
+ /** Fetch a single game's detail by id or slug. */
52
+ declare function useGame(idOrSlug: string | null | undefined): UseGame;
53
+ interface UseGameLaunch extends AsyncState<LaunchResult> {
54
+ launch: (provider: string, gameId: string, options?: {
55
+ playerId?: string;
56
+ currency?: string;
57
+ }) => Promise<LaunchResult>;
58
+ reset: () => void;
59
+ }
60
+ /**
61
+ * Imperatively open a game session with a provider adapter
62
+ * (`sdk.games.providerSession`); exposes the resulting `launchUrl` to render.
63
+ * Provider adapters are registered per tenant in the runtime (built-in `"fake"`
64
+ * for dev, or plugin-contributed).
65
+ */
66
+ declare function useGameLaunch(): UseGameLaunch;
67
+ interface UseCashier {
68
+ deposit: (input: DepositInput) => Promise<Awaited<ReturnType<CashierDeposit>>>;
69
+ withdraw: (input: WithdrawalInput) => Promise<Awaited<ReturnType<CashierWithdraw>>>;
70
+ loading: boolean;
71
+ error: Error | null;
72
+ }
73
+ type CashierDeposit = ReturnType<typeof useCasino>["cashier"]["deposit"];
74
+ type CashierWithdraw = ReturnType<typeof useCasino>["cashier"]["withdraw"];
75
+ /** Deposit/withdraw actions with shared loading/error state. */
76
+ declare function useCashier(): UseCashier;
77
+
78
+ /** Lifecycle of an ext hook's request. */
79
+ type ExtHookStatus = "idle" | "loading" | "success" | "error";
80
+ interface UseExtCatalog {
81
+ catalog: ExtCatalog | undefined;
82
+ status: ExtHookStatus;
83
+ error: Error | null;
84
+ /** Refetch the catalog unconditionally (`{ force: true }`). */
85
+ refresh: () => Promise<void>;
86
+ }
87
+ /** The tenant's plugin catalog (cached by the SDK; see `sdk.ext.catalog`). */
88
+ declare function useExtCatalog(): UseExtCatalog;
89
+ interface UseExtQueryOptions {
90
+ /** Skip fetching while false (default true). */
91
+ enabled?: boolean;
92
+ /**
93
+ * Realtime triggers as `"<channel>:<eventType>"`
94
+ * (e.g. `"ext.cashback:cashback.accrued"`); omit the `:<eventType>` part to
95
+ * refetch on every event of the channel. Silently inactive while
96
+ * `sdk.realtime` is not connected.
97
+ */
98
+ refetchOn?: string[];
99
+ }
100
+ interface UseExtQuery<T> {
101
+ data: T | undefined;
102
+ status: ExtHookStatus;
103
+ error: Error | null;
104
+ refetch: () => Promise<void>;
105
+ }
106
+ /** Run a `kind: "query"` plugin action and hold its result. */
107
+ declare function useExtQuery<T = unknown>(pluginKey: string, actionKey: string, input?: unknown, opts?: UseExtQueryOptions): UseExtQuery<T>;
108
+ interface UseExtAction<T> {
109
+ /** Run the mutation. Resolves with the action result; rejects and records the error on failure. */
110
+ mutate: (input?: unknown, opts?: ExtCallOpts) => Promise<T>;
111
+ status: ExtHookStatus;
112
+ error: Error | null;
113
+ result: T | undefined;
114
+ }
115
+ /** Imperatively run a `kind: "mutation"` plugin action. */
116
+ declare function useExtAction<T = unknown>(pluginKey: string, actionKey: string): UseExtAction<T>;
117
+
118
+ export { type AsyncState, CasinoProvider, type CasinoProviderProps, type ExtHookStatus, type UseAuth, type UseBalance, type UseCashier, type UseExtAction, type UseExtCatalog, type UseExtQuery, type UseExtQueryOptions, type UseGame, type UseGameLaunch, type UseLobby, useAuth, useBalance, useCashier, useCasino, useExtAction, useExtCatalog, useExtQuery, useGame, useGameLaunch, useLobby };