@idosgames/core 0.26.4 → 0.26.6

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.
@@ -1,2 +1,449 @@
1
- export { K as KeyValueStorage, P as PlatformAdapter } from '../PlatformAdapter-DU_8HalI.js';
2
- export { B as BrowserPlatformAdapter, a as BrowserStorage, M as MemoryStorage, N as NoopPlatformAdapter, P as PLATFORM_BRIDGE_ACK, b as PLATFORM_CREDITS_CONFIRM_MESSAGES, c as PLATFORM_ORIGINS, d as PLATFORM_PAGE_UNAVAILABLE, e as PLATFORM_SIGN_IN_MESSAGES, f as PLATFORM_TOPUP_MESSAGES, g as PlatformCreditsConfirmResult, h as PlatformPageAnswer, i as PlatformSignInAnswer, j as PlatformTopUpRequest, k as PlatformTopUpResult, T as TelegramInitDataUnsafe, l as TelegramWebApp, m as askPlatformPage, n as canPayWithPlatformCredits, o as canUsePlatformCreditsConfirm, p as canUsePlatformSignIn, q as canUsePlatformTopUp, s as clearPlatformSignInDeclined, z as getTelegramWebApp, t as isPlatformParentOrigin, u as isPlatformSignInDeclined, v as markPlatformSignInDeclined, w as requestPlatformCreditsConfirm, x as requestPlatformSignIn, y as requestPlatformTopUp } from '../index-YNXpT5ol.js';
1
+ import { G as GameHost, d as HostCapabilities, K as KeyValueStorage, h as HostFileStore, C as ClientPlatform, o as HostSignInAnswer, b as HostAdRequest, c as HostAdResult, e as HostCreditsConfirmRequest, l as HostResult, u as HostTopUpRequest, q as HostStorePurchaseRequest, r as HostStorePurchaseResult, s as HostStoreReceipt, i as HostPickFilesRequest, f as HostFile, k as HostPushTokenRequest, j as HostPushToken, n as HostShareRequest, m as HostShareOutcome, g as HostFileOutcome, w as HostWorkerOptions, v as HostUnsubscribe, t as HostStoredFileInfo } from '../GameHost-xACJW0x5.js';
2
+ export { H as HostAdProvider, p as HostStore, x as shareFallbackText } from '../GameHost-xACJW0x5.js';
3
+ import 'zod';
4
+
5
+ declare abstract class BaseHost implements GameHost {
6
+ abstract readonly id: string;
7
+ abstract readonly supports: HostCapabilities;
8
+ readonly storage: KeyValueStorage;
9
+ readonly files: HostFileStore;
10
+ private visible;
11
+ private readonly visibilityListeners;
12
+ private readonly linkListeners;
13
+ protected constructor(storage: KeyValueStorage, files?: HostFileStore);
14
+ abstract getPlatform(): string;
15
+ abstract getClientPlatform(): ClientPlatform;
16
+ abstract getFullURL(): string;
17
+ abstract getStartParameter(): string | null;
18
+ abstract getReferrer(): string | null;
19
+ abstract getTelegramInitDataRaw(): string | null;
20
+ abstract getDeviceModel(): string;
21
+ abstract getLanguage(): string;
22
+ abstract signIn(titleID: string): Promise<HostSignInAnswer>;
23
+ abstract showRewardedAd(request: HostAdRequest): Promise<HostAdResult>;
24
+ abstract confirmCredits(request: HostCreditsConfirmRequest): Promise<HostResult>;
25
+ abstract topUp(request: HostTopUpRequest): Promise<HostResult>;
26
+ /** No store here: every host except a creator's native app. */
27
+ buyProduct(_request: HostStorePurchaseRequest): Promise<HostStorePurchaseResult>;
28
+ finishPurchase(_receipt: HostStoreReceipt, _consumable: boolean): Promise<boolean>;
29
+ pendingPurchases(): Promise<HostStoreReceipt[]>;
30
+ /** No file picker here (tests, the server); browser-engine hosts override it. */
31
+ pickFiles(_request?: HostPickFilesRequest): Promise<HostFile[]>;
32
+ /** No device push here: every host except a native app with its own push service. */
33
+ requestPushToken(_request: HostPushTokenRequest): Promise<HostPushToken>;
34
+ abstract openInvoice(url: string): void;
35
+ abstract openUrl(url: string): void;
36
+ abstract share(request: HostShareRequest): Promise<HostShareOutcome>;
37
+ abstract shareFile(file: HostFile): Promise<HostFileOutcome>;
38
+ abstract copyText(text: string): Promise<boolean>;
39
+ abstract vibrate(pattern: number | readonly number[]): void;
40
+ abstract createWorker(url: string, options?: HostWorkerOptions): Worker | null;
41
+ getDeviceID(): string;
42
+ /** A fresh installation id (a host that knows its own overrides this). */
43
+ protected newDeviceID(): string;
44
+ setSignInDeclined(titleID: string, declined: boolean): void;
45
+ isSignInDeclined(titleID: string): boolean;
46
+ isVisible(): boolean;
47
+ onVisibilityChange(listener: (visible: boolean) => void): HostUnsubscribe;
48
+ onLinkOpened(listener: (url: string) => void): HostUnsubscribe;
49
+ /** The implementation reports a link that opened the running game. */
50
+ protected emitLink(url: string): void;
51
+ /** The implementation reports a change; listeners hear only real changes. */
52
+ protected setVisible(visible: boolean): void;
53
+ }
54
+
55
+ /**
56
+ * Sent by the site's feed to the game's frame when the card goes behind another tab or comes back
57
+ * (`GameFeedCard` in iDosGames_com: `{ type, hidden }`). Shared with the site: keep in step.
58
+ */
59
+ declare const SITE_FRAME_HIDDEN_MESSAGE = "IDOS_APP_FRAME_HIDDEN";
60
+ declare class WebHost extends BaseHost {
61
+ readonly id: string;
62
+ readonly supports: HostCapabilities;
63
+ private hiddenBySite;
64
+ private documentHidden;
65
+ constructor(storage?: KeyValueStorage);
66
+ private watchVisibility;
67
+ private update;
68
+ getPlatform(): string;
69
+ getClientPlatform(): ClientPlatform;
70
+ getFullURL(): string;
71
+ getStartParameter(): string | null;
72
+ getReferrer(): string | null;
73
+ getTelegramInitDataRaw(): string | null;
74
+ getDeviceModel(): string;
75
+ getLanguage(): string;
76
+ signIn(titleID: string): Promise<HostSignInAnswer>;
77
+ showRewardedAd(request: HostAdRequest): Promise<HostAdResult>;
78
+ confirmCredits(request: HostCreditsConfirmRequest): Promise<HostResult>;
79
+ topUp(request: HostTopUpRequest): Promise<HostResult>;
80
+ openInvoice(url: string): void;
81
+ openUrl(url: string): void;
82
+ share(request: HostShareRequest): Promise<HostShareOutcome>;
83
+ pickFiles(request?: HostPickFilesRequest): Promise<HostFile[]>;
84
+ shareFile(file: HostFile): Promise<HostFileOutcome>;
85
+ copyText(text: string): Promise<boolean>;
86
+ vibrate(pattern: number | readonly number[]): void;
87
+ createWorker(url: string, options?: HostWorkerOptions): Worker | null;
88
+ }
89
+
90
+ /** Protocol version this SDK speaks. */
91
+ declare const NATIVE_HOST_PROTOCOL = 1;
92
+ /** Name of the global the native shell installs. */
93
+ declare const NATIVE_HOST_GLOBAL = "__IDOS_HOST__";
94
+ /** Launch facts the shell knows before the game starts. */
95
+ interface NativeHostInfo {
96
+ deviceId?: string;
97
+ deviceModel?: string;
98
+ language?: string;
99
+ launchUrl?: string;
100
+ startParameter?: string | null;
101
+ /** The game starts visible unless the shell says otherwise. */
102
+ visible?: boolean;
103
+ }
104
+ /** What the shell installs at `globalThis.__IDOS_HOST__`. */
105
+ interface NativeHostGlobal {
106
+ protocol: number;
107
+ id?: string;
108
+ clientPlatform?: string;
109
+ capabilities?: Partial<Record<keyof HostCapabilities, boolean>>;
110
+ info?: NativeHostInfo;
111
+ post(message: string): void;
112
+ /** Set by the SDK: the shell calls it with each message. */
113
+ receive?: (message: string) => void;
114
+ }
115
+ /** Request methods: params → result. */
116
+ interface NativeHostMethods {
117
+ signIn: {
118
+ params: {
119
+ titleID: string;
120
+ };
121
+ result: {
122
+ code?: string;
123
+ ticket?: string;
124
+ };
125
+ };
126
+ showRewardedAd: {
127
+ params: HostAdRequest;
128
+ result: {
129
+ via?: "ad" | "unit";
130
+ };
131
+ };
132
+ confirmCredits: {
133
+ params: HostCreditsConfirmRequest;
134
+ result: Record<string, never>;
135
+ };
136
+ topUp: {
137
+ params: HostTopUpRequest;
138
+ result: Record<string, never>;
139
+ };
140
+ openInvoice: {
141
+ params: {
142
+ url: string;
143
+ };
144
+ result: Record<string, never>;
145
+ };
146
+ openUrl: {
147
+ params: {
148
+ url: string;
149
+ };
150
+ result: Record<string, never>;
151
+ };
152
+ share: {
153
+ params: HostShareRequest;
154
+ result: {
155
+ outcome: HostShareOutcome;
156
+ };
157
+ };
158
+ /** The file's bytes travel as base64 (`data`). */
159
+ shareFile: {
160
+ params: {
161
+ name: string;
162
+ mime: string;
163
+ data: string;
164
+ };
165
+ result: {
166
+ outcome: HostFileOutcome;
167
+ };
168
+ };
169
+ copyText: {
170
+ params: {
171
+ text: string;
172
+ };
173
+ result: Record<string, never>;
174
+ };
175
+ vibrate: {
176
+ params: {
177
+ pattern: number[];
178
+ };
179
+ result: Record<string, never>;
180
+ };
181
+ /** The store's purchase window (`storePurchases`). Errors: `CANCELLED`, `PENDING`, `ALREADY_OWNED`, … */
182
+ buyProduct: {
183
+ params: HostStorePurchaseRequest;
184
+ result: {
185
+ receipt: HostStoreReceipt;
186
+ };
187
+ };
188
+ /** Consume / acknowledge after the server granted. */
189
+ finishPurchase: {
190
+ params: {
191
+ receipt: HostStoreReceipt;
192
+ consumable: boolean;
193
+ };
194
+ result: Record<string, never>;
195
+ };
196
+ /** Paid, not closed purchases. */
197
+ pendingPurchases: {
198
+ params: Record<string, never>;
199
+ result: {
200
+ receipts: HostStoreReceipt[];
201
+ };
202
+ };
203
+ /**
204
+ * The device's push token (`pushNotifications`); `prompt` asks for permission. Errors: `NOT_GRANTED`, `BLOCKED`,
205
+ * `UNAVAILABLE`.
206
+ */
207
+ requestPushToken: {
208
+ params: {
209
+ prompt: boolean;
210
+ };
211
+ result: {
212
+ token: string;
213
+ transport?: "Fcm" | "Apns";
214
+ };
215
+ };
216
+ }
217
+ type NativeHostMethod = keyof NativeHostMethods;
218
+ /** Events the shell sends. */
219
+ interface NativeHostEvents {
220
+ /** The game went on / off screen (app to background, the feed scrolled away). */
221
+ visibility: {
222
+ visible: boolean;
223
+ };
224
+ /** A link opened the running game (an app link, a notification's link). */
225
+ link: {
226
+ url: string;
227
+ };
228
+ }
229
+ interface NativeRequestMessage {
230
+ v: number;
231
+ kind: "request";
232
+ id: string;
233
+ method: NativeHostMethod;
234
+ params: unknown;
235
+ }
236
+ interface NativeResponseMessage {
237
+ v: number;
238
+ kind: "response";
239
+ id: string;
240
+ ok: boolean;
241
+ result?: unknown;
242
+ error?: string;
243
+ }
244
+ interface NativeEventMessage {
245
+ v: number;
246
+ kind: "event";
247
+ name: string;
248
+ data?: unknown;
249
+ }
250
+ /** The shell's global, when this page runs inside a native shell of a protocol this SDK speaks. */
251
+ declare function readNativeHostGlobal(): NativeHostGlobal | null;
252
+
253
+ declare class NativeHost extends BaseHost {
254
+ readonly id: string;
255
+ readonly supports: HostCapabilities;
256
+ private readonly shell;
257
+ private readonly pending;
258
+ private nextId;
259
+ constructor(shell: NativeHostGlobal, storage?: KeyValueStorage);
260
+ private receive;
261
+ /** One request to the shell. Never rejects. */
262
+ private request;
263
+ /** Fire and forget: the answer only matters to the shell. */
264
+ private notify;
265
+ protected newDeviceID(): string;
266
+ getPlatform(): string;
267
+ getClientPlatform(): ClientPlatform;
268
+ getFullURL(): string;
269
+ getStartParameter(): string | null;
270
+ getReferrer(): string | null;
271
+ getTelegramInitDataRaw(): string | null;
272
+ getDeviceModel(): string;
273
+ getLanguage(): string;
274
+ signIn(titleID: string): Promise<HostSignInAnswer>;
275
+ showRewardedAd(request: HostAdRequest): Promise<HostAdResult>;
276
+ confirmCredits(request: HostCreditsConfirmRequest): Promise<HostResult>;
277
+ topUp(request: HostTopUpRequest): Promise<HostResult>;
278
+ openInvoice(url: string): void;
279
+ buyProduct(request: HostStorePurchaseRequest): Promise<HostStorePurchaseResult>;
280
+ finishPurchase(receipt: HostStoreReceipt, consumable: boolean): Promise<boolean>;
281
+ pendingPurchases(): Promise<HostStoreReceipt[]>;
282
+ requestPushToken(request: HostPushTokenRequest): Promise<HostPushToken>;
283
+ openUrl(url: string): void;
284
+ share(request: HostShareRequest): Promise<HostShareOutcome>;
285
+ pickFiles(request?: HostPickFilesRequest): Promise<HostFile[]>;
286
+ shareFile(file: HostFile): Promise<HostFileOutcome>;
287
+ copyText(text: string): Promise<boolean>;
288
+ vibrate(pattern: number | readonly number[]): void;
289
+ createWorker(url: string, options?: HostWorkerOptions): Worker | null;
290
+ }
291
+
292
+ interface MemoryHostOptions {
293
+ storage?: KeyValueStorage;
294
+ supports?: Partial<HostCapabilities>;
295
+ clientPlatform?: ClientPlatform;
296
+ deviceId?: string;
297
+ }
298
+ declare class MemoryHost extends BaseHost {
299
+ readonly id = "memory";
300
+ readonly supports: HostCapabilities;
301
+ private readonly clientPlatform;
302
+ private readonly deviceId;
303
+ constructor(options?: MemoryHostOptions | KeyValueStorage);
304
+ /** Lets a test drive the pause signal. */
305
+ setVisibleForTest(visible: boolean): void;
306
+ protected newDeviceID(): string;
307
+ getPlatform(): string;
308
+ getClientPlatform(): ClientPlatform;
309
+ getFullURL(): string;
310
+ getStartParameter(): string | null;
311
+ getReferrer(): string | null;
312
+ getTelegramInitDataRaw(): string | null;
313
+ getDeviceModel(): string;
314
+ getLanguage(): string;
315
+ signIn(): Promise<HostSignInAnswer>;
316
+ showRewardedAd(): Promise<HostAdResult>;
317
+ confirmCredits(): Promise<HostResult>;
318
+ topUp(): Promise<HostResult>;
319
+ openInvoice(): void;
320
+ openUrl(): void;
321
+ share(): Promise<HostShareOutcome>;
322
+ shareFile(): Promise<HostFileOutcome>;
323
+ copyText(): Promise<boolean>;
324
+ vibrate(): void;
325
+ createWorker(): Worker | null;
326
+ }
327
+
328
+ /**
329
+ * The host of this page, decided once when the client is created: a native shell that installed
330
+ * `__IDOS_HOST__` → `NativeHost`; a browser → `WebHost`; neither (SSR, a worker) → `MemoryHost`.
331
+ */
332
+ declare function createDefaultHost(): GameHost;
333
+
334
+ /** localStorage-backed key/value store (replaces Unity PlayerPrefs). Fails soft. */
335
+ declare class BrowserStorage implements KeyValueStorage {
336
+ getString(key: string): string | null;
337
+ setString(key: string, value: string): void;
338
+ remove(key: string): void;
339
+ }
340
+ /** In-memory store for tests / SSR. */
341
+ declare class MemoryStorage implements KeyValueStorage {
342
+ private readonly map;
343
+ getString(key: string): string | null;
344
+ setString(key: string, value: string): void;
345
+ remove(key: string): void;
346
+ }
347
+
348
+ /** Files in memory: tests, the server, a page without IndexedDB. */
349
+ declare class MemoryFileStore implements HostFileStore {
350
+ private readonly map;
351
+ read(key: string): Promise<Uint8Array | null>;
352
+ write(key: string, bytes: Uint8Array): Promise<boolean>;
353
+ remove(key: string): Promise<void>;
354
+ list(prefix?: string): Promise<HostStoredFileInfo[]>;
355
+ }
356
+ /** Files in IndexedDB of this address; memory when IndexedDB is not there or refuses. */
357
+ declare class BrowserFileStore implements HostFileStore {
358
+ private db;
359
+ private readonly fallback;
360
+ private open;
361
+ private store;
362
+ read(key: string): Promise<Uint8Array | null>;
363
+ write(key: string, bytes: Uint8Array): Promise<boolean>;
364
+ remove(key: string): Promise<void>;
365
+ list(prefix?: string): Promise<HostStoredFileInfo[]>;
366
+ }
367
+
368
+ interface TelegramInitDataUnsafe {
369
+ start_param?: string;
370
+ [key: string]: unknown;
371
+ }
372
+ interface TelegramWebApp {
373
+ platform?: string;
374
+ initData?: string;
375
+ initDataUnsafe?: TelegramInitDataUnsafe;
376
+ openTelegramLink?: (url: string) => void;
377
+ openInvoice?: (url: string, callback?: (status: string) => void) => void;
378
+ }
379
+ declare function getTelegramWebApp(): TelegramWebApp | null;
380
+
381
+ declare const PLATFORM_ORIGINS: readonly string[];
382
+ /**
383
+ * Is `origin` the platform page that framed us — including the local stand?
384
+ *
385
+ * The local allowance is deliberately symmetric: a localhost parent is accepted ONLY while this
386
+ * game is itself served from localhost. A shipped build lives on `{id}.idos.games`, so it answers
387
+ * nothing but the real site — a page on the player's own machine cannot ask it for anything.
388
+ * That is what makes the allowance safe enough to ship, instead of a build-time flag that has to
389
+ * survive four bundlers.
390
+ *
391
+ * On the AI Coder's preview host the parent is the dashboard, and only the dashboard.
392
+ *
393
+ * Use this for bridges a game exposes to its parent. A bridge that must NOT widen its existing
394
+ * behaviour (the wallet's) keeps checking {@link PLATFORM_ORIGINS} directly.
395
+ */
396
+ declare function isPlatformParentOrigin(origin: string): boolean;
397
+
398
+ /** Sent by the site the moment it receives any bridge request. Shared with the site — keep in step. */
399
+ declare const PLATFORM_BRIDGE_ACK = "IDOS_PLATFORM_WALLET_ACK";
400
+ /**
401
+ * The page around the game did not answer at all — an old site build without the bridge, or a
402
+ * parent that is not the platform. The value is the wallet bridge's historical one, kept as is.
403
+ */
404
+ declare const PLATFORM_PAGE_UNAVAILABLE = "PLATFORM_WALLET_UNAVAILABLE";
405
+ interface PlatformPageAnswer {
406
+ ok: boolean;
407
+ error?: string;
408
+ /** The answer message as the site sent it — the caller reads its own fields from here. */
409
+ data: Record<string, unknown>;
410
+ }
411
+ /**
412
+ * Posts `type` with `payload` to the parent page and resolves with its `responseType` answer.
413
+ * Never rejects: silence, a foreign origin and a refusal all resolve to `{ ok: false }` with a reason.
414
+ */
415
+ declare function askPlatformPage(type: string, responseType: string, payload: Record<string, unknown>, options?: {
416
+ answerTimeoutMs?: number;
417
+ }): Promise<PlatformPageAnswer>;
418
+
419
+ /** Message names. Shared with the website's `PlatformWebGLAuthBridge` — keep both in step. */
420
+ declare const PLATFORM_SIGN_IN_MESSAGES: {
421
+ readonly request: "IDOS_PLATFORM_AUTH_REQUEST";
422
+ readonly response: "IDOS_PLATFORM_AUTH_RESPONSE";
423
+ };
424
+
425
+ /** Message names. Shared with the website's `GameWalletLoginBridge` — keep both in step. */
426
+ declare const PLATFORM_TOPUP_MESSAGES: {
427
+ readonly request: "IDOS_PLATFORM_TOPUP_REQUEST";
428
+ readonly response: "IDOS_PLATFORM_TOPUP_RESPONSE";
429
+ };
430
+
431
+ /** Message names. Shared with the website's `GameCreditsConfirmBridge` — keep both in step. */
432
+ declare const PLATFORM_CREDITS_CONFIRM_MESSAGES: {
433
+ readonly request: "IDOS_PLATFORM_CREDITS_CONFIRM_REQUEST";
434
+ readonly response: "IDOS_PLATFORM_CREDITS_CONFIRM_RESPONSE";
435
+ };
436
+ /**
437
+ * Refusals after which the player already decided — do NOT fall back to the confirmation page.
438
+ * Anything else (`PLATFORM_WALLET_UNAVAILABLE`, `NOT_SIGNED_IN`, `ACCOUNT_MISMATCH`, `BUSY`, …) means "the site
439
+ * could not ask" and the game falls back to the link.
440
+ */
441
+ declare const PLATFORM_CREDITS_CONFIRM_FINAL: readonly ["DECLINED", "NOT_ENOUGH_CREDITS"];
442
+
443
+ /** Message names. Shared with the website's `GameAdBridge`: keep both in step. */
444
+ declare const PLATFORM_AD_MESSAGES: {
445
+ readonly request: "IDOS_PLATFORM_AD_REQUEST";
446
+ readonly response: "IDOS_PLATFORM_AD_RESPONSE";
447
+ };
448
+
449
+ export { BrowserFileStore, BrowserStorage, GameHost, HostAdRequest, HostAdResult, HostCapabilities, HostCreditsConfirmRequest, HostFile, HostFileOutcome, HostFileStore, HostPickFilesRequest, HostPushToken, HostPushTokenRequest, HostResult, HostShareOutcome, HostShareRequest, HostSignInAnswer, HostStorePurchaseRequest, HostStorePurchaseResult, HostStoreReceipt, HostStoredFileInfo, HostTopUpRequest, HostUnsubscribe, HostWorkerOptions, KeyValueStorage, MemoryFileStore, MemoryHost, type MemoryHostOptions, MemoryStorage, NATIVE_HOST_GLOBAL, NATIVE_HOST_PROTOCOL, type NativeEventMessage, NativeHost, type NativeHostEvents, type NativeHostGlobal, type NativeHostInfo, type NativeHostMethod, type NativeHostMethods, type NativeRequestMessage, type NativeResponseMessage, PLATFORM_AD_MESSAGES, PLATFORM_BRIDGE_ACK, PLATFORM_CREDITS_CONFIRM_FINAL, PLATFORM_CREDITS_CONFIRM_MESSAGES, PLATFORM_ORIGINS, PLATFORM_PAGE_UNAVAILABLE, PLATFORM_SIGN_IN_MESSAGES, PLATFORM_TOPUP_MESSAGES, type PlatformPageAnswer, SITE_FRAME_HIDDEN_MESSAGE, type TelegramInitDataUnsafe, type TelegramWebApp, WebHost, askPlatformPage, createDefaultHost, getTelegramWebApp, isPlatformParentOrigin, readNativeHostGlobal };
@@ -1 +1 @@
1
- export{e as BrowserPlatformAdapter,a as BrowserStorage,b as MemoryStorage,y as NoopPlatformAdapter,h as PLATFORM_BRIDGE_ACK,u as PLATFORM_CREDITS_CONFIRM_MESSAGES,f as PLATFORM_ORIGINS,i as PLATFORM_PAGE_UNAVAILABLE,k as PLATFORM_SIGN_IN_MESSAGES,r as PLATFORM_TOPUP_MESSAGES,j as askPlatformPage,v as canPayWithPlatformCredits,w as canUsePlatformCreditsConfirm,l as canUsePlatformSignIn,s as canUsePlatformTopUp,p as clearPlatformSignInDeclined,c as getTelegramWebApp,g as isPlatformParentOrigin,q as isPlatformSignInDeclined,o as markPlatformSignInDeclined,x as requestPlatformCreditsConfirm,n as requestPlatformSignIn,t as requestPlatformTopUp}from'../chunk-4VTWZXB4.js';
1
+ export{c as BrowserFileStore,d as BrowserStorage,b as MemoryFileStore,s as MemoryHost,e as MemoryStorage,v as NATIVE_HOST_GLOBAL,u as NATIVE_HOST_PROTOCOL,x as NativeHost,G as PLATFORM_AD_MESSAGES,B as PLATFORM_BRIDGE_ACK,I as PLATFORM_CREDITS_CONFIRM_FINAL,H as PLATFORM_CREDITS_CONFIRM_MESSAGES,z as PLATFORM_ORIGINS,C as PLATFORM_PAGE_UNAVAILABLE,E as PLATFORM_SIGN_IN_MESSAGES,F as PLATFORM_TOPUP_MESSAGES,J as SITE_FRAME_HIDDEN_MESSAGE,K as WebHost,D as askPlatformPage,L as createDefaultHost,y as getTelegramWebApp,A as isPlatformParentOrigin,w as readNativeHostGlobal,t as shareFallbackText}from'../chunk-YZ32MQXQ.js';
@@ -1,7 +1,7 @@
1
- import { I as IceServer } from '../VoiceController-BBp83r66.cjs';
2
- export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-BBp83r66.cjs';
1
+ import { I as IceServer } from '../VoiceController-BWb8NTp2.cjs';
2
+ export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-BWb8NTp2.cjs';
3
3
  import 'zod';
4
- import '../PlatformAdapter-DU_8HalI.cjs';
4
+ import '../GameHost-xACJW0x5.cjs';
5
5
  import 'decimal.js';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
- import { I as IceServer } from '../VoiceController-ClaEESTz.js';
2
- export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-ClaEESTz.js';
1
+ import { I as IceServer } from '../VoiceController-BMXi4MNo.js';
2
+ export { C as ChannelName, M as MemberLeftKind, a as MicMode, R as RealtimeClient, b as RealtimeSession, c as RealtimeSessionEvents, d as RealtimeSessionOptions, V as VoiceController, e as VoiceControllerEvents, f as VoiceControllerOptions } from '../VoiceController-BMXi4MNo.js';
3
3
  import 'zod';
4
- import '../PlatformAdapter-DU_8HalI.js';
4
+ import '../GameHost-xACJW0x5.js';
5
5
  import 'decimal.js';
6
6
 
7
7
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idosgames/core",
3
- "version": "0.26.4",
3
+ "version": "0.26.6",
4
4
  "description": "Engine-agnostic core of the IDosGames SDK (transport, auth, cache, services, events).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,34 +0,0 @@
1
- interface KeyValueStorage {
2
- getString(key: string): string | null;
3
- setString(key: string, value: string): void;
4
- remove(key: string): void;
5
- }
6
- interface PlatformAdapter {
7
- readonly storage: KeyValueStorage;
8
- /** Platform id (e.g. Telegram `tdesktop`/`android`, or `Web`). */
9
- getPlatform(): string;
10
- /** Full launch URL — mirrors WebSDK.GetFullURL. */
11
- getFullURL(): string;
12
- /** Telegram `start_param` (referral/deeplink) if present. */
13
- getStartParameter(): string | null;
14
- /** Raw Telegram `initData` string for server-side auth (validated only on the server). */
15
- getTelegramInitDataRaw(): string | null;
16
- /** Stable per-device id (persisted) — replaces SystemInfo.deviceUniqueIdentifier. */
17
- getDeviceID(): string;
18
- /** Device/user-agent string — replaces SystemInfo.deviceModel. */
19
- getDeviceModel(): string;
20
- /**
21
- * Referring page (`document.referrer`), when the host has one.
22
- *
23
- * Optional on purpose: adding a required member here would break every adapter written outside
24
- * this repo, and an acquisition signal is not worth that. Absent referrer simply means one less
25
- * field in the signal.
26
- */
27
- getReferrer?(): string | null;
28
- shareLink(url: string): void;
29
- openInvoice(url: string): void;
30
- showAd(blockId: string): Promise<void>;
31
- copyToClipboard(text: string): Promise<void>;
32
- }
33
-
34
- export type { KeyValueStorage as K, PlatformAdapter as P };
@@ -1,34 +0,0 @@
1
- interface KeyValueStorage {
2
- getString(key: string): string | null;
3
- setString(key: string, value: string): void;
4
- remove(key: string): void;
5
- }
6
- interface PlatformAdapter {
7
- readonly storage: KeyValueStorage;
8
- /** Platform id (e.g. Telegram `tdesktop`/`android`, or `Web`). */
9
- getPlatform(): string;
10
- /** Full launch URL — mirrors WebSDK.GetFullURL. */
11
- getFullURL(): string;
12
- /** Telegram `start_param` (referral/deeplink) if present. */
13
- getStartParameter(): string | null;
14
- /** Raw Telegram `initData` string for server-side auth (validated only on the server). */
15
- getTelegramInitDataRaw(): string | null;
16
- /** Stable per-device id (persisted) — replaces SystemInfo.deviceUniqueIdentifier. */
17
- getDeviceID(): string;
18
- /** Device/user-agent string — replaces SystemInfo.deviceModel. */
19
- getDeviceModel(): string;
20
- /**
21
- * Referring page (`document.referrer`), when the host has one.
22
- *
23
- * Optional on purpose: adding a required member here would break every adapter written outside
24
- * this repo, and an acquisition signal is not worth that. Absent referrer simply means one less
25
- * field in the signal.
26
- */
27
- getReferrer?(): string | null;
28
- shareLink(url: string): void;
29
- openInvoice(url: string): void;
30
- showAd(blockId: string): Promise<void>;
31
- copyToClipboard(text: string): Promise<void>;
32
- }
33
-
34
- export type { KeyValueStorage as K, PlatformAdapter as P };
@@ -1,2 +0,0 @@
1
- var f=class{getString(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}setString(e,r){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,r);}catch{}}remove(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e);}catch{}}},g=class{map=new Map;getString(e){return this.map.get(e)??null}setString(e,r){this.map.set(e,r);}remove(e){this.map.delete(e);}};function n(){return globalThis.Telegram?.WebApp??null}function v(){return crypto.randomUUID()}var h="idos_device_id",w=class{storage;constructor(e=new f){this.storage=e;}getPlatform(){return n()?.platform??"Web"}getFullURL(){return typeof location<"u"?location.href:""}getStartParameter(){let e=n()?.initDataUnsafe?.start_param;return typeof e=="string"?e:null}getReferrer(){if(typeof document>"u")return null;let e=document.referrer;return e&&e.length>0?e:null}getTelegramInitDataRaw(){let e=n()?.initData;return e&&e.length>0?e:null}getDeviceID(){let e=this.storage.getString(h);return e||(e=v(),this.storage.setString(h,e)),e}getDeviceModel(){return typeof navigator<"u"&&navigator.userAgent?navigator.userAgent:"Web"}shareLink(e){let r=n();if(r?.openTelegramLink){r.openTelegramLink(e);return}typeof window<"u"&&window.open(e,"_blank");}openInvoice(e){let r=n();if(r?.openInvoice){r.openInvoice(e);return}typeof window<"u"&&window.open(e,"_blank");}async showAd(e){let r=globalThis;typeof r.showAd=="function"&&await r.showAd(e);}async copyToClipboard(e){typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(e);}};var U="idos_device_id",P=class{storage;constructor(e=new g){this.storage=e;}getPlatform(){return "Web"}getFullURL(){return ""}getStartParameter(){return null}getTelegramInitDataRaw(){return null}getDeviceID(){let e=this.storage.getString(U);return e||(e="noop-device",this.storage.setString(U,e)),e}getDeviceModel(){return "Noop"}shareLink(){}openInvoice(){}async showAd(){}async copyToClipboard(){}};var s=["https://idosgames.com","https://www.idosgames.com"],u="https://platform.idosgames.com",x=/^[a-z0-9]{8}-preview\.idos\.games$/;function I(t){return t==="localhost"||t==="127.0.0.1"||t==="[::1]"||t.endsWith(".localhost")}function S(){if(typeof window>"u")return false;let t=window.location.hostname.toLowerCase();return x.test(t)?true:I(t)&&globalThis.__IDOS_PREVIEW__!=null}function p(t){if(typeof window<"u"&&x.test(window.location.hostname.toLowerCase()))return t===u;if(s.includes(t))return true;if(typeof window>"u"||!I(window.location.hostname))return false;try{return I(new URL(t).hostname)}catch{return false}}var L="IDOS_PLATFORM_WALLET_ACK",C="PLATFORM_WALLET_UNAVAILABLE",N=5e3,F=18e4;function W(){if(p(u))return [u];let t=[...s],e=window.location.ancestorOrigins?.[0];return e&&!t.includes(e)&&p(e)&&t.push(e),t}function G(){return `wallet-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function i(t,e,r,l={}){let c={ok:false,error:C,data:{}};if(typeof window>"u"||window.self===window.top)return Promise.resolve(c);let E=window.parent;if(!E)return Promise.resolve(c);let D=G(),k=l.answerTimeoutMs??F;return new Promise(b=>{let O=false,m,d=a=>{O||(O=true,window.removeEventListener("message",M),clearTimeout(m),b(a));},M=a=>{if(!p(a.origin))return;let o=a.data;if(!(!o||o.requestId!==D)){if(o.type===L){clearTimeout(m),m=setTimeout(()=>d({ok:false,error:"TIMEOUT",data:{}}),k);return}o.type===e&&d({ok:o.ok===true,error:typeof o.error=="string"?o.error:void 0,data:o});}};m=setTimeout(()=>d(c),N),window.addEventListener("message",M);for(let a of W())try{E.postMessage({type:t,requestId:D,...r},a);}catch{}})}var T={request:"IDOS_PLATFORM_TOPUP_REQUEST",response:"IDOS_PLATFORM_TOPUP_RESPONSE"},V=15*6e4,K=/^[a-z0-9]{8}-preview\.idos\.games$/;function _(){if(typeof window>"u")return false;try{if(window.self===window.top||window.parent!==window.top)return !1}catch{return false}return !K.test(window.location.hostname.toLowerCase())}async function q(t){let e=await i(T.request,T.response,{titleID:t.titleID,userID:t.userID,currencyID:t.currencyID,amount:t.amount},{answerTimeoutMs:V});return e.ok?{ok:true}:{ok:false,error:e.error}}var A={request:"IDOS_PLATFORM_AUTH_REQUEST",response:"IDOS_PLATFORM_AUTH_RESPONSE"},B=30*6e4,R="idos:platformSignIn:declined:";function H(){if(typeof window>"u")return false;try{if(window.self===window.top||window.parent!==window.top)return !1}catch{return false}if(S())return false;let t=window.location.ancestorOrigins?.[0];if(t&&!s.includes(t))try{let e=new URL(t).hostname;if(e!=="localhost"&&e!=="127.0.0.1")return !1}catch{return false}return true}function we(){if(typeof window>"u"||!S())return false;try{return window.self!==window.top&&window.parent===window.top}catch{return false}}async function $(t){let e=await i(A.request,A.response,{titleID:t,supports:["pgs"]},{answerTimeoutMs:B}),r=e.data.ticket;if(e.ok&&typeof r=="string"&&r.length>0)return {ticket:r};let l=e.data.code;return e.ok&&typeof l=="string"&&l.length>0?{code:l}:{error:e.error??"no_code"}}function Q(t){try{window.localStorage.setItem(R+t,"1");}catch{}}function Y(t){try{window.localStorage.removeItem(R+t);}catch{}}function z(t){try{return window.localStorage.getItem(R+t)==="1"}catch{return false}}var y={request:"IDOS_PLATFORM_CREDITS_CONFIRM_REQUEST",response:"IDOS_PLATFORM_CREDITS_CONFIRM_RESPONSE"},X=10*6e4;function j(){let t=globalThis.navigator?.userAgent??"";if(!/\biDosGamesApp\/(?:player|studio)\//.test(t))return true;let e=/\biDosGamesPlatform\/(ios|android)\b/.exec(t);return (e?e[1]:/\bAndroid\b/.test(t)?"android":"ios")!=="ios"}function J(){return _()}async function Z(t){let e=await i(y.request,y.response,{titleID:t.titleID,confirmationID:t.confirmationID},{answerTimeoutMs:X});return e.ok?{ok:true}:{ok:false,error:e.error}}
2
- export{f as a,g as b,n as c,v as d,w as e,s as f,p as g,L as h,C as i,i as j,A as k,H as l,we as m,$ as n,Q as o,Y as p,z as q,T as r,_ as s,q as t,y as u,j as v,J as w,Z as x,P as y};